mirror of
https://github.com/jenkinsci/kubernetes-operator.git
synced 2026-10-22 07:02:58 +02:00
feat(operator): several updates (#806)
- prepare to switch from `master` to `main` - avoid to run workflow in case is not needed - add a way to bump the lts via make - use latest jenkins lts 2.387.1 - add the docker labels - update base plugins - fix #797 - Add more tests with bats - Update base plugin to latest version - Temporary revert #807 - Better nightly job
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
setup() {
|
||||
load 'test_helper'
|
||||
_common_setup
|
||||
}
|
||||
|
||||
diag() {
|
||||
echo "# DEBUG $@" >&3
|
||||
}
|
||||
|
||||
#bats test_tags=phase:setup
|
||||
@test "1.0 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" {
|
||||
run echo ${DETIK_CLIENT_NAMESPACE}
|
||||
run echo ${OPERATOR_IMAGE}
|
||||
${HELM} status default && skip "Helm release 'default' already exists"
|
||||
run ${HELM} install default \
|
||||
--set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set namespace=${DETIK_CLIENT_NAMESPACE} \
|
||||
--set operator.image=${OPERATOR_IMAGE} \
|
||||
chart/jenkins-operator
|
||||
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" {
|
||||
[[ ! -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
|
||||
@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
|
||||
|
||||
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
|
||||
@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
|
||||
|
||||
run verify "there is 1 service named 'jenkins-operator-slave-jenkins'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@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
|
||||
run verify "there is 1 configmap named 'jenkins-operator-init-configuration-jenkins'"
|
||||
assert_success
|
||||
run verify "there is 1 configmap named 'jenkins-operator-scripts-jenkins'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@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
|
||||
run verify "there is 1 role named 'leader-election-role'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@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
|
||||
run verify "there is 1 rolebinding named 'leader-election-rolebinding'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#bats test_tags=phase:helm
|
||||
@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
|
||||
}
|
||||
|
||||
@test "1.9 Helm: Clean" {
|
||||
rm "chart/jenkins-operator/deploy.tmp"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
_common_setup() {
|
||||
export BATS_LIB_PATH="/usr/lib/"
|
||||
bats_load_library bats-support
|
||||
bats_load_library bats-assert
|
||||
bats_load_library bats-file
|
||||
bats_load_library bats-detik/detik.bash
|
||||
|
||||
CONTEXT="kind-jenkins"
|
||||
export DETIK_CLIENT_NAME="kubectl"
|
||||
export DETIK_CLIENT_NAMESPACE="ns-$(git rev-parse --verify HEAD --short)"
|
||||
export KUBECTL="kubectl --context=${CONTEXT} -n ${DETIK_CLIENT_NAMESPACE}"
|
||||
export HELM="helm --kube-context=${CONTEXT} -n ${DETIK_CLIENT_NAMESPACE}"
|
||||
}
|
||||
Reference in New Issue
Block a user