|
| 1 | +run_non_root_charm() { |
| 2 | + echo |
| 3 | + |
| 4 | + file="${TEST_DIR}/test-rootless-non-root-charm.log" |
| 5 | + |
| 6 | + ensure "test-rootless-non-root-charm" "${file}" |
| 7 | + |
| 8 | + juju deploy ./testcharms/charms/sidecar-non-root --resource ubuntu=public.ecr.aws/ubuntu/ubuntu:22.04 |
| 9 | + |
| 10 | + wait_for "sidecar-non-root" "$(idle_condition "sidecar-non-root" 0 0)" |
| 11 | + sleep 10 # wait for logs |
| 12 | + |
| 13 | + output=$(juju debug-log --replay) |
| 14 | + check_contains "$output" "charm=170" |
| 15 | + check_contains "$output" "sudo=no" |
| 16 | + check_contains "$output" "rootless=10000" |
| 17 | + check_contains "$output" "rootful=0" |
| 18 | + |
| 19 | + destroy_model "test-rootless-non-root-charm" |
| 20 | +} |
| 21 | + |
| 22 | +run_sudoer_charm() { |
| 23 | + echo |
| 24 | + |
| 25 | + file="${TEST_DIR}/test-rootless-sudoer-charm.log" |
| 26 | + |
| 27 | + ensure "test-rootless-sudoer-charm" "${file}" |
| 28 | + |
| 29 | + juju deploy ./testcharms/charms/sidecar-sudoer --resource ubuntu=public.ecr.aws/ubuntu/ubuntu:22.04 |
| 30 | + |
| 31 | + wait_for "sidecar-sudoer" "$(idle_condition "sidecar-sudoer" 0 0)" |
| 32 | + sleep 10 # wait for logs |
| 33 | + |
| 34 | + output=$(juju debug-log --replay) |
| 35 | + check_contains "$output" "charm=171" |
| 36 | + check_contains "$output" "sudo=yes" |
| 37 | + check_contains "$output" "rootless=10000" |
| 38 | + check_contains "$output" "rootful=0" |
| 39 | + |
| 40 | + destroy_model "test-rootless-sudoer-charm" |
| 41 | +} |
| 42 | + |
| 43 | +test_rootless() { |
| 44 | + if [ "$(skip 'test_rootless')" ]; then |
| 45 | + echo "==> TEST SKIPPED: test_rootless" |
| 46 | + return |
| 47 | + fi |
| 48 | + |
| 49 | + ( |
| 50 | + set_verbosity |
| 51 | + |
| 52 | + cd .. || exit |
| 53 | + |
| 54 | + run "run_non_root_charm" |
| 55 | + run "run_sudoer_charm" |
| 56 | + ) |
| 57 | +} |
0 commit comments