Skip to content

Commit

Permalink
Add unit tests for updating multiple ng
Browse files Browse the repository at this point in the history
  • Loading branch information
nikimanoledaki committed Jul 1, 2021
1 parent 196d404 commit 06ce9f0
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion pkg/actions/nodegroup/update_test.go
Expand Up @@ -49,7 +49,7 @@ var _ = Describe("Update", func() {
Expect(err).To(MatchError(ContainSubstring("could not find managed nodegroup with name \"my-ng\"")))
})

It("[happy path] successfully updates nodegroup with updateConfig and maxUnavailable", func() {
It("[happy path] successfully updates a nodegroup with updateConfig and maxUnavailable", func() {
p.MockEKS().On("DescribeNodegroup", &awseks.DescribeNodegroupInput{
ClusterName: &clusterName,
NodegroupName: &ngName,
Expand Down Expand Up @@ -77,4 +77,63 @@ var _ = Describe("Update", func() {
err := m.Update()
Expect(err).NotTo(HaveOccurred())
})

It("[happy path] successfully updates multiple nodegroups with updateConfig and maxUnavailable", func() {
p.MockEKS().On("DescribeNodegroup", &awseks.DescribeNodegroupInput{
ClusterName: &clusterName,
NodegroupName: &ngName,
}).Return(&awseks.DescribeNodegroupOutput{
Nodegroup: &awseks.Nodegroup{
UpdateConfig: &awseks.NodegroupUpdateConfig{
MaxUnavailable: aws.Int64(4),
},
},
}, nil)

p.MockEKS().On("DescribeNodegroup", &awseks.DescribeNodegroupInput{
ClusterName: &clusterName,
NodegroupName: aws.String("ng-2"),
}).Return(&awseks.DescribeNodegroupOutput{
Nodegroup: &awseks.Nodegroup{
UpdateConfig: &awseks.NodegroupUpdateConfig{
MaxUnavailable: aws.Int64(4),
},
},
}, nil)

p.MockEKS().On("UpdateNodegroupConfig", &awseks.UpdateNodegroupConfigInput{
UpdateConfig: &awseks.NodegroupUpdateConfig{
MaxUnavailable: aws.Int64(6),
},
ClusterName: &clusterName,
NodegroupName: &ngName,
}).Return(nil, nil)

p.MockEKS().On("UpdateNodegroupConfig", &awseks.UpdateNodegroupConfigInput{
UpdateConfig: &awseks.NodegroupUpdateConfig{
MaxUnavailable: aws.Int64(6),
},
ClusterName: &clusterName,
NodegroupName: aws.String("ng-2"),
}).Return(nil, nil)

cfg.ManagedNodeGroups[0].UpdateConfig = &api.NodeGroupUpdateConfig{
MaxUnavailable: aws.Int(6),
}

newNg := &api.ManagedNodeGroup{
NodeGroupBase: &api.NodeGroupBase{
Name: "ng-2",
},
UpdateConfig: &api.NodeGroupUpdateConfig{
MaxUnavailable: aws.Int(6),
},
}

cfg.ManagedNodeGroups = append(cfg.ManagedNodeGroups, newNg)

m = New(cfg, &eks.ClusterProvider{Provider: p}, nil)
err := m.Update()
Expect(err).NotTo(HaveOccurred())
})
})

0 comments on commit 06ce9f0

Please sign in to comment.