Skip to content

Commit

Permalink
Change logs-dir and improve the test's performance (red-hat-storage#8403
Browse files Browse the repository at this point in the history
)

- Change logs-dir to be under the default rsh directory
- Improve the test's performance building one big command on the
ocs-ci agent and run it once via the s3cli-pod to create a batch of logs
on the s3cli pod, instead of uploading them one by one to the pod.

Signed-off-by: Sagi Hirshfeld <[email protected]>
  • Loading branch information
sagihirshfeld authored Sep 21, 2023
1 parent 7dc6c29 commit 4a0eee1
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions ocs_ci/ocs/resources/mockup_bucket_logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime
import logging
import uuid
from ocs_ci.helpers.helpers import setup_pod_directories

from ocs_ci.ocs import constants
from ocs_ci.ocs.bucket_utils import (
Expand All @@ -23,8 +24,6 @@ class MockupBucketLogger:
"""

LOG_FILES_DIR = "/log_files"

def __init__(self, awscli_pod, mcg_obj, bucket_factory, platform, region):
"""
Args:
Expand All @@ -38,6 +37,7 @@ def __init__(self, awscli_pod, mcg_obj, bucket_factory, platform, region):

self.awscli_pod = awscli_pod
self.mcg_obj = mcg_obj
self.log_files_dir = setup_pod_directories(awscli_pod, ["bucket_logs_dir"])[0]

logger.info("Creating the AWS logs bucket Namespacestore")

Expand Down Expand Up @@ -129,25 +129,26 @@ def _upload_mockup_logs(self, bucket_name, obj_list, op):

logger.info(f"Logging {op} operations for {len(obj_list)} objects")

self.awscli_pod.exec_cmd_on_pod(f"mkdir {self.LOG_FILES_DIR}")
# Build one command that creates all the log files on the awscli_pod
command = "bash -c " + '"'
for obj_name in obj_list:
s3mockuplog = S3MockupLog(bucket_name, obj_name, op)
command = (
"bash -c "
+ '"echo '
command += (
"echo "
+ f"'{s3mockuplog}'"
+ f' > {self.LOG_FILES_DIR}/{s3mockuplog.file_name}"'
+ f" > {self.log_files_dir}/{s3mockuplog.file_name};"
)
self.awscli_pod.exec_cmd_on_pod(command)
command += '"'
self.awscli_pod.exec_cmd_on_pod(command)

sync_object_directory(
self.awscli_pod,
f"{self.LOG_FILES_DIR}",
f"{self.log_files_dir}",
f"s3://{self.logs_bucket_mcg_name}",
self.mcg_obj,
)

self.awscli_pod.exec_cmd_on_pod(f"rm -rf {self.LOG_FILES_DIR}")
self.awscli_pod.exec_cmd_on_pod(f"rm -rf {self.log_files_dir}/*")


class S3MockupLog:
Expand Down

0 comments on commit 4a0eee1

Please sign in to comment.