-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JUJU-1209] Added a bash-based version of the unregister-controller test. #14538
Merged
jujubot
merged 4 commits into
juju:2.9
from
anvial:JUJU-1209-rewrite-to-bash-based-nw-unregister-controller
Sep 6, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fc4ff33
Added bash-based unregister-controller test.
anvial cda592d
Removed autogenerated comments from expect scripts.
anvial 573b34b
Added accounts.yaml backup/restore, that helped to avoid using expect…
anvial b0e5a61
Added check that default controller is not equal to unregistered one …
anvial File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
run_unregister() { | ||
echo | ||
|
||
file="${TEST_DIR}/unregister.log" | ||
|
||
ensure "unregister" "${file}" | ||
|
||
echo "Get controller name" | ||
controller_name=$(juju controllers --format=json | jq -r '."current-controller"') | ||
|
||
echo "Check controller is known" | ||
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 | ||
|
||
echo "Unregister controller" | ||
juju unregister --yes "${controller_name}" | ||
|
||
echo "Check controller is not known" | ||
juju controllers --format=json | jq -r ".\"controllers\".\"${controller_name}\"" | check null | ||
|
||
echo "Check the default controller is not equal to unregistered one" | ||
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 | ||
|
||
juju controllers --format=json | jq -r '."current-controller"' | check "${controller_name}" | ||
|
||
destroy_model "unregister" | ||
} | ||
|
||
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" | ||
) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a comment here with:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have a concern that this check doesn't really check what I think the behavior of
unregister
is meant to be.The meaning of
juju unregister
is not 'I have unset the default controller'. The meaning is that "I no longer know who $controller is", whether they were the default or not.So I'd rather see a test of:
juju controllers
and that before the unregister it lists that the named controller is there, and after the unregister it no longer does.I think it is fine to then also include "and if the controller that was removed was the default controller, we don't leave a default value that points to something that is now unknown".
But we are missing the bit that says "this is no longer a known controller".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it,
I've added:
juju controllers
output before the unregisterjuju unregister
.