github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/tests/suites/deploy/deploy_revision.sh (about) 1 run_deploy_revision() { 2 echo 3 4 model_name="test-deploy-revision" 5 file="${TEST_DIR}/${model_name}.log" 6 7 ensure "${model_name}" "${file}" 8 9 # revision 23 is in channel 2.0/edge 10 juju deploy juju-qa-test --revision 23 --channel 2.0/stable 11 wait_for "juju-qa-test" "$(charm_rev "juju-qa-test" 23)" 12 13 # check resource revision per channel specified. 14 got=$(juju resources juju-qa-test --format json | jq -S '.resources[0] | .["revision"] == "1"') 15 check_contains "${got}" "true" 16 17 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 18 19 juju config juju-qa-test foo-file=true 20 wait_for "resource line one: testing one." "$(workload_status juju-qa-test 0).message" 21 22 # check resource revision again per channel specified. 23 juju resources juju-qa-test --format json | jq -S '.resources[0] | .[ "revision"] == "1"' 24 25 destroy_model "${model_name}" 26 } 27 28 run_deploy_revision_resource() { 29 echo 30 31 model_name="test-deploy-revision-resource" 32 file="${TEST_DIR}/${model_name}.log" 33 34 ensure "${model_name}" "${file}" 35 36 # revision 23 is in channel 2.0/edge 37 juju deploy juju-qa-test --revision 23 --channel 2.0/stable --resource foo-file=4 38 wait_for "juju-qa-test" "$(charm_rev "juju-qa-test" 23)" 39 40 # check resource revision as specified in command. 41 got=$(juju resources juju-qa-test --format json | jq -S '.resources[0] | .["revision"] == "4"') 42 check_contains "${got}" "true" 43 44 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 45 46 juju config juju-qa-test foo-file=true 47 wait_for "resource line one: testing four." "$(workload_status juju-qa-test 0).message" 48 49 # check resource revision again per channel specified. 50 juju resources juju-qa-test --format json | jq -S '.resources[0] | .[ "revision"] == "4"' 51 52 destroy_model "${model_name}" 53 } 54 55 run_deploy_revision_fail() { 56 echo 57 58 model_name="test-deploy-revision-fail" 59 file="${TEST_DIR}/${model_name}.log" 60 61 ensure "${model_name}" "${file}" 62 63 got=$(juju deploy juju-qa-test --revision 9 2>&1 || true) 64 # bad request should be caught by client 65 check_contains "${got}" 'revision requires a channel for future upgrades' 66 67 destroy_model "${model_name}" 68 } 69 70 run_deploy_revision_refresh() { 71 echo 72 73 model_name="test-deploy-refresh" 74 file="${TEST_DIR}/${model_name}.log" 75 76 ensure "${model_name}" "${file}" 77 78 # revision 23 is in channel 2.0/edge 79 juju deploy juju-qa-test --revision 23 --channel latest/edge 80 wait_for "juju-qa-test" "$(charm_rev "juju-qa-test" 23)" 81 82 # NOTE: 83 # The following loop is specific to juju 3.0+ due to 84 # async charm download and should NOT be removed in 85 # a merge from 2.9. 86 attempt=0 87 while true; do 88 # Ensure that refresh gets the revision from the channel 89 # listed at deploy. 90 # revision 15 is in channel latest/edge 91 OUT=$(juju refresh juju-qa-test 2>&1 || true) 92 if echo "${OUT}" | grep -E -q "Added"; then 93 break 94 fi 95 attempt=$((attempt + 1)) 96 if [ $attempt -eq 10 ]; then 97 # shellcheck disable=SC2046 98 echo $(red "timeout: waiting for charm download to complete 50sec") 99 exit 5 100 fi 101 sleep 5 102 done 103 104 # revision 21 is in channel latest/edge 105 wait_for "juju-qa-test" "$(charm_rev "juju-qa-test" 21)" 106 wait_for "juju-qa-test" "$(charm_channel "juju-qa-test" "latest/edge")" 107 108 destroy_model "${model_name}" 109 } 110 111 test_deploy_revision() { 112 if [ "$(skip 'test_deploy_revision')" ]; then 113 echo "==> TEST SKIPPED: deploy revision" 114 return 115 fi 116 117 ( 118 set_verbosity 119 120 cd .. || exit 121 122 run "run_deploy_revision" 123 run "run_deploy_revision_fail" 124 run "run_deploy_revision_refresh" 125 run "run_deploy_revision_resource" 126 ) 127 }