Skip to content

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rndstr authored and D3nn committed Oct 8, 2019
1 parent a084e7c commit dc11d25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
33 changes: 15 additions & 18 deletions integration/cluster_api_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var _ = Describe("(Integration) Create and Update Cluster with Endpoint Configs"
Private bool
Public bool
Type string
Error error
Fails bool
}

DescribeTable("Can create/update Cluster Endpoint Access",
Expand Down Expand Up @@ -86,7 +86,7 @@ var _ = Describe("(Integration) Create and Update Cluster with Endpoint Configs"
"--config-file", tmpfile.Name(),
"--without-nodegroup",
).WithoutArg("--region", region)
if e.Error != nil {
if e.Fails {
Expect(cmd).ShouldNot(RunSuccessfully())
return
}
Expand All @@ -101,7 +101,7 @@ var _ = Describe("(Integration) Create and Update Cluster with Endpoint Configs"
fmt.Sprintf("--private-access=%v", e.Private),
fmt.Sprintf("--public-access=%v", e.Public),
"--approve")
if e.Error != nil {
if e.Fails {
Expect(utilsCmd).ShouldNot(RunSuccessfully())
return
}
Expand Down Expand Up @@ -133,82 +133,79 @@ var _ = Describe("(Integration) Create and Update Cluster with Endpoint Configs"
)
Expect(deleteCmd).Should(RunSuccessfully())
awsSession := NewSession(region)
Eventually(awsSession, timeOut, pollInterval).ShouldNot(
HaveExistingCluster(clName, awseks.ClusterStatusActive, version))
// Eventually(getCmd).ShouldNot(RunSuccessfully())
Eventually(awsSession, timeOut, pollInterval).
ShouldNot(HaveExistingCluster(clName, awseks.ClusterStatusActive, version))
}
},
Entry("Create cluster1, Private=false, Public=true, should succeed", endpointAccessCase{
Name: "cluster1",
Private: false,
Public: true,
Type: createCluster,
Error: nil,
Fails: false,
}),
Entry("Create cluster2, Private=true, Public=false, should not succeed", endpointAccessCase{
Name: "cluster2",
Private: true,
Public: false,
Type: createCluster,
Error: errors.New(api.PrivateOnlyUseUtilsMsg()),
Fails: true,
}),
Entry("Create cluster3, Private=true, Public=true, should succeed", endpointAccessCase{
Name: "cluster3",
Private: true,
Public: true,
Type: createCluster,
Error: nil,
Fails: false,
}),
Entry("Create cluster4, Private=false, Public=false, should not succeed", endpointAccessCase{
Name: "cluster4",
Private: false,
Public: false,
Type: createCluster,
Error: errors.New(api.NoAccessMsg(
&api.ClusterEndpoints{PrivateAccess: api.Disabled(), PublicAccess: api.Disabled()},
)),
Fails: true,
}),
Entry("Update cluster1 to Private=true, Public=false, should succeed", endpointAccessCase{
Name: "cluster1",
Private: true,
Public: false,
Type: updateCluster,
Error: nil,
Fails: false,
}),
Entry("Update cluster3 to Private=true, Public=false, should succeed", endpointAccessCase{
Name: "cluster3",
Private: true,
Public: false,
Type: updateCluster,
Error: nil,
Fails: false,
}),
Entry("Update cluster3 to Private=false, Public=false, should not succeed", endpointAccessCase{
Name: "cluster3",
Private: false,
Public: false,
Type: updateCluster,
Error: errors.New("Unable to make requested changes. Either public access or private access must be enabled"),
Fails: true,
}),
Entry("Update cluster3 to Private=false, Public=true, should succeed", endpointAccessCase{
Name: "cluster3",
Private: false,
Public: true,
Type: updateCluster,
Error: nil,
Fails: false,
}),
Entry("Delete cluster1, should succeed (test case updates access)", endpointAccessCase{
Name: "cluster1",
Private: true,
Public: false,
Type: deleteCluster,
Error: nil,
Fails: false,
}),
Entry("Delete cluster3, succeed", endpointAccessCase{
Name: "cluster3",
Private: false,
Public: true,
Type: deleteCluster,
Error: nil,
Fails: false,
}),
)
})
7 changes: 0 additions & 7 deletions pkg/apis/eksctl.io/v1alpha5/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ func ValidateClusterConfig(cfg *ClusterConfig) error {
return nil
}

// PrivateOnlyUseUtilsMsg returns a message that indicates that the operation must be done using
// eksctl utils update-cluster-endpoints
func PrivateOnlyUseUtilsMsg() string {
return "eksctl cannot join worker nodes to the EKS cluster when public access isn't allowed. " +
"use 'eksctl utils update-cluster-endpoints ...' after creating cluster with default access"
}

// ValidateClusterEndpointConfig checks the endpoint configuration for potential issues
func (c *ClusterConfig) ValidateClusterEndpointConfig() error {
endpts := c.VPC.ClusterEndpoints
Expand Down
7 changes: 2 additions & 5 deletions pkg/apis/eksctl.io/v1alpha5/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,13 @@ var _ = Describe("ClusterConfig validation", func() {
It("should error on private=true, public=false", func() {
cfg.VPC.ClusterEndpoints = &ClusterEndpoints{PrivateAccess: Enabled(), PublicAccess: Disabled()}
err = cfg.ValidateClusterEndpointConfig()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(BeIdenticalTo(PrivateOnlyAwsChangesNeededMsg()))
Expect(err).To(BeIdenticalTo(ErrClusterEndpointPrivateOnly))
})

It("should error on private=false, public=false", func() {
cfg.VPC.ClusterEndpoints = &ClusterEndpoints{PrivateAccess: Disabled(), PublicAccess: Disabled()}
ep := cfg.VPC.ClusterEndpoints
err = cfg.ValidateClusterEndpointConfig()
Expect(err).ToNot(BeNil())
Expect(err.Error()).To(BeIdenticalTo(NoAccessMsg(ep)))
Expect(err).To(BeIdenticalTo(ErrClusterEndpointNoAccess))
})
})

Expand Down

0 comments on commit dc11d25

Please sign in to comment.