Skip to content
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

fix: broken authorized keys bootstrap test #18400

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

tlm
Copy link
Member

@tlm tlm commented Nov 21, 2024

This commit fixes broken authorized keys test for bootstrap. It has been a problem that the authorized_keys bootstrap tests have been failing in our CI environment and not on local machines when testing.

The reason for this failaure is due to our CI environment having set the JUJU_DATA env variable. This set of tests needs to be able to hijack the Juju home data directory to establish a controlled environment.

Because the CI system had this env set Juju was using the wrong directory for it's data. The fix is to make sure that we set this variable for the duration of the test to the value we want.

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • [] Go unit tests, with comments saying what you're testing
  • [ ] Integration tests, with comments saying what you're testing
  • [ ] doc.go added or updated in changed packages

QA steps

We can confirm this fix with the following steps:

  1. cd tests
  2. JUJU_DATA=foobar ./main.sh -v authorized_keys test_bootstrap_authorized_keys

If the tests run successfully then everything is resolved.

Documentation changes

Jira card: JUJU-6889

@tlm tlm requested a review from hpidcock November 21, 2024 10:34
@hpidcock hpidcock added the 4.0 label Nov 21, 2024
@tlm tlm requested a review from Aflynn50 November 21, 2024 10:34
Copy link
Contributor

@Aflynn50 Aflynn50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works on my machine, but I'm not sure this change actually fixes the problem you described.

@@ -28,10 +28,11 @@ run_bootstrap_authorized_keys_loaded() {
ssh-keygen -t ed25519 -f "$extra_key_file" -C "[email protected]" -P ""

HOME="${SUB_TEST_DIR}"
JUJU_DATA="${juju_home_dir}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this works? This variable is not actually being exported here, just set locally. I don't think the juju cli would be aware of it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hence the shell check error:

     | In tests/suites/authorized_keys/bootstrap.sh line 77:
    | JUJU_DATA="${juju_home_dir}"
    | ^-------^ SC2034 (warning): JUJU_DATA appears unused. Verify use (or export if used externally).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed up.

bootstrap_additional_args=(--config "'authorized-keys=$(cat ${extra_key_file_pub})'")
export BOOTSTRAP_ADDITIONAL_ARGS="${bootstrap_additional_args[*]}"
export BOOTSTRAP_REUSE=false
bootstrap "authorized-keys-default" "$log_file"
bootstrap "authorized-keys-loaded" "$log_file"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the controller name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was wrong and causing another issue. It should reflect the name of the test. Just a bad copy and paste i fixed as a drive by.

@tlm tlm force-pushed the authorized-key-tests-failures branch from 2674b57 to 9b08995 Compare November 22, 2024 00:45
@tlm
Copy link
Member Author

tlm commented Nov 24, 2024

/build

@tlm tlm force-pushed the authorized-key-tests-failures branch from d281894 to c28c2c7 Compare November 25, 2024 05:09
This commit fixes broken authorized keys test for bootstrap. It has been
a problem that the authorized_keys bootstrap tests have been failing in
our CI environment and not on local machines when testing.

The reason for this failaure is due to our CI environment having set the
JUJU_DATA env variable. This set of tests needs to be able to hijack the
Juju home data directory to establish a controlled environment.

Because the CI system had this env set Juju was using the wrong
directory for it's data. The fix is to make sure that we set this
variable for the duration of the test to the value we want.
@tlm tlm force-pushed the authorized-key-tests-failures branch from c28c2c7 to 9b1268f Compare November 25, 2024 05:24
@tlm
Copy link
Member Author

tlm commented Nov 25, 2024

/build

@tlm
Copy link
Member Author

tlm commented Nov 25, 2024

/merge

@jujubot jujubot merged commit e4cc164 into juju:main Nov 25, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants