Skip to content

Commit

Permalink
Added additional stack tests. Added make file target for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
richardcase committed Aug 23, 2018
1 parent 857d986 commit 4b35a85
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ build:
test:
go test -v ./pkg/... ./cmd/...

.PHONY: integration-test
integration-test: build
go test -tags integration -v -timeout 21m ./tests/integration/... -args -skip-creation true

.PHONY: test-with-coverage
test-with-coverage:
go test -v -covermode=count -coverprofile=coverage.out ./pkg/... ./cmd/...
Expand Down
20 changes: 12 additions & 8 deletions pkg/testutils/matchers/have_cfn_stack_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"reflect"
"strings"

"github.com/onsi/gomega/types"

Expand All @@ -12,6 +13,10 @@ import (
"github.com/aws/aws-sdk-go/service/cloudformation"
)

const (
errorMerssageTemplate = "Stack with id %s does not exist"
)

// HaveCfnStack returns a GoMega matcher that will check for the existence of an cloudformatioin stack
func HaveCfnStack(expectedStackName string) types.GomegaMatcher {
return &haveCfnStackMatcher{expectedStackName: expectedStackName}
Expand All @@ -38,16 +43,15 @@ func (m *haveCfnStackMatcher) Match(actual interface{}) (success bool, err error
}
_, err = cfn.ListStackResources(input)

//TODO: test for not found

if err != nil {
// Check if its a not found error: ResourceNotFoundException
//if !strings.Contains(err.Error(), awseks.ErrCodeResourceNotFoundException) {
return false, err
//}
// Check if its a not found error
errorMessage := fmt.Sprintf(errorMerssageTemplate, m.expectedStackName)
if !strings.Contains(err.Error(), errorMessage) {
return false, err
}

//m.clusterNotFound = true
//return false, nil
m.stackNotFound = true
return false, nil
}

return true, nil
Expand Down
14 changes: 8 additions & 6 deletions tests/integration/create_get_delete/integration_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package create_test
// +build integration

package create_get_delete

import (
"flag"
Expand All @@ -20,7 +22,7 @@ import (
)

const (
clusterName = "int-cluster2"
clusterName = "int-cluster"
createTimeoutInMins = 20
eksRegion = "us-west-2"
)
Expand Down Expand Up @@ -88,10 +90,10 @@ var _ = Describe("Create (Integration)", func() {
It("should have the required cloudformation stacks", func() {
session := newSession()

vpcStack := fmt.Sprintf("EKS-%s-VPC", clusterName)
Expect(session).To(HaveCfnStack(vpcStack))

//TODO: finish
Expect(session).To(HaveCfnStack(fmt.Sprintf("EKS-%s-VPC", clusterName)))
Expect(session).To(HaveCfnStack(fmt.Sprintf("EKS-%s-ControlPlane", clusterName)))
Expect(session).To(HaveCfnStack(fmt.Sprintf("EKS-%s-ServiceRole", clusterName)))
Expect(session).To(HaveCfnStack(fmt.Sprintf("EKS-%s-DefaultNodeGroup", clusterName)))
})

})
Expand Down

0 comments on commit 4b35a85

Please sign in to comment.