@@ -100,6 +100,13 @@ func getResultVMSS() armcompute.VirtualMachineScaleSet {
100100 return resultVMSS
101101}
102102
103+ func getMemFloatResultVMSS () armcompute.VirtualMachineScaleSet {
104+ resultVMSS := newDefaultVMSS ("VM_SIZE_MEM_FLOAT" )
105+ resultVMSS .ID = ptr .To (defaultVMSSID )
106+
107+ return resultVMSS
108+ }
109+
103110func TestReconcileVMSS (t * testing.T ) {
104111 defaultInstances := newDefaultInstances ()
105112 resultVMSS := newDefaultVMSS ("VM_SIZE" )
@@ -213,6 +220,29 @@ func TestReconcileVMSS(t *testing.T) {
213220 s .ScaleSetSpec (gomockinternal .AContext ()).Return (& spec ).AnyTimes ()
214221 },
215222 },
223+ {
224+ name : "validate spec success: Memory is float" ,
225+ expectedError : "" ,
226+ expect : func (g * WithT , s * mock_scalesets.MockScaleSetScopeMockRecorder , r * mock_async.MockReconcilerMockRecorder , m * mock_scalesets.MockClientMockRecorder ) {
227+ s .DefaultedAzureServiceReconcileTimeout ().Return (reconciler .DefaultAzureServiceReconcileTimeout )
228+ spec := newVMSSSpecWithSKU (resourceskus .MemoryGB , "217.13" )
229+ spec .Size = "VM_SIZE_MEM_FLOAT"
230+ spec .Capacity = 2
231+ spec .SSHKeyData = sshKeyData
232+ memFloatVMSS := newDefaultVMSS ("VM_SIZE_MEM_FLOAT" )
233+ memFloatVMSS .ID = ptr .To (defaultVMSSID )
234+
235+ s .ScaleSetSpec (gomockinternal .AContext ()).Return (& spec ).AnyTimes ()
236+ m .Get (gomockinternal .AContext (), & spec ).Return (memFloatVMSS , nil )
237+ m .ListInstances (gomockinternal .AContext (), spec .ResourceGroup , spec .Name ).Return (defaultInstances , nil )
238+ fetchedMemFloatVMSS := converters .SDKToVMSS (getMemFloatResultVMSS (), defaultInstances )
239+ s .ReconcileReplicas (gomockinternal .AContext (), & fetchedMemFloatVMSS ).Return (nil ).Times (2 )
240+ s .SetProviderID (azureutil .ProviderIDPrefix + defaultVMSSID ).Times (2 )
241+ s .SetVMSSState (& fetchedMemFloatVMSS ).Times (2 )
242+ r .CreateOrUpdateResource (gomockinternal .AContext (), & spec , serviceName ).Return (getMemFloatResultVMSS (), nil )
243+ s .UpdatePutStatus (infrav1 .BootstrapSucceededCondition , serviceName , nil )
244+ },
245+ },
216246 {
217247 name : "validate spec failure: failed to get SKU" ,
218248 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" ,
@@ -634,6 +664,34 @@ func getFakeSkus() []armcompute.ResourceSKU {
634664 },
635665 },
636666 },
667+ {
668+ Name : ptr .To ("VM_SIZE_MEM_FLOAT" ),
669+ ResourceType : ptr .To (string (resourceskus .VirtualMachines )),
670+ Kind : ptr .To (string (resourceskus .VirtualMachines )),
671+ Locations : []* string {
672+ ptr .To ("test-location" ),
673+ },
674+ LocationInfo : []* armcompute.ResourceSKULocationInfo {
675+ {
676+ Location : ptr .To ("test-location" ),
677+ Zones : []* string {ptr .To ("1" ), ptr .To ("3" )},
678+ },
679+ },
680+ Capabilities : []* armcompute.ResourceSKUCapabilities {
681+ {
682+ Name : ptr .To (resourceskus .AcceleratedNetworking ),
683+ Value : ptr .To (string (resourceskus .CapabilityUnsupported )),
684+ },
685+ {
686+ Name : ptr .To (resourceskus .VCPUs ),
687+ Value : ptr .To ("4" ),
688+ },
689+ {
690+ Name : ptr .To (resourceskus .MemoryGB ),
691+ Value : ptr .To ("217.13" ),
692+ },
693+ },
694+ },
637695 }
638696}
639697
@@ -729,6 +787,15 @@ func newWindowsVMSSSpec() ScaleSetSpec {
729787 vmss .OSDisk .OSType = azure .WindowsOS
730788 return vmss
731789}
790+ func newVMSSSpecWithSKU (capName string , capValue string ) ScaleSetSpec {
791+ vmsSpec := newDefaultVMSSSpec ()
792+ inputCapability := armcompute.ResourceSKUCapabilities {
793+ Name : ptr .To (capName ),
794+ Value : ptr .To (capValue ),
795+ }
796+ vmsSpec .SKU .Capabilities = append (vmsSpec .SKU .Capabilities , & inputCapability )
797+ return vmsSpec
798+ }
732799
733800func newDefaultExistingVMSS () armcompute.VirtualMachineScaleSet {
734801 vmss := newDefaultVMSS ("VM_SIZE" )
0 commit comments