github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/tests/suites/model/multi.sh (about) 1 run_model_multi() { 2 # Echo out to ensure nice output to the test suite. 3 echo 4 5 # The following ensures that a bootstrap juju exists. 6 file="${TEST_DIR}/test-model-multi.log" 7 ensure "model-multi" "${file}" 8 9 deploy_stack "test-models" 10 11 juju add-model env1 12 deploy_stack "env1" 13 14 juju add-model env2 15 deploy_stack "env2" 16 17 check_services "test-models" 18 check_services "env1" 19 check_services "env2" 20 21 destroy_model "env1" 22 destroy_model "env2" 23 destroy_model "model-multi" 24 } 25 26 deploy_stack() { 27 name=${1} 28 29 juju switch "${name}" 30 31 juju deploy juju-qa-dummy-source --series jammy 32 juju deploy juju-qa-dummy-sink --series jammy 33 34 juju integrate dummy-source dummy-sink 35 juju expose dummy-sink 36 37 wait_for_machine_agent_status 0 "started" 38 wait_for_machine_agent_status 1 "started" 39 } 40 41 check_services() { 42 name=${1} 43 44 juju switch "${name}" 45 46 token=$(rnd_str) 47 echo "[+] Setting token for ${name} with ${token}" 48 juju config dummy-source token="${token}" 49 50 attempt=0 51 until [[ $(juju status --format json | jq -er ".applications | .[\"dummy-source\"] | .units | .[\"dummy-source/0\"] | .[\"workload-status\"] | select(.[\"message\"] == \"Token is ${token}\") | .message") ]]; do 52 echo "[+] (attempt ${attempt}) polling status" 53 sleep "${SHORT_TIMEOUT}" 54 attempt=$((attempt + 1)) 55 56 if [ "${attempt}" -gt 2 ]; then 57 echo "[-] $(red 'Failed polling status')" 58 exit 1 59 fi 60 done 61 62 if [ "${attempt}" -eq 0 ]; then 63 echo "[-] $(red 'Failed polling status')" 64 exit 1 65 fi 66 67 echo "[+] $(green 'Completed polling status')" 68 } 69 70 test_model_multi() { 71 if [ -n "$(skip 'test_model_multi')" ]; then 72 echo "==> SKIP: Asked to skip model multi tests" 73 return 74 fi 75 76 ( 77 set_verbosity 78 79 cd .. || exit 80 81 run "run_model_multi" 82 ) 83 }