Skip to content

Commit

Permalink
Move cluster package e2e tests to integration tests (#341)
Browse files Browse the repository at this point in the history
* Move cluster e2e to package
* Rename integration test clusters

Signed-off-by: Pablo Chacin <[email protected]>
  • Loading branch information
pablochacin authored Sep 14, 2023
1 parent bdd2e7b commit a986f26
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ integration-kubernetes:
integration-kubectl:
go test -tags integration ./pkg/testutils/e2e/kubectl/

integration: integration-agent integration-kubernetes integration-kubectl
integration-cluster:
go test -tags integration ./pkg/testutils/cluster

integration: integration-agent integration-kubernetes integration-kubectl integration-cluster


# Running with -buildvcs=false works around the issue of `go list all` failing when git, which runs as root inside
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -19,9 +18,9 @@ import (

func Test_DefaultConfig(t *testing.T) {
// create cluster with default configuration
config, err := cluster.NewConfig(
"e2e-default-cluster",
cluster.Options{
config, err := NewConfig(
"default-cluster",
Options{
Wait: time.Second * 60,
},
)
Expand All @@ -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(
"e2e-etcdramdisk-cluster",
cluster.Options{
config, err := NewConfig(
"etcd-ramdisk-cluster",
Options{
Wait: time.Second * 60,
UseEtcdRAMDisk: true,
},
Expand Down Expand Up @@ -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(
"e2e-cluster-with-images",
cluster.Options{
config, err := NewConfig(
"cluster-with-images",
Options{
Wait: time.Second * 60,
Images: []string{"busybox"},
},
Expand Down Expand Up @@ -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(
"e2e-default-cluster",
cluster.Options{
config, err := NewConfig(
"k8s-1-24-cluster",
Options{
Version: "v1.24.0",
Wait: time.Second * 60,
},
Expand All @@ -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(
"e2e-default-cluster",
cluster.Options{
config, err := NewConfig(
"invalid-k8s-version-cluster",
Options{
Version: "v0.0.0",
Wait: time.Second * 60,
},
Expand All @@ -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(
"e2e-preexisting-cluster",
cluster.Options{
config, err := NewConfig(
"preexisting-cluster",
Options{
Wait: time.Second * 60,
},
)
Expand All @@ -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
Expand All @@ -222,9 +221,9 @@ func Test_GetCluster(t *testing.T) {

func Test_DeleteCluster(t *testing.T) {
// create cluster with configuration
config, err := cluster.NewConfig(
"existing-cluster",
cluster.Options{
config, err := NewConfig(
"for-delete-cluster",
Options{
Wait: time.Second * 30,
},
)
Expand All @@ -247,7 +246,7 @@ func Test_DeleteCluster(t *testing.T) {
}{
{
test: "delete existing cluster",
name: "existing-cluster",
name: "for-delete-cluster",
quiet: false,
expectError: false,
},
Expand All @@ -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)
}
Expand Down

0 comments on commit a986f26

Please sign in to comment.