From c9be98e80e46b496ad7a2e851966852df8b283fa Mon Sep 17 00:00:00 2001 From: Pablo Chacin Date: Tue, 12 Sep 2023 21:10:55 +0200 Subject: [PATCH] Move cluster e2e to package Signed-off-by: Pablo Chacin --- Makefile | 5 ++- .../testutils/cluster/integration_test.go | 39 +++++++++---------- 2 files changed, 23 insertions(+), 21 deletions(-) rename e2e/cluster/cluster_e2e_test.go => pkg/testutils/cluster/integration_test.go (90%) diff --git a/Makefile b/Makefile index ca53ca8e..b191af11 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,10 @@ format: integration-agent: agent-image go test -tags integration ./pkg/agent/... -integration: integration-agent +integration-cluster: + go test -tags integration ./pkg/testutils/cluster + +integration: integration-agent integration-agent # Running with -buildvcs=false works around the issue of `go list all` failing when git, which runs as root inside # the container, refuses to operate on the disruptor source tree as it is not owned by the same user (root). diff --git a/e2e/cluster/cluster_e2e_test.go b/pkg/testutils/cluster/integration_test.go similarity index 90% rename from e2e/cluster/cluster_e2e_test.go rename to pkg/testutils/cluster/integration_test.go index edb49b42..4d3be00f 100644 --- a/e2e/cluster/cluster_e2e_test.go +++ b/pkg/testutils/cluster/integration_test.go @@ -1,14 +1,13 @@ -//go:build e2e -// +build e2e +//go:build integration +// +build integration -package e2e +package cluster import ( "context" "testing" "time" - "github.com/grafana/xk6-disruptor/pkg/testutils/cluster" "github.com/grafana/xk6-disruptor/pkg/testutils/kubernetes/builders" corev1 "k8s.io/api/core/v1" @@ -19,9 +18,9 @@ import ( func Test_DefaultConfig(t *testing.T) { // create cluster with default configuration - config, err := cluster.NewConfig( + config, err := NewConfig( "e2e-default-cluster", - cluster.Options{ + Options{ Wait: time.Second * 60, }, ) @@ -42,9 +41,9 @@ func Test_DefaultConfig(t *testing.T) { func Test_UseEtcdRamDisk(t *testing.T) { // create cluster with default configuration - config, err := cluster.NewConfig( + config, err := NewConfig( "e2e-etcdramdisk-cluster", - cluster.Options{ + Options{ Wait: time.Second * 60, UseEtcdRAMDisk: true, }, @@ -80,9 +79,9 @@ func getKubernetesClient(kubeconfig string) (kubernetes.Interface, error) { func Test_PreloadImages(t *testing.T) { // create cluster with preloaded images - config, err := cluster.NewConfig( + config, err := NewConfig( "e2e-cluster-with-images", - cluster.Options{ + Options{ Wait: time.Second * 60, Images: []string{"busybox"}, }, @@ -141,9 +140,9 @@ func Test_PreloadImages(t *testing.T) { func Test_KubernetesVersion(t *testing.T) { // create cluster with default configuration - config, err := cluster.NewConfig( + config, err := NewConfig( "e2e-default-cluster", - cluster.Options{ + Options{ Version: "v1.24.0", Wait: time.Second * 60, }, @@ -165,9 +164,9 @@ func Test_KubernetesVersion(t *testing.T) { func Test_InvalidKubernetesVersion(t *testing.T) { // create cluster with default configuration - config, err := cluster.NewConfig( + config, err := NewConfig( "e2e-default-cluster", - cluster.Options{ + Options{ Version: "v0.0.0", Wait: time.Second * 60, }, @@ -189,9 +188,9 @@ func Test_InvalidKubernetesVersion(t *testing.T) { // returned cluster is functional. func Test_GetCluster(t *testing.T) { // create cluster with configuration - config, err := cluster.NewConfig( + config, err := NewConfig( "e2e-preexisting-cluster", - cluster.Options{ + Options{ Wait: time.Second * 60, }, ) @@ -206,7 +205,7 @@ func Test_GetCluster(t *testing.T) { return } - cluster, err := cluster.GetCluster(c.Name(), c.Kubeconfig()) + cluster, err := GetCluster(c.Name(), c.Kubeconfig()) if err != nil { t.Errorf("failed to get cluster: %v", err) return @@ -222,9 +221,9 @@ func Test_GetCluster(t *testing.T) { func Test_DeleteCluster(t *testing.T) { // create cluster with configuration - config, err := cluster.NewConfig( + config, err := NewConfig( "existing-cluster", - cluster.Options{ + Options{ Wait: time.Second * 30, }, ) @@ -268,7 +267,7 @@ func Test_DeleteCluster(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { - err = cluster.DeleteCluster(tc.name, tc.quiet) + err = DeleteCluster(tc.name, tc.quiet) if err != nil && !tc.expectError { t.Fatalf("failed deleting cluster: %v", err) }