From 8e70dbd819e5a0cd3dc9206914d1c59198bb34e9 Mon Sep 17 00:00:00 2001 From: Mahesh Shetty Date: Wed, 24 Apr 2024 13:11:30 +0530 Subject: [PATCH] test activitylogs table for unneccessary logs when in default log level Signed-off-by: Mahesh Shetty --- .../object/mcg/test_write_to_bucket.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/functional/object/mcg/test_write_to_bucket.py b/tests/functional/object/mcg/test_write_to_bucket.py index b97309fd92bc..35e468154bc6 100644 --- a/tests/functional/object/mcg/test_write_to_bucket.py +++ b/tests/functional/object/mcg/test_write_to_bucket.py @@ -20,6 +20,7 @@ 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, @@ -27,7 +28,9 @@ craft_s3_command, s3_put_object, s3_head_object, + rm_object_recursive, ) + from ocs_ci.framework.pytest_customization.marks import ( skipif_managed_service, bugzilla, @@ -456,3 +459,42 @@ def test_content_encoding_with_write( logger.info( "Put object operation is preserving ContentEncoding as a object metadata" ) + + @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 + ): + + """ + 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 + + """ + + bucket = bucket_factory()[0] + full_objectpath = f"s3://{bucket.name}" + logger.info("successfully created bucket") + + sync_object_directory( + awscli_pod_session, AWSCLI_TEST_OBJ_DIR, full_objectpath, mcg_obj + ) + logger.info("uploaded objects to the bucket") + + rm_object_recursive(awscli_pod_session, bucket.name, mcg_obj) + logger.info("deleted all the objects from the bucket") + + nb_activitylogs = exec_nb_db_query("SELECT data ->> 'event' FROM activitylogs;") + 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" + )