@@ -67,14 +67,14 @@ func newTestScaleSetWithState(ctrl *gomock.Controller) (*scaleSet, error) {
67
67
return ss .(* scaleSet ), nil
68
68
}
69
69
70
- func buildTestVMSS (lbBackendpoolIDs []string ) compute.VirtualMachineScaleSet {
70
+ func buildTestVMSS (name string , lbBackendpoolIDs []string ) compute.VirtualMachineScaleSet {
71
71
lbBackendpools := make ([]compute.SubResource , 0 )
72
72
for _ , id := range lbBackendpoolIDs {
73
73
lbBackendpools = append (lbBackendpools , compute.SubResource {ID : to .StringPtr (id )})
74
74
}
75
75
76
76
expectedVMSS := compute.VirtualMachineScaleSet {
77
- Name : to . StringPtr ( testVMSSName ) ,
77
+ Name : & name ,
78
78
VirtualMachineScaleSetProperties : & compute.VirtualMachineScaleSetProperties {
79
79
ProvisioningState : to .StringPtr ("Running" ),
80
80
VirtualMachineProfile : & compute.VirtualMachineScaleSetVMProfile {
@@ -1732,7 +1732,7 @@ func TestEnsureVMSSInPool(t *testing.T) {
1732
1732
ss .LoadBalancerSku = loadBalancerSkuStandard
1733
1733
}
1734
1734
1735
- expectedVMSS := buildTestVMSS ([]string {testLBBackendpoolID0 })
1735
+ expectedVMSS := buildTestVMSS (testVMSSName , []string {testLBBackendpoolID0 })
1736
1736
if test .isVMSSDeallocating {
1737
1737
expectedVMSS .ProvisioningState = & virtualMachineScaleSetsDeallocating
1738
1738
}
@@ -1829,7 +1829,7 @@ func TestEnsureHostsInPool(t *testing.T) {
1829
1829
ss .LoadBalancerSku = loadBalancerSkuStandard
1830
1830
ss .ExcludeMasterFromStandardLB = to .BoolPtr (true )
1831
1831
1832
- expectedVMSS := buildTestVMSS ([]string {testLBBackendpoolID0 })
1832
+ expectedVMSS := buildTestVMSS (testVMSSName , []string {testLBBackendpoolID0 })
1833
1833
mockVMSSClient := ss .cloud .VirtualMachineScaleSetsClient .(* mockvmssclient.MockInterface )
1834
1834
mockVMSSClient .EXPECT ().List (gomock .Any (), ss .ResourceGroup ).Return ([]compute.VirtualMachineScaleSet {expectedVMSS }, nil ).AnyTimes ()
1835
1835
mockVMSSClient .EXPECT ().Get (gomock .Any (), ss .ResourceGroup , testVMSSName ).Return (expectedVMSS , nil ).MaxTimes (1 )
@@ -2006,7 +2006,7 @@ func TestEnsureBackendPoolDeletedFromVMSS(t *testing.T) {
2006
2006
2007
2007
ss .LoadBalancerSku = loadBalancerSkuStandard
2008
2008
2009
- expectedVMSS := buildTestVMSS ([]string {testLBBackendpoolID0 })
2009
+ expectedVMSS := buildTestVMSS (testVMSSName , []string {testLBBackendpoolID0 })
2010
2010
if test .isVMSSDeallocating {
2011
2011
expectedVMSS .ProvisioningState = & virtualMachineScaleSetsDeallocating
2012
2012
}
@@ -2100,7 +2100,7 @@ func TestEnsureBackendPoolDeleted(t *testing.T) {
2100
2100
ss , err := newTestScaleSet (ctrl )
2101
2101
assert .NoError (t , err , test .description )
2102
2102
2103
- expectedVMSS := buildTestVMSS ([]string {testLBBackendpoolID0 })
2103
+ expectedVMSS := buildTestVMSS (testVMSSName , []string {testLBBackendpoolID0 })
2104
2104
mockVMSSClient := ss .cloud .VirtualMachineScaleSetsClient .(* mockvmssclient.MockInterface )
2105
2105
mockVMSSClient .EXPECT ().List (gomock .Any (), ss .ResourceGroup ).Return ([]compute.VirtualMachineScaleSet {expectedVMSS }, nil ).AnyTimes ()
2106
2106
mockVMSSClient .EXPECT ().Get (gomock .Any (), ss .ResourceGroup , testVMSSName ).Return (expectedVMSS , nil ).MaxTimes (1 )
@@ -2130,7 +2130,7 @@ func TestEnsureBackendPoolDeletedConcurrently(t *testing.T) {
2130
2130
BackendIPConfigurations : & []network.InterfaceIPConfiguration {
2131
2131
{
2132
2132
Name : to .StringPtr ("ip-1" ),
2133
- ID : to .StringPtr ("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss/virtualMachines/0/networkInterfaces/nic" ),
2133
+ ID : to .StringPtr ("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-0 /virtualMachines/0/networkInterfaces/nic" ),
2134
2134
},
2135
2135
},
2136
2136
},
@@ -2141,7 +2141,7 @@ func TestEnsureBackendPoolDeletedConcurrently(t *testing.T) {
2141
2141
BackendIPConfigurations : & []network.InterfaceIPConfiguration {
2142
2142
{
2143
2143
Name : to .StringPtr ("ip-1" ),
2144
- ID : to .StringPtr ("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss/virtualMachines/0/networkInterfaces/nic" ),
2144
+ ID : to .StringPtr ("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-1 /virtualMachines/0/networkInterfaces/nic" ),
2145
2145
},
2146
2146
},
2147
2147
},
@@ -2153,35 +2153,43 @@ func TestEnsureBackendPoolDeletedConcurrently(t *testing.T) {
2153
2153
BackendIPConfigurations : & []network.InterfaceIPConfiguration {
2154
2154
{
2155
2155
Name : to .StringPtr ("ip-1" ),
2156
- ID : to .StringPtr ("/subscriptions/sub/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachineScaleSets/vmss/virtualMachines/0/networkInterfaces/nic" ),
2156
+ ID : to .StringPtr ("/subscriptions/sub/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-0 /virtualMachines/0/networkInterfaces/nic" ),
2157
2157
},
2158
2158
},
2159
2159
},
2160
2160
},
2161
2161
}
2162
- expectedVMSS := buildTestVMSS ([]string {testLBBackendpoolID0 , testLBBackendpoolID1 })
2163
-
2164
- expectedVMSSVMs , _ , _ := buildTestVirtualMachineEnv (ss .cloud , testVMSSName , "" , 0 , []string {"vmss-vm-000000" }, "succeeded" )
2165
- vmssVMNetworkConfigs := expectedVMSSVMs [0 ].NetworkProfileConfiguration
2166
- vmssVMIPConfigs := (* vmssVMNetworkConfigs .NetworkInterfaceConfigurations )[0 ].VirtualMachineScaleSetNetworkConfigurationProperties .IPConfigurations
2167
- lbBackendpools := (* vmssVMIPConfigs )[0 ].LoadBalancerBackendAddressPools
2168
- * lbBackendpools = append (* lbBackendpools , compute.SubResource {ID : to .StringPtr (testLBBackendpoolID1 )})
2162
+ vmss0 := buildTestVMSS ("vmss-0" , []string {testLBBackendpoolID0 , testLBBackendpoolID1 })
2163
+ vmss1 := buildTestVMSS ("vmss-1" , []string {testLBBackendpoolID0 , testLBBackendpoolID1 })
2164
+
2165
+ expectedVMSSVMsOfVMSS0 , _ , _ := buildTestVirtualMachineEnv (ss .cloud , "vmss-0" , "" , 0 , []string {"vmss-vm-000000" }, "succeeded" )
2166
+ expectedVMSSVMsOfVMSS1 , _ , _ := buildTestVirtualMachineEnv (ss .cloud , "vmss-1" , "" , 0 , []string {"vmss-vm-000001" }, "succeeded" )
2167
+ for _ , expectedVMSSVMs := range [][]compute.VirtualMachineScaleSetVM {expectedVMSSVMsOfVMSS0 , expectedVMSSVMsOfVMSS1 } {
2168
+ vmssVMNetworkConfigs := expectedVMSSVMs [0 ].NetworkProfileConfiguration
2169
+ vmssVMIPConfigs := (* vmssVMNetworkConfigs .NetworkInterfaceConfigurations )[0 ].VirtualMachineScaleSetNetworkConfigurationProperties .IPConfigurations
2170
+ lbBackendpools := (* vmssVMIPConfigs )[0 ].LoadBalancerBackendAddressPools
2171
+ * lbBackendpools = append (* lbBackendpools , compute.SubResource {ID : to .StringPtr (testLBBackendpoolID1 )})
2172
+ }
2169
2173
2170
2174
mockVMSSClient := ss .cloud .VirtualMachineScaleSetsClient .(* mockvmssclient.MockInterface )
2171
- mockVMSSClient .EXPECT ().List (gomock .Any (), ss .ResourceGroup ).Return ([]compute.VirtualMachineScaleSet {expectedVMSS }, nil ).AnyTimes ()
2172
- mockVMSSClient .EXPECT ().Get (gomock .Any (), ss .ResourceGroup , testVMSSName ).Return (expectedVMSS , nil ).MaxTimes (2 )
2173
- mockVMSSClient .EXPECT ().CreateOrUpdate (gomock .Any (), ss .ResourceGroup , testVMSSName , gomock .Any ()).Return (nil ).Times (2 )
2175
+ mockVMSSClient .EXPECT ().List (gomock .Any (), ss .ResourceGroup ).Return ([]compute.VirtualMachineScaleSet {vmss0 , vmss1 }, nil ).AnyTimes ()
2176
+ mockVMSSClient .EXPECT ().Get (gomock .Any (), ss .ResourceGroup , "vmss-0" ).Return (vmss0 , nil ).MaxTimes (2 )
2177
+ mockVMSSClient .EXPECT ().Get (gomock .Any (), ss .ResourceGroup , "vmss-1" ).Return (vmss1 , nil ).MaxTimes (2 )
2178
+ mockVMSSClient .EXPECT ().CreateOrUpdate (gomock .Any (), ss .ResourceGroup , gomock .Any (), gomock .Any ()).Return (nil ).Times (2 )
2174
2179
2175
2180
mockVMSSVMClient := ss .cloud .VirtualMachineScaleSetVMsClient .(* mockvmssvmclient.MockInterface )
2176
- mockVMSSVMClient .EXPECT ().List (gomock .Any (), ss .ResourceGroup , testVMSSName , gomock .Any ()).Return (expectedVMSSVMs , nil ).AnyTimes ()
2177
- mockVMSSVMClient .EXPECT ().UpdateVMs (gomock .Any (), ss .ResourceGroup , testVMSSName , gomock .Any (), gomock .Any ()).Return (nil ).Times (2 )
2181
+ mockVMSSVMClient .EXPECT ().List (gomock .Any (), ss .ResourceGroup , "vmss-0" , gomock .Any ()).Return (expectedVMSSVMsOfVMSS0 , nil ).AnyTimes ()
2182
+ mockVMSSVMClient .EXPECT ().List (gomock .Any (), ss .ResourceGroup , "vmss-1" , gomock .Any ()).Return (expectedVMSSVMsOfVMSS1 , nil ).AnyTimes ()
2183
+ mockVMSSVMClient .EXPECT ().UpdateVMs (gomock .Any (), ss .ResourceGroup , gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil ).Times (2 )
2178
2184
2179
2185
backendpoolAddressIDs := []string {testLBBackendpoolID0 , testLBBackendpoolID1 , testLBBackendpoolID2 }
2186
+ testVMSSNames := []string {"vmss-0" , "vmss-1" , "vmss-0" }
2180
2187
testFunc := make ([]func () error , 0 )
2181
- for _ , id := range backendpoolAddressIDs {
2188
+ for i , id := range backendpoolAddressIDs {
2189
+ i := i
2182
2190
id := id
2183
2191
testFunc = append (testFunc , func () error {
2184
- return ss .EnsureBackendPoolDeleted (& v1.Service {}, id , testVMSSName , backendAddressPools )
2192
+ return ss .EnsureBackendPoolDeleted (& v1.Service {}, id , testVMSSNames [ i ] , backendAddressPools )
2185
2193
})
2186
2194
}
2187
2195
errs := utilerrors .AggregateGoroutines (testFunc ... )
0 commit comments