-
Notifications
You must be signed in to change notification settings - Fork 200
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
Add global registration bats tests for Katello clients #1391
Add global registration bats tests for Katello clients #1391
Conversation
echo "rc=${status}" | ||
echo "${output}" | ||
|
||
registration_command=$(curl https://admin:changeme@$HOSTNAME/api/registration_commands -X POST -H 'Content-Type: application/json' -d '"activation_key":"${ACTIVATION_KEY}","organization":"${ORGANIZATION_LABEL}"' | ruby -e "require 'json'; puts JSON.load(ARGF.read)['registration_command']") |
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.
This appears to not work as it generates the registration command with Default_Organization
instead of Test_Organization
not respecting passing the organization label? Is this a bug or am I setting this wrong? @ares @stejskalleos
Additionally, I noticed that if I pass a parameter that registeration does not support there is not an error, the parameter is just ignored. That led to some debugging confusion
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.
For what it's worth, you shouldn't have to post using JSON. You can also shorten the Ruby line a bit.
registration_command=$(curl https://admin:changeme@$HOSTNAME/api/registration_commands -X POST -H 'Content-Type: application/json' -d '"activation_key":"${ACTIVATION_KEY}","organization":"${ORGANIZATION_LABEL}"' | ruby -e "require 'json'; puts JSON.load(ARGF.read)['registration_command']") | |
registration_command=$(curl https://admin:changeme@$HOSTNAME/api/registration_commands -X POST -d "activation_key=${ACTIVATION_KEY}" -d "organization=${ORGANIZATION_LABEL}" | ruby -rjson -e "puts JSON.load(ARGF.read)['registration_command']") |
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 you need to pass IDs, not names/labels for org?
https://github.com/theforeman/foreman/blob/5a66daa44921e63522bb90d01f8924b6cd4abcd5/app/controllers/concerns/foreman/controller/registration.rb#L17-L20
https://github.com/theforeman/foreman/blob/5a66daa44921e63522bb90d01f8924b6cd4abcd5/app/controllers/api/v2/registration_commands_controller.rb#L9-L21
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.
Additionally, I noticed that if I pass a parameter that registeration does not support there is not an error, the parameter is just ignored. That led to some debugging confusion
What if I told you, ALL of our API behaves like this, and I might have gray hair because of that?
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.
Yea... @ares was saddening me with this. Just makes debugging that much harder in this case to know what my client is doing.
I think you need to pass IDs, not names/labels for org?
Yea... for this to work right now I will have to do that. I left it like to to first help the conversation about adding name/label support for organizations.
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 can file an RFE for the label for Katello. Should name work though?
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 can file an RFE for the label for Katello. Should name work though?
Oh I guess not from what @evgeni linked. I'll file an issue for that too.
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 would call it an RFE :-) I guess we shouldn't block the test on it. Note that if you insisht on org label and not the name, it must be added from Katello, since label is a katello thing. Perhaps it's time to move this extension to Foreman core where it belongs to?
By extension, you mean the concept of a label on organization to Foreman core?
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 filed the following for consideration:
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.
For what it's worth, you shouldn't have to post using JSON. You can also shorten the Ruby line a bit.
The API only accepts JSON when using POST.
@@ -17,6 +17,7 @@ bats_tests: | |||
- "fb-test-katello.bats" | |||
- "fb-katello-content.bats" | |||
- "fb-katello-client.bats" | |||
- "fb-katello-client-global-registration.bats" |
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 probably need to not include this for some versions of Foreman and Katello we currently support. What those would be, I am not presently sure of.
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.
4.0+ I believe
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.
Great to see we'll have test for this, do we only keep happy paths here or can we add more variants? It would be awesome to have a test that also creates PAT (personal access token) for a user (e.g. admin) and then we get the registration command using that instead of changeme
password. OTOH if we already have test for PAT elsewhere, ignore me :-)
f9eaa72
to
cf22743
Compare
cf22743
to
8fc2e8f
Compare
This has been updated to use My goal is to get basic coverage for the Katello scenario to help ensure the new workflow works as we aim to replace the old one and then in subsequent PRs layer in new test suites. |
@jturel @stejskalleos Could you both take a look to ensure this looks OK and that it captures a workflow you'd expect? |
Makes sense to me, IMHO good to go in (didn't perform the syntax check, just the semantics) 👍 |
Looks good to me :) |
@evgeni Mind giving this a look? |
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.
Two comments, but willing to give it a try as-is and cleanup the broken pieces later.
(Assuming you have run this against nightly and it passes 😅)
fi | ||
|
||
cleanSubscriptionManager | ||
tPackageRemove subscription-manager |
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.
Is that so that the GR command can install it again?
Doesn't this break pulp3 on EL8 where this might kill python3-rhsm (or whatever the right pkg name is)?
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 hope not. I did not see any breaks with my testing.
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.
If you ran it on EL8 and it did not make pulp-certguard go belly up, we're good.
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.
Looks all good:
==========================================================================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================================================================================================================================================
Removing:
subscription-manager x86_64 1.28.13-3.el8_4 @baseos 4.3 M
Removing unused dependencies:
dnf-plugin-subscription-manager x86_64 1.28.13-3.el8_4 @baseos 87 k
python3-dmidecode x86_64 3.12.2-15.el8 @baseos 308 k
python3-ethtool x86_64 0.14-3.el8 @baseos 92 k
python3-inotify noarch 0.9.6-13.el8 @baseos 243 k
python3-librepo x86_64 1.12.0-3.el8 @baseos 172 k
usermode x86_64 1.113-1.el8 @baseos 837 k
Transaction Summary
==========================================================================================================================================================================================================================================================================================
Remove 7 Packages
tPackageInstall walrus-0.71 && tPackageExists walrus-0.71 | ||
} | ||
|
||
@test "check available errata" { |
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.
Feels like this duplicates the original content tests -- might want to move it to a helper 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.
Yea, can do, as I have another test suite in mind that would do the same thing.
No description provided.