Skip to content

Commit

Permalink
Test noobaa db activitylogs table for unnecessary logs when in defaul…
Browse files Browse the repository at this point in the history
…t log level (#9720)

Signed-off-by: Mahesh Shetty <[email protected]>
  • Loading branch information
mashetty330 authored Jun 26, 2024
1 parent 6e6d403 commit 4821e84
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions tests/functional/object/mcg/test_write_to_bucket.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import time
import zipfile
from concurrent.futures import ThreadPoolExecutor
from zipfile import ZipFile
Expand All @@ -20,14 +21,18 @@
acceptance,
performance,
)
from ocs_ci.utility.utils import exec_nb_db_query
from ocs_ci.ocs import constants
from ocs_ci.ocs.bucket_utils import (
sync_object_directory,
retrieve_test_objects_to_pod,
craft_s3_command,
s3_put_object,
s3_head_object,
rm_object_recursive,
write_random_test_objects_to_bucket,
)

from ocs_ci.framework.pytest_customization.marks import (
skipif_managed_service,
bugzilla,
Expand Down Expand Up @@ -456,3 +461,63 @@ def test_content_encoding_with_write(
logger.info(
"Put object operation is preserving ContentEncoding as a object metadata"
)

@tier2
@bugzilla("2259189")
@bugzilla("2264480")
@pytest.mark.polarion_id("OCS-5773")
def test_nb_db_activity_logs_on_io(
self,
bucket_factory,
awscli_pod_session,
mcg_obj,
change_the_noobaa_log_level,
test_directory_setup,
):

"""
This test checks if the activity logs are being logged
in the activitylogs table for every object upload and
deletion when noobaa log is set to default. As no activity
logs are expected for creation/deletion at defualt log level.
"""
logger.info("Making sure noobaa log is at default_level...")
change_the_noobaa_log_level(level="default_level")

bucket = bucket_factory()[0]
logger.info("successfully created bucket")

obj_uploaded = write_random_test_objects_to_bucket(
awscli_pod_session,
bucket.name,
test_directory_setup.origin_dir,
amount=1,
mcg_obj=mcg_obj,
)[0]
logger.info(f"uploaded object {obj_uploaded} to the bucket")

rm_object_recursive(awscli_pod_session, bucket.name, mcg_obj)
logger.info("deleted all the objects from the bucket")

tries = 0
while tries <= 10:
logger.info("Checking the logs for 10 minutes if any ")
nb_activitylogs = [
line
for line in exec_nb_db_query("SELECT data FROM activitylogs;")
if obj_uploaded in line
]
logger.info("successfully fetched noobaa db activitylogs data")

assert "obj.uploaded" not in str(
nb_activitylogs
), "Object upload event is being logged in activitylogs table"
assert "obj.deleted" not in str(
nb_activitylogs
), "Object deletion event is being logged in activitylogs table"
logger.info(
"No object upload/deletion info is being updated in the activitylogs table"
)
time.sleep(60)
tries += 1

0 comments on commit 4821e84

Please sign in to comment.