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

[4.18] Test MCG bucket notifications - utility functions and happy path validation #11041

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Address first review comments
Signed-off-by: Sagi Hirshfeld <shirshfe@redhat.com>
  • Loading branch information
sagihirshfeld committed Jan 16, 2025
commit 532cf1636eb019e1906c95e8e390174639bcaf40
1 change: 1 addition & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
@@ -413,6 +413,7 @@

# AMQ
AMQ_NAMESPACE = "myproject"
KAFKA_ENDPOINT = f"my-cluster-kafka-bootstrap.{AMQ_NAMESPACE}.svc.cluster.local:9092"
KAFKA_OPERATOR = "https://github.com/strimzi/strimzi-kafka-operator"
RGW_KAFKA_NOTIFY = "https://github.com/shonpaz123/notify/"
OCS_WORKLOADS = "https://github.com/red-hat-storage/ocs-workloads"
18 changes: 8 additions & 10 deletions ocs_ci/ocs/resources/bucket_notifications_manager.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import logging
import os
import tempfile
import time
from time import sleep

from ocs_ci.framework import config
from ocs_ci.helpers.helpers import (
@@ -17,7 +17,7 @@
from ocs_ci.ocs.ocp import OCP
from ocs_ci.ocs.resources.pod import (
Pod,
get_noobaa_endpoint_pods,
get_noobaa_pods,
get_pods_having_label,
wait_for_pods_to_be_running,
)
@@ -81,10 +81,9 @@ def enable_bucket_notifs_on_cr(self, use_provided_pvc=False):
)
)
elif use_provided_pvc and self.pvc_factory:
clstr_proj_obj = OCP(namespace=self.namespace)
provided_notifs_pvc = self.pvc_factory(
interface=constants.CEPHFILESYSTEM,
project=clstr_proj_obj,
project=OCP(namespace=self.namespace),
size=20,
access_mode=constants.ACCESS_MODE_RWX,
).name
@@ -207,14 +206,14 @@ def create_kafka_conn_secret(self, topic):
conn_file_name = ""

kafka_conn_config = {
"metadata.broker.list": "my-cluster-kafka-bootstrap.myproject.svc.cluster.local:9092",
"metadata.broker.list": constants.KAFKA_ENDPOINT,
"notification_protocol": "kafka",
"topic": topic,
"name": conn_name,
}

with tempfile.NamedTemporaryFile(
mode="w+", prefix="kafka_conn_", suffix=".json", delete=True
mode="w+", prefix="kafka_conn_", suffix=".json"
) as conn_file:
conn_file_name = os.path.basename(conn_file.name)
conn_file.write(json.dumps(kafka_conn_config))
@@ -244,16 +243,15 @@ def add_notif_conn_to_noobaa_cr(self, secret):
"name": secret.resource_name,
"namespace": secret.namespace,
}
patch_path = "/spec/bucketNotifications/connections"
patch_path = os.path.join(NOTIFS_YAML_PATH_NB_CR, "connections")
add_op = [{"op": "add", "path": f"{patch_path}/-", "value": conn_data}]
self.nb_config_resource.patch(
resource_name=constants.NOOBAA_RESOURCE_NAME,
params=json.dumps(add_op),
format_type="json",
)

nb_pods = [pod.name for pod in get_noobaa_endpoint_pods()]
nb_pods += [constants.NOOBAA_CORE_POD]
nb_pods = [pod.name for pod in get_noobaa_pods()]
wait_for_pods_to_be_running(
namespace=self.namespace,
pod_names=nb_pods,
@@ -292,7 +290,7 @@ def put_bucket_notification(self, awscli_pod, mcg_obj, bucket, events, conn_file
)
)
logger.info("Waiting for put-bucket-notification to propogate")
time.sleep(60)
sleep(60)

def get_bucket_notification(self, awscli_pod, mcg_obj, bucket):
"""
Loading