github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/tests/suites/resources/basic.sh (about) 1 run_deploy_repo_resource() { 2 echo 3 name="deploy-repo-resource" 4 5 file="${TEST_DIR}/test-${name}.log" 6 7 ensure "test-${name}" "${file}" 8 9 juju deploy juju-qa-test --channel candidate 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 four." "$(workload_status juju-qa-test 0).message" 15 16 destroy_model "test-${name}" 17 } 18 19 run_deploy_local_resource() { 20 echo 21 name="deploy-local-resource" 22 23 file="${TEST_DIR}/test-${name}.log" 24 25 ensure "test-${name}" "${file}" 26 27 juju deploy juju-qa-test --resource foo-file="./tests/suites/resources/foo-file.txt" 28 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 29 juju config juju-qa-test foo-file=true 30 31 # wait for update-status 32 wait_for "resource line one: did the resource attach?" "$(workload_status juju-qa-test 0).message" 33 34 destroy_model "test-${name}" 35 } 36 37 run_resource_attach() { 38 echo 39 name="resource-attach" 40 41 file="${TEST_DIR}/test-${name}.log" 42 43 ensure "test-${name}" "${file}" 44 45 juju deploy juju-qa-test 46 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 47 juju attach-resource juju-qa-test foo-file="./tests/suites/resources/foo-file.txt" 48 49 juju config juju-qa-test foo-file=true 50 # wait for config-changed, the charm will update the status 51 # to include the contents of foo-file.txt 52 wait_for "resource line one: did the resource attach?" "$(workload_status juju-qa-test 0).message" 53 54 destroy_model "test-${name}" 55 } 56 57 run_resource_attach_large() { 58 echo 59 name="resource-attach-large" 60 61 file="${TEST_DIR}/test-${name}.log" 62 63 ensure "test-${name}" "${file}" 64 65 juju deploy juju-qa-test 66 wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")" 67 68 # .txt suffix required for attach. 69 FILE=$(mktemp /tmp/resource-XXXXX.txt) 70 # Use urandom to add alpha numeric characters with new lines added to the file 71 dd if=/dev/urandom bs=1048576 count=100 2>/dev/null | base64 >"${FILE}" 72 line=$(head -n 1 "${FILE}") 73 juju attach-resource juju-qa-test foo-file="${FILE}" 74 75 juju config juju-qa-test foo-file=true 76 # wait for config-changed, the charm will update the status 77 # to include the contents of foo-file.txt 78 wait_for "resource line one: ${line}" "$(workload_status juju-qa-test 0).message" 79 80 rm "${FILE}" 81 destroy_model "test-${name}" 82 } 83 84 test_basic_resources() { 85 if [ "$(skip 'test_basic_resources')" ]; then 86 echo "==> TEST SKIPPED: Resource basics" 87 return 88 fi 89 90 ( 91 set_verbosity 92 93 cd .. || exit 94 95 run "run_deploy_local_resource" 96 run "run_deploy_repo_resource" 97 98 # these belong in a new file when there is time to update the CI jobs. 99 run "run_resource_attach" 100 run "run_resource_attach_large" 101 ) 102 }