forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
339 changed files
with
18,243 additions
and
9,991 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
parameters: | ||
- name: TOPOLOGY | ||
type: string | ||
|
||
- name: POLL_INTERVAL | ||
type: number | ||
default: 10 | ||
|
||
- name: POLL_TIMEOUT | ||
type: number | ||
default: 36000 | ||
|
||
- name: MIN_WORKER | ||
type: string | ||
default: 1 | ||
|
||
- name: MAX_WORKER | ||
type: string | ||
default: 1 | ||
|
||
- name: NUM_ASIC | ||
type: number | ||
default: 1 | ||
|
||
- name: TEST_SET | ||
type: string | ||
default: "" | ||
|
||
- name: DEPLOY_MG_EXTRA_PARAMS | ||
type: string | ||
default: "" | ||
|
||
- name: COMMON_EXTRA_PARAMS | ||
type: string | ||
default: "" | ||
|
||
- name: VM_TYPE | ||
type: string | ||
default: "ceos" | ||
|
||
- name: TESTBED_NAME | ||
type: string | ||
default: "" | ||
|
||
- name: IMAGE_URL | ||
type: string | ||
default: "" | ||
|
||
- name: HWSKU | ||
type: string | ||
default: "" | ||
|
||
- name: TEST_PLAN_TYPE | ||
type: string | ||
default: "" | ||
|
||
- name: PLATFORM | ||
type: string | ||
default: "" | ||
|
||
- name: SCRIPTS | ||
type: string | ||
default: "" | ||
|
||
- name: FEATURES | ||
type: string | ||
default: "" | ||
|
||
- name: SCRIPTS_EXCLUDE | ||
type: string | ||
default: "" | ||
|
||
- name: FEATURES_EXCLUDE | ||
type: string | ||
default: "" | ||
|
||
- name: REPO_NAME | ||
type: string | ||
default: "" | ||
|
||
- name: MGMT_BRANCH | ||
type: string | ||
default: "" | ||
|
||
- name: MGMT_URL | ||
type: string | ||
default: "https://raw.githubusercontent.com/sonic-net/sonic-mgmt" | ||
|
||
- name: STOP_ON_FAILURE | ||
type: string | ||
default: "" | ||
|
||
- name: RETRY_TIMES | ||
type: string | ||
default: "" | ||
|
||
- name: DUMP_KVM_IF_FAIL | ||
type: string | ||
default: "True" | ||
values: | ||
- "True" | ||
- "False" | ||
|
||
- name: REQUESTER | ||
type: string | ||
default: "" | ||
|
||
- name: MAX_RUN_TEST_MINUTES | ||
type: number | ||
default: 480 | ||
|
||
- name: KVM_IMAGE_BRANCH | ||
type: string | ||
default: "" | ||
|
||
- name: EXPECTED_RESULT | ||
type: string | ||
default: "" | ||
|
||
|
||
steps: | ||
- ${{ if not(contains(variables['BUILD.REPOSITORY.NAME'], 'sonic-mgmt')) }}: | ||
- script: | | ||
# If not sonic-mgmt/sonic-mgmt-int repo, need to download test_plan.py and pr_test_scripts.yaml | ||
set -ex | ||
curl "https://raw.githubusercontent.com/sonic-net/sonic-mgmt/master/.azure-pipelines/test_plan.py" -o ./.azure-pipelines/test_plan.py | ||
displayName: "Download test plan script" | ||
- script: | | ||
# If not sonic-mgmt/sonic-mgmt-int repo, need to download pr_test_scripts.yaml | ||
set -ex | ||
# If public build image repo, download pr test scripts from public sonic-mgmt repo | ||
if [[ "$(BUILD.REPOSITORY.NAME)" = "sonic-net/sonic-buildimage" ]]; then | ||
curl "${{ parameters.MGMT_URL }}/${{ parameters.MGMT_BRANCH }}/.azure-pipelines/pr_test_scripts.yaml" -o ./.azure-pipelines/pr_test_scripts.yaml | ||
# Else, internal build image repo, download from internal sonic-mgmt repo | ||
else | ||
curl -u $(AZP_REPO_ACCESS_TOKEN) "${{ parameters.MGMT_URL }}&commitOrBranch=${{ parameters.MGMT_BRANCH }}&api-version=5.0-preview.1&path=.azure-pipelines%2Fpr_test_scripts.yaml" -o ./.azure-pipelines/pr_test_scripts.yaml | ||
fi | ||
displayName: "Download pr script" | ||
- ${{ else }}: | ||
- ${{ if ne(parameters.MGMT_BRANCH, 'master') }}: | ||
- script: | | ||
# Else, sonic-mgmt repo, if not master branch, need to download test_plan.py | ||
set -ex | ||
curl "https://raw.githubusercontent.com/sonic-net/sonic-mgmt/master/.azure-pipelines/test_plan.py" -o ./.azure-pipelines/test_plan.py | ||
displayName: "Download test plan script" | ||
- script: | | ||
set -e | ||
pip install PyYAML | ||
rm -f new_test_plan_id.txt | ||
python ./.azure-pipelines/test_plan.py create \ | ||
-t ${{ parameters.TOPOLOGY }} \ | ||
-o new_test_plan_id.txt \ | ||
--min-worker ${{ parameters.MIN_WORKER }} \ | ||
--max-worker ${{ parameters.MAX_WORKER }} \ | ||
--test-set ${{ parameters.TEST_SET }} \ | ||
--kvm-build-id $(KVM_BUILD_ID) \ | ||
--kvm-image-branch "${{ parameters.KVM_IMAGE_BRANCH }}" \ | ||
--deploy-mg-extra-params "${{ parameters.DEPLOY_MG_EXTRA_PARAMS }}" \ | ||
--common-extra-params "${{ parameters.COMMON_EXTRA_PARAMS }}" \ | ||
--vm-type ${{ parameters.VM_TYPE }} --num-asic ${{ parameters.NUM_ASIC }} \ | ||
--image_url ${{ parameters.IMAGE_URL }} \ | ||
--hwsku ${{ parameters.HWSKU }} \ | ||
--test-plan-type ${{ parameters.TEST_PLAN_TYPE }} \ | ||
--platform ${{ parameters.PLATFORM }} \ | ||
--testbed-name "${{ parameters.TESTBED_NAME }}" \ | ||
--scripts "${{ parameters.SCRIPTS }}" \ | ||
--features "${{ parameters.FEATURES }}" \ | ||
--scripts-exclude "${{ parameters.SCRIPTS_EXCLUDE }}" \ | ||
--features-exclude "${{ parameters.FEATURES_EXCLUDE }}" \ | ||
--repo-name ${{ parameters.REPO_NAME }} \ | ||
--mgmt-branch ${{ parameters.MGMT_BRANCH }} \ | ||
--stop-on-failure ${{ parameters.STOP_ON_FAILURE }} \ | ||
--retry-times ${{ parameters.RETRY_TIMES }} \ | ||
--dump-kvm-if-fail ${{ parameters.DUMP_KVM_IF_FAIL }} \ | ||
--requester "${{ parameters.REQUESTER }}" \ | ||
--max-execute-seconds $((${{ parameters.MAX_RUN_TEST_MINUTES }} * 60)) | ||
TEST_PLAN_ID=`cat new_test_plan_id.txt` | ||
echo "Created test plan $TEST_PLAN_ID" | ||
echo -e "\033[33mSONiC PR system-level test is powered by SONiC Elastictest, for any issue, please send email to sonicelastictest@microsoft.com \033[0m" | ||
echo -e -n "\033[33mPlease visit Elastictest page \033[0m" | ||
echo -n "$(FRONTEND_URL)/scheduler/testplan/$TEST_PLAN_ID " | ||
echo -e "\033[33mfor detailed test plan progress \033[0m" | ||
echo "##vso[task.setvariable variable=TEST_PLAN_ID]$TEST_PLAN_ID" | ||
displayName: "Trigger test" | ||
- script: | | ||
set -e | ||
echo "Lock testbed" | ||
echo -e "\033[33mSONiC PR system-level test is powered by SONiC Elastictest, for any issue, please send email to sonicelastictest@microsoft.com \033[0m" | ||
echo -e -n "\033[33mPlease visit Elastictest page \033[0m" | ||
echo -n "$(FRONTEND_URL)/scheduler/testplan/$TEST_PLAN_ID " | ||
echo -e "\033[33mfor detailed test plan progress \033[0m" | ||
# When "LOCK_TESTBED" finish, it changes into "PREPARE_TESTBED" | ||
echo "##[group][test_plan.py] poll LOCK_TESTBED status" | ||
python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --expected-state LOCK_TESTBED | ||
echo "##[endgroup]" | ||
displayName: "Lock testbed" | ||
- script: | | ||
set -e | ||
echo "Prepare testbed" | ||
echo "Preparing the testbed(add-topo, deploy-mg) may take 15-30 minutes. Before the testbed is ready, the progress of the test plan keeps displayed as 0, please be patient" | ||
echo -e "\033[33mSONiC PR system-level test is powered by SONiC Elastictest, for any issue, please send email to sonicelastictest@microsoft.com \033[0m" | ||
echo -e -n "\033[33mPlease visit Elastictest page \033[0m" | ||
echo -n "$(FRONTEND_URL)/scheduler/testplan/$TEST_PLAN_ID " | ||
echo -e "\033[33mfor detailed test plan progress \033[0m" | ||
# When "PREPARE_TESTBED" finish, it changes into "EXECUTING" | ||
echo "##[group][test_plan.py] poll PREPARE_TESTBED status" | ||
python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --expected-state PREPARE_TESTBED | ||
echo "##[endgroup]" | ||
displayName: "Prepare testbed" | ||
- script: | | ||
set -e | ||
echo "Run test" | ||
echo -e "\033[33mSONiC PR system-level test is powered by SONiC Elastictest, for any issue, please send email to sonicelastictest@microsoft.com \033[0m" | ||
echo -e -n "\033[33mPlease visit Elastictest page \033[0m" | ||
echo -n "$(FRONTEND_URL)/scheduler/testplan/$TEST_PLAN_ID " | ||
echo -e "\033[33mfor detailed test plan progress \033[0m" | ||
# When "EXECUTING" finish, it changes into "KVMDUMP", "FAILED", "CANCELLED" or "FINISHED" | ||
echo "##[group][test_plan.py] poll EXECUTING status" | ||
python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --expected-state EXECUTING --expected-result ${{ parameters.EXPECTED_RESULT }} | ||
echo "##[endgroup]" | ||
displayName: "Run test" | ||
timeoutInMinutes: ${{ parameters.MAX_RUN_TEST_MINUTES }} | ||
- ${{ if eq(parameters.DUMP_KVM_IF_FAIL, 'True') }}: | ||
- script: | | ||
set -e | ||
echo "KVM dump" | ||
echo -e "\033[33mSONiC PR system-level test is powered by SONiC Elastictest, for any issue, please send email to sonicelastictest@microsoft.com \033[0m" | ||
echo -e -n "\033[33mPlease visit Elastictest page \033[0m" | ||
echo -n "$(FRONTEND_URL)/scheduler/testplan/$TEST_PLAN_ID " | ||
echo -e "\033[33mfor detailed test plan progress \033[0m" | ||
# When "KVMDUMP" finish, it changes into "FAILED", "CANCELLED" or "FINISHED" | ||
echo "##[group][test_plan.py] poll KVMDUMP status" | ||
python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --expected-state KVMDUMP | ||
echo "##[endgroup]" | ||
condition: succeededOrFailed() | ||
displayName: "KVM dump" | ||
- script: | | ||
set -e | ||
echo "Try to cancel test plan $TEST_PLAN_ID, cancelling finished test plan has no effect." | ||
python ./.azure-pipelines/test_plan.py cancel -i "$(TEST_PLAN_ID)" | ||
condition: always() | ||
displayName: "Finalize running test plan" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.