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

Commit

Permalink
Updated the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamsg199 committed Dec 9, 2021
1 parent 31dda58 commit e5f096e
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 11 deletions.
81 changes: 70 additions & 11 deletions tests/test_health.py
Expand Up @@ -667,23 +667,55 @@ 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
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
8. Run foreman-maintain health check --label check-postgresql-checkpoint-segments.
9. Assert that check-postgresql-checkpoint-segments pass.
3. Assert that check-postgresql-checkpoint-segments gives proper
error message saying an invalid yaml file
4. Make /etc/foreman-installer/custom-hiera.yaml file valid
5. Add config_entries section in /etc/foreman-installer/custom-hiera.yaml
6. Run foreman-maintain health check --label check-postgresql-checkpoint-segments.
7. Assert that check-postgresql-checkpoint-segments fails.
8. Add checkpoint_segments parameter in /etc/foreman-installer/custom-hiera.yaml
9. Run foreman-maintain health check --label check-postgresql-checkpoint-segments.
10. Assert that check-postgresql-checkpoint-segments fails.
11. Remove config_entries section from /etc/foreman-installer/custom-hiera.yaml
12. Run foreman-maintain health check --label check-postgresql-checkpoint-segments.
13. Assert that check-postgresql-checkpoint-segments pass.
:BZ: 1894149, 1899322
:expectedresults: check-postgresql-checkpoint-segments should work.
:CaseImportance: High
"""
custom_hiera = "/etc/foreman-installer/custom-hiera.yaml"
# Create invalid yaml file
ansible_module.lineinfile(
path=custom_hiera,
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
# Make yaml file valid
ansible_module.lineinfile(
path=custom_hiera,
regexp="----",
line="---",
state="present",
)
# Add config_entries section
ansible_module.blockinfile(
path="/etc/foreman-installer/custom-hiera.yaml",
path=custom_hiera,
block="postgresql::server::config_entries:",
)
# Run check-postgresql-checkpoint-segments check.
Expand All @@ -698,7 +730,7 @@ def test_positive_check_postgresql_checkpoint_segments(ansible_module):
assert result["rc"] == 1
# Add checkpoint_segments
ansible_module.blockinfile(
path="/etc/foreman-installer/custom-hiera.yaml",
path=custom_hiera,
block="postgresql::server::config_entries: \n checkpoint_segments: 32",
)
# Run check-postgresql-checkpoint-segments check.
Expand All @@ -713,7 +745,7 @@ def test_positive_check_postgresql_checkpoint_segments(ansible_module):
assert result["rc"] == 1
# Remove config_entries section
ansible_module.blockinfile(
path="/etc/foreman-installer/custom-hiera.yaml",
path=custom_hiera,
block="postgresql::server::config_entries: \n checkpoint_segments: 32",
state="absent",
)
Expand Down Expand Up @@ -892,3 +924,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_postgresql12ss(ansible_module):
"""Verify warnings when available space in /var/opt/rh/rh-postgresql12/
is less than consumed space of /var/lib/pgsql/
: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: Verify warnings when available space in /var/opt/rh/rh-postgresql12/
is less than consumed space of /var/lib/pgsql/
:CaseImportance: High
"""
25 changes: 25 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,27 @@ 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 install/update
of rubygem-foreman_maintain package
: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 install/update
of rubygem-foreman_maintain package
:BZ: 1825841
:expectedresults: satellite-installer should not be executed after install/update
of rubygem-foreman_maintain package
:CaseImportance: Critical
"""

0 comments on commit e5f096e

Please sign in to comment.