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

feat(test): Adding betelgeuse docstrings to test_client.py #270

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
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
123 changes: 102 additions & 21 deletions integration-tests/test_client.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
zpetrace marked this conversation as resolved.
Show resolved Hide resolved
"""
: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):
Expand Down Expand Up @@ -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
Expand All @@ -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
zpetrace marked this conversation as resolved.
Show resolved Hide resolved
"""
: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
Expand All @@ -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"
Expand All @@ -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
zpetrace marked this conversation as resolved.
Show resolved Hide resolved

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"
Expand Down Expand Up @@ -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 exist
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()
Expand All @@ -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 = [
Expand Down
Loading