Merge branch 'master' into fix-1014
This commit is contained in:
		
						commit
						076e1f6de7
					
				|  | @ -1,40 +0,0 @@ | |||
| name: CI Lint | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - master | ||||
|       - main | ||||
|   pull_request: | ||||
|     types: [opened, synchronize, ready_for_review, reopened] | ||||
| jobs: | ||||
|   codespell: | ||||
|     name: Codespell | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|     - name: Checkout | ||||
|       uses: actions/checkout@v4 | ||||
|     - name: Codespell | ||||
|       uses: codespell-project/actions-codespell@v2 | ||||
|       with: | ||||
|         check_filenames: true | ||||
|         ignore_words_list: aks,ags,startin,NotIn | ||||
|         skip: "*.js,package-lock.json,*.lock,*/Font-Awesome/*,*.toml,*.svg,*assets/vendor/bootstrap*,cert-manager.crds.yaml,*/docs/*" | ||||
|   pre-commit: | ||||
|     name: PreCommit | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|     - uses: actions/setup-python@v5.1.1 | ||||
|     - uses: DeterminateSystems/nix-installer-action@v13 | ||||
|       with: | ||||
|         diagnostic-endpoint: "" | ||||
|     - uses: DeterminateSystems/magic-nix-cache-action@v7 | ||||
|       with: | ||||
|         diagnostic-endpoint: "" | ||||
|     - name: Checkout | ||||
|       uses: actions/checkout@v4 | ||||
|     - id: files | ||||
|       uses: tj-actions/changed-files@v44 | ||||
|     - name: nix checks | ||||
|       run: nix flake check | ||||
|     - name: nix pre-commit | ||||
|       run: nix develop . --command pre-commit run --files ${{ steps.files.outputs.all_changed_files }} --show-diff-on-failure | ||||
|  | @ -105,7 +105,7 @@ setup() { | |||
|     --set jenkins.nodeSelector.batstest=yep \ | ||||
|     --set jenkins.image="jenkins/jenkins:2.462.3-lts" \ | ||||
|     --set jenkins.imagePullPolicy="IfNotPresent" \ | ||||
|     --set jenkins.lifecycle.preStop.command='["echo bats test"]' \ | ||||
|     --set jenkins.lifecycle.preStop.exec.command="{echo bats-test}" \ | ||||
|     --set jenkins.backup.makeBackupBeforePodDeletion=false \ | ||||
|     --set jenkins.backup.image=quay.io/jenkins-kubernetes-operator/backup-pvc:e2e-test \ | ||||
|     chart/jenkins-operator --wait | ||||
|  | @ -139,16 +139,15 @@ setup() { | |||
| } | ||||
| 
 | ||||
| #bats test_tags=phase:helm,scenario:more-options | ||||
| @test "2.5  Helm: check lifecycle" { | ||||
| @test "2.12  Helm: check lifecycle hook injection" { | ||||
|   [[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly" | ||||
| 
 | ||||
|   run ${KUBECTL} get pod jenkins-jenkins -o jsonpath={.spec.containers[0].lifecycle.preStop.exec.command[0]} | ||||
|   run try "at most 20 times every 10s to get pods named 'jenkins-jenkins' and verify that '.spec.containers[?(@.name==\"jenkins-master\")].lifecycle.preStop.exec.command[0]' is 'echo bats-test'" | ||||
|   assert_success | ||||
|   assert_output "echo 'bats test'" | ||||
| } | ||||
| 
 | ||||
| #bats test_tags=phase:helm,scenario:more-options | ||||
| @test "2.12 Helm: check node selector again" { | ||||
| @test "2.13 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}) | ||||
|  | @ -159,17 +158,32 @@ setup() { | |||
| } | ||||
| 
 | ||||
| #bats test_tags=phase:helm,scenario:more-options | ||||
| @test "2.13 Helm: check jenkins-plugin-cli command again" { | ||||
| @test "2.14 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 | ||||
|   # Check logs for jenkins-plugin-cli command with retry. | ||||
|   # Retry is necessary here to reduce flakiness due to additional delays | ||||
|   # from reconciling and recreating jenkins pods after helm upgrade. | ||||
|   # We assert success only after the retry loop to reduce noise. | ||||
|   LOG_CMD="${KUBECTL} logs -c jenkins-master jenkins-jenkins" | ||||
| 
 | ||||
|   EXPECTED_LOG_LINE_BASE_PLUGINS="jenkins-plugin-cli --verbose --latest true -f /var/lib/jenkins/base-plugins.txt" | ||||
|   retry 10 10 "${LOG_CMD} | grep -e '${EXPECTED_LOG_LINE_BASE_PLUGINS}'" | ||||
| 
 | ||||
|   run $LOG_CMD | ||||
|   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' | ||||
|   assert_output --partial "${EXPECTED_LOG_LINE_BASE_PLUGINS}" | ||||
| 
 | ||||
|   EXPECTED_LOG_LINE_USER_PLUGINS="jenkins-plugin-cli --verbose --latest true -f /var/lib/jenkins/user-plugins.txt" | ||||
|   retry 10 10 "${LOG_CMD} | grep -e '${EXPECTED_LOG_LINE_USER_PLUGINS}'" | ||||
| 
 | ||||
|   run $LOG_CMD | ||||
|   assert_success | ||||
|   assert_output --partial "${EXPECTED_LOG_LINE_USER_PLUGINS}" | ||||
| } | ||||
| 
 | ||||
| #bats test_tags=phase:helm,scenario:more-options | ||||
| @test "2.14 Helm: clean" { | ||||
| @test "2.15 Helm: clean" { | ||||
|   [[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly" | ||||
| 
 | ||||
|   run ${HELM} uninstall options --wait | ||||
|  |  | |||
|  | @ -15,3 +15,36 @@ _common_setup() { | |||
| get_latest_chart_version() { | ||||
|     helm search repo jenkins-operator/jenkins --versions | awk 'NR==2 {print $2}' | sed 's/v//' | ||||
| } | ||||
| 
 | ||||
| retry() { | ||||
|     # based on bats-detik's try function | ||||
| 
 | ||||
|     if [[ $# -ne 3 ]]; then | ||||
|         echo "[ERROR] Usage: retry <times> <delay> <command>" | ||||
|         return 1 | ||||
|     fi | ||||
| 
 | ||||
|     local times="$1" | ||||
|     local delay="$2" | ||||
|     local cmd="$3" | ||||
| 
 | ||||
|     code=0 | ||||
|     for ((i=1; i<=times; i++)); do | ||||
| 
 | ||||
|         # Run the command | ||||
|         eval "$cmd" && code=$? || code=$? | ||||
| 
 | ||||
|         # Break the loop prematurely? | ||||
|         if [[ "$code" == "0" ]]; then | ||||
|             break | ||||
|         elif [[ "$i" != "1" ]]; then | ||||
|             code=3 | ||||
|             sleep "$delay" | ||||
|         else | ||||
|             code=3 | ||||
|         fi | ||||
|     done | ||||
| 
 | ||||
|     ## Error code | ||||
|     return $code | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue