Skip to content

Commit bfc160e

Browse files
authored
Replace dyn_client with client to align with ocp wrapper change (#3286)
##### Short description: As part of the change in RedHatQE/openshift-python-wrapper#2623, `dyn_client` arg is going to be replaced with `client` to be consistant with the arg name in all places. ##### More details: ##### What this PR does / why we need it: ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### jira-ticket: <!-- full-ticket-url needs to be provided. This would add a link to the pull request to the jira and close it when the pull request is merged If the task is not tracked by a Jira ticket, just write "NONE". --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit # Release Notes * **Refactor** * Standardized internal parameter naming across resource retrieval methods for improved code consistency and maintainability. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 1fa8269 commit bfc160e

86 files changed

Lines changed: 259 additions & 273 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/after_cluster_deploy_sanity/test_after_cluster_deploy_sanity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
def wait_for_terminating_pvc(admin_client):
2929
def _get_terminating_pvcs():
3030
terminating_pvcs = []
31-
for pvc in PersistentVolumeClaim.get(dyn_client=admin_client):
31+
for pvc in PersistentVolumeClaim.get(client=admin_client):
3232
if pvc.instance.status.phase == pvc.Status.TERMINATING:
3333
terminating_pvcs.append(pvc.name)
3434
return terminating_pvcs
@@ -105,7 +105,7 @@ def test_boot_volume_health(
105105
def test_pvc_health(admin_client):
106106
not_bound = []
107107
is_terminating_pvcs = False
108-
for pvc in PersistentVolumeClaim.get(dyn_client=admin_client):
108+
for pvc in PersistentVolumeClaim.get(client=admin_client):
109109
pvc_instance = pvc.instance
110110
pvc_status = pvc_instance.status.phase
111111
LOGGER.info(f"PVC {pvc.name} is in {pvc_status} state")
@@ -128,7 +128,7 @@ def test_pvc_health(admin_client):
128128
def test_namespace_health(admin_client):
129129
if errored_namespaces := [
130130
f"{ns.name} found in status {ns.status}"
131-
for ns in Namespace.get(dyn_client=admin_client)
131+
for ns in Namespace.get(client=admin_client)
132132
if ns.exists and ns.status != Namespace.Status.ACTIVE
133133
]:
134134
pytest.fail(f"{errored_namespaces} found in not active state")
@@ -143,7 +143,7 @@ def test_cluster_operator_health(admin_client):
143143
@pytest.mark.cluster_health_check
144144
def test_machine_config_pool_health(admin_client):
145145
failed_mcps = []
146-
for mcp in MachineConfigPool.get(dyn_client=admin_client):
146+
for mcp in MachineConfigPool.get(client=admin_client):
147147
mcp_instance = mcp.instance
148148
ready_count = mcp_instance.status.readyMachineCount
149149
machine_count = mcp_instance.status.machineCount

tests/chaos/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def kmp_manager_nodes(admin_client):
150150
yield [
151151
pod.node
152152
for pod in get_pod_by_name_prefix(
153-
dyn_client=admin_client,
153+
client=admin_client,
154154
pod_prefix=KUBEMACPOOL_MAC_CONTROLLER_MANAGER,
155155
namespace=py_config["hco_namespace"],
156156
get_all=True,
@@ -189,7 +189,7 @@ def pod_deleting_process(request, admin_client):
189189
pod_prefix = request.param["pod_prefix"]
190190
namespace_name = request.param["namespace_name"]
191191
process = create_pod_deleting_process(
192-
dyn_client=admin_client,
192+
client=admin_client,
193193
pod_prefix=pod_prefix,
194194
namespace_name=namespace_name,
195195
ratio=request.param["ratio"],
@@ -390,7 +390,7 @@ def deleted_pod_by_name_prefix(admin_client, cnv_pod_deletion_test_matrix__class
390390
pod_deletion_config = cnv_pod_deletion_test_matrix__class__[pod_matrix_key]
391391

392392
deleted_pod_by_name_prefix = create_pod_deleting_process(
393-
dyn_client=admin_client,
393+
client=admin_client,
394394
pod_prefix=pod_deletion_config["pod_prefix"],
395395
namespace_name=pod_deletion_config["namespace_name"],
396396
ratio=pod_deletion_config["ratio"],

tests/chaos/utils.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353

5454
def create_pod_deleting_process(
55-
dyn_client,
55+
client,
5656
pod_prefix,
5757
namespace_name,
5858
ratio,
@@ -64,7 +64,7 @@ def create_pod_deleting_process(
6464
continuously deletes pods for a certain amount of time or until the process is stopped.
6565
6666
Args:
67-
dyn_client (DynamicClient)
67+
client (DynamicClient)
6868
pod_prefix (str): Pod name prefix used to find the pods to be deleted.
6969
namespace_name (str): Name of the namespace were the pods to be deleted live.
7070
ratio (float): Percentage of pods to be deleted (expressed as a fraction between 0 and 1).
@@ -76,17 +76,17 @@ def create_pod_deleting_process(
7676
7777
Example:
7878
pod_deleting_process = create_pod_deleting_process(
79-
dyn_client=admin_client, pod_prefix="apiserver",
79+
client=admin_client, pod_prefix="apiserver",
8080
namespace_name="openshift-apiserver", ratio=0.5, interval=5, max_duration=180
8181
)
8282
pod_deleting_process.start()
8383
...
8484
pod_deleting_process.terminate()
8585
"""
8686

87-
def _choose_surviving_pods(dyn_client, pod_prefix, namespace_name, ratio):
87+
def _choose_surviving_pods(_client, pod_prefix, namespace_name, ratio):
8888
initial_pods = get_pod_by_name_prefix(
89-
dyn_client=dyn_client,
89+
client=_client,
9090
pod_prefix=pod_prefix,
9191
namespace=namespace_name,
9292
get_all=True,
@@ -100,9 +100,9 @@ def _choose_surviving_pods(dyn_client, pod_prefix, namespace_name, ratio):
100100

101101
return surviving_pods
102102

103-
def _delete_pods(dyn_client, pod_prefix, namespace_name, surviving_pods):
103+
def _delete_pods(_client, pod_prefix, namespace_name, surviving_pods):
104104
deleted_pods = get_pod_by_name_prefix(
105-
dyn_client=dyn_client,
105+
client=_client,
106106
pod_prefix=pod_prefix,
107107
namespace=namespace_name,
108108
get_all=True,
@@ -113,9 +113,9 @@ def _delete_pods(dyn_client, pod_prefix, namespace_name, surviving_pods):
113113
with resource_log_level_error(resource=pod) as _pod:
114114
_pod.delete()
115115

116-
def _delete_pods_continuously(dyn_client, pod_prefix, namespace_name, ratio, interval, max_duration):
116+
def _delete_pods_continuously(_client, pod_prefix, namespace_name, ratio, interval, max_duration):
117117
surviving_pods = _choose_surviving_pods(
118-
dyn_client=dyn_client,
118+
_client=_client,
119119
pod_prefix=pod_prefix,
120120
namespace_name=namespace_name,
121121
ratio=ratio,
@@ -126,7 +126,7 @@ def _delete_pods_continuously(dyn_client, pod_prefix, namespace_name, ratio, int
126126
wait_timeout=max_duration,
127127
sleep=interval,
128128
func=_delete_pods,
129-
dyn_client=dyn_client,
129+
_client=client,
130130
pod_prefix=pod_prefix,
131131
namespace_name=namespace_name,
132132
surviving_pods=surviving_pods,
@@ -139,7 +139,7 @@ def _delete_pods_continuously(dyn_client, pod_prefix, namespace_name, ratio, int
139139
name="pod_delete",
140140
target=_delete_pods_continuously,
141141
args=(
142-
dyn_client,
142+
client,
143143
pod_prefix,
144144
namespace_name,
145145
ratio,
@@ -206,7 +206,7 @@ def _monitor_nginx_server(
206206
def get_pods_status(admin_client, namespaces):
207207
pods_status = {"pod_status": {}}
208208
for namespace in namespaces:
209-
pods = get_pods(dyn_client=admin_client, namespace=namespace)
209+
pods = get_pods(client=admin_client, namespace=namespace)
210210
pods_status["pod_status"][namespace.name] = {}
211211
for pod in pods:
212212
# Set the log level to ERROR to avoid cluttering the console

tests/conftest.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def unprivileged_client(
421421

422422
@pytest.fixture(scope="session")
423423
def nodes(admin_client):
424-
yield list(Node.get(dyn_client=admin_client))
424+
yield list(Node.get(client=admin_client))
425425

426426

427427
@pytest.fixture(scope="session")
@@ -1154,7 +1154,7 @@ def golden_images_namespace(
11541154
):
11551155
for ns in Namespace.get(
11561156
name=py_config["golden_images_namespace"],
1157-
dyn_client=admin_client,
1157+
client=admin_client,
11581158
):
11591159
return ns
11601160

@@ -1165,7 +1165,7 @@ def golden_images_cluster_role_edit(
11651165
):
11661166
for cluster_role in ClusterRole.get(
11671167
name="os-images.kubevirt.io:edit",
1168-
dyn_client=admin_client,
1168+
client=admin_client,
11691169
):
11701170
return cluster_role
11711171

@@ -1287,7 +1287,7 @@ def hyperconverged_ovs_annotations_fetched(hyperconverged_resource_scope_functio
12871287

12881288
@pytest.fixture(scope="session")
12891289
def network_addons_config_scope_session(admin_client):
1290-
nac = list(NetworkAddonsConfig.get(dyn_client=admin_client))
1290+
nac = list(NetworkAddonsConfig.get(client=admin_client))
12911291
assert nac, "There should be one NetworkAddonsConfig CR."
12921292
return nac[0]
12931293

@@ -1329,7 +1329,7 @@ def hyperconverged_ovs_annotations_enabled_scope_session(
13291329
wait_for_ovs_status(network_addons_config=network_addons_config_scope_session, status=False)
13301330
wait_for_pods_deletion(
13311331
pods=get_pods(
1332-
dyn_client=admin_client,
1332+
client=admin_client,
13331333
namespace=hco_namespace,
13341334
label="app=ovs-cni",
13351335
)
@@ -1338,7 +1338,7 @@ def hyperconverged_ovs_annotations_enabled_scope_session(
13381338

13391339
@pytest.fixture(scope="session")
13401340
def cluster_storage_classes(admin_client):
1341-
return list(StorageClass.get(dyn_client=admin_client))
1341+
return list(StorageClass.get(client=admin_client))
13421342

13431343

13441344
@pytest.fixture(scope="session")
@@ -1391,7 +1391,7 @@ def hpp_cr_installed(hostpath_provisioner_scope_session):
13911391

13921392
@pytest.fixture(scope="module")
13931393
def cnv_pods(admin_client, hco_namespace):
1394-
yield list(Pod.get(dyn_client=admin_client, namespace=hco_namespace.name))
1394+
yield list(Pod.get(client=admin_client, namespace=hco_namespace.name))
13951395

13961396

13971397
@pytest.fixture(scope="session")
@@ -1540,7 +1540,7 @@ def cluster_info(
15401540
def ocs_current_version(ocs_storage_class, admin_client):
15411541
if ocs_storage_class:
15421542
for csv in ClusterServiceVersion.get(
1543-
dyn_client=admin_client,
1543+
client=admin_client,
15441544
namespace="openshift-storage",
15451545
label_selector=f"{ClusterServiceVersion.ApiGroup.OPERATORS_COREOS_COM}/ocs-operator.openshift-storage",
15461546
):
@@ -1549,7 +1549,7 @@ def ocs_current_version(ocs_storage_class, admin_client):
15491549

15501550
@pytest.fixture(scope="session")
15511551
def openshift_current_version(admin_client):
1552-
return get_clusterversion(dyn_client=admin_client).instance.status.history[0].version
1552+
return get_clusterversion(client=admin_client).instance.status.history[0].version
15531553

15541554

15551555
@pytest.fixture(scope="session")
@@ -1567,7 +1567,7 @@ def hco_image(
15671567
return CNV_NOT_INSTALLED
15681568
source_name = cnv_subscription_scope_session.instance.spec.source
15691569
for cs in CatalogSource.get(
1570-
dyn_client=admin_client,
1570+
client=admin_client,
15711571
name=source_name,
15721572
namespace=py_config["marketplace_namespace"],
15731573
):
@@ -1955,7 +1955,7 @@ def compact_cluster(nodes, workers, control_plane_nodes):
19551955

19561956
@pytest.fixture()
19571957
def virt_pods_with_running_status(admin_client, hco_namespace):
1958-
return get_all_virt_pods_with_running_status(dyn_client=admin_client, hco_namespace=hco_namespace)
1958+
return get_all_virt_pods_with_running_status(client=admin_client, hco_namespace=hco_namespace)
19591959

19601960

19611961
@pytest.fixture(scope="session")

tests/infrastructure/golden_images/update_boot_source/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def custom_data_import_cron_scope_function(
9494
sleep=5,
9595
func=lambda: list(
9696
DataImportCron.get(
97-
dyn_client=admin_client,
97+
client=admin_client,
9898
name=expected_data_import_cron_name,
9999
namespace=golden_images_namespace.name,
100100
)
@@ -111,7 +111,7 @@ def custom_data_source_scope_function(admin_client, custom_data_import_cron_scop
111111
try:
112112
return list(
113113
DataSource.get(
114-
dyn_client=admin_client,
114+
client=admin_client,
115115
name=custom_data_source_name,
116116
namespace=custom_data_import_cron_scope_function.namespace,
117117
)
@@ -217,7 +217,7 @@ def created_persistent_volume_claim(unprivileged_client, data_import_cron_namesp
217217
def _get_first_pvc():
218218
return next(
219219
PersistentVolumeClaim.get(
220-
dyn_client=unprivileged_client,
220+
client=unprivileged_client,
221221
namespace=data_import_cron_namespace.name,
222222
),
223223
None,

tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def update_data_source(data_source):
224224

225225
@pytest.fixture()
226226
def golden_images_data_sources_scope_function(admin_client, golden_images_namespace):
227-
return list(DataSource.get(dyn_client=admin_client, namespace=golden_images_namespace.name))
227+
return list(DataSource.get(client=admin_client, namespace=golden_images_namespace.name))
228228

229229

230230
@pytest.fixture()

tests/infrastructure/sap/test_sap_hana_vm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def sriov_network_node_policy(admin_client, sriov_namespace):
327327
sriov_available_node_policies = [
328328
policy
329329
for policy in SriovNetworkNodePolicy.get(
330-
dyn_client=admin_client,
330+
client=admin_client,
331331
namespace=sriov_namespace.name,
332332
)
333333
if "sriov-network-policy" in policy.name

tests/infrastructure/workload_availability/remediation_fencing/test_nodehealthcheck_default_remediation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def created_nodehealthcheck_snr_object(admin_client, snr_remediation_template):
4343

4444
@pytest.fixture(scope="module")
4545
def snr_remediation_template(admin_client, checkup_nodehealthcheck_operator_deployment):
46-
template = next(SelfNodeRemediationTemplate.get(namespace=REMEDIATION_OPERATOR_NAMESPACE, dyn_client=admin_client))
46+
template = next(SelfNodeRemediationTemplate.get(namespace=REMEDIATION_OPERATOR_NAMESPACE, client=admin_client))
4747
return {
4848
"apiVersion": template.api_version,
4949
"name": template.name,

tests/install_upgrade_operators/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def cnv_deployment_by_name(admin_client, hco_namespace, hpp_cr_installed, cnv_de
4646
pytest.xfail(f"{deployment_name} deployment shouldn't be present on the cluster if HPP CR is not installed")
4747
hpp_pool_deployments = list(
4848
Deployment.get(
49-
dyn_client=admin_client,
49+
client=admin_client,
5050
namespace=hco_namespace.name,
5151
label_selector=f"{StorageClass.Provisioner.HOSTPATH_CSI}/storagePool=hpp-csi-pvc-block-hpp",
5252
)
@@ -89,7 +89,7 @@ def cnv_pods_by_type(
8989
if pod_prefix.startswith((HOSTPATH_PROVISIONER_CSI, HPP_POOL)) and not hpp_cr_installed:
9090
pytest.xfail(f"{pod_prefix} pods shouldn't be present on the cluster if HPP CR is not installed")
9191
pod_list = get_pod_by_name_prefix(
92-
dyn_client=admin_client,
92+
client=admin_client,
9393
namespace=hco_namespace.name,
9494
pod_prefix=pod_prefix,
9595
get_all=True,

tests/install_upgrade_operators/crds_cluster_readers_role/test_crds_cluster_readers_role.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_cnv_crds(admin_client: DynamicClient) -> list[CustomResourceDefinition]:
4545
"""
4646
return [
4747
crd
48-
for crd in CustomResourceDefinition.get(dyn_client=admin_client)
48+
for crd in CustomResourceDefinition.get(client=admin_client)
4949
if crd.name.endswith(Resource.ApiGroup.KUBEVIRT_IO)
5050
]
5151

0 commit comments

Comments
 (0)