fix(test): bats test fix webhook upgrade (#987)
This commit is contained in:
		
							parent
							
								
									036b20c01b
								
							
						
					
					
						commit
						1a7dc9107a
					
				|  | @ -35,7 +35,7 @@ diag() { | ||||||
|     --set jenkins.latestPlugins=true \ |     --set jenkins.latestPlugins=true \ | ||||||
|     --set jenkins.image="jenkins/jenkins:2.440.1-lts" \ |     --set jenkins.image="jenkins/jenkins:2.440.1-lts" \ | ||||||
|     --set jenkins.backup.makeBackupBeforePodDeletion=false \ |     --set jenkins.backup.makeBackupBeforePodDeletion=false \ | ||||||
|     jenkins-operator/jenkins-operator --version=$(cat ../../VERSION.txt | sed 's/v//') |     jenkins-operator/jenkins-operator --version=$(cat VERSION.txt | sed 's/v//') | ||||||
|   assert_success |   assert_success | ||||||
|   assert ${HELM} status default |   assert ${HELM} status default | ||||||
|   touch "chart/jenkins-operator/deploy.tmp" |   touch "chart/jenkins-operator/deploy.tmp" | ||||||
|  |  | ||||||
|  | @ -20,9 +20,9 @@ setup() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #bats test_tags=phase:helm,scenario:more-options | #bats test_tags=phase:helm,scenario:more-options | ||||||
| @test "2.2  Helm Install helm chart with options" { | @test "2.2  Helm: install helm chart with options" { | ||||||
|   #assert_success |  | ||||||
|   run ${KUBECTL} label node jenkins-control-plane batstest=yep |   run ${KUBECTL} label node jenkins-control-plane batstest=yep | ||||||
|  |   assert_success | ||||||
|   run ${HELM} install options \ |   run ${HELM} install options \ | ||||||
|     --set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \ |     --set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \ | ||||||
|     --set namespace=${DETIK_CLIENT_NAMESPACE} \ |     --set namespace=${DETIK_CLIENT_NAMESPACE} \ | ||||||
|  | @ -31,7 +31,7 @@ setup() { | ||||||
|     --set jenkins.nodeSelector.batstest=yep \ |     --set jenkins.nodeSelector.batstest=yep \ | ||||||
|     --set jenkins.image="jenkins/jenkins:2.440.1-lts" \ |     --set jenkins.image="jenkins/jenkins:2.440.1-lts" \ | ||||||
|     --set jenkins.backup.makeBackupBeforePodDeletion=false \ |     --set jenkins.backup.makeBackupBeforePodDeletion=false \ | ||||||
|     jenkins-operator/jenkins-operator --version=$(cat ../../VERSION.txt | sed 's/v//') |     jenkins-operator/jenkins-operator --version=$(cat VERSION.txt | sed 's/v//') | ||||||
|   assert_success |   assert_success | ||||||
|   assert ${HELM} status options |   assert ${HELM} status options | ||||||
|   touch "chart/jenkins-operator/deploy.tmp" |   touch "chart/jenkins-operator/deploy.tmp" | ||||||
|  | @ -55,10 +55,10 @@ setup() { | ||||||
| @test "2.4  Helm: check Jenkins Pod status" { | @test "2.4  Helm: check Jenkins Pod status" { | ||||||
|   [[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly" |   [[ ! -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'" |   run try "at most 20 times every 5s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"backup\")].ready' is 'true'" | ||||||
|   assert_success |   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'" |   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 |   assert_success | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -95,12 +95,6 @@ setup() { | ||||||
| 
 | 
 | ||||||
| #bats test_tags=phase:helm,scenario:more-options | #bats test_tags=phase:helm,scenario:more-options | ||||||
| @test "2.9  Helm: upgrade from main branch same value" { | @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 \ |   run ${HELM} upgrade options \ | ||||||
|     --set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \ |     --set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \ | ||||||
|     --set namespace=${DETIK_CLIENT_NAMESPACE} \ |     --set namespace=${DETIK_CLIENT_NAMESPACE} \ | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ setup() { | ||||||
|     --set jenkins.image="jenkins/jenkins:2.440.1-lts" \ |     --set jenkins.image="jenkins/jenkins:2.440.1-lts" \ | ||||||
|     --set jenkins.backup.makeBackupBeforePodDeletion=true \ |     --set jenkins.backup.makeBackupBeforePodDeletion=true \ | ||||||
|     --set webhook.enabled=true \ |     --set webhook.enabled=true \ | ||||||
|     jenkins-operator/jenkins-operator --version=$(cat ../../VERSION.txt | sed 's/v//') |     jenkins-operator/jenkins-operator --version=$(cat VERSION.txt | sed 's/v//') | ||||||
|   assert_success |   assert_success | ||||||
|   assert ${HELM} status webhook |   assert ${HELM} status webhook | ||||||
|   touch "chart/jenkins-operator/deploy.tmp" |   touch "chart/jenkins-operator/deploy.tmp" | ||||||
|  | @ -50,16 +50,16 @@ setup() { | ||||||
| 
 | 
 | ||||||
|   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'" |   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 |   assert_success | ||||||
|  | 
 | ||||||
|  |   run ${KUBECTL} rollout restart deployment webhook-jenkins-operator | ||||||
|  |   assert_success | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #bats test_tags=phase:helm,scenario:webhook | #bats test_tags=phase:helm,scenario:webhook | ||||||
| @test "3.4  Helm: check Jenkins Pod status" { | @test "3.4  Helm: check Jenkins Pod status" { | ||||||
|   [[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly" |   [[ ! -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'" |   run try "at most 30 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 |   assert_success | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -81,8 +81,7 @@ setup() { | ||||||
| @test "3.7  Helm: upgrade from main branch same value" { | @test "3.7  Helm: upgrade from main branch same value" { | ||||||
|   run ${HELM} dependency update chart/jenkins-operator |   run ${HELM} dependency update chart/jenkins-operator | ||||||
|   assert_success |   assert_success | ||||||
|   ${HELM} status webhook && skip "Helm release 'webhook' already exists" |   run ${HELM} upgrade webhook \ | ||||||
|   run ${HELM} install webhook \ |  | ||||||
|     --set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \ |     --set jenkins.namespace=${DETIK_CLIENT_NAMESPACE} \ | ||||||
|     --set namespace=${DETIK_CLIENT_NAMESPACE} \ |     --set namespace=${DETIK_CLIENT_NAMESPACE} \ | ||||||
|     --set operator.image=${OPERATOR_IMAGE} \ |     --set operator.image=${OPERATOR_IMAGE} \ | ||||||
|  | @ -93,6 +92,7 @@ setup() { | ||||||
|     chart/jenkins-operator |     chart/jenkins-operator | ||||||
|   assert_success |   assert_success | ||||||
|   assert ${HELM} status webhook |   assert ${HELM} status webhook | ||||||
|  |   sleep 10 | ||||||
|   touch "chart/jenkins-operator/deploy.tmp" |   touch "chart/jenkins-operator/deploy.tmp" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -116,9 +116,6 @@ setup() { | ||||||
| 
 | 
 | ||||||
|   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'" |   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 |   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 | #bats test_tags=phase:helm,scenario:webhook | ||||||
|  | @ -147,3 +144,5 @@ setup() { | ||||||
| 
 | 
 | ||||||
|   rm "chart/jenkins-operator/deploy.tmp" |   rm "chart/jenkins-operator/deploy.tmp" | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | #TODO: add another test scenario while installing from kubectl apply | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue