This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2598 from 2opremio/e2e-manifest-generation
e2e: Add manifest generation test
- Loading branch information
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bats | ||
|
||
load lib/env | ||
load lib/install | ||
load lib/poll | ||
load lib/defer | ||
|
||
function setup() { | ||
kubectl create namespace "$FLUX_NAMESPACE" | ||
# Install flux and the git server, allowing external access | ||
install_git_srv git_srv_result "22_manifest_generation/gitsrv" | ||
# shellcheck disable=SC2154 | ||
export GIT_SSH_COMMAND="${git_srv_result[0]}" | ||
# Teardown the created port-forward to gitsrv. | ||
defer kill "${git_srv_result[1]}" | ||
install_flux_with_fluxctl "22_manifest_generation/flux" | ||
} | ||
|
||
@test "Basic sync and editing" { | ||
# Wait until flux deploys the workloads | ||
poll_until_true 'workload podinfo' 'kubectl -n demo describe deployment/podinfo' | ||
|
||
# Make sure that the production patch is applied (the podinfo HorizontalPodAutoscaler should have | ||
# a minReplicas value of 2) | ||
poll_until_equals 'podinfo hpa minReplicas of 2' '2' "kubectl get hpa podinfo --namespace demo -o\"jsonpath={['spec']['minReplicas']}\"" | ||
|
||
# Make sure the 'patchUpdated' mechanism works when changing annotations through fluxctl | ||
fluxctl --k8s-fwd-ns "${FLUX_NAMESPACE}" automate -n demo --workload deployment/podinfo >&3 | ||
|
||
poll_until_true 'podinfo to be automated' "fluxctl --k8s-fwd-ns \"${FLUX_NAMESPACE}\" list-workloads -n demo | grep podinfod | grep automated" | ||
|
||
} | ||
|
||
function teardown() { | ||
run_deferred | ||
# Although the namespace delete below takes care of removing most Flux | ||
# elements, the global resources will not be removed without this. | ||
uninstall_flux_with_fluxctl | ||
# Removing the namespace also takes care of removing Flux and gitsrv. | ||
kubectl delete namespace "$FLUX_NAMESPACE" | ||
# Only remove the demo workloads after Flux, so that they cannot be recreated. | ||
kubectl delete namespace "$DEMO_NAMESPACE" | ||
} |
9 changes: 9 additions & 0 deletions
9
test/e2e/fixtures/kustom/22_manifest_generation/flux/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
bases: | ||
- "../../base/flux" | ||
patchesJson6902: | ||
- target: | ||
group: apps | ||
version: v1 | ||
kind: Deployment | ||
name: flux | ||
path: manifest_generation_patch.yaml |
6 changes: 6 additions & 0 deletions
6
test/e2e/fixtures/kustom/22_manifest_generation/flux/manifest_generation_patch.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --manifest-generation | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --git-path=production |
9 changes: 9 additions & 0 deletions
9
test/e2e/fixtures/kustom/22_manifest_generation/gitsrv/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
bases: | ||
- "../../base/gitsrv" | ||
patchesJson6902: | ||
- target: | ||
group: apps | ||
version: v1 | ||
kind: Deployment | ||
name: gitsrv | ||
path: manifest_generation_patch.yaml |
7 changes: 7 additions & 0 deletions
7
test/e2e/fixtures/kustom/22_manifest_generation/gitsrv/manifest_generation_patch.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- op: replace | ||
path: /spec/template/spec/containers/0/env | ||
value: | ||
- name: REPO | ||
value: "cluster.git" | ||
- name: TAR_URL | ||
value: https://github.com/weaveworks/flux-kustomize-example/archive/master.tar.gz |