Skip to content

Commit 252d600

Browse files
authored
[CI/CD] Add topo and device_type args for PR test scripts (#12731)
What is the motivation for this PR? Add "--topology" and "--device_type" arguments to PR test scripts. Fix the issue of "--device_type" skipped on test scripts without "device_type" mark. How did you do it? Add "--topology" and "--device_type" arguments to PR test scripts. Fix the issue of "--device_type" skipped on test scripts without "device_type" mark. How did you verify/test it? Raised Draft PR to test the template script: https://github.com/sonic-net/sonic-mgmt/pull/12645/files Signed-off-by: chunangli <[email protected]>
1 parent 0cf5094 commit 252d600

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.azure-pipelines/test_plan.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def get_token(self):
190190
"scope": get_scope(self.url)
191191
}
192192
attempt = 0
193-
while(attempt < MAX_GET_TOKEN_RETRY_TIMES):
193+
while (attempt < MAX_GET_TOKEN_RETRY_TIMES):
194194
try:
195195
resp = requests.post(token_url, headers=headers, data=payload, timeout=10).json()
196196
self._token = resp["access_token"]
@@ -223,6 +223,21 @@ def create(self, topology, test_plan_name="my_test_plan", deploy_mg_extra_params
223223

224224
common_extra_params = common_extra_params + " --completeness_level=confident --allow_recover"
225225

226+
# Add topo and device type args for PR test
227+
if test_plan_type == "PR":
228+
# Add topo arg
229+
if topology in ["t0", "t0-64-32"]:
230+
common_extra_params = common_extra_params + " --topology=t0,any"
231+
elif topology in ["t1-lag", "t1-8-lag"]:
232+
common_extra_params = common_extra_params + " --topology=t1,any"
233+
elif topology == "dualtor":
234+
common_extra_params = common_extra_params + " --topology=t0,dualtor,any"
235+
elif topology == "dpu":
236+
common_extra_params = common_extra_params + " --topology=dpu,any"
237+
238+
# Add device type arg
239+
common_extra_params = common_extra_params + " --device_type=vs"
240+
226241
# If triggered by the internal repos, use internal sonic-mgmt repo as the code base
227242
sonic_mgmt_repo_url = GITHUB_SONIC_MGMT_REPO
228243
if kwargs.get("source_repo") in INTERNAL_REPO_LIST:

tests/common/plugins/custom_markers/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def pytest_configure(config):
4242
allowed values: 'physical', 'vs'"
4343
)
4444
config.addinivalue_line(
45-
"markers", "supported_completeness_level(TEST_LEVEL): mark test to specify the completeness level for the test. \
46-
Allowed values: 'debug', 'basic' ,'confident', 'thorough'"
45+
"markers", "supported_completeness_level(TEST_LEVEL): mark test to specify the completeness level for the \
46+
test. Allowed values: 'debug', 'basic' ,'confident', 'thorough'"
4747
)
4848

4949

@@ -122,8 +122,7 @@ def check_device_type(item):
122122
if dev:
123123
if item.config.getoption("--device_type") not in dev:
124124
pytest.skip("test requires device type in {!r}".format(dev))
125-
else:
126-
pytest.skip("test does not match device type")
125+
# Else, test case not specify device_type explicitly, by default run on all devices
127126

128127

129128
def check_test_completeness(item):

0 commit comments

Comments
 (0)