Skip to content

Commit 9a2aad2

Browse files
committed
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtualization-tests into ocs_to_aws
2 parents 5716ae3 + 9318ed7 commit 9a2aad2

File tree

17 files changed

+130
-68
lines changed

17 files changed

+130
-68
lines changed

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,10 +2725,10 @@ def rhsm_created_secret(rhsm_credentials_from_bitwarden, namespace):
27252725

27262726

27272727
@pytest.fixture(scope="session")
2728-
def machine_config_pools():
2728+
def machine_config_pools(admin_client):
27292729
return [
2730-
get_machine_config_pool_by_name(mcp_name="master"),
2731-
get_machine_config_pool_by_name(mcp_name="worker"),
2730+
get_machine_config_pool_by_name(mcp_name="master", admin_client=admin_client),
2731+
get_machine_config_pool_by_name(mcp_name="worker", admin_client=admin_client),
27322732
]
27332733

27342734

tests/install_upgrade_operators/product_install/conftest.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from ocp_resources.hyperconverged import HyperConverged
99
from ocp_resources.installplan import InstallPlan
1010
from ocp_resources.persistent_volume import PersistentVolume
11-
from ocp_resources.resource import get_client
1211
from pytest_testconfig import py_config
1312

1413
from tests.install_upgrade_operators.product_install.constants import (
@@ -140,6 +139,7 @@ def hyperconverged_catalog_source(admin_client, is_production_source, cnv_image_
140139
catalog_source = create_catalog_source(
141140
catalog_name=HCO_CATALOG_SOURCE,
142141
image=cnv_image_url,
142+
admin_client=admin_client,
143143
)
144144
wait_for_catalogsource_ready(
145145
admin_client=admin_client,
@@ -163,17 +163,19 @@ def created_cnv_namespace(admin_client):
163163

164164

165165
@pytest.fixture(scope="module")
166-
def created_cnv_operator_group(created_cnv_namespace):
166+
def created_cnv_operator_group(admin_client, created_cnv_namespace):
167167
cnv_namespace_name = created_cnv_namespace.name
168168
return create_operator_group(
169169
namespace_name=cnv_namespace_name,
170170
operator_group_name="openshift-cnv-group",
171+
admin_client=admin_client,
171172
target_namespaces=[cnv_namespace_name],
172173
)
173174

174175

175176
@pytest.fixture(scope="module")
176177
def installed_cnv_subscription(
178+
admin_client,
177179
is_production_source,
178180
hyperconverged_catalog_source,
179181
created_cnv_namespace,
@@ -184,6 +186,7 @@ def installed_cnv_subscription(
184186
package_name=py_config["hco_cr_name"],
185187
namespace_name=created_cnv_namespace.name,
186188
catalogsource_name=PRODUCTION_CATALOG_SOURCE if is_production_source else hyperconverged_catalog_source.name,
189+
admin_client=admin_client,
187190
channel_name=cnv_version_to_install_info["channel"],
188191
)
189192

@@ -230,10 +233,11 @@ def installed_openshift_virtualization(
230233

231234

232235
@pytest.fixture(scope="module")
233-
def created_hco_cr(created_cnv_namespace, installed_openshift_virtualization):
236+
def created_hco_cr(admin_client, created_cnv_namespace, installed_openshift_virtualization):
234237
return create_operator(
235238
operator_class=HyperConverged,
236239
operator_name=py_config["hco_cr_name"],
240+
admin_client=admin_client,
237241
namespace_name=created_cnv_namespace.name,
238242
)
239243

@@ -266,11 +270,11 @@ def cluster_backend_storage(admin_client):
266270

267271

268272
@pytest.fixture(scope="module")
269-
def hpp_volume_size(cluster_backend_storage):
273+
def hpp_volume_size(admin_client, cluster_backend_storage):
270274
hpp_volume_size = "70Gi"
271275
if cluster_backend_storage == LOCAL_BLOCK_HPP:
272276
persistent_volumes = PersistentVolume.get(
273-
dyn_client=get_client(),
277+
dyn_client=admin_client,
274278
label_selector=f"storage.openshift.com/local-volume-owner-name={cluster_backend_storage}",
275279
)
276280
for persistent_volume in persistent_volumes:
@@ -281,19 +285,22 @@ def hpp_volume_size(cluster_backend_storage):
281285

282286

283287
@pytest.fixture(scope="module")
284-
def installed_hpp(cluster_backend_storage, hpp_volume_size):
288+
def installed_hpp(admin_client, cluster_backend_storage, hpp_volume_size):
285289
LOGGER.info(f"Creating HPP CR using backend storage: {cluster_backend_storage} and storage size: {hpp_volume_size}")
286290
hpp_cr = HPPWithStoragePool(
287291
name=HostPathProvisioner.Name.HOSTPATH_PROVISIONER,
288292
backend_storage_class_name=cluster_backend_storage,
289293
volume_size=hpp_volume_size,
294+
client=admin_client,
290295
)
291296
hpp_cr.deploy(wait=True)
292297
create_hpp_storage_class(
293298
storage_class_name=HppCsiStorageClass.Name.HOSTPATH_CSI_BASIC,
299+
admin_client=admin_client,
294300
)
295301
create_hpp_storage_class(
296302
storage_class_name=HppCsiStorageClass.Name.HOSTPATH_CSI_PVC_BLOCK,
303+
admin_client=admin_client,
297304
)
298305

299306

tests/install_upgrade_operators/product_install/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def wait_for_pod_running_by_prefix(
115115

116116

117117
def validate_hpp_installation(admin_client, cnv_namespace, schedulable_nodes):
118-
hpp_deployment = Deployment(name=HOSTPATH_PROVISIONER_OPERATOR, namespace=cnv_namespace.name)
118+
hpp_deployment = Deployment(name=HOSTPATH_PROVISIONER_OPERATOR, namespace=cnv_namespace.name, client=admin_client)
119119
assert hpp_deployment.exists
120120
hpp_deployment.wait_for_replicas(timeout=TIMEOUT_15MIN)
121121
wait_for_pod_running_by_prefix(

tests/install_upgrade_operators/product_uninstall/test_remove_hco.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ def assert_expected_strategy(resource_objects, expected_strategy):
4141
)
4242

4343

44-
def delete_cdi_configmap_and_secret(hco_namespace_name):
44+
def delete_cdi_configmap_and_secret(hco_namespace_name, admin_client):
4545
cdi_configmaps = [
4646
"cdi-apiserver-signer-bundle",
4747
"cdi-uploadproxy-signer-bundle",
4848
"cdi-uploadserver-client-signer-bundle",
4949
"cdi-uploadserver-signer-bundle",
5050
]
5151
secret_objects = [
52-
Secret(name=_secret, namespace=hco_namespace_name)
52+
Secret(name=_secret, namespace=hco_namespace_name, client=admin_client)
5353
for _secret in CDI_SECRETS
54-
if Secret(name=_secret, namespace=hco_namespace_name).exists
54+
if Secret(name=_secret, namespace=hco_namespace_name, client=admin_client).exists
5555
]
5656
configmap_objects = [
57-
ConfigMap(name=_cm, namespace=hco_namespace_name)
57+
ConfigMap(name=_cm, namespace=hco_namespace_name, client=admin_client)
5858
for _cm in cdi_configmaps
59-
if ConfigMap(name=_cm, namespace=hco_namespace_name).exists
59+
if ConfigMap(name=_cm, namespace=hco_namespace_name, client=admin_client).exists
6060
]
6161

6262
for resource in secret_objects + configmap_objects:
@@ -167,7 +167,7 @@ def stopped_fedora_vm(hco_fedora_vm):
167167
@pytest.fixture(scope="function")
168168
def removed_hco(admin_client, hco_namespace, hyperconverged_resource_scope_function):
169169
hyperconverged_resource_scope_function.delete(wait=True, timeout=TIMEOUT_10MIN)
170-
delete_cdi_configmap_and_secret(hco_namespace_name=hco_namespace.name)
170+
delete_cdi_configmap_and_secret(hco_namespace_name=hco_namespace.name, admin_client=admin_client)
171171
yield
172172

173173
# Recreate HCO, if it doesn't exist

tests/install_upgrade_operators/product_upgrade/conftest.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def ocp_image_url(pytestconfig):
260260

261261
@pytest.fixture(scope="session")
262262
def cluster_version(admin_client):
263-
cluster_version = ClusterVersion(name="version")
263+
cluster_version = ClusterVersion(name="version", client=admin_client)
264264
if cluster_version.exists:
265265
return cluster_version
266266

@@ -455,13 +455,13 @@ def machine_config_pools_conditions(active_machine_config_pools):
455455

456456

457457
@pytest.fixture(scope="session")
458-
def master_machine_config_pools():
459-
return [get_machine_config_pool_by_name(mcp_name="master")]
458+
def master_machine_config_pools(admin_client):
459+
return [get_machine_config_pool_by_name(mcp_name="master", admin_client=admin_client)]
460460

461461

462462
@pytest.fixture(scope="session")
463-
def worker_machine_config_pools():
464-
return [get_machine_config_pool_by_name(mcp_name="worker")]
463+
def worker_machine_config_pools(admin_client):
464+
return [get_machine_config_pool_by_name(mcp_name="worker", admin_client=admin_client)]
465465

466466

467467
@pytest.fixture(scope="module")
@@ -607,7 +607,8 @@ def updated_odf_subscription_source(odf_subscription, odf_version):
607607

608608
@pytest.fixture()
609609
def upgraded_odf(
610+
admin_client,
610611
odf_version,
611612
updated_odf_subscription_source,
612613
):
613-
wait_for_odf_update(target_version=odf_version)
614+
wait_for_odf_update(target_version=odf_version, admin_client=admin_client)

tests/install_upgrade_operators/product_upgrade/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,10 @@ def wait_for_hco_csv_creation(admin_client: DynamicClient, hco_namespace: str, h
681681
raise
682682

683683

684-
def wait_for_odf_update(target_version: str) -> None:
685-
def _get_updated_odf_csv(_target_version: str) -> list[str]:
684+
def wait_for_odf_update(target_version: str, admin_client: DynamicClient) -> None:
685+
def _get_updated_odf_csv(_target_version: str, _admin_client: DynamicClient) -> list[str]:
686686
csv_list = []
687-
for csv in ClusterServiceVersion.get(namespace=NamespacesNames.OPENSHIFT_STORAGE):
687+
for csv in ClusterServiceVersion.get(dyn_client=_admin_client, namespace=NamespacesNames.OPENSHIFT_STORAGE):
688688
if any(
689689
csv_name in csv.name
690690
for csv_name in [
@@ -706,6 +706,7 @@ def _get_updated_odf_csv(_target_version: str) -> list[str]:
706706
sleep=TIMEOUT_30SEC,
707707
func=_get_updated_odf_csv,
708708
_target_version=target_version,
709+
_admin_client=admin_client,
709710
)
710711

711712
for sample in upgrade_sampler:

tests/observability/metrics/test_general_metrics.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@ def test_vm_name_in_virt_launcher_label(self, fedora_vm_without_name_in_label):
8989
class TestVirtHCOSingleStackIpv6:
9090
@pytest.mark.ipv6
9191
@pytest.mark.polarion("CNV-11740")
92+
@pytest.mark.s390x
9293
def test_metric_kubevirt_hco_single_stack_ipv6(self, prometheus, ipv6_single_stack_cluster):
93-
if not ipv6_single_stack_cluster:
94-
pytest.fail("The cluster is not ipv6 single stack")
9594
validate_metrics_value(
9695
prometheus=prometheus,
9796
metric_name="kubevirt_hco_single_stack_ipv6",
98-
expected_value="1",
97+
expected_value="1" if ipv6_single_stack_cluster else "0",
9998
)

tests/storage/hpp/test_hpp_csi_cr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ def deleted_hpp_storage_classes(request, cluster_storage_classes):
112112

113113

114114
@pytest.fixture()
115-
def hpp_csi_storage_classes(request, cluster_storage_classes):
115+
def hpp_csi_storage_classes(request, admin_client, cluster_storage_classes):
116116
created_storage_classes_dict = {}
117117
for storage_class in request.param:
118118
sc = HppCsiStorageClass(
119119
name=storage_class,
120+
client=admin_client,
120121
storage_pool=STORAGE_CLASS_TO_STORAGE_POOL_MAPPING[storage_class],
121122
)
122123
sc.deploy()

tests/storage/upgrade/conftest.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,26 +120,28 @@ def snapshots_for_upgrade_b(
120120

121121

122122
@pytest.fixture(scope="session")
123-
def blank_disk_dv_with_default_sc(upgrade_namespace_scope_session):
123+
def blank_disk_dv_with_default_sc(admin_client, upgrade_namespace_scope_session):
124124
with create_dv(
125125
source="blank",
126126
dv_name="blank-dv",
127127
namespace=upgrade_namespace_scope_session.name,
128128
size="1Gi",
129129
storage_class=py_config["default_storage_class"],
130130
consume_wffc=False,
131+
client=admin_client,
131132
) as dv:
132133
yield dv
133134

134135

135136
@pytest.fixture(scope="session")
136-
def fedora_vm_for_hotplug_upg(upgrade_namespace_scope_session, cluster_common_node_cpu):
137+
def fedora_vm_for_hotplug_upg(unprivileged_client, upgrade_namespace_scope_session, cluster_common_node_cpu):
137138
name = "fedora-hotplug-upg"
138139
with VirtualMachineForTests(
139140
name=name,
140141
namespace=upgrade_namespace_scope_session.name,
141142
body=fedora_vm_body(name=name),
142143
cpu_model=cluster_common_node_cpu,
144+
client=unprivileged_client,
143145
) as vm:
144146
running_vm(vm=vm)
145147
yield vm
@@ -166,9 +168,9 @@ def fedora_vm_for_hotplug_upg_ssh_connectivity(fedora_vm_for_hotplug_upg):
166168

167169

168170
@pytest.fixture(scope="session")
169-
def skip_if_config_default_storage_class_access_mode_rwo():
171+
def skip_if_config_default_storage_class_access_mode_rwo(admin_client):
170172
storage_class = py_config["default_storage_class"]
171-
access_modes = StorageProfile(name=storage_class).first_claim_property_set_access_modes()
173+
access_modes = StorageProfile(name=storage_class, client=admin_client).first_claim_property_set_access_modes()
172174
assert access_modes, f"Could not get the access mode from the {storage_class} storage profile"
173175
access_mode = access_modes[0]
174176
LOGGER.info(f"Storage class '{storage_class}' has access mode: '{access_mode}'")

tests/storage/upgrade/test_upgrade_storage.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def test_cdiconfig_scratch_overriden_before_upgrade(
6060
@pytest.mark.dependency(name=f"{STORAGE_NODE_ID_PREFIX}::test_vm_snapshot_restore_before_upgrade")
6161
def test_vm_snapshot_restore_before_upgrade(
6262
self,
63+
admin_client,
6364
skip_if_no_storage_class_for_snapshot,
6465
cirros_vm_for_upgrade_a,
6566
snapshots_for_upgrade_a,
@@ -69,6 +70,7 @@ def test_vm_snapshot_restore_before_upgrade(
6970
namespace=snapshots_for_upgrade_a.namespace,
7071
vm_name=cirros_vm_for_upgrade_a.name,
7172
snapshot_name=snapshots_for_upgrade_a.name,
73+
client=admin_client,
7274
) as vm_restore:
7375
vm_restore.wait_restore_done()
7476
cirros_vm_for_upgrade_a.start(wait=True)
@@ -164,12 +166,15 @@ def test_vm_snapshot_restore_check_after_upgrade(
164166
],
165167
scope=DEPENDENCY_SCOPE_SESSION,
166168
)
167-
def test_vm_snapshot_restore_create_after_upgrade(self, cirros_vm_for_upgrade_b, snapshots_for_upgrade_b):
169+
def test_vm_snapshot_restore_create_after_upgrade(
170+
self, admin_client, cirros_vm_for_upgrade_b, snapshots_for_upgrade_b
171+
):
168172
with VirtualMachineRestore(
169173
name=f"restore-snapshot-{cirros_vm_for_upgrade_b.name}",
170174
namespace=snapshots_for_upgrade_b.namespace,
171175
vm_name=cirros_vm_for_upgrade_b.name,
172176
snapshot_name=snapshots_for_upgrade_b.name,
177+
client=admin_client,
173178
) as vm_restore:
174179
vm_restore.wait_restore_done()
175180
cirros_vm_for_upgrade_b.start(wait=True)

0 commit comments

Comments
 (0)