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 Cli/API/UI tests for bootc #17634

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pytest_fixtures/core/contenthosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,23 @@ def oracle_host(request, version):
yield host


@pytest.fixture
def bootc_host(request):
"""Fixture to check out boot-c hosts"""
with Broker(
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't we need ipv6 host?

**host_conf(request),
workflow='deploy-bootc',
host_class=ContentHost,
) as host:
assert (
host[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
host[0]
host

PRT fails with

20:09:15  >               host[0]
20:09:15                  .execute(f"echo '{constants.DUMMY_BOOTC_FACTS}' > /etc/rhsm/facts/bootc.facts")
20:09:15                  .status
20:09:15                  == 0
20:09:15              )
20:09:15  E           TypeError: 'ContentHost' object is not subscriptable

Did you plan to get multiple hosts (like with _count parameter) from this broker run?
The docstring says so but the fixture name and code don't.

.execute(f"echo '{constants.DUMMY_BOOTC_FACTS}' > /etc/rhsm/facts/bootc.facts")
.status
== 0
)
yield host


@pytest.fixture(scope='module', params=[{'rhel_version': 8, 'no_containers': True}])
def external_puppet_server(request):
deploy_args = host_conf(request)
Expand Down
15 changes: 15 additions & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,21 @@
EXPIRED_MANIFEST = 'expired-manifest.zip'
EXPIRED_MANIFEST_DATE = 'Fri Dec 03 2021'

DUMMY_BOOTC_FACTS = """{
"bootc.booted.image": "quay.io/centos-bootc/centos-bootc:stream10",
"bootc.booted.version": "stream10.20241202.0",
"bootc.booted.digest": "sha256:54256a998f0c62e16f3927c82b570f90bd8449a52e03daabd5fd16d6419fd572",
"bootc.staged.image": null,
"bootc.staged.version": null,
"bootc.staged.digest": null,
"bootc.rollback.image": "quay.io/centos-bootc/centos-bootc:stream10",
"bootc.rollback.version": "stream10.20241107.0",
"bootc.rollback.digest": "sha256:9ed49e9b189f5dae5a01ea9abdcef0884616300b565d32061aea619f2e916be3",
"bootc.available.image": null,
"bootc.available.version": null,
"bootc.available.digest": null
}"""


# Data File Paths
class DataFile(Box):
Expand Down
48 changes: 47 additions & 1 deletion tests/foreman/api/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
"""

import http
import json

from fauxfactory import gen_choice, gen_integer, gen_ipaddr, gen_mac, gen_string
from nailgun import client
import pytest
from requests.exceptions import HTTPError

from robottelo.config import get_credentials
from robottelo.constants import DEFAULT_CV, ENVIRONMENT
from robottelo.constants import DEFAULT_CV, DUMMY_BOOTC_FACTS, ENVIRONMENT
from robottelo.utils import datafactory


Expand Down Expand Up @@ -1068,6 +1069,51 @@ def test_positive_read_enc_information(
assert host_enc_parameters[param['name']] == param['value']


@pytest.mark.e2e
def test_positive_bootc_api_actions(target_sat, bootc_host, function_ak_with_cv, function_org):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the jira-id of the feature.

"""Register a bootc host and validate API information
:id: b94ab231-0dd8-4e47-a96b-972c5ee55f4d
:expectedresults: Upon registering a Bootc host, the API returns correct information across multiple endpoints
:CaseComponent:Hosts-Content
:CaseImportance: Critical
"""
bootc_dummy_info = json.loads(DUMMY_BOOTC_FACTS)
assert (
bootc_host[0].register(function_org, None, function_ak_with_cv.name, target_sat).status == 0
)
assert bootc_host[0].subscribed
# Testing bootc info from content_facet_attributes
bootc_host = target_sat.api.Host().search(query={'search': f'name={bootc_host[0].hostname}'})[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar question here (bootc_host[0]) and lower in the other tests.

assert (
bootc_host.content_facet_attributes['bootc_booted_image']
== bootc_dummy_info['bootc.booted.image']
)
assert (
bootc_host.content_facet_attributes['bootc_booted_digest']
== bootc_dummy_info['bootc.booted.digest']
)
assert (
bootc_host.content_facet_attributes['bootc_rollback_image']
== bootc_dummy_info['bootc.rollback.image']
)
assert (
bootc_host.content_facet_attributes['bootc_rollback_digest']
== bootc_dummy_info['bootc.rollback.digest']
)
# Testing bootc info from hosts/bootc_images
bootc_image_info = target_sat.api.Host().get_bootc_images()
assert bootc_image_info[0]['bootc_booted_image'] == bootc_dummy_info['bootc.booted.image']
assert (
bootc_image_info[0]['bootc_booted_image']['digests'][0]['bootc_booted_digest']
== bootc_dummy_info['bootc.booted.digest']
)
assert bootc_image_info[0]['bootc_booted_image']['digests'][0]['host_count'] > 0


@pytest.mark.tier2
@pytest.mark.stubbed
def test_positive_add_future_subscription():
Expand Down
28 changes: 28 additions & 0 deletions tests/foreman/cli/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

"""

import json
from random import choice
import re

Expand All @@ -23,6 +24,7 @@
from robottelo.config import settings
from robottelo.constants import (
DEFAULT_SUBSCRIPTION_NAME,
DUMMY_BOOTC_FACTS,
FAKE_1_CUSTOM_PACKAGE,
FAKE_1_CUSTOM_PACKAGE_NAME,
FAKE_2_CUSTOM_PACKAGE,
Expand Down Expand Up @@ -2041,6 +2043,32 @@ def test_syspurpose_end_to_end(
)


@pytest.mark.e2e
def test_positive_register_read_bootc(target_sat, bootc_host, function_ak_with_cv, function_org):
"""Register a bootc host and validate the information

:id: d9557843-4cc7-4e70-a035-7b2c4008dd5e

:expectedresults: Upon registering a Bootc host, the facts are attached to the host, and are accurate.

:CaseComponent:Hosts-Content

:CaseImportance: Critical
"""
bootc_dummy_info = json.loads(DUMMY_BOOTC_FACTS)
assert (
bootc_host[0].register(function_org, None, function_ak_with_cv.name, target_sat).status == 0
)
assert bootc_host[0].subscribed
bootc_info = target_sat.cli.Host.info({'name': bootc_host[0].hostname})[
'bootc-image-information'
]
assert bootc_info['running-image'] == bootc_dummy_info['bootc.booted.image']
assert bootc_info['running-image-digest'] == bootc_dummy_info['bootc.booted.digest']
assert bootc_info['rollback-image'] == bootc_dummy_info['bootc.rollback.image']
assert bootc_info['rollback-image-digest'] == bootc_dummy_info['bootc.rollback.digest']


# -------------------------- MULTI-CV SCENARIOS -------------------------
@pytest.mark.no_containers
@pytest.mark.rhel_ver_match('[^7]')
Expand Down
35 changes: 35 additions & 0 deletions tests/foreman/ui/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import copy
import csv
import json
import os
import re
import time
Expand All @@ -29,6 +30,7 @@
ANY_CONTEXT,
DEFAULT_CV,
DEFAULT_LOC,
DUMMY_BOOTC_FACTS,
ENVIRONMENT,
FAKE_1_CUSTOM_PACKAGE,
FAKE_7_CUSTOM_PACKAGE,
Expand Down Expand Up @@ -2108,6 +2110,39 @@ def test_all_hosts_bulk_build_management(target_sat, function_org, function_loca
)


@pytest.mark.tier2
def test_bootc_booted_container_images(target_sat, bootc_host, function_ak_with_cv, function_org):
"""Create a bootc host, and read it's information via the Booted Container Images UI

:id: c15f02a2-05e0-447a-bbcc-aace08d40d1a

:expectedresults: Booted Container Images contains the correct information for a given booted image

:CaseComponent:Hosts-Content

:Team: Phoenix-subscriptions
"""
bootc_dummy_info = json.loads(DUMMY_BOOTC_FACTS)
assert (
bootc_host[0].register(function_org, None, function_ak_with_cv.name, target_sat).status == 0
)
assert bootc_host[0].subscribed

with target_sat.ui_session() as session:
session.organization.select(function_org.name)
booted_container_image_info = session.bootc.read(bootc_dummy_info['bootc.booted.image'])
assert (
booted_container_image_info[0]['Image name'] == bootc_dummy_info['bootc.booted.image']
)
assert booted_container_image_info[0]['Image digests'] == '1'
assert booted_container_image_info[0]['Hosts'] == '1'
assert (
booted_container_image_info[1]['Image digest']
== bootc_dummy_info['bootc.booted.digest']
)
assert booted_container_image_info[1]['Hosts'] == '1'


@pytest.fixture(scope='module')
def change_content_source_prep(
module_target_sat,
Expand Down