Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
525c770
added boiler plate for test plan client
May 16, 2025
ebfc90f
users/ammar/feat/testplan
May 16, 2025
f09ab69
add testplans api client and models
May 16, 2025
0ebc4a5
update request model name
May 16, 2025
95053ad
test setup
May 16, 2025
5d96899
add create test
May 16, 2025
8eca2b3
lint
May 16, 2025
e9dfe5d
fix test
May 16, 2025
39630d8
test try 1
May 16, 2025
703d060
test try 1
May 16, 2025
881a44d
draft implementation
May 16, 2025
db0d53a
moved test plan to integration folder
May 16, 2025
d52edd6
Merge branch 'users/ammar/feat/testplan' of https://github.com/aravin…
May 16, 2025
5e2699e
lint
May 16, 2025
a08df7d
add tests
May 16, 2025
535ffd1
Merge branch 'users/ammar/feat/testplan' of https://github.com/aravin…
May 16, 2025
6100544
added rest of test cases
May 19, 2025
293d185
added documentation
May 19, 2025
10c8d8b
updated documentation
May 19, 2025
0298403
updated nit changes
May 19, 2025
0b8fa56
added comments in init files
May 19, 2025
99d7d9e
resolved comments
May 20, 2025
d93bbac
added documentation for test plan template
May 20, 2025
a10a6b6
update test
May 20, 2025
1b4b88c
update lint
May 20, 2025
3a63524
add query projection
May 20, 2025
1977508
fix lint
May 20, 2025
94054e9
Merge branch 'users/ammar/feat/testplan' of https://github.com/aravin…
May 20, 2025
bae388d
add query projection
May 20, 2025
dd9cd31
Merge branch 'users/ammar/feat/testplan' of https://github.com/aravin…
May 20, 2025
de1909d
lint
May 20, 2025
f74c454
add docs
May 20, 2025
ac8e9a0
lint
May 20, 2025
dc12eba
Merge branch 'users/ammar/feat/testplan' of https://github.com/aravin…
May 20, 2025
2b2f2b9
lint
May 20, 2025
5405c0f
add example
May 20, 2025
fdbaa5e
refactor
May 21, 2025
883ea06
updated implementation
May 21, 2025
cf34f10
refactor
May 21, 2025
54445cd
refactor
May 21, 2025
585f0b9
enum update
May 21, 2025
3ee9e7a
query request refactor
May 21, 2025
7c77939
test constant update
May 21, 2025
32f6f8a
resolving PR comments
May 22, 2025
aca8441
add api errors
May 22, 2025
557c4d8
Merge pull request #3 from aravindhan-ni/users/arvin/feat/testplan/te…
aravindhan-ni May 22, 2025
a62104c
update as per comment
May 22, 2025
06671e0
Merge branch 'users/ammar/feat/testplan' of https://github.com/aravin…
May 22, 2025
89aa933
added test plan module
May 22, 2025
5697644
refactor test plan api
May 22, 2025
15572cc
resolved comments
May 22, 2025
2231a4a
refactor file names
May 23, 2025
82de1be
update comment
May 23, 2025
42f8271
update test constant
May 23, 2025
a640feb
update test constant
May 23, 2025
d22d4c1
update test
May 23, 2025
09768cf
update constant
May 23, 2025
ce85d2a
refactor
May 23, 2025
8969220
update docs
May 23, 2025
1bff3b4
fix warnings
May 23, 2025
6915830
try example fail fix
May 23, 2025
5d080f4
lint
May 23, 2025
f2aa651
update execution actions
May 23, 2025
0fd415b
update run test py setup
May 24, 2025
cd55dd3
Update tests test name
aravindhan-ni May 24, 2025
142dfd4
lint and update exports
May 26, 2025
1f8d98b
Merge branch 'users/ammar/feat/test_plan_template_api' of https://git…
May 26, 2025
f34f0fb
refactor
May 26, 2025
2a8aed1
Merge branch 'master' of https://github.com/aravindhan-ni/nisystemlin…
May 26, 2025
8fc290c
Merge branch 'master' of https://github.com/aravindhan-ni/nisystemlin…
May 26, 2025
6431f9a
Create main.yml
aravindhan-ni May 26, 2025
7bcf337
Merge branch 'master' of https://github.com/aravindhan-ni/nisystemlin…
May 27, 2025
ef4704f
remove workflow
May 27, 2025
0f2db44
refactor
May 27, 2025
009b54b
Merge branch 'ni:master' into master
aravindhan-ni May 28, 2025
d884e7d
Merge branch 'master' of https://github.com/aravindhan-ni/nisystemlin…
May 28, 2025
732af5f
add comment to usage of workspace
May 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ API Reference
api_reference/feeds
api_reference/assetmanagement
api_reference/systems
api_reference/test_plan

Indices and tables
------------------
Expand Down
22 changes: 22 additions & 0 deletions docs/api_reference/test_plan.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. _api_tag_page:

nisystemlink.clients.test_plan
======================

.. autoclass:: nisystemlink.clients.test_plan.TestPlanClient
:exclude-members: __init__

.. automethod:: __init__
.. automethod:: create_test_plans
.. automethod:: delete_test_plans
.. automethod:: query_test_plans
.. automethod:: schedule_test_plans
.. automethod:: update_test_plans
.. automethod:: get_test_plan
.. automethod:: create_test_plan_templates
.. automethod:: query_test_plan_templates
.. automethod:: delete_test_plan_templates

.. automodule:: nisystemlink.clients.test_plan.models
:members:
:imported-members:
33 changes: 33 additions & 0 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,36 @@ Create, query, and remove some systems.
.. literalinclude:: ../examples/systems/systems.py
:language: python
:linenos:

TestPlan API
-------

Overview
~~~~~~~~

The :class:`.TestPlanClient` class is the primary entry point of the TestPlan API.

When constructing a :class:`.TestPlanClient`, you can pass an
:class:`.HttpConfiguration` (like one retrieved from the
:class:`.HttpConfigurationManager`), or let :class:`.TestPlanClient` use the
default connection. The default connection depends on your environment.

With a :class:`.TestPlanClient` object, you can:

* Create, query, get, update, schedule and delete TestPlans
* Create, query and delete test plan templates

Examples
~~~~~~~~

Create, query, get, update, schedule and delete TestPlans

.. literalinclude:: ../examples/test_plan/test_plans.py
:language: python
:linenos:

Create, query and delete test plan templates.

.. literalinclude:: ../examples/test_plan/test_plan_templates.py
:language: python
:linenos:
82 changes: 82 additions & 0 deletions examples/test_plan/test_plan_templates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from nisystemlink.clients.core._http_configuration import HttpConfiguration
from nisystemlink.clients.test_plan import TestPlanClient
from nisystemlink.clients.test_plan.models import (
CreateTestPlanTemplateRequest,
Dashboard,
Job,
JobExecution,
ManualExecution,
QueryTestPlanTemplatesRequest,
)


# Setup the server configuration to point to your instance of SystemLink Enterprise
server_configuration = HttpConfiguration(
server_uri="https://yourserver.yourcompany.com",
api_key="YourAPIKeyGeneratedFromSystemLink",
)
client = TestPlanClient(configuration=server_configuration)

# Test plan template request metadata
create_test_plan_template_request = [
CreateTestPlanTemplateRequest(
name="Python integration test plan template",
template_group="sample template group",
product_families=["FamilyA", "FamilyB"],
part_numbers=["PN-1001", "PN-1002"],
summary="Template for running integration test plans",
description="This template defines execution steps for integration workflows.",
test_program="TP-INT-002",
estimated_duration_in_seconds=86400,
system_filter="os:linux AND arch:x64",
execution_actions=[
ManualExecution(action="boot", type="MANUAL"),
JobExecution(
action="run",
type="JOB",
jobs=[
Job(
functions=["run_test_suite"],
arguments=[["test_suite.py"]],
metadata={"env": "staging"},
)
],
systemId="system-001",
),
],
file_ids=["file1", "file2"],
workspace="your_workspace_id",
properties={"env": "staging", "priority": "high"},
dashboard=Dashboard(
id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"}
),
)
]

# Create a test plan template
create_test_plan_template_response = client.create_test_plan_templates(
test_plan_templates=create_test_plan_template_request
)

create_test_plan_template_id = None

if (
create_test_plan_template_response.created_test_plan_templates
and create_test_plan_template_response.created_test_plan_templates[0].id
):
create_test_plan_template_id = str(
create_test_plan_template_response.created_test_plan_templates[0].id
)

# Query test plan templates using id
query_test_plan_template_request = QueryTestPlanTemplatesRequest(
filter=f'id="{create_test_plan_template_id}"', take=1
)

client.query_test_plan_templates(
query_test_plan_templates=query_test_plan_template_request
)

# Delete the created test plan template.
if create_test_plan_template_id is not None:
client.delete_test_plan_templates(ids=[create_test_plan_template_id])
108 changes: 108 additions & 0 deletions examples/test_plan/test_plans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
from datetime import datetime

from nisystemlink.clients.core._http_configuration import HttpConfiguration
from nisystemlink.clients.test_plan import TestPlanClient
from nisystemlink.clients.test_plan.models import (
CreateTestPlanRequest,
Dashboard,
Job,
JobExecution,
ManualExecution,
QueryTestPlansRequest,
ScheduleTestPlanRequest,
ScheduleTestPlansRequest,
UpdateTestPlanRequest,
UpdateTestPlansRequest,
)

# Setup the server configuration to point to your instance of SystemLink Enterprise
server_configuration = HttpConfiguration(
server_uri="https://yourserver.yourcompany.com",
api_key="YourAPIKeyGeneratedFromSystemLink",
)
client = TestPlanClient(configuration=server_configuration)

create_test_plans_request = [
CreateTestPlanRequest(
name="Python integration test plan",
state="NEW",
description="Test plan for verifying integration flow",
assigned_to="test.user@example.com",
estimated_duration_in_seconds=86400,
properties={"env": "staging", "priority": "high"},
part_number="px40482",
dut_id="Sample-Dut_Id",
test_program="TP-Integration-001",
system_filter="os:linux AND arch:x64",
workspace="your_workspace_id",
file_ids_from_template=["file1", "file2"],
dashboard=Dashboard(
id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"}
),
execution_actions=[
ManualExecution(action="boot", type="MANUAL"),
JobExecution(
action="run",
type="JOB",
jobs=[
Job(
functions=["run_test_suite"],
arguments=[["test_suite.py"]],
metadata={"env": "staging"},
)
],
systemId="system-001",
),
],
)
]

# create a test plan
created_test_plans_response = client.create_test_plans(
test_plans=create_test_plans_request
)

if created_test_plans_response.created_test_plans:
created_test_plan_id = created_test_plans_response.created_test_plans[0].id

# Query test plan using id.
query_test_plans_request = QueryTestPlansRequest(
skip=0, take=1, descending=False, returnCount=False
)
client.query_test_plans(query_request=query_test_plans_request)

# Get test plan
get_test_plan = client.get_test_plan(test_plan_id=created_test_plan_id)

# Update test plan
update_test_plans_request = UpdateTestPlansRequest(
test_plans=[
UpdateTestPlanRequest(
id=created_test_plan_id,
name="Updated Test Plan",
)
]
)
updated_test_plan = client.update_test_plans(update_request=update_test_plans_request)

# Schedule the test plan
schedule_test_plans_request = ScheduleTestPlansRequest(
test_plans=[
ScheduleTestPlanRequest(
id=created_test_plan_id,
planned_start_date_time=datetime.strptime(
"2025-05-20T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ"
),
estimated_end_date_time=datetime.strptime(
"2025-05-22T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ"
),
system_id="fake-system",
)
]
)
schedule_test_plan_response = client.schedule_test_plans(
schedule_request=schedule_test_plans_request
)

# Delete test plan
client.delete_test_plans(ids=[created_test_plan_id])
3 changes: 3 additions & 0 deletions nisystemlink/clients/test_plan/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ._test_plan_client import TestPlanClient

# flake8: noqa
Loading