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

Replace OPENSHIFT_STORAGE_NAMESPACE and ROOK_CLUSTER_NAMESPACE usage with configuration #8854

Merged
merged 1 commit into from
Nov 16, 2023
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
2 changes: 1 addition & 1 deletion ocs_ci/ocs/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ def validate_pdb_creation():
"""
pdb_obj = ocp.OCP(
kind="PodDisruptionBudget", namespace=constants.OPENSHIFT_STORAGE_NAMESPACE
kind="PodDisruptionBudget", namespace=config.ENV_DATA["cluster_namespace"]
)
item_list = pdb_obj.get().get("items")
pdb_count = constants.PDB_COUNT
Expand Down
7 changes: 2 additions & 5 deletions ocs_ci/ocs/must_gather/must_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
GATHER_COMMANDS_LOG,
)
from ocs_ci.utility import version
from ocs_ci.ocs.constants import (
OPENSHIFT_STORAGE_NAMESPACE,
MANAGED_SERVICE_PLATFORMS,
)
from ocs_ci.ocs.constants import MANAGED_SERVICE_PLATFORMS


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -151,7 +148,7 @@ def compare_running_pods(self):
"""
if self.type_log != "OTHERS":
return
pod_objs = get_all_pods(namespace=OPENSHIFT_STORAGE_NAMESPACE)
pod_objs = get_all_pods(namespace=config.ENV_DATA["cluster_namespace"])
pod_names = []
logger.info("Get pod names on openshift-storage project")
for pod in pod_objs:
Expand Down
2 changes: 1 addition & 1 deletion ocs_ci/ocs/resources/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3324,7 +3324,7 @@ def check_ceph_cmd_execute_successfully():
def search_pattern_in_pod_logs(
pod_name,
pattern,
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=config.ENV_DATA["cluster_namespace"],
container=None,
all_containers=False,
):
Expand Down
8 changes: 4 additions & 4 deletions ocs_ci/ocs/resources/storage_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ def get_in_transit_encryption_config_state():

ocp_obj = StorageCluster(
resource_name=cluster_name,
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=config.ENV_DATA["cluster_namespace"],
)

try:
Expand Down Expand Up @@ -1326,7 +1326,7 @@ def set_in_transit_encryption(enabled=True):

ocp_obj = StorageCluster(
resource_name=cluster_name,
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=config.ENV_DATA["cluster_namespace"],
)

patch = {"spec": {"network": {"connections": {"encryption": {"enabled": enabled}}}}}
Expand Down Expand Up @@ -2397,7 +2397,7 @@ class names. If a resource does not have a storage class name, it will be set to
"""
sc_obj = ocp.OCP(
kind=constants.STORAGECLUSTER,
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=config.ENV_DATA["cluster_namespace"],
)

keys_to_search = [
Expand Down Expand Up @@ -2579,7 +2579,7 @@ def validate_serviceexport():
"""
serviceexport = OCP(
kind="ServiceExport", namespace=constants.OPENSHIFT_STORAGE_NAMESPACE
kind="ServiceExport", namespace=config.ENV_DATA["cluster_namespace"]
)
osd_count = 0
mon_count = 0
Expand Down
4 changes: 2 additions & 2 deletions ocs_ci/ocs/scale_noobaa_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ def get_pod_obj(pod_name):
pod_obj = pod.get_pod_obj(
(
get_pod_name_by_pattern(
pattern=pod_name, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE
pattern=pod_name, namespace=config.ENV_DATA["cluster_namespace"]
)
)[0],
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=config.ENV_DATA["cluster_namespace"],
)
return pod_obj

Expand Down
23 changes: 15 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,8 @@ def factory(
)
elif interface == constants.CEPHFILESYSTEM:
cfs = ocp.OCP(
kind=constants.CEPHFILESYSTEM, namespace=defaults.ROOK_CLUSTER_NAMESPACE
kind=constants.CEPHFILESYSTEM,
namespace=ocsci_config.ENV_DATA["cluster_namespace"],
).get(defaults.CEPHFILESYSTEM_NAME)
ceph_pool_obj = OCS(**cfs)
assert ceph_pool_obj, f"Failed to create {interface} pool"
Expand Down Expand Up @@ -2521,7 +2522,9 @@ def scale_cli_fixture(request, scope_name):
assert scalecli_pod_obj.create(
do_reload=True
), f"Failed to create pod {scalecli_pod_name}"
OCP(namespace=defaults.ROOK_CLUSTER_NAMESPACE, kind="ConfigMap").wait_for_resource(
OCP(
namespace=ocsci_config.ENV_DATA["cluster_namespace"], kind="ConfigMap"
).wait_for_resource(
resource_name=service_ca_configmap.name, column="DATA", condition="1"
)
helpers.wait_for_resource_state(
Expand Down Expand Up @@ -4317,7 +4320,7 @@ def nb_ensure_endpoint_count(request):
max_ep_count = cls.MAX_ENDPOINT_COUNT

assert min_ep_count <= max_ep_count
namespace = defaults.ROOK_CLUSTER_NAMESPACE
namespace = ocsci_config.ENV_DATA["cluster_namespace"]
should_wait = False

# prior to 4.6 we configured the ep count directly on the noobaa cr.
Expand Down Expand Up @@ -5885,7 +5888,7 @@ def patch_consumer_toolbox_with_secret():

consumer_tools_deployment = OCP(
kind=constants.DEPLOYMENT,
namespace=defaults.ROOK_CLUSTER_NAMESPACE,
namespace=ocsci_config.ENV_DATA["cluster_namespace"],
resource_name="rook-ceph-tools",
)
patch_value = (
Expand All @@ -5905,7 +5908,7 @@ def patch_consumer_toolbox_with_secret():
# Wait for the new tools pod to reach Running state
new_tools_pod_info = get_pods_having_label(
label=constants.TOOL_APP_LABEL,
namespace=defaults.ROOK_CLUSTER_NAMESPACE,
namespace=ocsci_config.ENV_DATA["cluster_namespace"],
)[0]
new_tools_pod = Pod(**new_tools_pod_info)
helpers.wait_for_resource_state(new_tools_pod, constants.STATUS_RUNNING)
Expand Down Expand Up @@ -6548,7 +6551,9 @@ def fedora_pod_fixture(request, scope_name):
assert fedora_pod_obj.create(
do_reload=True
), f"Failed to create Pod {fedora_pod_name}"
OCP(namespace=defaults.ROOK_CLUSTER_NAMESPACE, kind="ConfigMap").wait_for_resource(
OCP(
namespace=ocsci_config.ENV_DATA["cluster_namespace"], kind="ConfigMap"
).wait_for_resource(
resource_name=service_ca_configmap.name, column="DATA", condition="1"
)
helpers.wait_for_resource_state(
Expand Down Expand Up @@ -6650,7 +6655,7 @@ def change_the_noobaa_log_level(request):
noobaa_cm = OCP(
kind="configmap",
resource_name="noobaa-config",
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=ocsci_config.ENV_DATA["cluster_namespace"],
)

def factory(level="all"):
Expand Down Expand Up @@ -6685,7 +6690,9 @@ def add_env_vars_to_noobaa_core_fixture(request, mcg_obj_session):
Add env vars to the noobaa-core sts
"""
sts_obj = OCP(kind="StatefulSet", namespace=defaults.ROOK_CLUSTER_NAMESPACE)
sts_obj = OCP(
kind="StatefulSet", namespace=ocsci_config.ENV_DATA["cluster_namespace"]
)
yaml_path_to_env_variables = "/spec/template/spec/containers/0/env"
op_template_dict = {"op": "", "path": "", "value": {"name": "", "value": ""}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TestManagedClusterNodeFailure:
},
"rbd-mirror": {
"label": constants.RBD_MIRROR_APP_LABEL,
"namespace": constants.OPENSHIFT_STORAGE_NAMESPACE,
"namespace": config.ENV_DATA["cluster_namespace"],
},
"submariner-gateway": {
"label": constants.SUBMARINER_GATEWAY_ACTIVE_LABEL,
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/kcs/test_disable_mcg_external_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from ocs_ci.utility.utils import TimeoutSampler
from ocs_ci.ocs.ocp import OCP
from ocs_ci.ocs import constants
from ocs_ci.framework import config
from ocs_ci.framework.pytest_customization.marks import (
tier2,
polarion_id,
Expand All @@ -23,7 +23,7 @@ def patch_noobaa_object(self, request):
# get noobaa object
noobaa_ocp_obj = OCP(
kind="noobaa",
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=config.ENV_DATA["cluster_namespace"],
resource_name="noobaa",
)

Expand Down Expand Up @@ -73,7 +73,7 @@ def test_disable_mcg_external_service(self, patch_noobaa_object):

# verify that services are now Cluster IP
service_obj = OCP(
kind="service", namespace=constants.OPENSHIFT_STORAGE_NAMESPACE
kind="service", namespace=config.ENV_DATA["cluster_namespace"]
)
services = ["s3", "sts"]

Expand Down
12 changes: 6 additions & 6 deletions tests/e2e/kcs/test_selinux_relabel_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_deploymentconfig_pod(self, **kwargs):
pod_obj = helpers.create_pod(
interface_type=constants.CEPHFS_INTERFACE,
pvc_name=self.pvc_obj.name,
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=config.ENV_DATA["cluster_namespace"],
sa_name=self.service_account_obj.name,
dc_deployment=True,
pod_dict_path=constants.PERF_DC_YAML,
Expand Down Expand Up @@ -135,7 +135,7 @@ def apply_selinux_solution_on_existing_pvc(self, pvc_obj):
}
]
ocp_pvc = ocp.OCP(
kind=constants.PVC, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE
kind=constants.PVC, namespace=config.ENV_DATA["cluster_namespace"]
)
ocp_pvc.patch(
resource_name=self.pvc_obj.name,
Expand All @@ -157,7 +157,7 @@ def get_pod_start_time(self, pod_name):
"""
try:
# Get the pod conditions
pod = ocp.OCP(kind="pod", namespace=constants.OPENSHIFT_STORAGE_NAMESPACE)
pod = ocp.OCP(kind="pod", namespace=config.ENV_DATA["cluster_namespace"])
conditions = pod.exec_oc_cmd(
f"get pod {pod_name} -n openshift-storage -o jsonpath='{{.status.conditions}}'"
)
Expand Down Expand Up @@ -218,7 +218,7 @@ def test_selinux_relabel_for_existing_pvc(
"""
self.ocp_project = ocp.OCP(
kind=constants.NAMESPACE, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE
kind=constants.NAMESPACE, namespace=config.ENV_DATA["cluster_namespace"]
)

# Create cephfs pvc
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_selinux_relabel_for_existing_pvc(
# Get the md5sum of some random files
data_path = f"{constants.FLEXY_MNT_CONTAINER_DIR}"
num_of_files = random.randint(3, 9)
pod = ocp.OCP(kind="pod", namespace=constants.OPENSHIFT_STORAGE_NAMESPACE)
pod = ocp.OCP(kind="pod", namespace=config.ENV_DATA["cluster_namespace"])
random_files = pod.exec_oc_cmd(
f"exec -it {self.pod_obj.name} -- /bin/bash"
f' -c "find {data_path} -type f | "shuf" -n {num_of_files}"',
Expand Down Expand Up @@ -296,7 +296,7 @@ def test_selinux_relabel_for_existing_pvc(
node_name = res_pod.get_pod_node(pod_obj=self.pod_obj).name

# Check SeLinux Relabeling is set to false
oc_cmd = ocp.OCP(namespace=constants.OPENSHIFT_STORAGE_NAMESPACE)
oc_cmd = ocp.OCP(namespace=config.ENV_DATA["cluster_namespace"])
cmd1 = "crictl inspect $(crictl ps --name perf -q)"
output = oc_cmd.exec_oc_debug_cmd(node=node_name, cmd_list=[cmd1])
key = '"selinuxRelabel": false'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import csv

from ocs_ci.ocs import constants, scale_noobaa_lib
from ocs_ci.framework import config
from ocs_ci.framework.pytest_customization.marks import orange_squad
from ocs_ci.framework.testlib import scale, E2ETest
from ocs_ci.helpers import helpers
Expand All @@ -17,7 +18,7 @@
@pytest.fixture(autouse=True)
def teardown(request):
def finalizer():
scale_noobaa_lib.cleanup(constants.OPENSHIFT_STORAGE_NAMESPACE)
scale_noobaa_lib.cleanup(config.ENV_DATA["cluster_namespace"])

request.addfinalizer(finalizer)

Expand All @@ -26,7 +27,7 @@ def finalizer():
@scale
class TestScaleOBCStartTime(E2ETest):

namespace = constants.OPENSHIFT_STORAGE_NAMESPACE
namespace = config.ENV_DATA["cluster_namespace"]
scale_obc_count = 10
scale_obc_count_io = 2
num_obc_batch = 5
Expand Down
3 changes: 2 additions & 1 deletion tests/manage/mcg/test_bucket_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from ocs_ci.framework import config
from ocs_ci.framework.pytest_customization.marks import tier1, tier2, red_squad
from ocs_ci.ocs.exceptions import CommandFailed
from ocs_ci.framework.testlib import MCGTest
Expand Down Expand Up @@ -400,7 +401,7 @@ def test_unidirectional_bucketclass_replication(
**(
get_pods_having_label(
label=constants.NOOBAA_DB_LABEL_47_AND_ABOVE,
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=config.ENV_DATA["cluster_namespace"],
)[0]
)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/manage/mcg/test_db_nfs_mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TestNoobaaDbNFSMount:
def mount_ngix_pod(self, request):
# try to mount the reesi004 nfs mount to nginx pod
nginx_pod_data = templating.load_yaml(constants.NGINX_POD_YAML)
nginx_pod_data["metadata"]["namespace"] = constants.OPENSHIFT_STORAGE_NAMESPACE
nginx_pod_data["metadata"]["namespace"] = config.ENV_DATA["cluster_namespace"]
nginx_pod_data["spec"]["containers"][0]["volumeMounts"][0]["name"] = "nfs-vol"
nginx_pod_data["spec"]["containers"][0]["volumeMounts"][0][
"mountPath"
Expand Down
3 changes: 2 additions & 1 deletion tests/manage/mcg/ui/test_namespace_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from ocs_ci.ocs.ocp import OCP
from ocs_ci.ocs import constants
from ocs_ci.framework import config
from ocs_ci.framework.pytest_customization.marks import black_squad
from ocs_ci.framework.testlib import tier1, ui, polarion_id
from ocs_ci.ocs.ui.mcg_ui import NamespaceStoreUI
Expand Down Expand Up @@ -41,7 +42,7 @@ def test_create_namespace_store_ui(self, setup_ui_class, pvc_factory):

"""
self.namespace_store_obj = None
openshift_storage_ns_obj = OCP(namespace=constants.OPENSHIFT_STORAGE_NAMESPACE)
openshift_storage_ns_obj = OCP(namespace=config.ENV_DATA["cluster_namespace"])
pvc_obj = pvc_factory(
interface=constants.CEPHFILESYSTEM,
project=openshift_storage_ns_obj,
Expand Down
8 changes: 5 additions & 3 deletions tests/manage/z_cluster/test_add_mds_to_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from ocs_ci.framework import config
from ocs_ci.framework.pytest_customization.marks import brown_squad
from ocs_ci.framework.testlib import ManageTest
from ocs_ci.ocs.defaults import ROOK_CLUSTER_NAMESPACE
from ocs_ci.ocs.resources.ocs import OCS
from ocs_ci.utility.utils import TimeoutSampler

Expand All @@ -28,9 +27,12 @@ def finalizer():
fs_data = cephfs.get(defaults.CEPHFILESYSTEM_NAME)
fs_data["spec"]["metadataServer"]["activeCount"] = original_active_count
ceph_obj.apply(**fs_data)
pod = ocp.OCP(kind=constants.POD, namespace=ROOK_CLUSTER_NAMESPACE)
pod = ocp.OCP(
kind=constants.POD, namespace=config.ENV_DATA["cluster_namespace"]
)
mds_pods = pod.get(
selector=constants.MDS_APP_LABEL, all_namespaces=ROOK_CLUSTER_NAMESPACE
selector=constants.MDS_APP_LABEL,
all_namespaces=config.ENV_DATA["cluster_namespace"],
)["items"]
mds_names = [pod.get("metadata").get("name") for pod in mds_pods]
for mds in mds_names:
Expand Down
15 changes: 10 additions & 5 deletions tests/manage/z_cluster/test_delete_local_volume_sym_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import pytest

from ocs_ci.ocs.utils import get_pod_name_by_pattern
from ocs_ci.ocs.defaults import ROOK_CLUSTER_NAMESPACE
from ocs_ci.framework.testlib import E2ETest, tier4b
from ocs_ci.ocs import ocp, constants
from ocs_ci.framework.pytest_customization.marks import skipif_no_lso, brown_squad
Expand Down Expand Up @@ -33,12 +32,16 @@ def test_delete_local_volume_sym_link(self):
"""
# Get rook-ceph-crashcollector pod objects
crashcollector_pods = get_pod_name_by_pattern(
pattern="rook-ceph-crashcollector", namespace=ROOK_CLUSTER_NAMESPACE
pattern="rook-ceph-crashcollector",
namespace=config.ENV_DATA["cluster_namespace"],
)
crashcollector_pods_objs = []
for crashcollector_pod in crashcollector_pods:
crashcollector_pods_objs.append(
get_pod_obj(name=crashcollector_pod, namespace=ROOK_CLUSTER_NAMESPACE)
get_pod_obj(
name=crashcollector_pod,
namespace=config.ENV_DATA["cluster_namespace"],
)
)

# Get Node object
Expand All @@ -47,12 +50,14 @@ def test_delete_local_volume_sym_link(self):
# Get Sym link
osd_pvcs = get_deviceset_pvcs()
pv_name = osd_pvcs[0].data["spec"]["volumeName"]
ocp_obj = ocp.OCP(namespace=ROOK_CLUSTER_NAMESPACE, kind=constants.PV)
ocp_obj = ocp.OCP(
namespace=config.ENV_DATA["cluster_namespace"], kind=constants.PV
)
pv_obj = ocp_obj.get(resource_name=pv_name)
path = pv_obj["spec"]["local"]["path"]

log.info("Delete sym link")
oc_cmd = ocp.OCP(namespace=ROOK_CLUSTER_NAMESPACE)
oc_cmd = ocp.OCP(namespace=config.ENV_DATA["cluster_namespace"])
cmd = f"rm -rfv {path}"
oc_cmd.exec_oc_debug_cmd(node=node_obj.name, cmd_list=[cmd])

Expand Down
Loading
Loading