Skip to content

Commit

Permalink
Improve the upgrade test with more high-level Zarf primitives (#1789)
Browse files Browse the repository at this point in the history
## Description

Some thoughts I had on improvements for the upgrade test to make it more
robust.

## Related Issue

Fixes #N/A

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [X] Other (security config, docs update, etc)

## Checklist before merging

- [X] Test, docs, adr added or updated as needed
- [X] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed
  • Loading branch information
Racer159 authored Jun 6, 2023
1 parent 4978ab0 commit 2422284
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ jobs:
sudo env "PATH=$PATH" CI=true APPLIANCE_MODE=true make test-e2e ARCH=amd64
sudo chown $USER /tmp/zarf-*.log
- name: Run the upgrade tests
# NOTE: "PATH=$PATH" preserves the default user $PATH. This is needed to maintain the version of zarf installed
# in a previous step. This test run will the current release to create a K3s cluster.
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/k8s/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (k *K8s) WaitForPodsAndContainers(target PodLookup, include PodFilter) []st

}

k.Log("Ready pods", readyPods)
k.Log("Ready pods %#v", readyPods)
if len(readyPods) > 0 {
return readyPods
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/upgrade/files/data-injection-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
podAnnotations:
zarf.dev/dataInjections: ###ZARF_DATA_INJECTION_MARKER###
17 changes: 17 additions & 0 deletions src/test/upgrade/files/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: podinfo
annotations:
zarf.dev/connect-description: Access Podinfo
labels:
# Enables "zarf connect podinfo"
zarf.dev/connect-name: podinfo
spec:
selector:
app.kubernetes.io/name: podinfo-upgrade
ports:
- name: http
port: 9898
protocol: TCP
targetPort: 9898
24 changes: 23 additions & 1 deletion src/test/upgrade/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,34 @@ metadata:

components:
- name: test-upgrade-package
description: A semi-contrived example that deploys podinfo and lets us upgrade it a few times.
description: A semi-contrived example that deploys podinfo using many Zarf primitives and lets us upgrade it a few times.
required: true
charts:
- name: podinfo-upgrade
version: "###ZARF_PKG_VAR_PODINFO_VERSION###"
namespace: podinfo-upgrade
url: oci://ghcr.io/stefanprodan/charts/podinfo
valuesFiles:
- files/data-injection-values.yaml
manifests:
- name: connect-service
namespace: podinfo-upgrade
files:
- files/service.yaml
images:
- "ghcr.io/stefanprodan/podinfo:###ZARF_PKG_VAR_PODINFO_VERSION###"
repos:
- https://github.com/kelseyhightower/nocode.git
files:
- source: https://raw.githubusercontent.com/stefanprodan/podinfo/###ZARF_PKG_VAR_PODINFO_VERSION###/.cosign/cosign.pub
target: podinfo-cosign.pub
dataInjections:
- source: files
target:
selector: app.kubernetes.io/name=podinfo-upgrade
namespace: podinfo-upgrade
container: podinfo
path: /home/app/service.yaml
actions:
onDeploy:
after:
Expand All @@ -26,3 +42,9 @@ components:
setVariable: PODINFO_COSIGN_PUB
- cmd: "echo \"Successfully deployed podinfo ###ZARF_PKG_VAR_PODINFO_VERSION### with the following cosign key:\\n\\n${ZARF_VAR_PODINFO_COSIGN_PUB}\""
- cmd: rm podinfo-cosign.pub
- wait:
cluster:
kind: pod
name: app.kubernetes.io/name=podinfo-upgrade
namespace: podinfo-upgrade
condition: ready

0 comments on commit 2422284

Please sign in to comment.