Skip to content

Commit

Permalink
More of general cleanup
Browse files Browse the repository at this point in the history
- cosmetic style changes and refactoring
- get rid of nested directory
- remove dead code
- unexport matcher struct
- use canonical tag key
- update suite name
  • Loading branch information
errordeveloper committed Oct 16, 2018
1 parent 880d6df commit 8431066
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 102 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ integration-test-dev: build ## Run the integration tests without cluster teardow
@./eksctl utils write-kubeconfig \
--auto-kubeconfig \
--name=$(TEST_CLUSTER)
@go test -tags integration -v -timeout 21m ./tests/integration/... \
@go test -tags integration -v -timeout 21m ./integration/... \
-args \
-eksctl.cluster=$(TEST_CLUSTER) \
-eksctl.create=false \
Expand All @@ -56,7 +56,7 @@ delete-integration-test-dev-cluster: build ## Delete the test cluster for use wh

.PHONY: integration-test
integration-test: build ## Run the integration tests (with cluster creation and cleanup)
@go test -tags integration -v -timeout 21m ./tests/integration/...
@go test -tags integration -v -timeout 21m ./integration/...

##@ Code Generation

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// +build integration

package create_get_delete
package integration_test

import (
"flag"
"fmt"
"io/ioutil"
"os"
"os/exec"
"testing"
"time"

awseks "github.com/aws/aws-sdk-go/service/eks"
Expand All @@ -26,30 +24,6 @@ import (
"github.com/weaveworks/eksctl/pkg/utils"
)

const (
createTimeout = 20
deleteTimeout = 10
getTimeout = 1
region = "us-west-2"
)

var (
eksctlPath string

// Flags to help with the development of the integration tests
clusterName string
doCreate bool
doDelete bool
kubeconfigPath string

kubeconfigTemp bool
)

func TestCreateIntegration(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Integration - Create Suite")
}

type tInterface interface {
GinkgoTInterface
Helper()
Expand All @@ -73,7 +47,7 @@ func newKubeTest() (*harness.Test, error) {
return h.NewTest(t), nil
}

var _ = Describe("Create (Integration)", func() {
var _ = Describe("(Integration) Create, Get & Delete", func() {

BeforeSuite(func() {
kubeconfigTemp = false
Expand Down Expand Up @@ -107,7 +81,7 @@ var _ = Describe("Create (Integration)", func() {

args := []string{"create", "cluster",
"--name", clusterName,
"--tags", "Purpose=ekscltIntegrationTest",
"--tags", "eksctl.cluster.k8s.io/v1alpha1/description=eksctl integration test",
"--node-type", "t2.medium",
"--nodes", "1",
"--region", region,
Expand All @@ -121,7 +95,7 @@ var _ = Describe("Create (Integration)", func() {
Fail(fmt.Sprintf("error starting process: %v", err), 1)
}

cmdSession.Wait(createTimeout * time.Minute)
cmdSession.Wait(createTimeout)
Expect(cmdSession.ExitCode()).Should(Equal(0))
})

Expand Down Expand Up @@ -193,16 +167,14 @@ var _ = Describe("Create (Integration)", func() {
var err error
args := []string{"get", "clusters", "--region", region}

fmt.Printf("wtf[eksctlPath]: '%s'", eksctlPath)

command := exec.Command(eksctlPath, args...)
cmdSession, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)

if err != nil {
Fail(fmt.Sprintf("error starting process: %v", err), 1)
}

cmdSession.Wait(getTimeout * time.Minute)
cmdSession.Wait(getTimeout)
Expect(cmdSession.ExitCode()).Should(Equal(0))
})

Expand All @@ -217,7 +189,11 @@ var _ = Describe("Create (Integration)", func() {
Skip("will not delete cluster " + clusterName)
}

args := []string{"delete", "cluster", "--name", clusterName, "--region", region, "--wait"}
args := []string{"delete", "cluster",
"--name", clusterName,
"--region", region,
"--wait",
}

command := exec.Command(eksctlPath, args...)
cmdSession, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expand All @@ -226,7 +202,7 @@ var _ = Describe("Create (Integration)", func() {
Fail(fmt.Sprintf("error starting process: %v", err), 1)
}

cmdSession.Wait(deleteTimeout * time.Minute)
cmdSession.Wait(deleteTimeout)
Expect(cmdSession.ExitCode()).Should(Equal(0))
})

Expand All @@ -251,13 +227,3 @@ var _ = Describe("Create (Integration)", func() {
})
})
})

func init() {
flag.StringVar(&eksctlPath, "eksctl.path", "../../../eksctl", "Path to eksctl")

// Flags to help with the development of the integration tests
flag.StringVar(&clusterName, "eksctl.cluster", "", "Cluster name (default: generate one)")
flag.BoolVar(&doCreate, "eksctl.create", true, "Skip the creation tests. Useful for debugging the tests")
flag.BoolVar(&doDelete, "eksctl.delete", true, "Skip the cleanup after the tests have run")
flag.StringVar(&kubeconfigPath, "eksctl.kubeconfig", "", "Path to kubeconfig (default: create it a temporary file)")
}
48 changes: 48 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// +build integration

package integration_test

import (
"flag"
"testing"
"time"

"github.com/weaveworks/eksctl/pkg/eks/api"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

const (
createTimeout = 25 * time.Minute
deleteTimeout = 15 * time.Minute
getTimeout = 1 * time.Minute
region = api.DefaultEKSRegion
)

var (
eksctlPath string

// Flags to help with the development of the integration tests
clusterName string
doCreate bool
doDelete bool
kubeconfigPath string

kubeconfigTemp bool
)

func init() {
flag.StringVar(&eksctlPath, "eksctl.path", "../eksctl", "Path to eksctl")

// Flags to help with the development of the integration tests
flag.StringVar(&clusterName, "eksctl.cluster", "", "Cluster name (default: generate one)")
flag.BoolVar(&doCreate, "eksctl.create", true, "Skip the creation tests. Useful for debugging the tests")
flag.BoolVar(&doDelete, "eksctl.delete", true, "Skip the cleanup after the tests have run")
flag.StringVar(&kubeconfigPath, "eksctl.kubeconfig", "", "Path to kubeconfig (default: create it a temporary file)")
}

func TestCreateIntegration(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "(Integration) Create, Get & Delete")
}
File renamed without changes.
30 changes: 0 additions & 30 deletions pkg/testutils/aws/eks.go

This file was deleted.

10 changes: 5 additions & 5 deletions pkg/testutils/matchers/have_cfn_stack_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (

// HaveExistingStack returns a GoMega matcher that will check for the existence of an cloudformation stack
func HaveExistingStack(expectedStackName string) types.GomegaMatcher {
return &ExistingStack{expectedStackName: expectedStackName}
return &existingStack{expectedStackName: expectedStackName}
}

type ExistingStack struct {
type existingStack struct {
expectedStackName string
stackNotFound bool
}

func (m *ExistingStack) Match(actual interface{}) (success bool, err error) {
func (m *existingStack) Match(actual interface{}) (success bool, err error) {
if actual == nil {
return false, errors.New("input is nil")
}
Expand All @@ -39,10 +39,10 @@ func (m *ExistingStack) Match(actual interface{}) (success bool, err error) {
return found, nil
}

func (m *ExistingStack) FailureMessage(actual interface{}) (message string) {
func (m *existingStack) FailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected to find a Cloudformation stack named %s but it wasn't found", m.expectedStackName)
}

func (m *ExistingStack) NegatedFailureMessage(_ interface{}) (message string) {
func (m *existingStack) NegatedFailureMessage(_ interface{}) (message string) {
return fmt.Sprintf("Expected NOT to find a Cloudformation stack named %s but it found", m.expectedStackName)
}
20 changes: 0 additions & 20 deletions tests/integration/cleanup.go

This file was deleted.

0 comments on commit 8431066

Please sign in to comment.