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

update test_http_proxy_in_virtwho_conf #214

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def owner_data():
owner["error"] = [
f"Organization with id {bad_owner} could not be found",
f"Couldn't find Organization '{bad_owner}'",
f"[Owner] with ID(s) {bad_owner} could not be found",
]
# the errors for null are different when virt-who host registered and unreigstered.
owner["null_error"] = [
Expand Down
16 changes: 8 additions & 8 deletions tests/function/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@pytest.mark.usefixtures("function_globalconf_clean")
@pytest.mark.usefixtures("class_hypervisor")
@pytest.mark.usefixtures("class_virtwho_d_conf_clean")
class TestConfiguration:
class TestConfigurationPositive:
@pytest.mark.tier1
def test_debug_in_virtwho_conf(self, virtwho, globalconf):
"""Test the debug option in /etc/virtwho.conf
Expand Down Expand Up @@ -520,22 +520,22 @@ def test_http_proxy_in_virtwho_conf(self, virtwho, globalconf, proxy_data):
globalconf.update("system_environment", proxy, proxy_data[proxy])
result = virtwho.run_service()
if HYPERVISOR == "ahv":
logger.info("=== AHV: failed with bz1992619 ===")
logger.info("=== AHV: failed with RHEL-1309 ===")
assert (
result["error"] == 0
and result["send"] == 1
and result["thread"] == 1
# Skip the below assertion due to open bz1989354
# Skip the below assertion due to open rhel13376
# and connection_msg in result["log"]
# and proxy_msg in result["log"]
)
bz1989354_test = result["log"]
rhel13376_test = result["log"]

# run virt-who with unreachable http_proxy/https_proxy setting
globalconf.update("system_environment", proxy, proxy_data[f"bad_{proxy}"])
result = virtwho.run_service()
if HYPERVISOR in ("kubvirt", "hyperv", "libvirt"):
logger.info("=== Kubevirt/Hyperv/Libvirt: failed with bz2175098 ===")
if HYPERVISOR in ("kubevirt", "hyperv", "libvirt"):
logger.info("=== Kubevirt/Hyperv/Libvirt: failed with RHEL-12391 ===")
assert result["error"] in (1, 2)
assert any(
error_msg in result["error_msg"] for error_msg in proxy_data["error"]
Expand All @@ -550,8 +550,8 @@ def test_http_proxy_in_virtwho_conf(self, virtwho, globalconf, proxy_data):

globalconf.delete("system_environment")

logger.info("=== All Hypervisors: failed with bz1989354 ===")
assert connection_msg in bz1989354_test and proxy_msg in bz1989354_test
logger.info("=== All Hypervisors: failed with RHEL-13376 ===")
assert connection_msg in rhel13376_test and proxy_msg in rhel13376_test


@pytest.mark.usefixtures("function_host_register_for_local_mode")
Expand Down
48 changes: 28 additions & 20 deletions tests/hypervisor/test_hyperv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from hypervisor.virt.hyperv.hypervcli import HypervCLI


@pytest.mark.usefixtures("function_virtwho_d_conf_clean")
@pytest.mark.usefixtures("class_debug_true")
@pytest.mark.usefixtures("class_globalconf_clean")
Expand Down Expand Up @@ -636,11 +637,13 @@ def test_exclude_host(self, virtwho, function_hypervisor, hypervisor_data):
and result["thread"] == 1
and hostname not in str(result["mappings"])
)

@pytest.mark.tier3
def test_biosguid_null(self, virtwho, function_hypervisor, hypervisor_data, register_data):
def test_biosguid_null(
self, virtwho, function_hypervisor, hypervisor_data, register_data
):
"""Test if the biosguid is null, whether virt-who can send the guest info to server.

:title: virt-who: hyperv: test biosguid null
:id: 4de4fed0-97c2-4146-9540-2223386297c4
:caseimportance: High
Expand All @@ -661,26 +664,24 @@ def test_biosguid_null(self, virtwho, function_hypervisor, hypervisor_data, regi
4. Succeeded to change the biosguid to null.
5. Succeeded to run the virt-who, cannot find the guest info in the server.
"""

hyperv = HypervCLI(
server = hypervisor_data["hypervisor_server"],
ssh_user = hypervisor_data["hypervisor_username"],
ssh_pwd = hypervisor_data["hypervisor_password"],
server=hypervisor_data["hypervisor_server"],
ssh_user=hypervisor_data["hypervisor_username"],
ssh_pwd=hypervisor_data["hypervisor_password"],
)

result = virtwho.run_service()
assert (
result["error"] == 0
and result["send"] == 1
and result["thread"] == 1
)
assert result["error"] == 0 and result["send"] == 1 and result["thread"] == 1
try:
origin_guid = hyperv.guest_uuid()
assert origin_guid != ""

result = hyperv.guest_uuid_change("00000000-0000-0000-0000-000000000000", hypervisor_data['guest_name'])
result = hyperv.guest_uuid_change(
"00000000-0000-0000-0000-000000000000", hypervisor_data["guest_name"]
)
assert result is True

timeout = 300
interval = 5
start_time = time.time()
Expand All @@ -689,20 +690,27 @@ def test_biosguid_null(self, virtwho, function_hypervisor, hypervisor_data, regi
if elapsed_time > timeout:
assert False, f"Timeout reached after {timeout} seconds!"
time.sleep(interval)

result = virtwho.run_service()
assert (
result["error"] == 0
and result["send"] == 1
and result["thread"] == 1
and len(result["mappings"][register_data["default_org"]][hypervisor_data["hypervisor_hostname"]]["guests"])==0
and len(
result["mappings"][register_data["default_org"]][
hypervisor_data["hypervisor_hostname"]
]["guests"]
)
== 0
)

new_guid = hyperv.guest_uuid()
assert new_guid == ""
finally:
result = hyperv.guest_uuid_change(origin_guid, hypervisor_data['guest_name'])
result = hyperv.guest_uuid_change(
origin_guid, hypervisor_data["guest_name"]
)
assert result is True

final_guid = hyperv.guest_uuid()
assert final_guid == origin_guid
1 change: 1 addition & 0 deletions virtwho/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ def hypervisors_list():
"""
return config.job.multi_hypervisors.strip("[").strip("]").split(",")


def is_host_responsive(host):
"""
Check if the host is responsive
Expand Down