Skip to content

Commit

Permalink
Merge pull request #262 from VirtwhoQE/jmolet/debuggin
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
Lorquas authored Dec 4, 2024
2 parents a6d93c0 + 83f6a48 commit 1e323f9
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 7 deletions.
3 changes: 1 addition & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ markers =
notSatellite: cases not for satellite
notRHSM: cases not for candlepin

notRHEL8: cases not for rhel8
notRHEL9: cases not for rhel9
release: configure which rhel release this test is for

notLocal: cases not for local libvirt mode
notRemote: cases not for remote mode
24 changes: 24 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ def pytest_runtest_logfinish(nodeid):
logger.info(f"Finished Test: {nodeid}")


def pytest_addoption(parser):
parser.addoption(
"--rhelver",
action="store",
metavar="NAME",
help="Only run tests for this RHEL version: rhel8, rhel9, rhel10",
)


def pytest_collection_modifyitems(config, items):
rhelver = config.getoption("--rhelver")
if not rhelver:
return
for item in items:
release = item.get_closest_marker("release")
if not release:
return
release_conf = release.kwargs
if rhelver not in release_conf:
return
if not release_conf[rhelver]:
item.add_marker("skip")


@pytest.fixture(scope="class")
def class_hypervisor():
"""Instantication of class VirtwhoHypervisorConfig()"""
Expand Down
1 change: 1 addition & 0 deletions tests/function/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import threading
import time
import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/function/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest

from virtwho import HYPERVISOR, RHEL_COMPOSE
Expand Down Expand Up @@ -567,7 +568,7 @@ def test_http_proxy_in_virtwho_conf(self, virtwho, globalconf, proxy_data):
@pytest.mark.usefixtures("function_globalconf_clean")
@pytest.mark.usefixtures("class_hypervisor")
@pytest.mark.usefixtures("class_virtwho_d_conf_clean")
@pytest.mark.notRHEL9
@pytest.mark.release(rhel8=True, rhel9=False, rhel10=False)
class TestSysConfiguration:
@pytest.mark.tier1
def test_debug_in_virtwho_sysconfig(self, virtwho, function_sysconfig):
Expand Down
1 change: 1 addition & 0 deletions tests/hypervisor/test_ahv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest

from virtwho import REGISTER
Expand Down
3 changes: 2 additions & 1 deletion tests/hypervisor/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest

from virtwho import REGISTER
Expand Down Expand Up @@ -258,7 +259,7 @@ def test_guest_facts(
assert virt_is_guest == "True"

@pytest.mark.tier1
@pytest.mark.notRHEL8
@pytest.mark.release(rhel8=False, rhel9=True, rhel10=True)
@pytest.mark.notLocal
def test_virtwho_status(
self,
Expand Down
1 change: 1 addition & 0 deletions tests/hypervisor/test_esx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import os
import random
import string
Expand Down
1 change: 1 addition & 0 deletions tests/hypervisor/test_hyperv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import time
import pytest

Expand Down
3 changes: 2 additions & 1 deletion tests/hypervisor/test_kubevirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest

from virtwho import REGISTER
Expand Down Expand Up @@ -375,7 +376,7 @@ def test_exclude_host(self, virtwho, function_hypervisor, hypervisor_data):
)

@pytest.mark.tier2
@pytest.mark.notRHEL8
@pytest.mark.release(rhel8=False, rhel9=True, rhel10=True)
def test_insecure(self, virtwho, function_hypervisor, hypervisor_data, ssh_host):
"""Test the insecure option in /etc/virt-who.d/hypervisor.conf
Expand Down
1 change: 1 addition & 0 deletions tests/hypervisor/test_libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest

from virtwho import REGISTER
Expand Down
1 change: 1 addition & 0 deletions tests/hypervisor/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest
import time

Expand Down
1 change: 1 addition & 0 deletions tests/hypervisor/test_multi_hypervisors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest

from virtwho import REGISTER, logger
Expand Down
1 change: 1 addition & 0 deletions tests/hypervisor/test_rhevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest

from virtwho import REGISTER
Expand Down
1 change: 1 addition & 0 deletions tests/hypervisor/test_xen.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest

from virtwho import REGISTER
Expand Down
1 change: 1 addition & 0 deletions tests/others/test_hypervisors_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

# All the test cases have been uploaded to Polarion with Inactive status
# because the cases are just used to test the test environments.

Expand Down
1 change: 1 addition & 0 deletions tests/others/test_hypervisors_sw.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

# The test case has been uploaded to Polarion with Inactive status because
# the case is just used to test the environments to support Subscription Watch team.

Expand Down
1 change: 1 addition & 0 deletions tests/package/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import os
import re
import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/package/test_install_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import re

import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/package/test_upgrade_downgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:caselevel: Component
"""

import pytest
from virtwho import VIRTWHO_PKG, RHEL_COMPOSE, RHEL_COMPOSE_PATH
from virtwho.base import virtwho_package_url
Expand Down Expand Up @@ -152,7 +153,7 @@ def test_upgrade_downgrade_by_rpm(self, ssh_host, virtwho, globalconf):
package_upgrade(ssh_host, "virt-who")

@pytest.mark.tier1
@pytest.mark.notRHEL8
@pytest.mark.release(rhel8=False, rhel9=True, rhel10=True)
def test_global_options_migration_after_upgrade(self, ssh_host, virtwho):
"""Test the global configurations in /etc/sysconfig/virt-who can be
migrated to /etc/virt-who.conf after upgrade
Expand Down
1 change: 1 addition & 0 deletions tests/subscription/test_rhsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest
from virtwho.base import msg_search

Expand Down
1 change: 1 addition & 0 deletions tests/subscription/test_rhsm_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest
from virtwho.base import msg_search
from virtwho import REGISTER, HYPERVISOR
Expand Down
1 change: 1 addition & 0 deletions tests/subscription/test_satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:subsystemteam: sst_subscription_virtwho
:caselevel: Component
"""

import pytest
from virtwho.base import msg_search
from virtwho import HYPERVISOR
Expand Down
3 changes: 2 additions & 1 deletion virtwho/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def log_clean(self):
Clean all log files under /var/log/rhsm/
Clean the json file created by print function of virt-who
"""
self.ssh.runcmd("rm -rf /var/log/rhsm/*")
self.ssh.runcmd("truncate -s 0 /var/log/rhsm/*.log")
self.ssh.runcmd("rm -f /var/log/rhsm/*.gz")

# comment this line as we need the print json file for fake mode testing
# self.ssh.runcmd(f"rm -rf {PRINT_JSON_FILE}")
Expand Down
1 change: 1 addition & 0 deletions virtwho/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Define and instantiate the configuration class for virtwho-test."""

import os
from configparser import ConfigParser

Expand Down

0 comments on commit 1e323f9

Please sign in to comment.