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.
Test gc by kustomizing flux deployment
This adds the ability to give an alternate kustomization when installing flux, and uses that to test flux with garbage collection.
- Loading branch information
Showing
8 changed files
with
93 additions
and
6 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 |
---|---|---|
|
@@ -38,7 +38,7 @@ function setup() { | |
sed -i'.bak' 's%stefanprodan/podinfo:2.1.0%stefanprodan/podinfo:3.1.5%' "${clone_dir}/workloads/podinfo-dep.yaml" | ||
git -c '[email protected]' -c 'user.name=Foo' commit -am "Bump podinfo" | ||
head_hash=$(git rev-list -n 1 HEAD) | ||
git push | ||
git push >&3 | ||
poll_until_equals "podinfo image" "stefanprodan/podinfo:3.1.5" "kubectl get pod -n demo -l app=podinfo -o\"jsonpath={['items'][0]['spec']['containers'][0]['image']}\"" | ||
git pull -f --tags | ||
sync_tag_hash=$(git rev-list -n 1 flux) | ||
|
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,60 @@ | ||
#!/usr/bin/env bats | ||
|
||
load lib/env | ||
load lib/install | ||
load lib/poll | ||
load lib/defer | ||
|
||
git_port_forward_pid="" | ||
|
||
function setup() { | ||
kubectl create namespace "$FLUX_NAMESPACE" | ||
# Install flux and the git server, allowing external access | ||
install_git_srv flux-git-deploy git_srv_result | ||
# shellcheck disable=SC2154 | ||
git_ssh_cmd="${git_srv_result[0]}" | ||
export GIT_SSH_COMMAND="$git_ssh_cmd" | ||
# shellcheck disable=SC2154 | ||
git_port_forward_pid="${git_srv_result[1]}" | ||
install_flux_with_fluxctl "13_sync_gc" | ||
} | ||
|
||
@test "Sync with garbage collection test" { | ||
# Wait until flux deploys the workloads, which indicates it has at least started a sync | ||
poll_until_true 'workload podinfo' 'kubectl -n demo describe deployment/podinfo' | ||
|
||
# make sure we have _finished_ a sync run | ||
fluxctl --k8s-fwd-ns "${FLUX_NAMESPACE}" sync | ||
|
||
# Clone the repo and check the sync tag | ||
local clone_dir | ||
clone_dir="$(mktemp -d)" | ||
defer rm -rf "$clone_dir" | ||
git clone -b master ssh://git@localhost/git-server/repos/cluster.git "$clone_dir" | ||
cd "$clone_dir" | ||
local sync_tag_hash | ||
sync_tag_hash=$(git rev-list -n 1 flux) | ||
head_hash=$(git rev-list -n 1 HEAD) | ||
[ "$sync_tag_hash" = "$head_hash" ] | ||
|
||
# Remove a manifest and commit that | ||
git rm workloads/podinfo-dep.yaml | ||
git -c '[email protected]' -c 'user.name=Foo' commit -m "Remove podinfo deployment" | ||
head_hash=$(git rev-list -n 1 HEAD) | ||
git push >&3 | ||
|
||
fluxctl --k8s-fwd-ns "${FLUX_NAMESPACE}" sync | ||
|
||
poll_until_equals "podinfo deployment removed" "[]" "kubectl get deploy -n demo -o\"jsonpath={['items']}\"" | ||
git pull -f --tags >&3 | ||
sync_tag_hash=$(git rev-list -n 1 flux) | ||
[ "$sync_tag_hash" = "$head_hash" ] | ||
} | ||
|
||
function teardown() { | ||
kill "$git_port_forward_pid" | ||
# 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" | ||
} |
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,3 @@ | ||
[ | ||
{ "op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--sync-garbage-collection" } | ||
] |
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,12 @@ | ||
bases: | ||
- "../base" | ||
patchesJson6902: | ||
## this patch is for test-specific patches; supply a filename to | ||
## install_flux_with_fluxctl and it will use that rather than the | ||
## (empty) default. | ||
- target: | ||
group: apps | ||
version: v1 | ||
kind: Deployment | ||
name: flux | ||
path: gc_patch.json |
File renamed without changes.
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 |
---|---|---|
|
@@ -12,4 +12,4 @@ patchesJson6902: | |
version: v1 | ||
kind: Deployment | ||
name: flux | ||
path: e2e_patch.yaml | ||
path: e2e_patch.json |
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 @@ | ||
[] |
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