-
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
Changes from 2 commits
fc4ff33
cda592d
573b34b
b0e5a61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/expect -f | ||
|
||
set force_conservative 0 ;# set to 1 to force conservative mode even if | ||
;# script wasn't run conservatively originally | ||
if {$force_conservative} { | ||
set send_slow {1 .1} | ||
proc send {ignore arg} { | ||
sleep .1 | ||
exp_send -s -- $arg | ||
} | ||
} | ||
|
||
set timeout 10 | ||
spawn juju change-user-password | ||
match_max 100000 | ||
expect -exact "new password: " | ||
send -- "adminpass\r" | ||
expect -exact "\r | ||
type new password again: " | ||
send -- "adminpass\r" | ||
expect eof |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/expect -f | ||
|
||
set force_conservative 0 ;# set to 1 to force conservative mode even if | ||
;# script wasn't run conservatively originally | ||
if {$force_conservative} { | ||
set send_slow {1 .1} | ||
proc send {ignore arg} { | ||
sleep .1 | ||
exp_send -s -- $arg | ||
} | ||
} | ||
|
||
set timeout 10 | ||
set controller_name [lindex $argv 1] | ||
spawn juju login -u admin -c {*}$argv | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this syntax seems a bit hard to understand, but I have the feeling we'll get used to it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backup/restore |
||
match_max 100000 | ||
expect -exact "please enter password for admin on $controller_name: " | ||
send -- "adminpass\r" | ||
expect eof |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
run_unregister() { | ||
echo | ||
|
||
file="${TEST_DIR}/unregister.log" | ||
|
||
ensure "unregister" "${file}" | ||
|
||
controller_name=$(juju controllers --format=json | jq -r '."current-controller"') | ||
|
||
echo "Change admin password" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At a high level, why is our "unregister test suite" worrying about change user password and login? (IOW, while this may be a faithful representation of our existing test suite, and it is great to port across, we should take a critical view and consider if we should be testing this behavior as part of this test.) Maybe it should, as you test that you can login again to a controller that you have unregistered. (presumably this is testing that the controller hasn't actually been destroyed, just removed from local info?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backup/restore |
||
./tests/suites/controller/expect-scripts/juju-change-user-password.exp | ||
|
||
echo "Backup controller info before unregister" | ||
cp ~/.local/share/juju/controllers.yaml ~/.local/share/juju/controllers.yaml.bak | ||
|
||
echo "Unregister controller" | ||
juju unregister --yes "${controller_name}" | ||
|
||
juju controllers --format=json | jq -r ".\"controllers\".\"${controller_name}\"" | check null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 The meaning of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, I've added:
|
||
|
||
echo "Restore controller info after unregister" | ||
mv ~/.local/share/juju/controllers.yaml.bak ~/.local/share/juju/controllers.yaml | ||
|
||
echo "Login to controller info after restoring" | ||
./tests/suites/controller/expect-scripts/juju-login.exp "${controller_name}" | ||
juju switch unregister | ||
|
||
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" | ||
) | ||
} |
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.
README.md also needs to be updated:
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 wonder if that exact version is still even correct anymore. I feel like this README entry should probably be redirected to something that is actually used by the CI suite as well, to ensure dependencies, so that we get them lined up, and can avoid future skew.
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.
Backup/restore
acoounts.yaml
file helped to avoid usingexpect
so we can postpone this tool introduction