@@ -101,6 +101,13 @@ func getResultVMSS() armcompute.VirtualMachineScaleSet {
101
101
return resultVMSS
102
102
}
103
103
104
+ func getMemFloatResultVMSS () armcompute.VirtualMachineScaleSet {
105
+ resultVMSS := newDefaultVMSS ("VM_SIZE_MEM_FLOAT" )
106
+ resultVMSS .ID = ptr .To (defaultVMSSID )
107
+
108
+ return resultVMSS
109
+ }
110
+
104
111
func TestReconcileVMSS (t * testing.T ) {
105
112
defaultInstances := newDefaultInstances ()
106
113
resultVMSS := newDefaultVMSS ("VM_SIZE" )
@@ -214,6 +221,29 @@ func TestReconcileVMSS(t *testing.T) {
214
221
s .ScaleSetSpec (gomockinternal .AContext ()).Return (& spec ).AnyTimes ()
215
222
},
216
223
},
224
+ {
225
+ name : "validate spec success: Memory is float" ,
226
+ expectedError : "" ,
227
+ expect : func (g * WithT , s * mock_scalesets.MockScaleSetScopeMockRecorder , r * mock_async.MockReconcilerMockRecorder , m * mock_scalesets.MockClientMockRecorder ) {
228
+ s .DefaultedAzureServiceReconcileTimeout ().Return (reconciler .DefaultAzureServiceReconcileTimeout )
229
+ spec := newVMSSSpecWithSKU (resourceskus .MemoryGB , "217.13" )
230
+ spec .Size = "VM_SIZE_MEM_FLOAT"
231
+ spec .Capacity = 2
232
+ spec .SSHKeyData = sshKeyData
233
+ memFloatVMSS := newDefaultVMSS ("VM_SIZE_MEM_FLOAT" )
234
+ memFloatVMSS .ID = ptr .To (defaultVMSSID )
235
+
236
+ s .ScaleSetSpec (gomockinternal .AContext ()).Return (& spec ).AnyTimes ()
237
+ m .Get (gomockinternal .AContext (), & spec ).Return (memFloatVMSS , nil )
238
+ m .ListInstances (gomockinternal .AContext (), spec .ResourceGroup , spec .Name ).Return (defaultInstances , nil )
239
+ fetchedMemFloatVMSS := converters .SDKToVMSS (getMemFloatResultVMSS (), defaultInstances )
240
+ s .ReconcileReplicas (gomockinternal .AContext (), & fetchedMemFloatVMSS ).Return (nil ).Times (2 )
241
+ s .SetProviderID (azureutil .ProviderIDPrefix + defaultVMSSID ).Times (2 )
242
+ s .SetVMSSState (& fetchedMemFloatVMSS ).Times (2 )
243
+ r .CreateOrUpdateResource (gomockinternal .AContext (), & spec , serviceName ).Return (getMemFloatResultVMSS (), nil )
244
+ s .UpdatePutStatus (infrav1 .BootstrapSucceededCondition , serviceName , nil )
245
+ },
246
+ },
217
247
{
218
248
name : "validate spec failure: failed to get SKU" ,
219
249
expectedError : "failed to get SKU INVALID_VM_SIZE in compute api: reconcile error that cannot be recovered occurred: resource sku with name 'INVALID_VM_SIZE' and category 'virtualMachines' not found in location 'test-location'. Object will not be requeued" ,
@@ -633,6 +663,34 @@ func getFakeSkus() []armcompute.ResourceSKU {
633
663
},
634
664
},
635
665
},
666
+ {
667
+ Name : ptr .To ("VM_SIZE_MEM_FLOAT" ),
668
+ ResourceType : ptr .To (string (resourceskus .VirtualMachines )),
669
+ Kind : ptr .To (string (resourceskus .VirtualMachines )),
670
+ Locations : []* string {
671
+ ptr .To ("test-location" ),
672
+ },
673
+ LocationInfo : []* armcompute.ResourceSKULocationInfo {
674
+ {
675
+ Location : ptr .To ("test-location" ),
676
+ Zones : []* string {ptr .To ("1" ), ptr .To ("3" )},
677
+ },
678
+ },
679
+ Capabilities : []* armcompute.ResourceSKUCapabilities {
680
+ {
681
+ Name : ptr .To (resourceskus .AcceleratedNetworking ),
682
+ Value : ptr .To (string (resourceskus .CapabilityUnsupported )),
683
+ },
684
+ {
685
+ Name : ptr .To (resourceskus .VCPUs ),
686
+ Value : ptr .To ("4" ),
687
+ },
688
+ {
689
+ Name : ptr .To (resourceskus .MemoryGB ),
690
+ Value : ptr .To ("217.13" ),
691
+ },
692
+ },
693
+ },
636
694
}
637
695
}
638
696
@@ -728,6 +786,15 @@ func newWindowsVMSSSpec() ScaleSetSpec {
728
786
vmss .OSDisk .OSType = azure .WindowsOS
729
787
return vmss
730
788
}
789
+ func newVMSSSpecWithSKU (capName string , capValue string ) ScaleSetSpec {
790
+ vmsSpec := newDefaultVMSSSpec ()
791
+ inputCapability := armcompute.ResourceSKUCapabilities {
792
+ Name : ptr .To (capName ),
793
+ Value : ptr .To (capValue ),
794
+ }
795
+ vmsSpec .SKU .Capabilities = append (vmsSpec .SKU .Capabilities , & inputCapability )
796
+ return vmsSpec
797
+ }
731
798
732
799
func newDefaultExistingVMSS () armcompute.VirtualMachineScaleSet {
733
800
vmss := newDefaultVMSS ("VM_SIZE" )
0 commit comments