Add unit test case for OTHER error handling

This commit is contained in:
Łukasz Osipiuk 2019-06-07 16:53:17 +02:00
parent 1b4f1855cb
commit be68d06b40
1 changed files with 21 additions and 5 deletions

View File

@ -817,7 +817,7 @@ func TestStaticAutoscalerRunOncePodsWithPriorities(t *testing.T) {
podDisruptionBudgetListerMock, daemonSetListerMock, onScaleUpMock, onScaleDownMock)
}
func TestStaticAutoscalerOutOfResources(t *testing.T) {
func TestStaticAutoscalerInstaceCreationErrors(t *testing.T) {
// setup
provider := &mockprovider.CloudProvider{}
@ -904,6 +904,16 @@ func TestStaticAutoscalerOutOfResources(t *testing.T) {
},
},
},
{
"A6",
&cloudprovider.InstanceStatus{
State: cloudprovider.InstanceCreating,
ErrorInfo: &cloudprovider.InstanceErrorInfo{
ErrorClass: cloudprovider.OtherErrorClass,
ErrorCode: "OTHER",
},
},
},
}, nil).Twice()
nodeGroupB.On("Exist").Return(true)
@ -944,14 +954,14 @@ func TestStaticAutoscalerOutOfResources(t *testing.T) {
// check delete was called on correct nodes
nodeGroupA.AssertCalled(t, "DeleteNodes", mock.MatchedBy(
func(nodes []*apiv1.Node) bool {
if len(nodes) != 3 {
if len(nodes) != 4 {
return false
}
names := make(map[string]bool)
for _, node := range nodes {
names[node.Spec.ProviderID] = true
}
return names["A3"] && names["A4"] && names["A5"]
return names["A3"] && names["A4"] && names["A5"] && names["A6"]
}))
// TODO assert that scaleup was failed (separately for QUOTA and STOCKOUT)
@ -968,14 +978,14 @@ func TestStaticAutoscalerOutOfResources(t *testing.T) {
// nodes should be deleted again
nodeGroupA.AssertCalled(t, "DeleteNodes", mock.MatchedBy(
func(nodes []*apiv1.Node) bool {
if len(nodes) != 3 {
if len(nodes) != 4 {
return false
}
names := make(map[string]bool)
for _, node := range nodes {
names[node.Spec.ProviderID] = true
}
return names["A3"] && names["A4"] && names["A5"]
return names["A3"] && names["A4"] && names["A5"] && names["A6"]
}))
// TODO assert that scaleup is not failed again
@ -1012,6 +1022,12 @@ func TestStaticAutoscalerOutOfResources(t *testing.T) {
State: cloudprovider.InstanceDeleting,
},
},
{
"A6",
&cloudprovider.InstanceStatus{
State: cloudprovider.InstanceDeleting,
},
},
}, nil)
clusterState.RefreshCloudProviderNodeInstancesCache()