diff --git a/test/e2e/common.go b/test/e2e/common.go index dd0b5e9f36..b6e9606b6a 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -25,6 +25,7 @@ import ( kindcmd "sigs.k8s.io/kind/pkg/cmd" ) +// ZarfE2ETest Struct holding common fields most of the tests will utilize type ZarfE2ETest struct { zarfBinPath string @@ -91,7 +92,7 @@ func (e2e *ZarfE2ETest) setUpKind() error { // Set up a KinD cluster if necessary e2e.provider = cluster.NewProvider(cluster.ProviderWithLogger(kindcmd.NewLogger())) - nodes, err := e2e.provider.ListNodes(e2e.clusterName) + nodes, _ := e2e.provider.ListNodes(e2e.clusterName) if len(nodes) == 0 { err = e2e.provider.Create( e2e.clusterName, @@ -273,7 +274,7 @@ func (e2e *ZarfE2ETest) checkIfClusterRunning() bool { func (e2e *ZarfE2ETest) waitForHealthyCluster() error { attempt := 0 - for attempt < 10 { + for attempt < 15 { pods, err := e2e.clientset.CoreV1().Pods("kube-system").List(context.TODO(), metav1.ListOptions{}) if err == nil && len(pods.Items) >= 0 { allPodsHealthy := true diff --git a/test/e2e/e2e_composability_test.go b/test/e2e/e2e_composability_test.go index 06d1432114..a755d37f3d 100644 --- a/test/e2e/e2e_composability_test.go +++ b/test/e2e/e2e_composability_test.go @@ -10,6 +10,8 @@ import ( ) func TestE2eExampleComposability(t *testing.T) { + defer e2e.cleanupAfterTest(t) + //run `zarf init` output, err := e2e.execZarfCommand("init", "--confirm") require.NoError(t, err, output) @@ -33,6 +35,4 @@ func TestE2eExampleComposability(t *testing.T) { // Validate the doom title in body. assert.Contains(t, string(body), "Zarf needs games too") assert.Equal(t, 200, resp.StatusCode) - - e2e.cleanupAfterTest(t) } diff --git a/test/e2e/e2e_data_injection_test.go b/test/e2e/e2e_data_injection_test.go index 9564d9832f..6c7e5554f3 100644 --- a/test/e2e/e2e_data_injection_test.go +++ b/test/e2e/e2e_data_injection_test.go @@ -9,6 +9,7 @@ import ( ) func TestDataInjection(t *testing.T) { + defer e2e.cleanupAfterTest(t) // run `zarf init` output, err := e2e.execZarfCommand("init", "--confirm", "-l=trace") @@ -40,6 +41,4 @@ func TestDataInjection(t *testing.T) { } assert.NoError(t, err) assert.Contains(t, execStdOut, "this-is-an-example-file.txt") - - e2e.cleanupAfterTest(t) } diff --git a/test/e2e/e2e_example_game_test.go b/test/e2e/e2e_example_game_test.go index d81d77ef4b..0d2977fcd9 100644 --- a/test/e2e/e2e_example_game_test.go +++ b/test/e2e/e2e_example_game_test.go @@ -9,6 +9,7 @@ import ( ) func TestE2eExampleGame(t *testing.T) { + defer e2e.cleanupAfterTest(t) //run `zarf init` output, err := e2e.execZarfCommand("init", "--confirm") @@ -27,7 +28,4 @@ func TestE2eExampleGame(t *testing.T) { resp, err := http.Get("http://127.0.0.1:22333?doom") assert.NoError(t, err, resp) assert.Equal(t, 200, resp.StatusCode) - - // Clean up after this test (incase other tests cases will be run afterwards) - e2e.cleanupAfterTest(t) } diff --git a/test/e2e/e2e_general_cli_test.go b/test/e2e/e2e_general_cli_test.go index b37aaaddda..18451c70fe 100644 --- a/test/e2e/e2e_general_cli_test.go +++ b/test/e2e/e2e_general_cli_test.go @@ -40,7 +40,7 @@ func TestGeneralCLI(t *testing.T) { assert.NotEqual(t, output, "UnknownVersion", "Zarf version should not be the default value") // Test for expected failure when given a bad componenet input - output, err = e2e.execZarfCommand("init", "--confirm", "--components=k3s,foo,logging") + _, err = e2e.execZarfCommand("init", "--confirm", "--components=k3s,foo,logging") assert.Error(t, err) // Test for expected failure when given invalid hostnames @@ -57,6 +57,7 @@ func TestGeneralCLI(t *testing.T) { } func TestInitZarf(t *testing.T) { + defer e2e.cleanupAfterTest(t) // Initialize Zarf for the next set of tests // This also confirms that using the `--confirm` flags does not hang when not also specifying the `--components` flag @@ -66,6 +67,4 @@ func TestInitZarf(t *testing.T) { // Test that `zarf package deploy` gives an error if deploying a remote package without the --insecure or --shasum flags output, err = e2e.execZarfCommand("package", "deploy", "https://zarf-examples.s3.amazonaws.com/zarf-package-appliance-demo-doom-20210125.tar.zst", "--confirm", "-l=trace") assert.Error(t, err, output) - - e2e.cleanupAfterTest(t) } diff --git a/test/e2e/e2e_gitea_and_grafana_test.go b/test/e2e/e2e_gitea_and_grafana_test.go index c98776c82b..f2c15b774d 100644 --- a/test/e2e/e2e_gitea_and_grafana_test.go +++ b/test/e2e/e2e_gitea_and_grafana_test.go @@ -9,6 +9,7 @@ import ( ) func TestGiteaAndGrafana(t *testing.T) { + defer e2e.cleanupAfterTest(t) // run `zarf init` output, err := e2e.execZarfCommand("init", "--components=gitops-service,logging", "--confirm") @@ -31,6 +32,4 @@ func TestGiteaAndGrafana(t *testing.T) { resp, err = http.Get("http://127.0.0.1:45002/monitor/login") assert.NoError(t, err) assert.Equal(t, 200, resp.StatusCode) - - e2e.cleanupAfterTest(t) } diff --git a/test/e2e/e2e_gitops_example_test.go b/test/e2e/e2e_gitops_example_test.go index 3d3892eed8..3ea74e133b 100644 --- a/test/e2e/e2e_gitops_example_test.go +++ b/test/e2e/e2e_gitops_example_test.go @@ -12,6 +12,8 @@ import ( ) func TestGitopsExample(t *testing.T) { + defer e2e.cleanupAfterTest(t) + // run `zarf init` output, err := e2e.execZarfCommand("init", "--confirm", "--components=gitops-service") require.NoError(t, err, output) @@ -43,7 +45,7 @@ func TestGitopsExample(t *testing.T) { expectedTag := "v0.15.0\n" err = os.Chdir("mirror__github.com__defenseunicorns__zarf") assert.NoError(t, err) - gitOutput, err = exec.Command("git", "tag").Output() + gitOutput, _ = exec.Command("git", "tag").Output() assert.Equal(t, expectedTag, string(gitOutput), "Expected tag should match output") // Check for correct commits @@ -62,6 +64,4 @@ func TestGitopsExample(t *testing.T) { err = os.Chdir("..") assert.NoError(t, err, "unable to change directories back to blah blah blah") - - e2e.cleanupAfterTest(t) }