From 9ec8cddd0b0cc6adc64ecb7f1c88d8933c7f7fbe Mon Sep 17 00:00:00 2001 From: zpetrace Date: Thu, 1 Aug 2024 14:07:40 +0200 Subject: [PATCH] feat(test): Adding betelgeuse docstrings to test_client.py --- integration-tests/test_client.py | 123 +++++++++++++++++++++++++------ 1 file changed, 102 insertions(+), 21 deletions(-) diff --git a/integration-tests/test_client.py b/integration-tests/test_client.py index 4d69ef2e..0b3d9484 100644 --- a/integration-tests/test_client.py +++ b/integration-tests/test_client.py @@ -1,3 +1,11 @@ +""" +:casecomponent: insights-client +:requirement: RHSS-291297 +:subsystemteam: sst_csi_client_tools +:caseautomation: Automated +:upstream: Yes +""" + import contextlib import glob import os @@ -8,9 +16,22 @@ @pytest.mark.usefixtures("register_subman") def test_client_files_permission(insights_client): - """Verify that permission for lastupload file is 0644: - file /etc/insights-client/.lastupload - Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1924990 + """ + :id: e793cf5e-1c25-4e31-93c9-6f0465f50cae + :title: Verify Client Files Permission + :description: + Verify that the permission for the last upload file + /etc/insights-client/.lastupload is set to 0644 + :reference: https://bugzilla.redhat.com/show_bug.cgi?id=1924990 + :tier: Tier 1 + :steps: + 1. Remove /etc/insights-client/.lastupload if it exists + 2. Register insights-client + 3. Verify the file permissions + :expectedresults: + 1. The file /etc/insights-client/.lastupload does not exist + 2. The insights-client is registered + 3. The permission of /etc/insights-client/.lastupload is set to 0644 """ file_last_upload = "/etc/insights-client/.lastupload" with contextlib.suppress(FileNotFoundError): @@ -46,7 +67,16 @@ def rpm_ql_insights_client(): ) def test_client_rpm_mandatory_files(filename, rpm_ql_insights_client): """ - Verify the existence of mandatory files for insights-client rpm + :id: c7d2edbe-ae78-47e0-9b3d-ae1634c0ac79 + :title: Verify mandatory files for RPM + :description: Verify the existence of mandatory files for the insights-client RPM + :tier: Tier 1 + :steps: + 1. List all files in the insights-client RPM package + 2. Check if each mandatory file exists in the package + :expectedresults: + 1. A list of files is generated + 2. All of the mandatory files are present in the RPM """ assert ( filename in rpm_ql_insights_client @@ -55,9 +85,20 @@ def test_client_rpm_mandatory_files(filename, rpm_ql_insights_client): @pytest.mark.usefixtures("register_subman") def test_client_logfiles_mask(insights_client): - """Verify that files in /var/log/insights-client have the right mode: 0600 - - Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1955724 + """ + :id: 8f24500c-d0ff-4ab1-a2ae-3b99cbf68e36 + :title: Verify Client logfiles Permissions + :description: + Verify that the log files in + /var/log/insights-client have the correct mode 0600 + :reference: https://bugzilla.redhat.com/show_bug.cgi?id=1955724 + :tier: Tier 1 + :steps: + 1. Register insights-client + 2. Check the file permission of each log file generated + :expectedresults: + 1. Insights-client is registered + 2. The file permissions for all log files are 0600 """ # It is necessary to perform some command using insights-client # to populate logs @@ -68,8 +109,15 @@ def test_client_logfiles_mask(insights_client): def test_client_logdir_permissions(): - """Verify that permissions on directory /var/log/insights-client - have the right mode: 0700 + """ + :id: 204b1d54-6d8f-4d87-9227-cf3924cc5bb8 + :title: Verify log directory permissions + :description: + Verify that the permissions on the directory + /var/log/insights-client are set to 0700 + :tier: Tier 1 + :steps: Check the directory permissions of /var/log/insights-client + :expectedresults: The directory permissions are set to 0700 """ logdir_name = "/var/log/insights-client" assert oct(os.stat(logdir_name).st_mode & 0o777) == "0o700" @@ -78,15 +126,25 @@ def test_client_logdir_permissions(): @pytest.mark.usefixtures("register_subman") def test_verify_logrotate_feature(insights_client): """ - Verify that the standard logrotate works for insights-client - Ref : https://bugzilla.redhat.com/show_bug.cgi?id=1940267 - - Test Steps: - 1 - Perform register and payload operation to ensure both - insights-client.log and insights-client-payload.log files have logs - 2 - Rotate logs by running logrotate command on CLI for insights-client - 3 - Verify insights-client.log and insights-client-payload.log size is 0B - 4 - Verify rotated files are created in log dir by comparing number of log files + :id: 5442729f-c6bc-4322-aa17-facd538e9fc3 + :title: Verify Logrotate feature + :description: Verify that the logrotate works properly for insights-client + :reference: https://bugzilla.redhat.com/show_bug.cgi?id=1940267 + :tier: Tier 1 + :steps: + 1. Ensure the logrotate configuration file exists + 2. Register insights-client + 3. Run the logrotate command + 4. Verify that 2 new log files were created + 5. Verify the size of insights-client.log + 6. Verify the size of insights-client-payload.log + :expectedresults: + 1. The logrotate config file exists + 2. The insights-client is registered + 3. The logrotate command is executed successfully + 4. Two new log files were created + 5. The size of insights-client.log is 0B + 6. The size of insights-client-payload.log is 0B """ logrotate_conf_file_path = "/etc/logrotate.d/insights-client" @@ -131,8 +189,20 @@ def test_verify_logrotate_feature(insights_client): @pytest.mark.usefixtures("register_subman") def test_insights_details_file_exists(insights_client): """ - This test verifies that /var/lib/insights/insights-details.json exists - when --check-results is called + :id: 2ccc8e00-0e76-47fd-bdb2-27998c0094ab + :title: Verify insights-client details file exists + :description: Verify that the file /var/lib/insights/insights-client.json exists + :tier: Tier 1 + :steps: + 1. Register insights-client + 2. Delete /var/lib/insights/insights-client.json if it exists + 3. run the --check-results command + 4. Verify the existence of /var/lib/insights/insights-client.json + :expectedresults: + 1. Insights-client is registered + 2. The file /var/lib/insights/insights-client.json does not exists + 3. The --check-results command is executed successfully + 4. The file /var/lib/insights/insights-client.json exists """ output_file = "/var/lib/insights/insights-details.json" insights_client.register() @@ -149,7 +219,18 @@ def test_insights_details_file_exists(insights_client): @pytest.mark.usefixtures("register_subman") def test_insights_directory_files(insights_client): """ - Test that /var/lib/insights have content available + :id: 02072b65-9905-4426-96dc-76af6a73e14f + :title: Verify insights directory files + :description: Verify that the /var/lib/insights directory has the expected content + :tier: Tier 1 + :steps: + 1. Register insights-client + 2. Check the content of /var/lib/insights directory + 3. Verify specific files exists + :expectedresults: + 1. Insights-client is registered + 2. The list of contents of /var/lib/insights directory is created + 3. All specified files are present """ directory = "/var/lib/insights" registered_contents = [