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

e2e: Add manifest generation test #2598

Merged
merged 2 commits into from
Nov 11, 2019
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
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,7 @@
- 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

2opremio marked this conversation as resolved.
Show resolved Hide resolved
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