Merge pull request #471 from krzysztof-jastrzebski/master

Fix unit static autoscaler unit tests.
This commit is contained in:
Marcin Wielgus 2017-11-16 11:31:57 +01:00 committed by GitHub
commit 5ba57468fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -99,6 +99,13 @@ func (tcp *TestCloudProvider) NodeGroups() []cloudprovider.NodeGroup {
return result
}
// GetNodeGroup returns node group with the given name.
func (tcp *TestCloudProvider) GetNodeGroup(name string) cloudprovider.NodeGroup {
tcp.Lock()
defer tcp.Unlock()
return tcp.groups[name]
}
// NodeGroupForNode returns the node group for the given node, nil if the node
// should not be processed by cluster autoscaler, or non-nil error if such
// occurred.

View File

@ -153,7 +153,8 @@ func TestStaticAutoscalerRunOnce(t *testing.T) {
nil, map[string]*schedulercache.NodeInfo{"ng1": tni})
provider.AddNodeGroup("ng1", 1, 10, 1)
provider.AddNode("ng1", n1)
ng1 := reflect.ValueOf(provider.NodeGroups()[0]).Interface().(*testprovider.TestNodeGroup)
ng1 := reflect.ValueOf(provider.GetNodeGroup("ng1")).Interface().(*testprovider.TestNodeGroup)
assert.NotNil(t, ng1)
assert.NotNil(t, provider)
fakeClient := &fake.Clientset{}
@ -328,7 +329,8 @@ func TestStaticAutoscalerRunOnceWithAutoprovisionedEnabled(t *testing.T) {
[]string{"TN1", "TN2"}, map[string]*schedulercache.NodeInfo{"TN1": tni1, "TN2": tni2, "ng1": tni3})
provider.AddNodeGroup("ng1", 1, 10, 1)
provider.AddAutoprovisionedNodeGroup("autoprovisioned-TN1", 0, 10, 0, "TN1")
autoprovisionedTN1 := reflect.ValueOf(provider.NodeGroups()[1]).Interface().(*testprovider.TestNodeGroup)
autoprovisionedTN1 := reflect.ValueOf(provider.GetNodeGroup("autoprovisioned-TN1")).Interface().(*testprovider.TestNodeGroup)
assert.NotNil(t, autoprovisionedTN1)
provider.AddNode("ng1,", n1)
assert.NotNil(t, provider)
@ -461,7 +463,8 @@ func TestStaticAutoscalerRunOnceWithALongUnregisteredNode(t *testing.T) {
brokenNode := BuildTestNode("broken", 1000, 1000)
provider.AddNode("ng1", brokenNode)
ng1 := reflect.ValueOf(provider.NodeGroups()[0]).Interface().(*testprovider.TestNodeGroup)
ng1 := reflect.ValueOf(provider.GetNodeGroup("ng1")).Interface().(*testprovider.TestNodeGroup)
assert.NotNil(t, ng1)
assert.NotNil(t, provider)
fakeClient := &fake.Clientset{}
@ -600,7 +603,8 @@ func TestStaticAutoscalerRunOncePodsWithPriorities(t *testing.T) {
provider.AddNode("ng2", n2)
provider.AddNode("ng2", n3)
assert.NotNil(t, provider)
ng2 := reflect.ValueOf(provider.NodeGroups()[1]).Interface().(*testprovider.TestNodeGroup)
ng2 := reflect.ValueOf(provider.GetNodeGroup("ng2")).Interface().(*testprovider.TestNodeGroup)
assert.NotNil(t, ng2)
fakeClient := &fake.Clientset{}
fakeRecorder := kube_record.NewFakeRecorder(5)