-
Notifications
You must be signed in to change notification settings - Fork 115
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
API-factory: Method to Associate needed entities, then Register the Host #14974
Conversation
trigger: test-robottelo |
cc8748f
to
fbfe2aa
Compare
PRT Result
|
trigger: test-robottelo |
ac316f8
to
398ae70
Compare
trigger: test-robottelo |
PRT Result
|
e2e4386
to
9f44f90
Compare
trigger: test-robottelo |
PRT Result
|
20ce1a4
to
8ac5e8f
Compare
9392427
to
50b1c42
Compare
50b1c42
to
a1d45f7
Compare
trigger: test-robottelo |
PRT Result
|
a1d45f7
to
fd1bdc6
Compare
trigger: test-robottelo |
PRT Result
|
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.
Nice work in good direction I think! I've just put a few suggestions/questions to consider.
* Add desired repos to the content-view prior to calling this helper. | ||
Or, add them to content-view after calling, then publish/promote. | ||
|
||
param satellite: sat instance where needed entities exist. |
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.
param satellite: sat instance where needed entities exist. |
if not force and client.subscribed: | ||
if unregister: | ||
client.unregister() | ||
else: | ||
method_error['message'] = ( | ||
'Passed client is already registered.' | ||
' Unregister the host prior to calling this method.' | ||
' Or, pass unregister=True, to unregister within this method first,' | ||
' Or, pass force=True, to bypass during registration.' | ||
) | ||
return method_error |
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.
As far as I know the force=True
option in registration basically performs the same under the hood - unregisters the host first and then registers it again. Do we really need this client.unregister()
prior to L912 (forceful) registration for some reason I don't see right now? (Like for some setup between this line and L912?)
If not, we could be fine with the force
option only.
if not force and client.subscribed: | |
if unregister: | |
client.unregister() | |
else: | |
method_error['message'] = ( | |
'Passed client is already registered.' | |
' Unregister the host prior to calling this method.' | |
' Or, pass unregister=True, to unregister within this method first,' | |
' Or, pass force=True, to bypass during registration.' | |
) | |
return method_error | |
if not force and client.subscribed: | |
method_error['message'] = ( | |
'Passed client is already registered.' | |
' Unregister the host prior to calling this method.' | |
' Or, pass force=True, to bypass during registration.' | |
) | |
return method_error |
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 has been removed in favor of unregistering the host, if subscribed, in any actual test or fixture that calls this method.
In parameterized sessions, the rhel ContentHost(s) can get reused and then will not re-register unless force=True.
|
||
if ( # publish a content-view-version if none exist, or needs_publish is True | ||
len(entities['ContentView'].version) == 0 | ||
or entities['ContentView'].needs_publish is True |
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 is interesting use of the feature.
): | ||
entities['ContentView'].publish() | ||
# read updated entitites after modifying CV | ||
entities = {k: v.read() for k, v in entities.items()} |
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.
Hmm, do we need to read/update all the entities? Wouldn't be update of entities['ContentView']
enough?
Nice syntax anyway.
activation_keys=entities['ActivationKey'].name, | ||
target=self._satellite, | ||
org=entities['Organization'], | ||
loc=None, |
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.
Maybe we could pass the loc
as parameter too (for future uses).
# ie: any repos added to content-view prior to calling this method. | ||
# note: this will fail if no repos are available to client from CV/AK | ||
if enable_repos: | ||
output = client.execute(r'subscription-manager repos --enable \*') |
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 know we use this at several places already. I just wonder if it wouldn't be better to do content-override at the AK entity (based on the enable_repos
param) prior to the client registration, so the repos would get enabled through the AK already.
fd1bdc6
to
cd1fb0d
Compare
trigger: test-robottelo |
PRT Result
|
cd1fb0d
to
2aa710c
Compare
2aa710c
to
fa4274e
Compare
trigger: test-robottelo |
PRT Result
|
Work has been brought into #15085 |
Problem Statement
Many hosts for Errata-UI, use a fixture
registered_contenthost
(@L223), which registers arhel_contenthost
fixture.In parameterized sessions, the
registered_contenthost
can fail if preexisting content is present, so decent cleanup was needed.repos_collection.setup_virtual_machine()
orContentHost.contenthost_setup()
.Solution
Create an API Factory method (could also exist in the
ContentHost
class?), that will accept desired entities to host content, associate them, then register the desired client (ie a passed fixturerhel_contenthost
) to the now attached entities, using ak.Note: For api-factory method, you can pass id (int), name (string), or instance for entities (except for client, must be the entity's instance, and except for boolean args)
Very minimal setup is needed, create the needed custom entities or import fixtures, add repos to CV prior if desired, then call the method. Prior to calling, you can also do varying amounts of custom setup to lce, CV etc. For CV, latest version (if any) will be used, can handle entities partially associated or fully.
test_end_to_end
, then call the new function. Once registered, I enable them within the method by flag, and the repos (custom or redhat) will be visible to the host, from CV associated to AK. Can also skipenable_repos
for method (default), and do it yourself after.setup_org_for_a_custom_repo
orsetup_rh_repo_and_return_id
etc,then simply add the repos to CV, before calling this new method. The content from repo(s) is associated and visible as expected.
MagicMock()
, to mock a request to add finalizer (cleanup method to unregister host during teardown).ie: can accept str "Library" for environment, and can accept "Default Organization View" for content-view.
Do not pass the Library env as an id or instance, this will fail (building a check for this).Done (ref ~@ln845)Related Issues
registered_contenthost
, fails setup, or mismatched content, between parameters of a combined session.Demonstration-PRT Case
UI::Errata::test_end_to_end
: Implemented to replace existingregistered_contenthost
local fixture, which relies on convoluted setup to achieve a useable host ready for content/with content.