Skip to content

Commit

Permalink
azure: increase UT coverage in azure_vms_pool
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Francis <[email protected]>
  • Loading branch information
jackfrancis committed Sep 13, 2024
1 parent d22b678 commit d76975f
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestDeleteOutdatedDeployments(t *testing.T) {
}
}

func TestGetVMsFromCache(t *testing.T) {
func TestAgentPoolGetVMsFromCache(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down Expand Up @@ -309,7 +309,7 @@ func TestAgentPoolIncreaseSize(t *testing.T) {
assert.NoError(t, err)
}

func TestDecreaseTargetSize(t *testing.T) {
func TestAgentPoolDecreaseTargetSize(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down
34 changes: 17 additions & 17 deletions cluster-autoscaler/cloudprovider/azure/azure_scale_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func newApiNode(orchmode compute.OrchestrationMode, vmID int64) *apiv1.Node {
}
return node
}
func TestMaxSize(t *testing.T) {
func TestScaleSetMaxSize(t *testing.T) {
provider := newTestProvider(t)
registered := provider.azureManager.RegisterNodeGroup(
newTestScaleSet(provider.azureManager, "test-asg"))
Expand All @@ -147,7 +147,7 @@ func TestMaxSize(t *testing.T) {
assert.Equal(t, provider.NodeGroups()[0].MaxSize(), 5)
}

func TestMinSize(t *testing.T) {
func TestScaleSetMinSize(t *testing.T) {
provider := newTestProvider(t)
registered := provider.azureManager.RegisterNodeGroup(
newTestScaleSet(provider.azureManager, "test-asg"))
Expand All @@ -156,7 +156,7 @@ func TestMinSize(t *testing.T) {
assert.Equal(t, provider.NodeGroups()[0].MinSize(), 1)
}

func TestMinSizeZero(t *testing.T) {
func TestScaleSetMinSizeZero(t *testing.T) {
provider := newTestProvider(t)
registered := provider.azureManager.RegisterNodeGroup(
newTestScaleSetMinSizeZero(provider.azureManager, testASG))
Expand All @@ -165,7 +165,7 @@ func TestMinSizeZero(t *testing.T) {
assert.Equal(t, provider.NodeGroups()[0].MinSize(), 0)
}

func TestTargetSize(t *testing.T) {
func TestScaleSetTargetSize(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down Expand Up @@ -235,7 +235,7 @@ func TestTargetSize(t *testing.T) {
}
}

func TestIncreaseSize(t *testing.T) {
func TestScaleSetIncreaseSize(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down Expand Up @@ -352,7 +352,7 @@ func TestIncreaseSize(t *testing.T) {

// TestIncreaseSizeOnVMProvisioningFailed has been tweeked only for Uniform Orchestration mode.
// If ProvisioningState == failed and power state is not running, Status.State == InstanceCreating with errorInfo populated.
func TestIncreaseSizeOnVMProvisioningFailed(t *testing.T) {
func TestScaleSetIncreaseSizeOnVMProvisioningFailed(t *testing.T) {
testCases := map[string]struct {
expectInstanceRunning bool
isMissingInstanceView bool
Expand Down Expand Up @@ -441,7 +441,7 @@ func TestIncreaseSizeOnVMProvisioningFailed(t *testing.T) {
}
}

func TestIncreaseSizeOnVMSSUpdating(t *testing.T) {
func TestScaleSetIncreaseSizeOnVMSSUpdating(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down Expand Up @@ -491,7 +491,7 @@ func TestIncreaseSizeOnVMSSUpdating(t *testing.T) {
assert.NoError(t, err)
}

func TestBelongs(t *testing.T) {
func TestScaleSetBelongs(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down Expand Up @@ -543,7 +543,7 @@ func TestBelongs(t *testing.T) {
}
}

func TestDeleteNodes(t *testing.T) {
func TestScaleSetDeleteNodes(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down Expand Up @@ -681,7 +681,7 @@ func TestDeleteNodes(t *testing.T) {
}
}

func TestDeleteNodeUnregistered(t *testing.T) {
func TestScaleSetDeleteNodeUnregistered(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down Expand Up @@ -794,7 +794,7 @@ func TestDeleteNodeUnregistered(t *testing.T) {
}
}

func TestDeleteInstancesWithForceDeleteEnabled(t *testing.T) {
func TestScaleSetDeleteInstancesWithForceDeleteEnabled(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
manager := newTestAzureManager(t)
Expand Down Expand Up @@ -908,7 +908,7 @@ func TestDeleteInstancesWithForceDeleteEnabled(t *testing.T) {

}

func TestDeleteNoConflictRequest(t *testing.T) {
func TestScaleSetDeleteNoConflictRequest(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down Expand Up @@ -969,7 +969,7 @@ func TestDeleteNoConflictRequest(t *testing.T) {
err = scaleSet.DeleteNodes([]*apiv1.Node{node})
}

func TestId(t *testing.T) {
func TestScaleSetId(t *testing.T) {
provider := newTestProvider(t)
registered := provider.azureManager.RegisterNodeGroup(
newTestScaleSet(provider.azureManager, "test-asg"))
Expand All @@ -978,7 +978,7 @@ func TestId(t *testing.T) {
assert.Equal(t, provider.NodeGroups()[0].Id(), "test-asg")
}

func TestDebug(t *testing.T) {
func TestAgentPoolDebug(t *testing.T) {
asg := ScaleSet{
manager: newTestAzureManager(t),
minSize: 5,
Expand Down Expand Up @@ -1057,7 +1057,7 @@ func TestScaleSetNodes(t *testing.T) {

}

func TestEnableVmssFlexNodesFlag(t *testing.T) {
func TestScaleSetEnableVmssFlexNodesFlag(t *testing.T) {

// flag set to false
ctrl := gomock.NewController(t)
Expand Down Expand Up @@ -1089,7 +1089,7 @@ func TestEnableVmssFlexNodesFlag(t *testing.T) {
assert.NoError(t, err)
}

func TestTemplateNodeInfo(t *testing.T) {
func TestScaleSetTemplateNodeInfo(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Expand Down Expand Up @@ -1211,7 +1211,7 @@ func TestTemplateNodeInfo(t *testing.T) {
})

}
func TestCseErrors(t *testing.T) {
func TestScaleSetCseErrors(t *testing.T) {
errorMessage := to.StringPtr("Error Message Test")
vmssVMs := compute.VirtualMachineScaleSetVM{
Name: to.StringPtr("vmTest"),
Expand Down
2 changes: 1 addition & 1 deletion cluster-autoscaler/cloudprovider/azure/azure_vms_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (agentPool *VMsPool) Nodes() ([]cloudprovider.Instance, error) {

nodes := make([]cloudprovider.Instance, 0, len(vms))
for _, vm := range vms {
if len(*vm.ID) == 0 {
if vm.ID == nil || len(*vm.ID) == 0 {
continue
}
resourceID, err := convertResourceGroupNameToLower("azure://" + *vm.ID)
Expand Down
Loading

0 comments on commit d76975f

Please sign in to comment.