Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: decrease reliance on dockerhub #2766

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/test/e2e/04_create_templating_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ func TestCreateTemplating(t *testing.T) {
decompressPath := filepath.Join(tmpdir, ".package-decompressed")
sbomPath := filepath.Join(tmpdir, ".sbom-location")

pkgName := fmt.Sprintf("zarf-package-variables-%s.tar.zst", e2e.Arch)
pkgName := fmt.Sprintf("zarf-package-templating-%s.tar.zst", e2e.Arch)

// Test that not specifying a package variable results in an error
_, stdErr, _ := e2e.Zarf(t, "package", "create", "examples/variables", "--confirm")
expectedOutString := "variable 'NGINX_VERSION' must be '--set' when using the '--confirm' flag"
require.Contains(t, stdErr, "", expectedOutString)
_, _, err := e2e.Zarf(t, "package", "create", "src/test/packages/04-templating", "--confirm")
require.Error(t, err)

// Test a simple package variable example with `--set` (will fail to pull an image if this is not set correctly)
stdOut, stdErr, err := e2e.Zarf(t, "package", "create", "examples/variables", "--set", "NGINX_VERSION=1.23.3", "--confirm")
stdOut, stdErr, err := e2e.Zarf(t, "package", "create", "src/test/packages/04-templating", "--set", "PODINFO_VERSION=6.4.0", "--confirm")
require.NoError(t, err, stdOut, stdErr)

stdOut, stdErr, err = e2e.Zarf(t, "t", "archiver", "decompress", pkgName, decompressPath, "--unarchive-all")
Expand All @@ -38,7 +37,7 @@ func TestCreateTemplating(t *testing.T) {
// Check that the constant in the zarf.yaml is replaced correctly
builtConfig, err := os.ReadFile(decompressPath + "/zarf.yaml")
require.NoError(t, err)
require.Contains(t, string(builtConfig), "name: NGINX_VERSION\n value: 1.23.3")
require.Contains(t, string(builtConfig), "name: PODINFO_VERSION\n value: 6.4.0")

// Test that files and file folders template and handle SBOMs correctly
stdOut, stdErr, err = e2e.Zarf(t, "package", "create", "src/test/packages/04-file-folders-templating-sbom/", "--sbom-out", sbomPath, "--confirm")
Expand Down
16 changes: 9 additions & 7 deletions src/test/e2e/13_find_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ func TestFindImages(t *testing.T) {
registry := "coolregistry.gov"
agentTag := "test"

stdOut, _, err := e2e.Zarf(t, "prepare", "find-images", ".", "--registry-url", registry, "--create-set", fmt.Sprintf("agent_image_tag=%s", agentTag))
stdOut, _, err := e2e.Zarf(t, "dev", "find-images", ".", "--registry-url", registry, "--create-set", fmt.Sprintf("agent_image_tag=%s", agentTag), "--skip-cosign")

require.NoError(t, err)
internalRegistryImage := fmt.Sprintf("%s/%s:%s", registry, "zarf-dev/zarf/agent", agentTag)
require.Contains(t, stdOut, internalRegistryImage, "registry image should be found with registry url")
require.Contains(t, stdOut, "busybox:latest", "Busybox image should be found as long as helm chart doesn't error")
require.Contains(t, stdOut, internalRegistryImage)
// busybox image is in git init package
require.Contains(t, stdOut, "busybox:latest")

path := filepath.Join("src", "test", "packages", "00-find-images-with-vars")
stdOut, _, err = e2e.Zarf(t, "prepare", "find-images", path, "--deploy-set", "BUSYBOX_IMAGE=busybox:earliest")
path := filepath.Join("src", "test", "packages", "13-find-images-with-vars")
stdOut, _, err = e2e.Zarf(t, "dev", "find-images", path, "--deploy-set", "PODINFO_IMAGE=cool-image.com/agent:latest", "--skip-cosign")
AustinAbro321 marked this conversation as resolved.
Show resolved Hide resolved
require.NoError(t, err)
require.Contains(t, stdOut, "nginx:latest", "Manifests aren't interpreting vars")
require.Contains(t, stdOut, "busybox:earliest", "Values files aren't interpreting vars")
require.Contains(t, stdOut, "ghcr.io/zarf-dev/zarf/agent:v0.36.1")
require.Contains(t, stdOut, "cool-image.com/agent:latest")
})

t.Run("zarf test find images --why w/ helm chart success", func(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion src/test/packages/00-find-images-with-vars/values.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions src/test/packages/04-templating/zarf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: ZarfPackageConfig
metadata:
name: templating

constants:
- name: PODINFO_VERSION
value: "###ZARF_PKG_TMPL_PODINFO_VERSION###"
pattern: "^[\\w\\-\\.]+$"

components:
- name: variables-with-podinfo
images:
# This sets the nginx image tag to the same PKG_TMPL used for the constant above to keep the zarf.yaml and nginx-deployment.yaml in sync
- "ghcr.io/stefanprodan/podinfo:###ZARF_PKG_TMPL_PODINFO_VERSION###"
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ spec:
spec:
containers:
- name: server
image: "###ZARF_CONST_SAMPLE_IMAGE###"
image: "###ZARF_CONST_AGENT_IMAGE###"
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ spec:
app: simple-deployment
spec:
containers:
- name: busybox
image: {{.Values.busybox}}
- name: podinfo
image: {{.Values.podinfo}}
1 change: 1 addition & 0 deletions src/test/packages/13-find-images-with-vars/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
podinfo: ###ZARF_VAR_PODINFO_IMAGE###
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ metadata:
description: Simple zarf package with variables

variables:
- name: BUSYBOX_IMAGE
default: "busybox:latest"
- name: PODINFO_IMAGE
default: "ghcr.io/stefanprodan/podinfo:latest"

constants:
- name: SAMPLE_IMAGE
value: "nginx:latest"
- name: AGENT_IMAGE
value: "ghcr.io/zarf-dev/zarf/agent:v0.36.1"

components:
- name: simple-var
Expand Down
4 changes: 2 additions & 2 deletions src/test/packages/28-helm-no-wait/never-ready.pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ metadata:
name: never-ready-zarf-wait-test
spec:
containers:
- name: alpine
image: alpine:latest
- name: podinfo
image: ghcr.io/stefanprodan/podinfo:6.4.0
command:
- "sleep"
- "infinity"
Expand Down
2 changes: 1 addition & 1 deletion src/test/packages/28-helm-no-wait/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ components:
files:
- never-ready.pod.yaml
images:
- alpine:latest
- ghcr.io/stefanprodan/podinfo:6.4.0
Loading