Skip to content

Commit

Permalink
e2e: remove skip-undeploy flag and go cleanup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
miampf committed Dec 12, 2024
1 parent 9d0a17b commit 175a333
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 35 deletions.
1 change: 0 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/e2e_aks_runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 0 additions & 15 deletions e2e/aks-runtime/aks_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 0 additions & 18 deletions e2e/internal/contrasttest/contrasttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -62,7 +60,6 @@ type ContrastTest struct {
ImageReplacementsFile string
Platform platforms.Platform
NamespaceFile string
SkipUndeploy bool
Kubeclient *kubeclient.Kubeclient

// outputs of contrast subcommands
Expand All @@ -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),
}
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 175a333

Please sign in to comment.