Skip to content

Commit 051c480

Browse files
author
Maosheng Ren
authored
refactor "Add a retry logic in Create Uniquer Bridge Network to avoid conflict (#8156)" (#8196)
Using "Wait Until Keyword Succeeds" instead of For loop. 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. 3.contruct a scenario of failure 5 times, make sure it fails. This reverts commit 3df36b3.
1 parent 7442d9f commit 051c480

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

tests/resources/VCH-Util.robot

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,29 @@ Set Test Environment Variables
8585

8686
# create a new, unique bridge if there isn't one already
8787
${status}= Run Keyword And Return Status Environment Variable Should Not Be Set BRIDGE_NETWORK
88-
Run Keyword If ${status} Wait Until Keyword Succeeds 5x 1s Create Unique Bridge Network
88+
Run Keyword If ${status} Create Unique Bridge Network
8989

9090
Create Unique Bridge Network
91-
#Retry 3 times if ${rc} not return 0; there might be vlan conflict while parallel tests are running.
92-
:FOR ${index} IN RANGE 3
91+
#Retry 5 times,there might be vlan conflict while parallel tests are running
92+
Wait Until Keyword Succeeds 5x 1s Create Unique Bridge Network Internal
93+
Create Unique Bridge Network Internal
9394
# Ensure unique bridges are non-overlapping in a shared build environment (our CI)
94-
\ @{URLs}= Split String %{TEST_URL_ARRAY}
95-
\ ${idx}= Get Index From List ${URLs} %{TEST_URL}
96-
\ ${lowerVLAN}= Evaluate (${idx}+2) * 100
97-
\ ${upperVLAN}= Evaluate ${lowerVLAN}+100
95+
@{URLs}= Split String %{TEST_URL_ARRAY}
96+
${idx}= Get Index From List ${URLs} %{TEST_URL}
97+
${lowerVLAN}= Evaluate (${idx}+2) * 100
98+
${upperVLAN}= Evaluate ${lowerVLAN}+100
9899

99100
# Set a unique bridge network for each VCH that has a random VLAN ID
100-
\ ${vlan}= Evaluate str(random.randint(${lowerVLAN}, ${upperVLAN})) modules=random
101-
\ ${vswitch}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.vswitch.info -json | jq -r ".Vswitch[0].Name"
102-
\ ${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}
103-
104-
\ ${dvs}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run govc find -type DistributedVirtualSwitch | head -n1
105-
\ ${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}
106-
\ Run Keyword If ${rc} == 0 Run Keyword And Return Set Environment Variable BRIDGE_NETWORK VCH-%{DRONE_BUILD_NUMBER}-${vlan}
107-
\ ... ELSE Log ${output} level=WARN
101+
${vlan}= Evaluate str(random.randint(${lowerVLAN}, ${upperVLAN})) modules=random
102+
${vswitch}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.vswitch.info -json | jq -r ".Vswitch[0].Name"
103+
${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}
104+
105+
${dvs}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run govc find -type DistributedVirtualSwitch | head -n1
106+
${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}
107+
108+
Run Keyword If ${rc} == 0 Run Keyword And Return Set Environment Variable BRIDGE_NETWORK VCH-%{DRONE_BUILD_NUMBER}-${vlan}
109+
... ELSE Log ${output} level=WARN
110+
Should Be Equal As Integers ${rc} 0
108111

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

0 commit comments

Comments
 (0)