From 8d140e77294deab9fe0b883767f8968a80a65a0c Mon Sep 17 00:00:00 2001 From: Johannes Frey Date: Mon, 15 Jul 2024 11:10:53 +0200 Subject: [PATCH] chore(e2e): refactor to use vcluster cli pkg --- .github/workflows/e2e.yaml | 8 ++++---- test/e2e/e2e_test.go | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index d87fdd63..40e1dbaf 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -123,7 +123,7 @@ jobs: kubectl wait --for=condition=ready vcluster -n vcluster-k3s vcluster-k3s --timeout=100s - name: Run E2E Tests K3S - run: NAMESPACE=vcluster-k3s LOCAL_PORT=14550 go test -mod=vendor ./test/e2e -v + run: CLUSTER_NAME=vcluster-k3s NAMESPACE=vcluster-k3s LOCAL_PORT=14550 go test -mod=vendor ./test/e2e -v - name: Create Vcluster Custom Resource K0S run: | @@ -140,7 +140,7 @@ jobs: kubectl wait --for=condition=ready vcluster -n vcluster-k0s vcluster-k0s --timeout=100s - name: Run E2E Tests K0S - run: NAMESPACE=vcluster-k0s LOCAL_PORT=14551 go test -mod=vendor ./test/e2e -v + run: CLUSTER_NAME=vcluster-k0s NAMESPACE=vcluster-k0s LOCAL_PORT=14551 go test -mod=vendor ./test/e2e -v - name: Create Vcluster Custom Resource K8S run: | @@ -157,7 +157,7 @@ jobs: kubectl wait --for=condition=ready vcluster -n vcluster-k8s vcluster-k8s --timeout=100s - name: Run E2E Tests K8S - run: NAMESPACE=vcluster-k8s LOCAL_PORT=14552 go test -mod=vendor ./test/e2e -v + run: CLUSTER_NAME=vcluster-k8s NAMESPACE=vcluster-k8s LOCAL_PORT=14552 go test -mod=vendor ./test/e2e -v - name: Create Vcluster Custom Resource EKS run: | @@ -174,4 +174,4 @@ jobs: kubectl wait --for=condition=ready vcluster -n vcluster-eks vcluster-eks --timeout=100s - name: Run E2E Tests EKS - run: NAMESPACE=vcluster-eks LOCAL_PORT=14553 go test -mod=vendor ./test/e2e -v + run: CLUSTER_NAME=vcluster-eks NAMESPACE=vcluster-eks LOCAL_PORT=14553 go test -mod=vendor ./test/e2e -v diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 2533ffaf..397ebacf 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -9,7 +9,8 @@ import ( "github.com/loft-sh/log" "github.com/loft-sh/vcluster/cmd/vclusterctl/cmd" - "github.com/loft-sh/vcluster/cmd/vclusterctl/flags" + "github.com/loft-sh/vcluster/pkg/cli" + "github.com/loft-sh/vcluster/pkg/cli/flags" logutil "github.com/loft-sh/vcluster/pkg/util/log" "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" @@ -52,6 +53,7 @@ var _ = ginkgo.Describe("e2e test", func() { gomega.Expect(err).NotTo(gomega.HaveOccurred()) namespace := os.Getenv("NAMESPACE") + name := os.Getenv("CLUSTER_NAME") localPort, err := strconv.Atoi(os.Getenv("LOCAL_PORT")) gomega.Expect(err).NotTo(gomega.HaveOccurred()) connectCmd := cmd.ConnectCmd{ @@ -60,10 +62,13 @@ var _ = ginkgo.Describe("e2e test", func() { Namespace: namespace, Debug: true, }, - KubeConfig: vKubeconfigFile.Name(), - LocalPort: localPort, // choosing a port that usually should be unused + ConnectOptions: cli.ConnectOptions{ + UpdateCurrent: false, + KubeConfig: vKubeconfigFile.Name(), + LocalPort: localPort, // choosing a port that usually should be unused + }, } - err = connectCmd.Connect(ctx, nil, namespace, nil) + err = cli.ConnectHelm(ctx, &connectCmd.ConnectOptions, connectCmd.GlobalFlags, name, nil, connectCmd.Log) gomega.Expect(err).NotTo(gomega.HaveOccurred()) err = wait.PollUntilContextTimeout(ctx, time.Second, time.Minute, false, func(ctx context.Context) (bool, error) {