mirror of
https://github.com/jenkinsci/kubernetes-operator.git
synced 2026-10-21 22:37:54 +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}"
|
||||
}
|
||||
@@ -26,11 +26,11 @@ const e2e = "e2e"
|
||||
var expectedBasePluginsList = []plugins.Plugin{
|
||||
plugins.Must(plugins.New("configuration-as-code:1569.vb_72405b_80249")),
|
||||
plugins.Must(plugins.New("git:5.0.0")),
|
||||
plugins.Must(plugins.New("kubernetes:3883.v4d70a_a_a_df034")),
|
||||
plugins.Must(plugins.New("kubernetes:3896.v19b_160fd9589")),
|
||||
plugins.Must(plugins.New("kubernetes-credentials-provider:1.209.v862c6e5fb_1ef")),
|
||||
plugins.Must(plugins.New("job-dsl:1.81")),
|
||||
plugins.Must(plugins.New("workflow-aggregator:590.v6a_d052e5a_a_b_5")),
|
||||
plugins.Must(plugins.New("workflow-job:1282.ve6d865025906")),
|
||||
plugins.Must(plugins.New("job-dsl:1.82")),
|
||||
plugins.Must(plugins.New("workflow-aggregator:596.v8c21c963d92d")),
|
||||
plugins.Must(plugins.New("workflow-job:1284.v2fe8ed4573d4")),
|
||||
}
|
||||
|
||||
func createUserConfigurationSecret(namespace string, stringData map[string]string) {
|
||||
|
||||
@@ -97,7 +97,7 @@ var _ = Describe("Jenkins controller", func() {
|
||||
|
||||
Context("when running Jenkins safe restart", func() {
|
||||
It("authorization strategy is not overwritten", func() {
|
||||
// TODO: @brokenpip3 temporary disable this flaky test
|
||||
// TODO: @brokenpip3 temporary disable this flaky test
|
||||
Skip("Temporary skipping this test")
|
||||
WaitForJenkinsBaseConfigurationToComplete(jenkins)
|
||||
WaitForJenkinsUserConfigurationToComplete(jenkins)
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
||||
)
|
||||
|
||||
const JenkinsTestImage = "jenkins/jenkins:2.375.3-lts"
|
||||
const JenkinsTestImage = "jenkins/jenkins:2.387.1-lts"
|
||||
|
||||
var (
|
||||
Cfg *rest.Config
|
||||
|
||||
@@ -47,7 +47,7 @@ var _ = Describe("Jenkins Controller", func() {
|
||||
|
||||
cmd := exec.Command("../../bin/helm", "upgrade", "jenkins", "../../chart/jenkins-operator", "--namespace", namespace.Name, "--debug",
|
||||
"--set-string", fmt.Sprintf("jenkins.namespace=%s", namespace.Name),
|
||||
"--set-string", fmt.Sprintf("jenkins.image=%s", "jenkins/jenkins:2.375.3-lts"),
|
||||
"--set-string", fmt.Sprintf("jenkins.image=%s", "jenkins/jenkins:2.387.1-lts"),
|
||||
"--set-string", fmt.Sprintf("operator.image=%s", *imageName), "--install")
|
||||
output, err := cmd.CombinedOutput()
|
||||
Expect(err).NotTo(HaveOccurred(), string(output))
|
||||
|
||||
Reference in New Issue
Block a user