Skip to content

Commit 5532c7b

Browse files
Maosheng Renzjs
authored andcommitted
Add a retry logic in Create Uniquer Bridge Network to avoid conflict (vmware#8156) (vmware#8184)
Fixes vmware#8061 Testing done: 1.run local-integration-test.sh with limit the lowerVLAN/upperVLAN to 217/220, by creating portgroup VCH-0-218,VCH-0-220 in vCenter before the tests. check debug.log to make sure the retry logic performs correctly. 2.run full regression in CI system to make sure no regression from the change. (cherry picked from commit 3df36b3)
1 parent c579c8f commit 5532c7b

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

tests/resources/VCH-Util.robot

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,23 @@ Set Test Environment Variables
8484
Run Keyword If ${status} Wait Until Keyword Succeeds 5x 1s Create Unique Bridge Network
8585

8686
Create Unique Bridge Network
87+
#Retry 3 times if ${rc} not return 0; there might be vlan conflict while parallel tests are running.
88+
:FOR ${index} IN RANGE 3
8789
# Ensure unique bridges are non-overlapping in a shared build environment (our CI)
88-
@{URLs}= Split String %{TEST_URL_ARRAY}
89-
${idx}= Get Index From List ${URLs} %{TEST_URL}
90-
${lowerVLAN}= Evaluate (${idx}+2) * 100
91-
${upperVLAN}= Evaluate ${lowerVLAN}+100
90+
\ @{URLs}= Split String %{TEST_URL_ARRAY}
91+
\ ${idx}= Get Index From List ${URLs} %{TEST_URL}
92+
\ ${lowerVLAN}= Evaluate (${idx}+2) * 100
93+
\ ${upperVLAN}= Evaluate ${lowerVLAN}+100
9294

9395
# Set a unique bridge network for each VCH that has a random VLAN ID
94-
${vlan}= Evaluate str(random.randint(${lowerVLAN}, ${upperVLAN})) modules=random
95-
${vswitch}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.vswitch.info -json | jq -r ".Vswitch[0].Name"
96-
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run And Return Rc And Output govc host.portgroup.add -vlan=${vlan} -vswitch ${vswitch} VCH-%{DRONE_BUILD_NUMBER}-${vlan}
97-
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Should Be Equal As Integers ${rc} 0
98-
99-
${dvs}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run govc find -type DistributedVirtualSwitch | head -n1
100-
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run And Return Rc And Output govc dvs.portgroup.add -vlan=${vlan} -dvs ${dvs} VCH-%{DRONE_BUILD_NUMBER}-${vlan}
101-
Run Keyword If '%{HOST_TYPE}' == 'VC' Should Be Equal As Integers ${rc} 0
102-
Set Environment Variable BRIDGE_NETWORK VCH-%{DRONE_BUILD_NUMBER}-${vlan}
96+
\ ${vlan}= Evaluate str(random.randint(${lowerVLAN}, ${upperVLAN})) modules=random
97+
\ ${vswitch}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.vswitch.info -json | jq -r ".Vswitch[0].Name"
98+
\ ${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run And Return Rc And Output govc host.portgroup.add -vlan=${vlan} -vswitch ${vswitch} VCH-%{DRONE_BUILD_NUMBER}-${vlan}
99+
100+
\ ${dvs}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run govc find -type DistributedVirtualSwitch | head -n1
101+
\ ${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run And Return Rc And Output govc dvs.portgroup.add -vlan=${vlan} -dvs ${dvs} VCH-%{DRONE_BUILD_NUMBER}-${vlan}
102+
\ Run Keyword If ${rc} == 0 Run Keyword And Return Set Environment Variable BRIDGE_NETWORK VCH-%{DRONE_BUILD_NUMBER}-${vlan}
103+
\ ... ELSE Log ${output} level=WARN
103104

104105
Set Test VCH Name
105106
${name}= Evaluate 'VCH-%{DRONE_BUILD_NUMBER}-' + str(random.randint(1000,9999)) modules=random

0 commit comments

Comments
 (0)