From 175a3331f2998cfe0a5188b5fbfd1657dca6a025 Mon Sep 17 00:00:00 2001 From: miampf Date: Thu, 5 Dec 2024 11:54:30 +0100 Subject: [PATCH] e2e: remove `skip-undeploy` flag and go cleanup logic --- .github/workflows/e2e.yml | 1 - .github/workflows/e2e_aks_runtime.yml | 1 - e2e/aks-runtime/aks_runtime_test.go | 15 --------------- e2e/internal/contrasttest/contrasttest.go | 18 ------------------ 4 files changed, 35 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f81d5bf69..d3f906e2a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -79,7 +79,6 @@ jobs: --image-replacements workspace/just.containerlookup \ --namespace-file workspace/e2e.namespace \ --platform ${{ inputs.platform }} \ - --skip-undeploy="${{ inputs.skip-undeploy && 'true' || 'false' }}" \ --namespace-suffix="-ci" - name: Download logs if: always() diff --git a/.github/workflows/e2e_aks_runtime.yml b/.github/workflows/e2e_aks_runtime.yml index 41fe749c2..0f383ba65 100644 --- a/.github/workflows/e2e_aks_runtime.yml +++ b/.github/workflows/e2e_aks_runtime.yml @@ -89,7 +89,6 @@ jobs: --image-replacements workspace/just.containerlookup \ --namespace-file workspace/e2e.namespace \ --platform AKS-CLH-SNP \ - --skip-undeploy="false" \ --namespace-suffix="-ci" - name: Download logs if: always() diff --git a/e2e/aks-runtime/aks_runtime_test.go b/e2e/aks-runtime/aks_runtime_test.go index 3a5c5922e..fc0306bff 100644 --- a/e2e/aks-runtime/aks_runtime_test.go +++ b/e2e/aks-runtime/aks_runtime_test.go @@ -20,7 +20,6 @@ import ( "github.com/edgelesssys/contrast/internal/kuberesource" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const testContainer = "testcontainer" @@ -104,20 +103,6 @@ func TestAKSRuntime(t *testing.T) { require.NoError(err) require.NoError(c.WaitFor(ctx, kubeclient.Ready, kubeclient.Deployment{}, namespace, testContainer)) - t.Cleanup(func() { - if contrasttest.Flags.SkipUndeploy { - return - } - - // delete the deployment - deletePolicy := metav1.DeletePropagationForeground - if err = c.Client.CoreV1().Namespaces().Delete(context.Background(), namespace, metav1.DeleteOptions{ - PropagationPolicy: &deletePolicy, - }); err != nil { - t.Fatalf("Failed to delete namespace %s", namespace) - } - }) - pods, err := c.PodsFromDeployment(ctx, namespace, testContainer) require.NoError(err) require.Len(pods, 1) diff --git a/e2e/internal/contrasttest/contrasttest.go b/e2e/internal/contrasttest/contrasttest.go index a2e98e769..96e13e37d 100644 --- a/e2e/internal/contrasttest/contrasttest.go +++ b/e2e/internal/contrasttest/contrasttest.go @@ -41,7 +41,6 @@ type testFlags struct { ImageReplacementsFile string NamespaceFile string NamespaceSuffix string - SkipUndeploy bool } // RegisterFlags registers the flags that are shared between all tests. @@ -50,7 +49,6 @@ func RegisterFlags() { flag.StringVar(&Flags.NamespaceFile, "namespace-file", "", "file to store the namespace in") flag.StringVar(&Flags.NamespaceSuffix, "namespace-suffix", "", "suffix to append to the namespace") flag.StringVar(&Flags.PlatformStr, "platform", "", "Deployment platform") - flag.BoolVar(&Flags.SkipUndeploy, "skip-undeploy", false, "Skip undeploying the test namespace") } // ContrastTest is the Contrast test helper struct. @@ -62,7 +60,6 @@ type ContrastTest struct { ImageReplacementsFile string Platform platforms.Platform NamespaceFile string - SkipUndeploy bool Kubeclient *kubeclient.Kubeclient // outputs of contrast subcommands @@ -81,7 +78,6 @@ func New(t *testing.T) *ContrastTest { ImageReplacementsFile: Flags.ImageReplacementsFile, Platform: platform, NamespaceFile: Flags.NamespaceFile, - SkipUndeploy: Flags.SkipUndeploy, Kubeclient: kubeclient.NewForTest(t), } } @@ -135,20 +131,6 @@ func (ct *ContrastTest) Init(t *testing.T, resources []any) { ct.Kubeclient.LogDebugInfo(ctx) } - if !ct.SkipUndeploy { - // Deleting the namespace sometimes fails when the cluster is - // unavailable (e.g. after a K3s restart). Retry deleting for up to - // 30 seconds. - for range 30 { - if err := ct.Kubeclient.Delete(ctx, namespace...); err != nil { - t.Logf("Could not delete namespace %q: %v", ct.Namespace, err) - time.Sleep(1 * time.Second) - } else { - break - } - } - } - if fifo != nil { if err := fifo.Done(ctx); err != nil { t.Logf("Could not mark fifo ticket as done: %v", err)