Skip to content

Commit

Permalink
Enable designating build id of KVM image (#6424)
Browse files Browse the repository at this point in the history
* Enable designating build id of KVM image

Support switch kvm images in un-testbedv2 test jobs

* Temporary comment dhcp_relay test since it relies on recent fix


Approach
What is the motivation for this PR?
Enable designating build id of KVM image to avoid image issue keep affecting sonic-mgmt repo pull requests.

How did you do it?
Enable designating build id of KVM image to avoid image issue keep affecting sonic-mgmt repo pull requests.

How did you verify/test it?
Pipeline tests it.

co-authorized by: jianquanye@microsoft.com
  • Loading branch information
yejianquan authored Sep 28, 2022
1 parent d6d8d9c commit c41f842
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .azure-pipelines/pr_test_scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ t0:
- container_checker/test_container_checker.py
- cacl/test_cacl_application.py
- cacl/test_cacl_function.py
- dhcp_relay/test_dhcp_relay.py
# - dhcp_relay/test_dhcp_relay.py
- dhcp_relay/test_dhcpv6_relay.py
- generic_config_updater/test_aaa.py
- generic_config_updater/test_bgpl.py
Expand Down Expand Up @@ -62,7 +62,7 @@ t0:
- test_procdockerstatsd.py

t0-2vlans:
- dhcp_relay/test_dhcp_relay.py
# - dhcp_relay/test_dhcp_relay.py
- dhcp_relay/test_dhcpv6_relay.py

t0-sonic:
Expand Down
6 changes: 4 additions & 2 deletions .azure-pipelines/run-test-scheduler-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ parameters:

steps:
- script: |
set -e
set -ex
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 }} --deploy-mg-extra-params "${{ parameters.DEPLOY_MG_EXTRA_PARAMS }}"
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) --deploy-mg-extra-params "${{ parameters.DEPLOY_MG_EXTRA_PARAMS }}"
TEST_PLAN_ID=`cat new_test_plan_id.txt`
echo "Created test plan $TEST_PLAN_ID"
Expand All @@ -47,6 +47,7 @@ steps:
displayName: Trigger test
- script: |
set -ex
echo "Polling Test plan"
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(We will improve the indication in a short time)"
echo "If the progress keeps as 0 for more than 1 hour, please cancel and retry this pipeline"
Expand All @@ -59,6 +60,7 @@ steps:
timeoutInMinutes: 300
- script: |
set -ex
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()
Expand Down
3 changes: 2 additions & 1 deletion .azure-pipelines/run-test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ steps:
project: build
pipeline: 1
artifact: sonic-buildimage.vs
runVersion: 'latestFromBranch'
runVersion: specific
runId: $(KVM_BUILD_ID)
runBranch: 'refs/heads/master'
allowPartiallySucceededBuilds: true
displayName: "Download sonic kvm image"
Expand Down
16 changes: 14 additions & 2 deletions .azure-pipelines/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _get_token(self):
except Exception as e:
raise Exception("Get token failed with exception: {}".format(repr(e)))

def create(self, topology, test_plan_name="my_test_plan", deploy_mg_extra_params="", min_worker=1, max_worker=2, pr_id="unknown", scripts=[],
def create(self, topology, test_plan_name="my_test_plan", deploy_mg_extra_params="", kvm_build_id="", min_worker=1, max_worker=2, pr_id="unknown", scripts=[],
output=None):
tp_url = "{}/test_plan".format(self.url)
print("Creating test plan, topology: {}, name: {}, build info:{} {} {}".format(topology, test_plan_name, repo_name, pr_id, build_id))
Expand Down Expand Up @@ -83,7 +83,8 @@ def create(self, topology, test_plan_name="my_test_plan", deploy_mg_extra_params
"extra_params": {
"pull_request_id": pr_id,
"build_id": build_id,
"source_repo": repo_name
"source_repo": repo_name,
"kvm_build_id": kvm_build_id
},
"priority": 10,
"requester": "pull request"
Expand Down Expand Up @@ -255,6 +256,16 @@ def poll(self, test_plan_id, interval=60, timeout=36000):
required=False,
help="Deploy minigraph extra params"
)
parser_create.add_argument(
"--kvm-build-id",
type=str,
nargs='?',
const='',
dest="kvm_build_id",
default="",
required=False,
help="KVM build id."
)

parser_poll = subparsers.add_parser("poll", help="Poll test plan status.")
parser_cancel = subparsers.add_parser("cancel", help="Cancel running test plan.")
Expand Down Expand Up @@ -338,6 +349,7 @@ def poll(self, test_plan_id, interval=60, timeout=36000):
args.topology,
test_plan_name=test_plan_name,
deploy_mg_extra_params=args.deploy_mg_extra_params,
kvm_build_id=args.kvm_build_id,
min_worker=args.min_worker,
max_worker=args.max_worker,
pr_id=pr_id,
Expand Down

0 comments on commit c41f842

Please sign in to comment.