feat(test): better bats tests, install from latest tag and then update from master (#986)
This commit is contained in:
parent
48aa102342
commit
036b20c01b
|
|
@ -24,6 +24,13 @@
|
|||
"version": "latest"
|
||||
},
|
||||
"ghcr.io/brokenpip3/devcontainers-bats/bats-libs:0": {
|
||||
},
|
||||
"ghcr.io/devcontainers/features/nix:1": {
|
||||
"multiUser": "false",
|
||||
"extraNixConfig": "experimental-features = nix-command flakes"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/hugo:1": {
|
||||
"version": "v0.99.1"
|
||||
}
|
||||
},
|
||||
// "forwardPorts": [],
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ on:
|
|||
- 'backup/**'
|
||||
- '*.md'
|
||||
|
||||
#TODO: create a matrix per earch bats file
|
||||
jobs:
|
||||
run-tests:
|
||||
if: github.event.pull_request.draft == false
|
||||
|
|
|
|||
|
|
@ -101,3 +101,4 @@ result
|
|||
### website
|
||||
website/node_modules
|
||||
website/public
|
||||
website/.hugo_build.lock
|
||||
|
|
|
|||
4
Makefile
4
Makefile
|
|
@ -181,6 +181,10 @@ update-lts-version: ## Update the latest lts version
|
|||
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/e2e/test_utility.go
|
||||
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/helm/helm_test.go
|
||||
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' pkg/constants/constants.go
|
||||
#TODO: source the version from config.base.env for bats test, no need of hardcoded version
|
||||
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/bats/1-deploy.bats
|
||||
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/bats/2-deploy-with-more-options.bats
|
||||
sed -i 's|jenkins/jenkins:[0-9]\+.[0-9]\+.[0-9]\+|jenkins/jenkins:$(LATEST_LTS_VERSION)|g' test/bats/3-deploy-with-webhook.bats
|
||||
|
||||
.PHONY: run
|
||||
run: export WATCH_NAMESPACE = $(NAMESPACE)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,14 @@
|
|||
})
|
||||
go_15_pkgs.go
|
||||
golangci_pkgs.golangci-lint
|
||||
|
||||
pkgs.kind
|
||||
(pkgs.bats.withLibraries (p: [
|
||||
p.bats-support
|
||||
p.bats-assert
|
||||
p.bats-file
|
||||
p.bats-detik
|
||||
]))
|
||||
];
|
||||
shellHook = ''
|
||||
echo Operator Version ${operatorVersion}
|
||||
|
|
|
|||
|
|
@ -7,15 +7,24 @@ diag() {
|
|||
echo "# DEBUG $@" >&3
|
||||
}
|
||||
|
||||
#bats test_tags=phase:setup
|
||||
@test "1.0 Create namespace" {
|
||||
#bats test_tags=phase:setup,scenario:vanilla
|
||||
@test "1.0 Init: create namespace" {
|
||||
${KUBECTL} get ns ${DETIK_CLIENT_NAMESPACE} && skip "Namespace ${DETIK_CLIENT_NAMESPACE} already exists"
|
||||
run ${KUBECTL} create ns ${DETIK_CLIENT_NAMESPACE}
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "1.1 Vanilla install helm chart" {
|
||||
#bats test_tags=phase:setup,scenario:vanilla
|
||||
@test "1.1 Init: add helm chart repo" {
|
||||
${HELM} repo list|grep -qc jenkins-operator && skip "Jenkins repo already exists"
|
||||
upstream_url="https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/chart"
|
||||
run ${HELM} repo add jenkins-operator $upstream_url
|
||||
assert_success
|
||||
assert_output '"jenkins-operator" has been added to your repositories'
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.2 Helm: vanilla install helm chart latest tagged version" {
|
||||
run echo ${DETIK_CLIENT_NAMESPACE}
|
||||
run echo ${OPERATOR_IMAGE}
|
||||
${HELM} status default && skip "Helm release 'default' already exists"
|
||||
|
|
@ -24,15 +33,16 @@ diag() {
|
|||
--set namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set operator.image=${OPERATOR_IMAGE} \
|
||||
--set jenkins.latestPlugins=true \
|
||||
--set jenkins.image="jenkins/jenkins:2.440.1-lts" \
|
||||
--set jenkins.backup.makeBackupBeforePodDeletion=false \
|
||||
chart/jenkins-operator
|
||||
jenkins-operator/jenkins-operator --version=$(cat ../../VERSION.txt | sed 's/v//')
|
||||
assert_success
|
||||
assert ${HELM} status default
|
||||
touch "chart/jenkins-operator/deploy.tmp"
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "1.2 Helm: check Jenkins operator pods status" {
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.2 Helm: check Jenkins operator pods status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 deployment named 'default-jenkins-operator'"
|
||||
assert_success
|
||||
|
|
@ -44,8 +54,8 @@ diag() {
|
|||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "1.3 Helm: check Jenkins Pod status" {
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.3 Helm: check Jenkins Pod status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run try "at most 20 times every 10s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
assert_success
|
||||
|
|
@ -54,8 +64,8 @@ diag() {
|
|||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "1.4 Helm: check Jenkins service status" {
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.4 Helm: check Jenkins service status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 service named 'jenkins-operator-http-jenkins'"
|
||||
assert_success
|
||||
|
|
@ -64,8 +74,8 @@ diag() {
|
|||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "1.5 Helm: check Jenkins configmaps created" {
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.5 Helm: check Jenkins configmaps created" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 configmap named 'jenkins-operator-base-configuration-jenkins'"
|
||||
assert_success
|
||||
|
|
@ -75,8 +85,8 @@ diag() {
|
|||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "1.6 Helm: check Jenkins operator role status" {
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.6 Helm: check Jenkins operator role status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there are 2 role named 'jenkins-operator*'"
|
||||
assert_success
|
||||
|
|
@ -84,8 +94,8 @@ diag() {
|
|||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "1.7 Helm: check Jenkins operator role binding status" {
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.7 Helm: check Jenkins operator role binding status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 rolebinding named 'jenkins-operator-jenkins'"
|
||||
assert_success
|
||||
|
|
@ -93,26 +103,81 @@ diag() {
|
|||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "1.8 Helm: check Jenkins operator service account status" {
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.8 Helm: check Jenkins operator service account status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there are 2 serviceaccount named 'jenkins-operator*'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "1.9 Helm: check Jenkins crd" {
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.9 Helm: check Jenkins crd" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 crd named 'jenkins.jenkins.io'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "1.9 Helm: Clean" {
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.10 Helm: upgrade from main branch same values" {
|
||||
run echo ${DETIK_CLIENT_NAMESPACE}
|
||||
run echo ${OPERATOR_IMAGE}
|
||||
run ${HELM} upgrade default \
|
||||
--set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set operator.image=${OPERATOR_IMAGE} \
|
||||
--set jenkins.latestPlugins=true \
|
||||
--set jenkins.image="jenkins/jenkins:2.440.1-lts" \
|
||||
--set jenkins.backup.makeBackupBeforePodDeletion=false \
|
||||
chart/jenkins-operator
|
||||
assert_success
|
||||
assert ${HELM} status default
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.11 Helm: check Jenkins operator pods status again" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 deployment named 'default-jenkins-operator'"
|
||||
assert_success
|
||||
|
||||
run verify "there is 1 pod named 'default-jenkins-operator-'"
|
||||
assert_success
|
||||
|
||||
run try "at most 20 times every 10s to get pods named 'default-jenkins-operator-' and verify that '.status.containerStatuses[?(@.name==\"jenkins-operator\")].ready' is 'true'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.12 Helm: check Jenkins operator pods status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 deployment named 'default-jenkins-operator'"
|
||||
assert_success
|
||||
|
||||
run verify "there is 1 pod named 'default-jenkins-operator-'"
|
||||
assert_success
|
||||
|
||||
run try "at most 20 times every 10s to get pods named 'default-jenkins-operator-' and verify that '.status.containerStatuses[?(@.name==\"jenkins-operator\")].ready' is 'true'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.13 Helm: check Jenkins Pod status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run try "at most 20 times every 10s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
assert_success
|
||||
|
||||
run try "at most 20 times every 5s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:vanilla
|
||||
@test "1.14 Helm: clean" {
|
||||
run ${HELM} uninstall default
|
||||
assert_success
|
||||
# Wait for the complete removal
|
||||
sleep 30
|
||||
|
||||
run verify "there is 0 pvc named 'jenkins backup'"
|
||||
assert_success
|
||||
|
||||
rm "chart/jenkins-operator/deploy.tmp"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,29 +3,42 @@ setup() {
|
|||
_common_setup
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "2.1 Install helm chart with options" {
|
||||
# The kind storage class provider needs some sec to delete the old pvc
|
||||
sleep 30
|
||||
run ${HELM} dependency update chart/jenkins-operator
|
||||
#bats test_tags=phase:setup,scenario:more-options
|
||||
@test "2.0 Init: create namespace" {
|
||||
${KUBECTL} get ns ${DETIK_CLIENT_NAMESPACE} && skip "Namespace ${DETIK_CLIENT_NAMESPACE} already exists"
|
||||
run ${KUBECTL} create ns ${DETIK_CLIENT_NAMESPACE}
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:setup,scenario:more-options
|
||||
@test "2.1 Init: add helm chart repo" {
|
||||
${HELM} repo list|grep -qc jenkins-operator && skip "Jenkins repo already exists"
|
||||
upstream_url="https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/chart"
|
||||
run ${HELM} repo add jenkins-operator $upstream_url
|
||||
assert_success
|
||||
assert_output '"jenkins-operator" has been added to your repositories'
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.2 Helm Install helm chart with options" {
|
||||
#assert_success
|
||||
run ${KUBECTL} label node jenkins-control-plane batstest=yep
|
||||
${HELM} status options && skip "Helm release 'options' already exists"
|
||||
run ${HELM} install options \
|
||||
--set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set operator.image=${OPERATOR_IMAGE} \
|
||||
--set jenkins.latestPlugins=true \
|
||||
--set jenkins.nodeSelector.batstest=yep \
|
||||
--set jenkins.image="jenkins/jenkins:2.440.1-lts" \
|
||||
--set jenkins.backup.makeBackupBeforePodDeletion=false \
|
||||
chart/jenkins-operator
|
||||
jenkins-operator/jenkins-operator --version=$(cat ../../VERSION.txt | sed 's/v//')
|
||||
assert_success
|
||||
assert ${HELM} status options
|
||||
touch "chart/jenkins-operator/deploy.tmp"
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "2.2 Helm: check Jenkins operator pods status" {
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.3 Helm: check Jenkins operator pods status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run verify "there is 1 deployment named 'options-jenkins-operator'"
|
||||
|
|
@ -38,8 +51,8 @@ setup() {
|
|||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@test "2.3 Helm: check Jenkins Pod status" {
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.4 Helm: check Jenkins Pod status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run try "at most 20 times every 10s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
|
|
@ -49,7 +62,8 @@ setup() {
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test "2.4 check node selector" {
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.5 Helm: check node selector" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
NODENAME=$(${KUBECTL} get pod jenkins-jenkins -o jsonpath={.spec.nodeName})
|
||||
|
|
@ -59,7 +73,8 @@ setup() {
|
|||
assert_output "node/$NODENAME"
|
||||
}
|
||||
|
||||
@test "2.5 check jenkins-plugin-cli command" {
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.6 Helm: check jenkins-plugin-cli command" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run ${KUBECTL} logs -c jenkins-master jenkins-jenkins
|
||||
|
|
@ -68,8 +83,8 @@ setup() {
|
|||
assert_output --partial 'jenkins-plugin-cli --verbose --latest true -f /var/lib/jenkins/user-plugins.txt'
|
||||
}
|
||||
|
||||
|
||||
@test "2.7 check backup" {
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.8 Helm: check backup" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
sleep 120
|
||||
run ${KUBECTL} logs -l app.kubernetes.io/name=jenkins-operator --tail 10000
|
||||
|
|
@ -78,13 +93,83 @@ setup() {
|
|||
assert_output --partial "Backup completed '1', updating status"
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.9 Helm: upgrade from main branch same value" {
|
||||
# The kind storage class provider needs some sec to delete the old pvc
|
||||
sleep 30
|
||||
#run ${HELM} dependency update chart/jenkins-operator
|
||||
#assert_success
|
||||
run ${KUBECTL} label node jenkins-control-plane batstest=yep
|
||||
${HELM} status options && skip "Helm release 'options' already exists"
|
||||
run ${HELM} upgrade options \
|
||||
--set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set operator.image=${OPERATOR_IMAGE} \
|
||||
--set jenkins.latestPlugins=true \
|
||||
--set jenkins.nodeSelector.batstest=yep \
|
||||
--set jenkins.image="jenkins/jenkins:2.440.1-lts" \
|
||||
--set jenkins.backup.makeBackupBeforePodDeletion=false \
|
||||
chart/jenkins-operator
|
||||
assert_success
|
||||
assert ${HELM} status options
|
||||
}
|
||||
|
||||
@test "2. Helm: Clean" {
|
||||
skip
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.10 Helm: check Jenkins operator pods status again" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run verify "there is 1 deployment named 'options-jenkins-operator'"
|
||||
assert_success
|
||||
|
||||
run verify "there is 1 pod named 'options-jenkins-operator-'"
|
||||
assert_success
|
||||
|
||||
run try "at most 20 times every 10s to get pods named 'options-jenkins-operator-' and verify that '.status.containerStatuses[?(@.name==\"jenkins-operator\")].ready' is 'true'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.11 Helm: check Jenkins Pod status again" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run try "at most 20 times every 10s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
assert_success
|
||||
|
||||
run try "at most 20 times every 5s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.12 Helm: check node selector again" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
NODENAME=$(${KUBECTL} get pod jenkins-jenkins -o jsonpath={.spec.nodeName})
|
||||
|
||||
run ${KUBECTL} get node -l batstest=yep -o name
|
||||
assert_success
|
||||
assert_output "node/$NODENAME"
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.13 Helm: check jenkins-plugin-cli command again" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run ${KUBECTL} logs -c jenkins-master jenkins-jenkins
|
||||
assert_success
|
||||
assert_output --partial 'jenkins-plugin-cli --verbose --latest true -f /var/lib/jenkins/base-plugins.txt'
|
||||
assert_output --partial 'jenkins-plugin-cli --verbose --latest true -f /var/lib/jenkins/user-plugins.txt'
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:more-options
|
||||
@test "2.14 Helm: clean" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run ${HELM} uninstall options
|
||||
assert_success
|
||||
sleep 30
|
||||
|
||||
run verify "there is 0 pvc named 'jenkins backup'"
|
||||
assert_success
|
||||
|
||||
rm "chart/jenkins-operator/deploy.tmp"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,149 @@
|
|||
setup() {
|
||||
load 'test_helper'
|
||||
_common_setup
|
||||
}
|
||||
|
||||
#bats test_tags=phase:setup,scenario:webhook
|
||||
@test "3.0 Init: create namespace" {
|
||||
${KUBECTL} get ns ${DETIK_CLIENT_NAMESPACE} && skip "Namespace ${DETIK_CLIENT_NAMESPACE} already exists"
|
||||
run ${KUBECTL} create ns ${DETIK_CLIENT_NAMESPACE}
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:setup,scenario:webhook
|
||||
@test "3.1 Init: add helm chart repo" {
|
||||
${HELM} repo list|grep -qc jenkins-operator && skip "Jenkins repo already exists"
|
||||
upstream_url="https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/chart"
|
||||
run ${HELM} repo add jenkins-operator $upstream_url
|
||||
assert_success
|
||||
assert_output '"jenkins-operator" has been added to your repositories'
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.2 Helm: install helm chart with webhook enabled" {
|
||||
run ${HELM} dependency update chart/jenkins-operator
|
||||
assert_success
|
||||
${HELM} status webhook && skip "Helm release 'webhook' already exists"
|
||||
run ${HELM} install webhook \
|
||||
--set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set operator.image=${OPERATOR_IMAGE} \
|
||||
--set jenkins.latestPlugins=true \
|
||||
--set jenkins.image="jenkins/jenkins:2.440.1-lts" \
|
||||
--set jenkins.backup.makeBackupBeforePodDeletion=true \
|
||||
--set webhook.enabled=true \
|
||||
jenkins-operator/jenkins-operator --version=$(cat ../../VERSION.txt | sed 's/v//')
|
||||
assert_success
|
||||
assert ${HELM} status webhook
|
||||
touch "chart/jenkins-operator/deploy.tmp"
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.3 Helm: check Jenkins operator pods status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run verify "there is 1 deployment named 'webhook-jenkins-operator'"
|
||||
assert_success
|
||||
|
||||
run verify "there is 1 pod named 'webhook-jenkins-operator-'"
|
||||
assert_success
|
||||
|
||||
run try "at most 20 times every 10s to get pods named 'webhook-jenkins-operator-' and verify that '.status.containerStatuses[?(@.name==\"jenkins-operator\")].ready' is 'true'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.4 Helm: check Jenkins Pod status" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run try "at most 20 times every 10s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
assert_success
|
||||
|
||||
run try "at most 20 times every 5s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.5 Helm: check Jenkins crd" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 crd named 'jenkins.jenkins.io'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.6 Helm: check cert-manager crd" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 crd named 'certificates.cert-manager.io'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.7 Helm: upgrade from main branch same value" {
|
||||
run ${HELM} dependency update chart/jenkins-operator
|
||||
assert_success
|
||||
${HELM} status webhook && skip "Helm release 'webhook' already exists"
|
||||
run ${HELM} install webhook \
|
||||
--set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set operator.image=${OPERATOR_IMAGE} \
|
||||
--set jenkins.latestPlugins=true \
|
||||
--set jenkins.image="jenkins/jenkins:2.440.1-lts" \
|
||||
--set jenkins.backup.makeBackupBeforePodDeletion=true \
|
||||
--set webhook.enabled=true \
|
||||
chart/jenkins-operator
|
||||
assert_success
|
||||
assert ${HELM} status webhook
|
||||
touch "chart/jenkins-operator/deploy.tmp"
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.8 Helm: check Jenkins operator pods status again" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run verify "there is 1 deployment named 'webhook-jenkins-operator'"
|
||||
assert_success
|
||||
|
||||
run verify "there is 1 pod named 'webhook-jenkins-operator-'"
|
||||
assert_success
|
||||
|
||||
run try "at most 20 times every 5s to get pods named 'webhook-jenkins-operator-' and verify that '.status.containerStatuses[?(@.name==\"jenkins-operator\")].ready' is 'true'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.9 Helm: check Jenkins Pod status again" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run try "at most 20 times every 10s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
assert_success
|
||||
|
||||
run try "at most 20 times every 5s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.10 Helm: check Jenkins crd again" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 crd named 'jenkins.jenkins.io'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm,scenario:webhook
|
||||
@test "3.11 Helm: check cert-manager crd again" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
run verify "there is 1 crd named 'certificates.cert-manager.io'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "3.12 Helm: clean" {
|
||||
[[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly"
|
||||
|
||||
run ${HELM} uninstall webhook
|
||||
assert_success
|
||||
sleep 30
|
||||
|
||||
run verify "there is 0 pvc named 'jenkins backup'"
|
||||
assert_success
|
||||
|
||||
rm "chart/jenkins-operator/deploy.tmp"
|
||||
}
|
||||
Loading…
Reference in New Issue