Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Rodolfo Olivieri <[email protected]>
  • Loading branch information
r0x0d committed Dec 2, 2022
1 parent 59a43c7 commit af5ffa5
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 1 deletion.
4 changes: 4 additions & 0 deletions plans/tier0.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@
/log_command_verification:
discover+:
test: log-command

/single_yum_transaction_validation:
discover+:
test: single-yum-transaction-validation
3 changes: 3 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dataclasses
import logging
import os
import re
import subprocess
import sys
Expand Down Expand Up @@ -30,6 +31,8 @@
SATELLITE_PKG_URL = "https://satellite.sat.engineering.redhat.com/pub/katello-ca-consumer-latest.noarch.rpm"
SATELLITE_PKG_DST = "/usr/share/convert2rhel/subscription-manager/katello-ca-consumer-latest.noarch.rpm"

SYSTEM_RELEASE = os.environ["SYSTEM_RELEASE"]


@pytest.fixture()
def shell(tmp_path):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
summary: single-yum-transaction-validation

tier: 0
test: pytest -svv
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import os
import shutil

from conftest import SYSTEM_RELEASE
from envparse import env


PKI_ENTITLEMENT_KEYS_PATH = "/etc/pki/entitlement"


def backup_entitlement_keys():
original_keys = os.listdir(PKI_ENTITLEMENT_KEYS_PATH)

for key in original_keys:
full_key = "{}/{}".format(PKI_ENTITLEMENT_KEYS_PATH, key)
new_key = "{}.bk".format(full_key)
shutil.move(full_key, new_key)


def rollback_entitlement_keys():
backup_keys = os.listdir(PKI_ENTITLEMENT_KEYS_PATH)

for key in backup_keys:
# This is already in the format with a .bk at the end of it
backup_key = "{}/{}".format(PKI_ENTITLEMENT_KEYS_PATH, key)
original_key = "{}".format(backup_key)
shutil.move(backup_key, original_key)


def test_remove_entitlement_keys(convert2rhel, shell):
"""Run the conversion using the single yum transaction.
This will run the conversion up until the point of the single yum
transaction package replacements.
"""

server_sub = "CentOS Linux"
pkgmanager = "yum"
if "oracle" in SYSTEM_RELEASE:
server_sub = "Oracle Linux Server"

if "8" in SYSTEM_RELEASE:
pkgmanager = "dnf"

with convert2rhel(
"-y --no-rpm-va --serverurl {} --username {} --password {} --pool {} --debug".format(
env.str("RHSM_SERVER_URL"),
env.str("RHSM_USERNAME"),
env.str("RHSM_PASSWORD"),
env.str("RHSM_POOL"),
)
) as c2r:
c2r.expect(
"Validating the {} transaction set, no modifications to the system will happen this time.".format(
pkgmanager
)
)
backup_entitlement_keys()
assert c2r.expect_exact("Failed to download the transaction packages.", timeout=600) == 0

assert c2r.exitstatus == 1

rollback_entitlement_keys()
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_single_yum_transaction(convert2rhel, shell):
pkgmanager = "dnf"

with convert2rhel(
("-y --no-rpm-va --serverurl {} --username {} --password {} --pool {} --debug").format(
"-y --no-rpm-va --serverurl {} --username {} --password {} --pool {} --debug".format(
env.str("RHSM_SERVER_URL"),
env.str("RHSM_USERNAME"),
env.str("RHSM_PASSWORD"),
Expand Down

0 comments on commit af5ffa5

Please sign in to comment.