Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2598 from 2opremio/e2e-manifest-generation
Browse files Browse the repository at this point in the history
e2e: Add manifest generation test
  • Loading branch information
2opremio authored Nov 11, 2019
2 parents 859d711 + db05020 commit f7f5ad8
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/e2e/22_manifest_generation.bats
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"
}
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
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
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
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

0 comments on commit f7f5ad8

Please sign in to comment.