Skip to content

Commit

Permalink
[clusterapi] Update tests for nodegroups with minSize=maxSize
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxFedotov committed Mar 13, 2024
1 parent 30ebf5c commit 6c65baa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1043,9 +1043,8 @@ func TestControllerNodeGroupForNodeWithPositiveScalingBounds(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
// We don't scale from 0 so nodes must belong to a
// nodegroup that has a scale size of at least 1.
if ng != nil {
// We allow scaling if minSize=maxSize
if ng == nil {
t.Fatalf("unexpected nodegroup: %v", ng)
}
}
Expand Down Expand Up @@ -1124,19 +1123,19 @@ func TestControllerNodeGroups(t *testing.T) {
nodeGroupMaxSizeAnnotationKey: "1",
}

// Test #5: machineset with no scaling bounds results in no nodegroups
// Test #5: 5 machineset with minSize=maxSize results in a five nodegroup
machineSetConfigs = createMachineSetTestConfigs(namespace, clusterName, RandomString(6), 5, 1, annotations, nil)
if err := addTestConfigs(t, controller, machineSetConfigs...); err != nil {
t.Fatalf("unexpected error: %v", err)
}
assertNodegroupLen(t, controller, 0)
assertNodegroupLen(t, controller, 5)

// Test #6: machinedeployment with no scaling bounds results in no nodegroups
// Test #6: add 2 machinedeployment with minSize=maxSize
machineDeploymentConfigs = createMachineDeploymentTestConfigs(namespace, clusterName, RandomString(6), 2, 1, annotations, nil)
if err := addTestConfigs(t, controller, machineDeploymentConfigs...); err != nil {
t.Fatalf("unexpected error: %v", err)
}
assertNodegroupLen(t, controller, 0)
assertNodegroupLen(t, controller, 7)

annotations = map[string]string{
nodeGroupMinSizeAnnotationKey: "-1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ func TestNodeGroupNewNodeGroupConstructor(t *testing.T) {
nodeCount: 5,
errors: false,
expectNil: true,
}, {
description: "no error and expect notNil: min=max=2",
annotations: map[string]string{
nodeGroupMinSizeAnnotationKey: "2",
nodeGroupMaxSizeAnnotationKey: "2",
},
nodeCount: 1,
minSize: 2,
maxSize: 2,
replicas: 1,
errors: false,
expectNil: false,
}}

newNodeGroup := func(controller *machineController, testConfig *testConfig) (*nodegroup, error) {
Expand Down

0 comments on commit 6c65baa

Please sign in to comment.