Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Racer159 committed Jun 13, 2024
1 parent 3904297 commit fec65c3
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pkg/cluster/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ func AdoptZarfManagedLabels(labels map[string]string) map[string]string {
labels = make(map[string]string)
}
labels[k8s.ZarfManagedByLabel] = "zarf"
delete(labels, k8s.AgentLabel) // remove
return labels
}
16 changes: 16 additions & 0 deletions src/test/e2e/26_simple_packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,19 @@ func TestManifests(t *testing.T) {
stdOut, stdErr, err = e2e.Zarf("package", "remove", "manifests", "--confirm")
require.NoError(t, err, stdOut, stdErr)
}

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))

// Create the agent ignore test package
stdOut, stdErr, err := e2e.Zarf("package", "create", testCreate, "-o", "build", "--confirm")
require.NoError(t, err, stdOut, stdErr)

// Deploy the agent ignore test package
stdOut, stdErr, err = e2e.Zarf("package", "deploy", testDeploy, "--confirm")
require.NoError(t, err, stdOut, stdErr)
}
20 changes: 20 additions & 0 deletions src/test/packages/26-agent-ignore/manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd-deployment
spec:
selector:
matchLabels:
app: httpd
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: httpd
spec:
containers:
- name: httpd
# This is explicitly a different tag than examples/manifests to ensure it has to pull the image from outside the cluster
image: "httpd:alpine"
ports:
- containerPort: 80
6 changes: 6 additions & 0 deletions src/test/packages/26-agent-ignore/manifests/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: httpd-ignored
labels:
zarf.dev/agent: ignore
23 changes: 23 additions & 0 deletions src/test/packages/26-agent-ignore/zarf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: ZarfPackageConfig
metadata:
name: agent-ignore-namespace
description: Simple test to check that Zarf respects ignored namespaces.

components:
- name: httpd-deployment
required: true
manifests:
- name: agent-ignore-httpd
namespace: httpd-ignored
files:
- manifests/deployment.yaml
- manifests/namespace.yaml
actions:
onDeploy:
after:
- wait:
cluster:
kind: deployment
name: httpd-deployment
namespace: httpd-ignored
condition: "{.status.readyReplicas}=2"

0 comments on commit fec65c3

Please sign in to comment.