Skip to content

Commit b492ed8

Browse files
authored
Refine PR test template to reduce code maintenance costs (sonic-net#20002)
What is the motivation for this PR? Currently PR KVM test jobs are all put in azure-pipelines.yml, but in other usage scenarios, baseline test and buildimage PR test, PR KVM tests are required. If we can put KVM test jobs into a template yaml, will reduce lots of code maintenance costs and make it easier to imported by other repos. How did you do it? Create PR KVM test template yaml with jobs in matrix to reduce duplicate logs. How did you verify/test it? Compared test plan contents in this PR with other PRs, contents are the same. Signed-off-by: opcoder0 <[email protected]>
1 parent 3e69292 commit b492ed8

File tree

3 files changed

+180
-292
lines changed

3 files changed

+180
-292
lines changed

.azure-pipelines/baseline_test/baseline.test.mgmt.public.yml

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,78 @@ schedules:
1111
- master
1212
always: true
1313

14-
stages:
14+
parameters:
15+
- name: BUILD_REASON
16+
type: string
17+
default: "BaselineTest"
1518

16-
- stage: Test_round_1
17-
variables:
19+
- name: TEST_PLAN_NUM
20+
type: string
21+
default: $(BASELINE_MGMT_PUBLIC_MASTER_TEST_NUM)
22+
23+
- name: RETRY_TIMES
24+
type: string
25+
default: "0"
26+
27+
- name: TEST_PLAN_STOP_ON_FAILURE
28+
type: string
29+
default: "False"
30+
31+
variables:
1832
- group: SONiC-Elastictest
1933
- name: inventory
2034
value: veos_vtb
2135
- name: testbed_file
2236
value: vtestbed.yaml
37+
- name: BUILD_BRANCH
38+
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
39+
value: $(System.PullRequest.TargetBranch)
40+
${{ else }}:
41+
value: $(Build.SourceBranchName)
42+
43+
stages:
44+
45+
- stage: Test_round_1
2346
jobs:
24-
- template: baseline.test.template.yml
47+
- template: ../pr_test_template.yml
48+
- parameters:
49+
BUILD_REASON: ${{ parameters.BUILD_REASON }}
50+
TEST_PLAN_NUM: ${{ parameters.TEST_PLAN_NUM }}
51+
RETRY_TIMES: ${{ parameters.RETRY_TIMES }}
52+
TEST_PLAN_STOP_ON_FAILURE: ${{ parameters.TEST_PLAN_STOP_ON_FAILURE }}
2553

2654
- stage: Test_round_2
2755
dependsOn:
2856
- Test_round_1
2957
condition: succeededOrFailed('Test_round_1')
30-
variables:
31-
- group: SONiC-Elastictest
32-
- name: inventory
33-
value: veos_vtb
34-
- name: testbed_file
35-
value: vtestbed.yaml
3658
jobs:
37-
- template: baseline.test.template.yml
59+
- template: ../pr_test_template.yml
60+
- parameters:
61+
BUILD_REASON: ${{ parameters.BUILD_REASON }}
62+
TEST_PLAN_NUM: ${{ parameters.TEST_PLAN_NUM }}
63+
RETRY_TIMES: ${{ parameters.RETRY_TIMES }}
64+
TEST_PLAN_STOP_ON_FAILURE: ${{ parameters.TEST_PLAN_STOP_ON_FAILURE }}
3865

3966
- stage: Test_round_3
4067
dependsOn:
4168
- Test_round_2
4269
condition: succeededOrFailed('Test_round_2')
43-
variables:
44-
- group: SONiC-Elastictest
45-
- name: inventory
46-
value: veos_vtb
47-
- name: testbed_file
48-
value: vtestbed.yaml
4970
jobs:
50-
- template: baseline.test.template.yml
71+
- template: ../pr_test_template.yml
72+
- parameters:
73+
BUILD_REASON: ${{ parameters.BUILD_REASON }}
74+
TEST_PLAN_NUM: ${{ parameters.TEST_PLAN_NUM }}
75+
RETRY_TIMES: ${{ parameters.RETRY_TIMES }}
76+
TEST_PLAN_STOP_ON_FAILURE: ${{ parameters.TEST_PLAN_STOP_ON_FAILURE }}
5177

5278
- stage: Test_round_4
5379
dependsOn:
5480
- Test_round_3
5581
condition: succeededOrFailed('Test_round_3')
56-
variables:
57-
- group: SONiC-Elastictest
58-
- name: inventory
59-
value: veos_vtb
60-
- name: testbed_file
61-
value: vtestbed.yaml
6282
jobs:
63-
- template: baseline.test.template.yml
83+
- template: ../pr_test_template.yml
84+
- parameters:
85+
BUILD_REASON: ${{ parameters.BUILD_REASON }}
86+
TEST_PLAN_NUM: ${{ parameters.TEST_PLAN_NUM }}
87+
RETRY_TIMES: ${{ parameters.RETRY_TIMES }}
88+
TEST_PLAN_STOP_ON_FAILURE: ${{ parameters.TEST_PLAN_STOP_ON_FAILURE }}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
parameters:
2+
- name: BUILD_REASON
3+
type: string
4+
default: "PullRequest"
5+
6+
- name: TIMEOUT_IN_MINUTES_PR_TEST
7+
type: number
8+
default: 480
9+
10+
- name: MAX_RUN_TEST_MINUTES
11+
type: number
12+
default: 240
13+
14+
- name: TEST_PLAN_NUM
15+
type: string
16+
default: "1"
17+
18+
- name: TEST_PLAN_STOP_ON_FAILURE
19+
type: string
20+
default: "True"
21+
22+
- name: RETRY_TIMES
23+
type: string
24+
default: "2"
25+
26+
jobs:
27+
- job: get_impacted_area
28+
cancelTimeoutInMinutes: 10
29+
displayName: "Get impacted area"
30+
timeoutInMinutes: 240
31+
continueOnError: false
32+
pool: sonic-ubuntu-1c
33+
steps:
34+
- template: impacted_area_testing/get-impacted-area.yml
35+
36+
- job: impacted_area_kvmtest
37+
displayName: " "
38+
cancelTimeoutInMinutes: 10
39+
dependsOn: get_impacted_area
40+
strategy:
41+
matrix:
42+
impacted-area-kvmtest-t0_by_Elastictest:
43+
TESTBED_PREP_TOPOLOGY: t0
44+
CHECKER: t0_checker
45+
TOPOLOGY: t0
46+
impacted-area-kvmtest-t0-2vlans_by_Elastictest:
47+
TESTBED_PREP_TOPOLOGY: t0-2vlans
48+
CHECKER: t0-2vlans_checker
49+
DEPLOY_MG_EXTRA_PARAMS: "-e vlan_config=two_vlan_a "
50+
TOPOLOGY: t0
51+
impacted-area-kvmtest-t1-lag_by_Elastictest:
52+
TESTBED_PREP_TOPOLOGY: t1
53+
CHECKER: t1_checker
54+
TOPOLOGY: t1-lag
55+
impacted-area-kvmtest-dualtor_by_Elastictest:
56+
TESTBED_PREP_TOPOLOGY: dualtor
57+
CHECKER: dualtor_checker
58+
COMMON_EXTRA_PARAMS: "--disable_loganalyzer --disable_sai_validation "
59+
TOPOLOGY: dualtor
60+
impacted-area-kvmtest-multi-asic-t1_by_Elastictest:
61+
TESTBED_PREP_TOPOLOGY: t1-multi-asic
62+
CHECKER: t1-multi-asic_checker
63+
TOPOLOGY: t1-8-lag
64+
NUM_ASIC: 4
65+
impacted-area-kvmtest-multi-asic-t1_by_Elastictest_optional:
66+
TESTBED_PREP_TOPOLOGY: t1
67+
CHECKER: t1_checker
68+
TOPOLOGY: t1-8-lag
69+
NUM_ASIC: 4
70+
STOP_ON_FAILURE: "False"
71+
impacted-area-kvmtest-t0-sonic_by_Elastictest:
72+
TESTBED_PREP_TOPOLOGY: t0-sonic
73+
CHECKER: t0-sonic_checker
74+
COMMON_EXTRA_PARAMS: "--neighbor_type=sonic --disable_sai_validation "
75+
TOPOLOGY: t0-64-32
76+
VM_TYPE: vsonic
77+
SPECIFIC_PARAM: '[
78+
{"name": "bgp/test_bgp_fact.py", "param": "--neighbor_type=sonic --enable_macsec --macsec_profile=128_SCI,256_XPN_SCI"},
79+
{"name": "macsec", "param": "--neighbor_type=sonic --enable_macsec --macsec_profile=128_SCI,256_XPN_SCI"}
80+
]'
81+
impacted-area-kvmtest-dpu_by_Elastictest:
82+
TESTBED_PREP_TOPOLOGY: dpu
83+
CHECKER: dpu_checker
84+
TOPOLOGY: dpu
85+
SPECIFIC_PARAM: '[
86+
{"name": "dash/test_dash_vnet.py", "param": "--skip_dataplane_checking"}
87+
]'
88+
impacted-area-kvmtest-t2_by_Elastictest_optional:
89+
TESTBED_PREP_TOPOLOGY: t2
90+
CHECKER: t2_checker
91+
TOPOLOGY: t2
92+
STOP_ON_FAILURE: "False"
93+
94+
condition: contains(dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS'], variables['CHECKER'])
95+
variables:
96+
TEST_SCRIPTS: $[ dependencies.get_impacted_area.outputs['SetVariableTask.TEST_SCRIPTS'] ]
97+
NUM_ASIC: 1
98+
VM_TYPE: ceos
99+
STOP_ON_FAILURE: ${{ parameters.TEST_PLAN_STOP_ON_FAILURE }}
100+
COMMON_EXTRA_PARAMS: "--disable_sai_validation "
101+
DEPLOY_MG_EXTRA_PARAMS: ""
102+
SPECIFIC_PARAM: "[]"
103+
timeoutInMinutes: ${{ parameters.TIMEOUT_IN_MINUTES_PR_TEST }}
104+
continueOnError: false
105+
pool: sonic-ubuntu-1c
106+
steps:
107+
- template: impacted_area_testing/calculate-instance-numbers.yml
108+
parameters:
109+
TOPOLOGY: $(TESTBED_PREP_TOPOLOGY)
110+
BUILD_BRANCH: $(BUILD_BRANCH)
111+
112+
- template: run-test-elastictest-template.yml
113+
parameters:
114+
TOPOLOGY: $(TOPOLOGY)
115+
SCRIPTS: $(SCRIPTS)
116+
MIN_WORKER: $(INSTANCE_NUMBER)
117+
MAX_WORKER: $(INSTANCE_NUMBER)
118+
DEPLOY_MG_EXTRA_PARAMS: $(DEPLOY_MG_EXTRA_PARAMS)
119+
COMMON_EXTRA_PARAMS: $(COMMON_EXTRA_PARAMS)
120+
KVM_IMAGE_BRANCH: $(BUILD_BRANCH)
121+
MGMT_BRANCH: $(BUILD_BRANCH)
122+
BUILD_REASON: ${{ parameters.BUILD_REASON }}
123+
RETRY_TIMES: ${{ parameters.RETRY_TIMES }}
124+
STOP_ON_FAILURE: $(STOP_ON_FAILURE)
125+
TEST_PLAN_NUM: ${{ parameters.TEST_PLAN_NUM }}
126+
NUM_ASIC: $(NUM_ASIC)
127+
VM_TYPE: $(VM_TYPE)
128+
SPECIFIC_PARAM: $(SPECIFIC_PARAM)
129+
MAX_RUN_TEST_MINUTES: ${{ parameters.MAX_RUN_TEST_MINUTES }}

0 commit comments

Comments
 (0)