Skip to content

Commit

Permalink
Fixed test-controller-test-unregister-test.
Browse files Browse the repository at this point in the history
  • Loading branch information
anvial committed Sep 17, 2022
1 parent 6ac8f81 commit 6722902
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/suites/controller/unregister.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ run_unregister() {
juju controllers --format=json | jq -r ".\"controllers\" | has(\"${controller_name}\")" | check true

echo "Backup controller info before unregister"
cp ~/.local/share/juju/controllers.yaml ~/.local/share/juju/controllers.yaml.bak
cp ~/.local/share/juju/accounts.yaml ~/.local/share/juju/accounts.yaml.bak
if [[ -f "${HOME}/.local/share/juju/controllers.yaml" ]]
then
cp "${HOME}/.local/share/juju/controllers.yaml" "${HOME}/.local/share/juju/controllers.yaml.bak"
fi
if [[ -f "${HOME}/.local/share/juju/accounts.yaml" ]]
then
cp "${HOME}/.local/share/juju/accounts.yaml" "${HOME}/.local/share/juju/accounts.yaml.bak"
fi

echo "Unregister controller"
juju unregister --yes "${controller_name}"
Expand All @@ -25,8 +31,14 @@ run_unregister() {
check_not_contains "$(juju controllers --format=json | jq -r '."current-controller"')" "${controller_name}"

echo "Restore controller info after unregister"
mv ~/.local/share/juju/controllers.yaml.bak ~/.local/share/juju/controllers.yaml
mv ~/.local/share/juju/accounts.yaml.bak ~/.local/share/juju/accounts.yaml
if [[ -f "${HOME}/.local/share/juju/controllers.yaml.bak" ]]
then
mv "${HOME}/.local/share/juju/controllers.yaml.bak" "${HOME}/.local/share/juju/controllers.yaml"
fi
if [[ -f "${HOME}/.local/share/juju/accounts.yaml.ba"k ]]
then
mv "${HOME}/.local/share/juju/accounts.yaml.bak" "${HOME}/.local/share/juju/accounts.yaml"
fi

juju controllers --format=json | jq -r '."current-controller"' | check "${controller_name}"

Expand Down

0 comments on commit 6722902

Please sign in to comment.