github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/tests/suites/resources/refresh.sh (about) 1 run_resource_refresh() { 2 echo 3 name="resource-upgrade" 4 5 file="${TEST_DIR}/test-${name}.log" 6 7 ensure "test-${name}" "${file}" 8 9 juju deploy juju-qa-test --channel 2.0/edge 10 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 11 juju config juju-qa-test foo-file=true 12 13 # wait for update-status 14 wait_for "resource line one: testing one plus one." "$(workload_status juju-qa-test 0).message" 15 juju config juju-qa-test foo-file=false 16 17 juju refresh juju-qa-test --channel 2.0/stable 18 wait_for "juju-qa-test" "$(charm_channel "juju-qa-test" "2.0/stable")" 19 20 juju config juju-qa-test foo-file=true 21 wait_for "resource line one: testing one." "$(workload_status juju-qa-test 0).message" 22 23 destroy_model "test-${name}" 24 } 25 26 run_resource_refresh_no_new_charm_rev() { 27 echo 28 name="resource-upgrade-no-new-charm-rev" 29 30 file="${TEST_DIR}/test-${name}.log" 31 32 ensure "test-${name}" "${file}" 33 34 juju deploy juju-qa-test --resource foo-file=4 35 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 36 juju config juju-qa-test foo-file=true 37 38 # wait for update-status 39 wait_for "resource line one: testing four." "$(workload_status juju-qa-test 0).message" 40 juju resources juju-qa-test --format json | jq -S '.resources[0] | .[ "revision"] == "4"' 41 juju config juju-qa-test foo-file=false 42 43 juju refresh juju-qa-test 44 45 juju config juju-qa-test foo-file=true 46 wait_for "resource line one: testing two." "$(workload_status juju-qa-test 0).message" 47 juju resources juju-qa-test --format json | jq -S '.resources[0] | .[ "revision"] == "2"' 48 49 destroy_model "test-${name}" 50 } 51 52 run_resource_refresh_no_new_charm_rev_supply_res_rev() { 53 # refresh the resource revision without changing the 54 # charm url 55 echo 56 name="resource-refresh-no-new-charm-rev-supply-res-rev" 57 58 file="${TEST_DIR}/test-${name}.log" 59 60 ensure "test-${name}" "${file}" 61 62 juju deploy juju-qa-test 63 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 64 juju config juju-qa-test foo-file=true 65 66 # wait for update-status 67 wait_for "resource line one: testing two." "$(workload_status juju-qa-test 0).message" 68 juju resources juju-qa-test --format json | jq -S '.resources[0] | .[ "revision"] == "2"' 69 juju config juju-qa-test foo-file=false 70 71 juju refresh juju-qa-test --resource foo-file=3 72 73 juju config juju-qa-test foo-file=true 74 wait_for "resource line one: testing one plus one." "$(workload_status juju-qa-test 0).message" 75 juju resources juju-qa-test --format json | jq -S '.resources[0] | .[ "revision"] == "3"' 76 77 destroy_model "test-${name}" 78 } 79 80 run_resource_no_upgrade_after_upload() { 81 # Deploy with an uploaded resource. Verify the resource doesn't 82 # change after refresh. 83 echo 84 name="resource-no-upgrade-after-upload" 85 86 file="${TEST_DIR}/test-${name}.log" 87 88 ensure "test-${name}" "${file}" 89 90 juju deploy juju-qa-test --resource foo-file="./tests/suites/resources/foo-file.txt" 91 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 92 93 juju config juju-qa-test foo-file=true 94 # wait for config-changed, the charm will update the status 95 # to include the contents of foo-file.txt 96 wait_for "resource line one: did the resource attach?" "$(workload_status juju-qa-test 0).message" 97 98 juju refresh juju-qa-test --channel 2.0/stable 99 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 100 101 # check resource revision hasn't changed. 102 juju resources juju-qa-test --format json | jq -S '.resources[0] | .[ "revision"] == "0"' 103 juju resources juju-qa-test --format json | jq -S '.resources[0] | .[ "origin"] == "upload"' 104 105 destroy_model "test-${name}" 106 } 107 108 test_upgrade_resources() { 109 if [ "$(skip 'test_upgrade_resources')" ]; then 110 echo "==> TEST SKIPPED: Resource upgrades" 111 return 112 fi 113 114 ( 115 set_verbosity 116 117 cd .. || exit 118 119 run "run_resource_refresh" 120 run "run_resource_refresh_no_new_charm_rev" 121 run "run_resource_no_upgrade_after_upload" 122 run "run_resource_refresh_no_new_charm_rev_supply_res_rev" 123 ) 124 }