Skip to content

Commit

Permalink
test: simplifying e2e test checks (#2721)
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinAbro321 committed Jul 12, 2024
1 parent eca0c53 commit a567687
Show file tree
Hide file tree
Showing 23 changed files with 2 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
args:
- "--allow-missing-credentials"
- id: detect-private-key
exclude: "src/test/e2e/30_config_file_test.go"
exclude: "src/test/e2e/29_config_file_test.go"
- id: end-of-file-fixer
exclude: site/src/content/docs/commands/.*
- id: fix-byte-order-marker
Expand Down
9 changes: 0 additions & 9 deletions src/test/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type ZarfE2ETest struct {
Arch string
ApplianceMode bool
ApplianceModeKeep bool
RunClusterTests bool
}

var logRegex = regexp.MustCompile(`Saving log file to (?P<logFile>.*?\.log)`)
Expand All @@ -53,14 +52,6 @@ func GetCLIName() string {
return binaryName
}

// SetupWithCluster performs actions for each test that requires a K8s cluster.
func (e2e *ZarfE2ETest) SetupWithCluster(t *testing.T) {
if !e2e.RunClusterTests {
t.Skip("")
}
_ = exec.CmdWithPrint("sh", "-c", fmt.Sprintf("%s tools kubectl describe nodes | grep -A 99 Non-terminated", e2e.ZarfBinPath))
}

// Zarf executes a Zarf command.
func (e2e *ZarfE2ETest) Zarf(args ...string) (string, string, error) {
if !slices.Contains(args, "--tmpdir") && !slices.Contains(args, "tools") {
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/20_zarf_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

func TestZarfInit(t *testing.T) {
t.Log("E2E: Zarf init")
e2e.SetupWithCluster(t)

initComponents := "git-server"
if e2e.ApplianceMode {
Expand Down
2 changes: 0 additions & 2 deletions src/test/e2e/21_connect_creds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type RegistryResponse struct {

func TestConnectAndCreds(t *testing.T) {
t.Log("E2E: Connect")
e2e.SetupWithCluster(t)

prevAgentSecretData, _, err := e2e.Kubectl("get", "secret", "agent-hook-tls", "-n", "zarf", "-o", "jsonpath={.data}")
require.NoError(t, err)
Expand All @@ -44,7 +43,6 @@ func TestConnectAndCreds(t *testing.T) {

func TestMetrics(t *testing.T) {
t.Log("E2E: Emits metrics")
e2e.SetupWithCluster(t)

c, err := cluster.NewCluster()
require.NoError(t, err)
Expand Down
3 changes: 0 additions & 3 deletions src/test/e2e/22_git_and_gitops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

func TestGit(t *testing.T) {
t.Log("E2E: Git")
e2e.SetupWithCluster(t)

buildPath := filepath.Join("src", "test", "packages", "22-git-data")
stdOut, stdErr, err := e2e.Zarf("package", "create", buildPath, "-o=build", "--confirm")
Expand All @@ -48,14 +47,12 @@ func TestGit(t *testing.T) {

func TestGitOpsFlux(t *testing.T) {
t.Log("E2E: GitOps / Flux")
e2e.SetupWithCluster(t)

waitFluxPodInfoDeployment(t)
}

func TestGitOpsArgoCD(t *testing.T) {
t.Log("E2E: ArgoCD / Flux")
e2e.SetupWithCluster(t)

waitArgoDeployment(t)
}
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/23_data_injection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

func TestDataInjection(t *testing.T) {
t.Log("E2E: Data injection")
e2e.SetupWithCluster(t)

ctx := context.Background()

Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/24_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

func TestVariables(t *testing.T) {
t.Log("E2E: Package variables")
e2e.SetupWithCluster(t)

evilSrc := filepath.Join("src", "test", "packages", "24-evil-variables")
evilPath := fmt.Sprintf("zarf-package-evil-variables-%s.tar.zst", e2e.Arch)
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/25_helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var helmChartsPkg string

func TestHelm(t *testing.T) {
t.Log("E2E: Helm chart")
e2e.SetupWithCluster(t)

helmChartsPkg = filepath.Join("build", fmt.Sprintf("zarf-package-helm-charts-%s-0.0.1.tar.zst", e2e.Arch))

Expand Down
3 changes: 0 additions & 3 deletions src/test/e2e/26_simple_packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

func TestDosGames(t *testing.T) {
t.Log("E2E: Dos games")
e2e.SetupWithCluster(t)

path := filepath.Join("build", fmt.Sprintf("zarf-package-dos-games-%s-1.0.0.tar.zst", e2e.Arch))

Expand Down Expand Up @@ -53,7 +52,6 @@ func TestDosGames(t *testing.T) {

func TestManifests(t *testing.T) {
t.Log("E2E: Local, Remote, and Kustomize Manifests")
e2e.SetupWithCluster(t)

path := filepath.Join("build", fmt.Sprintf("zarf-package-manifests-%s-0.0.1.tar.zst", e2e.Arch))

Expand All @@ -68,7 +66,6 @@ func TestManifests(t *testing.T) {

func TestAgentIgnore(t *testing.T) {
t.Log("E2E: Test Manifests that are Agent Ignored")
e2e.SetupWithCluster(t)

testCreate := filepath.Join("src", "test", "packages", "26-agent-ignore")
testDeploy := filepath.Join("build", fmt.Sprintf("zarf-package-agent-ignore-namespace-%s.tar.zst", e2e.Arch))
Expand Down
2 changes: 0 additions & 2 deletions src/test/e2e/27_deploy_regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

func TestGHCRDeploy(t *testing.T) {
t.Log("E2E: GHCR OCI deploy")
e2e.SetupWithCluster(t)

var sha string
// shas for package published 2023-08-08T22:13:51Z
Expand All @@ -36,7 +35,6 @@ func TestGHCRDeploy(t *testing.T) {

func TestCosignDeploy(t *testing.T) {
t.Log("E2E: Cosign deploy")
e2e.SetupWithCluster(t)

// Test with command from https://docs.zarf.dev/getting-started/install/
command := fmt.Sprintf("%s package deploy sget://defenseunicorns/zarf-hello-world:$(uname -m) --confirm", e2e.ZarfBinPath)
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/28_wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func zarfCommandWStruct(e2e test.ZarfE2ETest, path string) (result zarfCommandRe

func TestNoWait(t *testing.T) {
t.Log("E2E: Helm Wait")
e2e.SetupWithCluster(t)

stdOut, stdErr, err := e2e.Zarf("package", "create", "src/test/packages/28-helm-no-wait", "-o=build", "--confirm")
require.NoError(t, err, stdOut, stdErr)
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/29_config_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

func TestConfigFile(t *testing.T) {
t.Log("E2E: Config file")
e2e.SetupWithCluster(t)

var (
path = fmt.Sprintf("zarf-package-config-file-%s.tar.zst", e2e.Arch)
Expand Down
2 changes: 0 additions & 2 deletions src/test/e2e/30_component_action_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

func TestComponentActionRemove(t *testing.T) {
t.Log("E2E: Component action remove")
e2e.SetupWithCluster(t)

packagePath := filepath.Join("build", fmt.Sprintf("zarf-package-component-actions-%s.tar.zst", e2e.Arch))

Expand All @@ -31,7 +30,6 @@ func TestComponentActionRemove(t *testing.T) {

func TestComponentActionEdgeCases(t *testing.T) {
t.Log("E2E: Component action edge cases")
e2e.SetupWithCluster(t)

sourcePath := filepath.Join("src", "test", "packages", "31-component-actions-edgecases")
packagePath := fmt.Sprintf("zarf-package-component-actions-edgecases-%s.tar.zst", e2e.Arch)
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/31_checksum_and_signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

func TestChecksumAndSignature(t *testing.T) {
t.Log("E2E: Checksum and Signature")
e2e.SetupWithCluster(t)

testPackageDirPath := "examples/dos-games"
pkgName := fmt.Sprintf("zarf-package-dos-games-%s-1.0.0.tar.zst", e2e.Arch)
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/32_component_webhooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

func TestComponentWebhooks(t *testing.T) {
t.Log("E2E: Component Webhooks")
e2e.SetupWithCluster(t)

// Deploy example Pepr webhook.
webhookPath := fmt.Sprintf("build/zarf-package-component-webhooks-%s-0.0.1.tar.zst", e2e.Arch)
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/34_custom_init_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func TestCustomInit(t *testing.T) {
t.Log("E2E: Custom Init Package")
e2e.SetupWithCluster(t)

buildPath := filepath.Join("src", "test", "packages", "35-custom-init-package")
pkgName := fmt.Sprintf("zarf-init-%s-%s.tar.zst", e2e.Arch, e2e.GetZarfVersion(t))
privateKeyFlag := "--signing-key=src/test/packages/zarf-test.prv-key"
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/35_custom_retries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

func TestRetries(t *testing.T) {
t.Log("E2E: Custom Retries")
e2e.SetupWithCluster(t)

tmpDir := t.TempDir()

Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/50_oci_publish_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ func (suite *PublishDeploySuiteTestSuite) Test_3_Copy() {
}

func TestPublishDeploySuite(t *testing.T) {
e2e.SetupWithCluster(t)

suite.Run(t, new(PublishDeploySuiteTestSuite))
}
1 change: 0 additions & 1 deletion src/test/e2e/51_oci_compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ func (suite *SkeletonSuite) verifyComponentPaths(unpackedPath string, components
}

func TestSkeletonSuite(t *testing.T) {
e2e.SetupWithCluster(t)

suite.Run(t, new(SkeletonSuite))
}
2 changes: 0 additions & 2 deletions src/test/e2e/99_appliance_remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ func TestApplianceRemove(t *testing.T) {
return
}

e2e.SetupWithCluster(t)

initPackageVersion := e2e.GetZarfVersion(t)

path := fmt.Sprintf("build/zarf-init-%s-%s.tar.zst", e2e.Arch, initPackageVersion)
Expand Down
3 changes: 0 additions & 3 deletions src/test/e2e/99_yolo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ func TestYOLOMode(t *testing.T) {
return
}

e2e.SetupWithCluster(t)

// Destroy the cluster to test Zarf cleaning up after itself
stdOut, stdErr, err := e2e.Zarf("destroy", "--confirm", "--remove-components")
require.NoError(t, err, stdOut, stdErr)
Expand Down Expand Up @@ -54,7 +52,6 @@ func TestDevDeploy(t *testing.T) {
if e2e.ApplianceMode {
return
}
e2e.SetupWithCluster(t)

stdOut, stdErr, err := e2e.Zarf("dev", "deploy", "examples/dos-games")
require.NoError(t, err, stdOut, stdErr)
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func TestMain(m *testing.M) {
e2e.ZarfBinPath = filepath.Join("build", test.GetCLIName())
e2e.ApplianceMode = os.Getenv(applianceModeEnvVar) == "true"
e2e.ApplianceModeKeep = os.Getenv(applianceModeKeepEnvVar) == "true"
e2e.RunClusterTests = true

message.SetLogLevel(message.TraceLevel)

Expand Down
2 changes: 0 additions & 2 deletions src/test/nightly/ecr_publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ func TestECRPublishing(t *testing.T) {
// Set up the e2e configs
e2e.Arch = config.GetArch()
e2e.ZarfBinPath = path.Join("build", test.GetCLIName())
e2e.ApplianceMode = true
e2e.RunClusterTests = false

// Set up variables for common names/locations
testPackageName := "helm-charts"
Expand Down

0 comments on commit a567687

Please sign in to comment.