Skip to content

Commit

Permalink
Rewrote the test using fake controllers.yaml. Moved test to cli suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
anvial committed Sep 19, 2022
1 parent 713bdfd commit a12b468
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 50 deletions.
1 change: 1 addition & 0 deletions tests/suites/cli/task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test_cli() {
test_local_charms
test_model_config
test_model_defaults
test_unregister

destroy_controller "test-cli"
}
57 changes: 57 additions & 0 deletions tests/suites/cli/unregister.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
run_unregister() {
echo

echo "Create temporary controllers.yaml file"
mkdir -p "${TEST_DIR}/juju"
echo "" >>"${TEST_DIR}/juju/controllers.yaml"

CONTROLLERS=$(
cat <<'EOF'
controllers:
unregister-test:
uuid: c2a22492-e551-4856-850c-f3df36e9a828
api-endpoints: ['10.209.4.183:17070']
ca-cert: |
-----BEGIN CERTIFICATE-----
XXX==
-----END CERTIFICATE-----
cloud: lxd
region: default
type: lxd
agent-version: 2.9.35.1
controller-machine-count: 1
active-controller-machine-count: 0
machine-count: 1
EOF
)

echo "Set fake data about unregister-test controller in controllers.yaml"
echo "${CONTROLLERS}" >>"${TEST_DIR}/juju/controllers.yaml"

echo "Unregister the unregister-test controller"
JUJU_DATA="${TEST_DIR}/juju" juju unregister --yes "unregister-test"

echo "Check that temporary controllers.yaml has no controllers' data"
EXPECTED="controllers: {}"
OUT=$(cat "${TEST_DIR}/juju/controllers.yaml" )
if [ "${OUT}" != "${EXPECTED}" ]; then
echo "expected ${EXPECTED}, got ${OUT}"
exit 1
fi

}

test_unregister() {
if [ -n "$(skip 'test_unregister')" ]; then
echo "==> SKIP: Asked to skip controller unregister tests"
return
fi

(
set_verbosity

cd .. || exit

run "run_unregister"
)
}
1 change: 0 additions & 1 deletion tests/suites/controller/task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ test_controller() {
test_enable_ha
# Leave this one last, as it can cause mongo to slowdown to a snails pace.
test_mongo_memory_profile
test_unregister

destroy_controller "test-controller"
}
49 changes: 0 additions & 49 deletions tests/suites/controller/unregister.sh

This file was deleted.

0 comments on commit a12b468

Please sign in to comment.