From 3cd1ced3be42f62a8f5a83d69768909461222fdc Mon Sep 17 00:00:00 2001 From: Yutong Zhang Date: Fri, 17 Jan 2025 09:56:19 +0800 Subject: [PATCH] Roll out the left PR checkers --- .../get-impacted-area.yml | 2 +- .../impacted_area_testing/get_test_scripts.py | 15 +- azure-pipelines.yml | 186 +++++++++++++++--- 3 files changed, 169 insertions(+), 34 deletions(-) diff --git a/.azure-pipelines/impacted_area_testing/get-impacted-area.yml b/.azure-pipelines/impacted_area_testing/get-impacted-area.yml index 46e2b79340a..c89d315fd90 100644 --- a/.azure-pipelines/impacted_area_testing/get-impacted-area.yml +++ b/.azure-pipelines/impacted_area_testing/get-impacted-area.yml @@ -62,7 +62,7 @@ steps: exit 1 fi - PR_CHECKERS=$(echo "${TEST_SCRIPTS}" | jq -c 'keys') + PR_CHECKERS=$(echo "${TEST_SCRIPTS}" | jq -c 'keys' | sed 's/\[//;s/\]//' | sed "s/,/, /g" | sed "s/^/(/;s/\$/)/") if [[ $? -ne 0 ]]; then echo "##vso[task.complete result=Failed;]Get valid PR checkers fails." diff --git a/.azure-pipelines/impacted_area_testing/get_test_scripts.py b/.azure-pipelines/impacted_area_testing/get_test_scripts.py index 787dde48347..45ade5534a7 100644 --- a/.azure-pipelines/impacted_area_testing/get_test_scripts.py +++ b/.azure-pipelines/impacted_area_testing/get_test_scripts.py @@ -65,11 +65,6 @@ def collect_scripts_by_topology_type(features: str, location: str) -> dict: # Note: The full path and name of files are stored in a list named "files" scripts = [] - # This is just for the first stage of rolling out - # To avoid the overuse of resource, we will ignore the PR which modifies the common part. - if features == "": - return {} - for feature in features.split(","): feature_path = os.path.join(location, feature) for root, dirs, script in os.walk(feature_path): @@ -103,7 +98,15 @@ def collect_scripts_by_topology_type(features: str, location: str) -> dict: except Exception as e: raise Exception('Exception occurred while trying to get topology in {}, error {}'.format(s, e)) - return {k: v for k, v in test_scripts_per_topology_type.items() if v} + test_scripts = {k: v for k, v in test_scripts_per_topology_type.items() if v} + + # This is just for the first stage of rolling out + # To avoid the overuse of resource, we will ignore the PR which modifies the common part. + if features == "": + test_scripts.pop("t0") + test_scripts.pop("t1") + + return test_scripts def main(features, location): diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a02dfce4e2a..001e6d5b494 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -74,6 +74,7 @@ stages: value: $(Build.SourceBranchName) jobs: +# Below are Impacted Area Based PR checkers - job: get_impacted_area displayName: "Get impacted area" timeoutInMinutes: 240 @@ -85,7 +86,7 @@ stages: - job: impacted_area_t0_elastictest displayName: "impacted-area-kvmtest-t0 by Elastictest - optional" dependsOn: get_impacted_area - condition: contains(dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS'], 't0') + condition: in('t0', dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS']) variables: TEST_SCRIPTS: $[ dependencies.get_impacted_area.outputs['SetVariableTask.TEST_SCRIPTS'] ] timeoutInMinutes: 240 @@ -104,9 +105,165 @@ stages: MIN_WORKER: $(INSTANCE_NUMBER) MAX_WORKER: $(INSTANCE_NUMBER) KVM_IMAGE_BRANCH: $(BUILD_BRANCH) - MGMT_BRANCH: $(BUILD_BRANCH) + MGMT_BRANCH: "master" + STOP_ON_FAILURE: "False" + + - job: impacted_area_t0_2vlans_elastictest + displayName: "impacted-area-kvmtest-t0_2vlans by Elastictest - optional" + dependsOn: get_impacted_area + condition: in('t0-2vlans', dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS']) + variables: + TEST_SCRIPTS: $[ dependencies.get_impacted_area.outputs['SetVariableTask.TEST_SCRIPTS'] ] + timeoutInMinutes: 240 + continueOnError: true + pool: sonic-ubuntu-1c + steps: + - template: .azure-pipelines/impacted_area_testing/calculate-instance-numbers.yml + parameters: + TOPOLOGY: t0-2vlans + BUILD_BRANCH: $(BUILD_BRANCH) + + - template: .azure-pipelines/run-test-elastictest-template.yml + parameters: + TOPOLOGY: t0 + SCRIPTS: $(SCRIPTS) + MIN_WORKER: $(INSTANCE_NUMBER) + MAX_WORKER: $(INSTANCE_NUMBER) + DEPLOY_MG_EXTRA_PARAMS: "-e vlan_config=two_vlan_a" + KVM_IMAGE_BRANCH: $(BUILD_BRANCH) + MGMT_BRANCH: "master" + STOP_ON_FAILURE: "False" + + - job: impacted_area_t1_lag_elastictest + displayName: "impacted-area-kvmtest-t1-lag by Elastictest - optional" + dependsOn: get_impacted_area + condition: in('t1', dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS']) + variables: + TEST_SCRIPTS: $[ dependencies.get_impacted_area.outputs['SetVariableTask.TEST_SCRIPTS'] ] + timeoutInMinutes: 240 + continueOnError: true + pool: sonic-ubuntu-1c + steps: + - template: .azure-pipelines/impacted_area_testing/calculate-instance-numbers.yml + parameters: + TOPOLOGY: t1 + BUILD_BRANCH: $(BUILD_BRANCH) + + - template: .azure-pipelines/run-test-elastictest-template.yml + parameters: + TOPOLOGY: t1-lag + SCRIPTS: $(SCRIPTS) + MIN_WORKER: $(INSTANCE_NUMBER) + MAX_WORKER: $(INSTANCE_NUMBER) + KVM_IMAGE_BRANCH: $(BUILD_BRANCH) + MGMT_BRANCH: "master" + STOP_ON_FAILURE: "False" + + - job: impacted_area_dualtor_elastictest + displayName: "impacted-area-kvmtest-dualtor by Elastictest - optional" + dependsOn: get_impacted_area + condition: in('dualtor', dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS']) + variables: + TEST_SCRIPTS: $[ dependencies.get_impacted_area.outputs['SetVariableTask.TEST_SCRIPTS'] ] + timeoutInMinutes: 240 + continueOnError: true + pool: sonic-ubuntu-1c + steps: + - template: .azure-pipelines/impacted_area_testing/calculate-instance-numbers.yml + parameters: + TOPOLOGY: dualtor + BUILD_BRANCH: $(BUILD_BRANCH) + + - template: .azure-pipelines/run-test-elastictest-template.yml + parameters: + TOPOLOGY: dualtor + SCRIPTS: $(SCRIPTS) + MIN_WORKER: $(INSTANCE_NUMBER) + MAX_WORKER: $(INSTANCE_NUMBER) + COMMON_EXTRA_PARAMS: "--disable_loganalyzer " + KVM_IMAGE_BRANCH: $(BUILD_BRANCH) + MGMT_BRANCH: "master" STOP_ON_FAILURE: "False" + - job: impacted_area_multi_asic_elastictest + displayName: "impacted-area-kvmtest-multi_asic by Elastictest - optional" + dependsOn: get_impacted_area + condition: in('t1-multi-asic', dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS']) + variables: + TEST_SCRIPTS: $[ dependencies.get_impacted_area.outputs['SetVariableTask.TEST_SCRIPTS'] ] + timeoutInMinutes: 240 + continueOnError: true + pool: sonic-ubuntu-1c + steps: + - template: .azure-pipelines/impacted_area_testing/calculate-instance-numbers.yml + parameters: + TOPOLOGY: t1-multi-asic + BUILD_BRANCH: $(BUILD_BRANCH) + + - template: .azure-pipelines/run-test-elastictest-template.yml + parameters: + TOPOLOGY: t1-8-lag + SCRIPTS: $(SCRIPTS) + MIN_WORKER: $(INSTANCE_NUMBER) + MAX_WORKER: $(INSTANCE_NUMBER) + NUM_ASIC: 4 + KVM_IMAGE_BRANCH: $(BUILD_BRANCH) + MGMT_BRANCH: "master" + STOP_ON_FAILURE: "False" + + - job: impacted_area_sonic_t0_elastictest + displayName: "impacted-area-kvmtest-sonic_t0 by Elastictest - optional" + dependsOn: get_impacted_area + condition: in('t0-sonic', dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS']) + variables: + TEST_SCRIPTS: $[ dependencies.get_impacted_area.outputs['SetVariableTask.TEST_SCRIPTS'] ] + timeoutInMinutes: 240 + continueOnError: true + pool: sonic-ubuntu-1c + steps: + - template: .azure-pipelines/impacted_area_testing/calculate-instance-numbers.yml + parameters: + TOPOLOGY: t0-sonic + BUILD_BRANCH: $(BUILD_BRANCH) + + - template: .azure-pipelines/run-test-elastictest-template.yml + parameters: + TOPOLOGY: t0-64-32 + SCRIPTS: $(SCRIPTS) + MIN_WORKER: $(INSTANCE_NUMBER) + MAX_WORKER: $(INSTANCE_NUMBER) + KVM_IMAGE_BRANCH: $(BUILD_BRANCH) + COMMON_EXTRA_PARAMS: "--neighbor_type=sonic " + VM_TYPE: vsonic + MGMT_BRANCH: "master" + STOP_ON_FAILURE: "False" + + - job: impacted_area_dpu_elastictest + displayName: "impacted-area-kvmtest-dpu by Elastictest - optional" + dependsOn: get_impacted_area + condition: in('dpu', dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS']) + variables: + TEST_SCRIPTS: $[ dependencies.get_impacted_area.outputs['SetVariableTask.TEST_SCRIPTS'] ] + timeoutInMinutes: 240 + continueOnError: true + pool: sonic-ubuntu-1c + steps: + - template: .azure-pipelines/impacted_area_testing/calculate-instance-numbers.yml + parameters: + TOPOLOGY: dpu + BUILD_BRANCH: $(BUILD_BRANCH) + + - template: .azure-pipelines/run-test-elastictest-template.yml + parameters: + TOPOLOGY: dpu + SCRIPTS: $(SCRIPTS) + MIN_WORKER: $(INSTANCE_NUMBER) + MAX_WORKER: $(INSTANCE_NUMBER) + KVM_IMAGE_BRANCH: $(BUILD_BRANCH) + MGMT_BRANCH: "master" + STOP_ON_FAILURE: "False" + +# Below is the original PR checkers - job: t0_elastictest displayName: "kvmtest-t0 by Elastictest" timeoutInMinutes: 240 @@ -151,31 +308,6 @@ stages: KVM_IMAGE_BRANCH: $(BUILD_BRANCH) MGMT_BRANCH: "master" - - job: impacted_area_t1_lag_elastictest - displayName: "impacted-area-kvmtest-t1-lag by Elastictest - optional" - dependsOn: get_impacted_area - condition: contains(dependencies.get_impacted_area.outputs['SetVariableTask.PR_CHECKERS'], 't1') - variables: - TEST_SCRIPTS: $[ dependencies.get_impacted_area.outputs['SetVariableTask.TEST_SCRIPTS'] ] - timeoutInMinutes: 240 - continueOnError: true - pool: sonic-ubuntu-1c - steps: - - template: .azure-pipelines/impacted_area_testing/calculate-instance-numbers.yml - parameters: - TOPOLOGY: t1 - BUILD_BRANCH: $(BUILD_BRANCH) - - - template: .azure-pipelines/run-test-elastictest-template.yml - parameters: - TOPOLOGY: t1-lag - SCRIPTS: $(SCRIPTS) - MIN_WORKER: $(INSTANCE_NUMBER) - MAX_WORKER: $(INSTANCE_NUMBER) - KVM_IMAGE_BRANCH: $(BUILD_BRANCH) - MGMT_BRANCH: $(BUILD_BRANCH) - STOP_ON_FAILURE: "False" - - job: dualtor_elastictest displayName: "kvmtest-dualtor-t0 by Elastictest" timeoutInMinutes: 240