Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
Add manual tests and test for BZ-1894149
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamsg199 committed Dec 8, 2021
1 parent 31dda58 commit 7645784
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 5 deletions.
67 changes: 62 additions & 5 deletions tests/test_health.py
Expand Up @@ -667,20 +667,50 @@ def test_positive_check_postgresql_checkpoint_segments(ansible_module):
1. foreman-maintain should be installed.
:steps:
1. Add config_entries section in /etc/foreman-installer/custom-hiera.yaml
1. Have an invalid /etc/foreman-installer/custom-hiera.yaml file
2. Run foreman-maintain health check --label check-postgresql-checkpoint-segments.
3. Assert that check-postgresql-checkpoint-segments fails.
4. Add checkpoint_segments parameter in /etc/foreman-installer/custom-hiera.yaml
3. Assert that check-postgresql-checkpoint-segments gives proper
error message saying an invalid yaml file
4. Add config_entries section in /etc/foreman-installer/custom-hiera.yaml
5. Run foreman-maintain health check --label check-postgresql-checkpoint-segments.
6. Assert that check-postgresql-checkpoint-segments fails.
7. Remove config_entries section from /etc/foreman-installer/custom-hiera.yaml
7. Add checkpoint_segments parameter in /etc/foreman-installer/custom-hiera.yaml
8. Run foreman-maintain health check --label check-postgresql-checkpoint-segments.
9. Assert that check-postgresql-checkpoint-segments pass.
9. Assert that check-postgresql-checkpoint-segments fails.
10. Remove config_entries section from /etc/foreman-installer/custom-hiera.yaml
11. Run foreman-maintain health check --label check-postgresql-checkpoint-segments.
12.Assert that check-postgresql-checkpoint-segments pass.
:BZ: 1894149
:expectedresults: check-postgresql-checkpoint-segments should work.
:CaseImportance: High
"""
# Create invalid yaml file
ansible_module.lineinfile(
path="/etc/foreman-installer/custom-hiera.yaml",
regexp="---",
line="----",
state="present",
)
contacted = ansible_module.command(
Health.check(["--label", "check-postgresql-checkpoint-segments"])
)
for result in contacted.values():
logger.info(result["stdout"])
assert (
"File /etc/foreman-installer/custom-hiera.yaml is not a yaml file." in result["stdout"]
)
assert "FAIL" in result["stdout"]
assert result["rc"] == 1

ansible_module.lineinfile(
path="/etc/foreman-installer/custom-hiera.yaml",
regexp="----",
line="---",
state="present",
)
# Add config_entries section
ansible_module.blockinfile(
path="/etc/foreman-installer/custom-hiera.yaml",
Expand Down Expand Up @@ -892,3 +922,30 @@ def test_positive_check_non_rh_packages(setup_custom_package, ansible_module):
assert "walrus-5.21-1.noarch" in result["stdout"]
assert "WARNING" in result["stdout"]
assert result["rc"] == 78


@stubbed
def test_positive_available_space_postgresql(ansible_module):
"""Verify Warning or Error is displayed when enough space is not
available under /var/opt/rh/rh-postgresql12/ after the following command.
:id: 283e627d-6afc-49cb-afdb-5b77a91bbd1e
:setup:
1. foreman-maintain should be installed.
2. Have some data under /var/lib/pgsql (upgrade templates have ~565Mib data)
3. Create dir /var/opt/rh/rh-postgresql12/ and mount a partition of ~300Mib
to this dir (less than /var/lib/pgsql).
:steps:
1. foreman-maintain health check --label available-space-for-postgresql12
2. Verify Warning or Error is displayed when enough space is not
available under /var/opt/rh/rh-postgresql12/
:BZ: 1898108, 1973363
:expectedresults: Warning or Error should be displayed after running
foreman-maintain health check --label available-space-for-postgresql12
:CaseImportance: High
"""
22 changes: 22 additions & 0 deletions tests/test_packages.py
@@ -1,5 +1,6 @@
import pytest

from testfm.decorators import stubbed
from testfm.log import logger
from testfm.packages import Packages

Expand Down Expand Up @@ -246,3 +247,24 @@ def test_positive_fm_packages_update(ansible_module, setup_packages_update):
logger.info(result["stdout"])
assert result["rc"] == 0
assert "walrus-5.21-1" in result["stdout"]


@stubbed
def test_positive_fm_packages_sat_installer(ansible_module):
"""Verify satellite installer is not executed after packages install/update
:id: d73971a1-68b4-4ab2-a87c-76cc5ff80a39
:setup:
1. foreman-maintain should be installed.
:steps:
1. Run foreman-maintain packages install/update rubygem-foreman_maintain
2. Verify satellite installer is not executed after packages install/update
:BZ: 1825841
:expectedresults: satellite installer should not be executed after packages install/update
:CaseImportance: Critical
"""

0 comments on commit 7645784

Please sign in to comment.