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

Add global registration bats tests for Katello clients #1391

Merged

Conversation

ehelms
Copy link
Member

@ehelms ehelms commented Jul 21, 2021

No description provided.

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']")
Copy link
Member Author

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

Copy link
Member

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.

Suggested change
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']")

Copy link
Member

@evgeni evgeni Jul 22, 2021

Choose a reason for hiding this comment

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

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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?

Copy link
Member Author

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.

Copy link
Member Author

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

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"
Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

4.0+ I believe

Copy link
Member

@ares ares left a 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 :-)

@ehelms ehelms force-pushed the add-katello-client-global-registration branch from f9eaa72 to cf22743 Compare August 6, 2021 16:49
@ehelms ehelms force-pushed the add-katello-client-global-registration branch from cf22743 to 8fc2e8f Compare August 6, 2021 17:45
@ehelms
Copy link
Member Author

ehelms commented Aug 6, 2021

This has been updated to use organization_id for now while we work out what to do about name and label. This only adds tests for Katello at the moment and aims to mimic the basics of the existing client bats tests. I opened an issue to track adding additional global registration tests: #1396

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.

@ehelms
Copy link
Member Author

ehelms commented Aug 11, 2021

@jturel @stejskalleos Could you both take a look to ensure this looks OK and that it captures a workflow you'd expect?

@ares
Copy link
Member

ares commented Aug 12, 2021

Makes sense to me, IMHO good to go in (didn't perform the syntax check, just the semantics) 👍

@jturel
Copy link
Contributor

jturel commented Aug 12, 2021

Looks good to me :)

@ehelms
Copy link
Member Author

ehelms commented Aug 18, 2021

@evgeni Mind giving this a look?

@ehelms ehelms requested review from evgeni and ares August 24, 2021 15:17
Copy link
Member

@evgeni evgeni left a 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
Copy link
Member

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)?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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" {
Copy link
Member

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?

Copy link
Member Author

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.

@ehelms ehelms merged commit b07f7d6 into theforeman:master Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants