Skip to content

Commit

Permalink
feat: e2e tests uses registered_system and not_registered_system already
Browse files Browse the repository at this point in the history
  • Loading branch information
jstavel committed Nov 24, 2023
1 parent 248ec0b commit 2d132ef
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions integration-tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,26 @@
import os
import funcy

from functools import partial

from pytest_client_tools import rhc

"""
Tests related to ingress service. The service provides information
about every system that is connected to the account.
"""


def test_rhc_fetch_from_inventory(external_candlepin,
test_config,
def test_rhc_fetch_from_inventory(not_registered_system,
settings,
get_rhc_status,
fetch_from_inventory,
subscription_manager,
subtests):
"""
rhc client can download inventory file from ingress service.
There are all important fields in the inventory file.
"""
assert not rhc.is_registered
candlepin_config = partial(test_config.get, "candlepin")
rhc.connect(
username=candlepin_config("username"),
password=candlepin_config("password"),
)
assert rhc.is_registered
sh.rhc('connect',
'--username', settings.get("candlepin.username"),
'--password', settings.get("candlepin.password"),
)
assert get_rhc_status().get('rhsm_connected')

machine_id = open("/etc/insights-client/machine-id", "rt").read().strip()
data = fetch_from_inventory(insights_id=machine_id)
Expand All @@ -49,7 +43,7 @@ def test_rhc_fetch_from_inventory(external_candlepin,
org name: 16769664
org ID: 16769664
"""
output = subscription_manager("identity")
output = sh.subscription_manager("identity")

def parse_output(output):
data = dict([re.split(r': +', line)
Expand All @@ -64,25 +58,27 @@ def parse_output(output):
"Organization ID in an inventory record should be the same as 'subscription-manager identity' provides"


def test_rhc_tags_in_inventory(external_candlepin, test_config, fetch_from_inventory, fetch_tags_from_inventory, rhc,
set_rhc_tags, subtests):
def test_rhc_tags_in_inventory(not_registered_system,
settings,
fetch_from_inventory,
fetch_tags_from_inventory,
set_rhc_tags,
get_rhc_status,
subtests):
"""
There is a file 'tags.toml' in /etc/rhc/.
The file consist of tags that specify a connected system somehow.
An inventory file fetched from ingress service should consist of each specified tag.
"""
assert not rhc.is_registered

test_tags = {"uptime": "99.999",
"production": "true", "region": "us-east-1"}
set_rhc_tags(test_tags)

candlepin_config = partial(test_config.get, "candlepin")
rhc.connect(
username=candlepin_config("username"),
password=candlepin_config("password"),
)
assert rhc.is_registered
sh.rhc('connect',
'--username', settings.get("candlepin.username"),
'--password', settings.get("candlepin.password"),
)
assert get_rhc_status().get("rhsm_connected")
assert 'This host is registered' in sh.insights_client("--status"), \
"A system should be registered to Insights service after 'rhc connect'"

Expand Down

0 comments on commit 2d132ef

Please sign in to comment.