SatelliteQE / robottelo

Robottelo is a test suite that exercises The Foreman.
GNU General Public License v3.0
61 stars 112 forks source link

GET subscriptions/:id fails, requires organization #7615

Closed swadeley closed 4 years ago

swadeley commented 4 years ago

Hello

While running test test_inc_updates.py [1] against recent snap of 6.7 I got:

> if sub.read_json()['product_name'] == DEFAULT_SUBSCRIPTION_NAME:

tests/foreman/longrun/test_inc_updates.py:173:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../shiningpanda/jobs/14e83bb9/virtualenvs/d41d8cd9/lib/python3.6/site-packages/nailgun  /entity_mixins.py:750: in read_json
  response.raise_for_status() 

> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://qe-sat6/katello/api/v2/subscriptions/346

The GET request subscriptions/:id. fails with error: "errors":["This subscription is not relevant to the current user and organization."

See comment https://bugzilla.redhat.com/show_bug.cgi?id=1787147#c7 in: Bug 1787147 - An admin cannot GET subscription/manifest uploaded in org created by another admin

The code [1] has this in the setup:

for sub in subs:
        if sub.read_json()['product_name'] == DEFAULT_SUBSCRIPTION_NAME:
            rhel_6_partial_ak.add_subscriptions(data={
                u'subscription_id': sub.id
            })

The read_json() calls read_raw() which makes a GET request which fails. [2] However, just before this section, there is another call for the same [3] entity, which works because it inclueds organization_id

subs = entities.Subscription(organization=self.org).search()

This means the call that is failing is in any case redundant. We can replace this line:

if sub.read_json()['product_name'] == DEFAULT_SUBSCRIPTION_NAME:

with:

if sub.name == DEFAULT_SUBSCRIPTION_NAME:

[1] https://github.com/SatelliteQE/robottelo/blob/359a3e851efcd50f390d7940e5ea85e5944e6915/tests/foreman/longrun/test_inc_updates.py#L170 [2] https://github.com/SatelliteQE/nailgun/blob/c1fbde2cc55500e06281b6255d6ebdd869ddc6a3/nailgun/entity_mixins.py#L721 [3] https://github.com/SatelliteQE/robottelo/blob/359a3e851efcd50f390d7940e5ea85e5944e6915/tests/foreman/longrun/test_inc_updates.py#L166

swadeley commented 4 years ago

While that setup section works with that "if sub.name" line, I now get failure to install katello-agent becuase the repos are not enabled in the activation key:

2020-01-29 11:42:57 - nailgun.client - DEBUG - Making HTTP PUT request to https://dhcp-2-118.vms.sat.rdu2.redhat.com/katello/api/v2/activation_keys/4/content_override with options {'auth': ('admin', 'changeme'), 'verify': False, 'headers': {'content-type': 'application/json'}}, no params and data {"content_override": {"content_label": "rhel-6-server-satellite-tools-6.6-rpms", "value": "1"}}.

I do not see the confirmation that it is enabled:

2020-01-29 11:43:26 - nailgun.client - DEBUG - Received HTTP 200 response: {"service_level":null,"content_overrides":[],"id":4,"name":"NPEwYsypet","description":null,"unlimited_hosts":true,"auto_attach":true,"content_view_id":9,"environment_id":13,"usage_count":0,"user_id":4,"max_hosts":null,"release_version":null,"purpose_usage":null,"purpose_role":null,"organization_id":6,"organization":{"name":"dhaRiKrRFW","label":"dhaRiKrRFW","id":6},"created_at":"2020-01-29 11:21:11 UTC","updated_at":"2020-01-29 11:21:11 UTC","content_view":{"id":9,"name":"jsxNCAiFBc"},"environment":{"name":"QE","id":13},"products":[{"id":203,"name":"Red Hat Enterprise Linux Server"}],"host_collections":[{"id":4,"name":"rJQMcCnqOG"}],"purpose_addons":[],"permissions":{"view_activation_keys":true,"edit_activation_keys":true,"destroy_activation_keys":true}}