Skip to content

Add foremanctl test for deploy using tuning profiles#21357

Open
shubhamsg199 wants to merge 1 commit into
SatelliteQE:masterfrom
shubhamsg199:foremanctl_tuning_profile_deploy
Open

Add foremanctl test for deploy using tuning profiles#21357
shubhamsg199 wants to merge 1 commit into
SatelliteQE:masterfrom
shubhamsg199:foremanctl_tuning_profile_deploy

Conversation

@shubhamsg199
Copy link
Copy Markdown
Contributor

@shubhamsg199 shubhamsg199 commented Apr 20, 2026

Adding foremanctl test for deploy using tuning profiles(SAT-41408)

Summary by Sourcery

Add automated coverage for foremanctl deploy behavior when using tuning profiles and resetting to default.

Tests:

  • Add integration test verifying foremanctl deploy with the medium tuning profile records the setting and applies corresponding PostgreSQL parameters.
  • Add regression check that switching back to the default tuning profile updates the parameters file and restores default PostgreSQL settings.

@shubhamsg199 shubhamsg199 self-assigned this Apr 20, 2026
@shubhamsg199 shubhamsg199 added No-CherryPick PR doesnt need CherryPick to previous branches Stream Introduced in or relating directly to Satellite Stream/Master labels Apr 20, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 20, 2026

Reviewer's Guide

Adds an automated pytest that verifies foremanctl deploy correctly applies and reverts PostgreSQL tuning profiles, checking both the foremanctl parameters file and live PostgreSQL settings for medium and default profiles.

File-Level Changes

Change Details Files
Add an end-to-end pytest that validates foremanctl deploy with medium and default tuning profiles and asserts PostgreSQL settings match expected profile values.
  • Introduce test_positive_foremanctl_tuning_profile_apply parametrized over the default Satellite-on-RHEL fixture
  • Define an in-test TUNING_PROFILES mapping with expected PostgreSQL values for medium and default profiles
  • Run foremanctl deploy --tuning medium and assert success, then verify the parameters file records tuning: medium
  • Query PostgreSQL inside the postgresql pod via psql for max_connections, shared_buffers, and effective_cache_size and assert they match the medium profile
  • Run foremanctl deploy --tuning default and assert success, then verify the parameters file records tuning: default
  • Re-run the PostgreSQL SHOW queries and assert values reverted to the default profile expectations
tests/foreman/installer/test_install_foremanctl.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Consider extracting the TUNING_PROFILES mapping to a shared fixture or module-level constant so it can be reused by other tuning-related tests and kept in sync with any future profile additions or changes.
  • The single test currently performs two full foremanctl deploy runs (medium and default) and multiple PostgreSQL checks, which may be slow and harder to debug; consider splitting into two focused tests (apply medium / reset to default) or parametrizing them to keep each scenario smaller and clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the `TUNING_PROFILES` mapping to a shared fixture or module-level constant so it can be reused by other tuning-related tests and kept in sync with any future profile additions or changes.
- The single test currently performs two full `foremanctl deploy` runs (medium and default) and multiple PostgreSQL checks, which may be slow and harder to debug; consider splitting into two focused tests (apply medium / reset to default) or parametrizing them to keep each scenario smaller and clearer.

## Individual Comments

### Comment 1
<location path="tests/foreman/installer/test_install_foremanctl.py" line_range="207-208" />
<code_context>
+        },
+    }
+    sat = module_sat_ready_rhel
+    # foremanctl deploy with medium tuning profile
+    assert (
+        sat.execute(
+            'foremanctl deploy --tuning medium',
</code_context>
<issue_to_address>
**nitpick (typo):** Fix the misleading comment for the second deploy call where `--tuning default` is used

The inline comment still says `medium`, but this deploy uses `foremanctl deploy --tuning medium`. Please update the comment to match the actual tuning profile so the test intent stays clear.

Suggested implementation:

```python
    # foremanctl deploy with default tuning profile

```

If this comment appears in multiple places (e.g. for both a `--tuning medium` and a `--tuning default` deploy), you should:
1. Apply the above change only to the second deploy call that uses `foremanctl deploy --tuning default`.
2. Leave or adjust the comment for the deploy that uses `--tuning medium` so it still correctly says "medium" there.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tests/foreman/installer/test_install_foremanctl.py Outdated
@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch from 1512117 to fd91f4b Compare April 20, 2026 11:54
@shubhamsg199 shubhamsg199 requested a review from a team as a code owner April 20, 2026 11:54
@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch from fd91f4b to 0f649a7 Compare April 20, 2026 12:09
@shubhamsg199
Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile

@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15167
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile --external-logging
Test Result : ========== 1 failed, 15 deselected, 10 warnings in 1854.86s (0:30:54) ==========

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Apr 20, 2026
@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch 2 times, most recently from 2318b3f to 826cec5 Compare April 21, 2026 08:04
@shubhamsg199
Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile

@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15184
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile --external-logging
Test Result : ========== 1 failed, 15 deselected, 10 warnings in 2213.80s (0:36:53) ==========

@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch from 826cec5 to 9906feb Compare April 21, 2026 11:09
@shubhamsg199
Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile

@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch from 9906feb to 231fe12 Compare April 21, 2026 11:11
@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15193
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile --external-logging
Test Result : ========== 1 passed, 15 deselected, 10 warnings in 2199.42s (0:36:39) ==========

@Satellite-QE Satellite-QE added PRT-Passed Indicates that latest PRT run is passed for the PR and removed PRT-Failed Indicates that latest PRT run is failed for the PR labels Apr 21, 2026
@amolpati30
Copy link
Copy Markdown
Contributor

@shubhamsg199
Do you think we should also add coverage to verify min_cpu_cores and min_ram_mb values both before and after the change?

@evgeni
Copy link
Copy Markdown
Member

evgeni commented Apr 24, 2026

Do you think we should also add coverage to verify min_cpu_cores and min_ram_mb values both before and after the change?

I think we should. Asserting the value in the params file seems like the wrong way to verify a change actually happened

@amolpati30
Copy link
Copy Markdown
Contributor

amolpati30 commented Apr 24, 2026

Do you think we should also add coverage to verify min_cpu_cores and min_ram_mb values both before and after the change?

I think we should. Asserting the value in the params file seems like the wrong way to verify a change actually happened

It would be good if we could verify the CPU and RAM values. I would say that, at the moment, we do not have any other reliable way to assert whether tuning is applied or not, apart from checking params file. If there is anything you would like to suggest to check tuning. We can also add both assertion points: one to verify in the parameter file, and another to validate the actual CPU and RAM values against the expected configuration.
For example, for the large profile:
min_cpu_cores: 16
min_ram_mb: 65536

@stejskalleos
Copy link
Copy Markdown
Contributor

For example, for the large profile:
min_cpu_cores: 16
min_ram_mb: 65536

@amolpati30, where are those values saved? In the parameters.yaml file?

@evgeni
Copy link
Copy Markdown
Member

evgeni commented Apr 27, 2026

Do you think we should also add coverage to verify min_cpu_cores and min_ram_mb values both before and after the change?

I think we should. Asserting the value in the params file seems like the wrong way to verify a change actually happened

It would be good if we could verify the CPU and RAM values.

You could try configuring extra-extra-large which requires 48 cores and see that fail.

I would say that, at the moment, we do not have any other reliable way to assert whether tuning is applied or not, apart from checking params file. If there is anything you would like to suggest to check tuning. We can also add both assertion points: one to verify in the parameter file, and another to validate the actual CPU and RAM values against the expected configuration. For example, for the large profile: min_cpu_cores: 16 min_ram_mb: 65536

We do configure PostgreSQL differently starting with medium (see theforeman/foremanctl#331), so you could tune it to medium and ask the postgresql server about it's config:

$ psql -t -c 'show max_connections;'
 500

@amolpati30
Copy link
Copy Markdown
Contributor

amolpati30 commented Apr 27, 2026

We do configure PostgreSQL differently starting with medium (see theforeman/foremanctl#331), so you could tune it to medium and ask the postgresql server about it's config:

We can use nproc to check the number of CPU cores and grep MemTotal /proc/meminfo for memory.

@evgeni
Copy link
Copy Markdown
Member

evgeni commented Apr 27, 2026

We do configure PostgreSQL differently starting with medium (see theforeman/foremanctl#331), so you could tune it to medium and ask the postgresql server about it's config:

We can use nproc to check the number of CPU cores and grep MemTotal /proc/meminfo for memory.

How would that help?

@amolpati30
Copy link
Copy Markdown
Contributor

We do configure PostgreSQL differently starting with medium (see theforeman/foremanctl#331), so you could tune it to medium and ask the postgresql server about it's config:

We can use nproc to check the number of CPU cores and grep MemTotal /proc/meminfo for memory.

How would that help?

It provides CPU and memory information, but I am not sure how we can compare it in assertion, since we use the deploy_flavor parameter in Broker to provision machines with predefined flavors such as default, large, and extra-large.

@shubhamsg199
Copy link
Copy Markdown
Contributor Author

Do you think we should also add coverage to verify min_cpu_cores and min_ram_mb values both before and after the change?

I think we should. Asserting the value in the params file seems like the wrong way to verify a change actually happened

It would be good if we could verify the CPU and RAM values.

You could try configuring extra-extra-large which requires 48 cores and see that fail.

I would say that, at the moment, we do not have any other reliable way to assert whether tuning is applied or not, apart from checking params file. If there is anything you would like to suggest to check tuning. We can also add both assertion points: one to verify in the parameter file, and another to validate the actual CPU and RAM values against the expected configuration. For example, for the large profile: min_cpu_cores: 16 min_ram_mb: 65536

We do configure PostgreSQL differently starting with medium (see theforeman/foremanctl#331), so you could tune it to medium and ask the postgresql server about it's config:

$ psql -t -c 'show max_connections;'
 500

Yes, this was my initial thought which I already tried here. But since our default deploy flavor doesn't have the cores needed for medium tuning it resulted failed deploy. Error I got was msg: System must have at least 8 CPU cores, but only 6 available.
I can try to write a new fixture to deploy with large flavor(https://github.com/SatelliteQE/robottelo/blob/master/conf/flavors.yaml.template)

@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch from 231fe12 to d194ebb Compare April 28, 2026 13:05
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label Apr 28, 2026
@shubhamsg199
Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile

Comment thread tests/foreman/installer/test_install_foremanctl.py Outdated
Comment thread robottelo/constants/__init__.py Outdated
@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch from d194ebb to 28505ac Compare April 28, 2026 13:38
@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15250
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile --external-logging
Test Result : =========== 16 deselected, 9 warnings, 1 error in 1125.44s (0:18:45) ===========

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Apr 28, 2026
@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch 2 times, most recently from 1f0f98b to 7592de5 Compare April 28, 2026 14:02
@shubhamsg199
Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile

@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15254
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile --external-logging
Test Result : ========== 1 failed, 16 deselected, 10 warnings in 1983.68s (0:33:03) ==========

@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch from 7592de5 to 662f20b Compare April 28, 2026 18:49
@shubhamsg199
Copy link
Copy Markdown
Contributor Author

The --reset-tuning or updating tuning profile to default fails to update the tuning values for postgresql.
Fix raised: http://github.com/theforeman/foremanctl/pull/479

Signed-off-by: Shubham Ganar <sganar@redhat.com>
@shubhamsg199 shubhamsg199 force-pushed the foremanctl_tuning_profile_deploy branch from 662f20b to 3634414 Compare May 25, 2026 06:57
@shubhamsg199
Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile

@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15575
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile --external-logging
Test Result : =========== 19 deselected, 8 warnings, 1 error in 1085.31s (0:18:05) ===========

@shubhamsg199
Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile
theforeman:
  foremanctl: 450

@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15577
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/installer/test_install_foremanctl.py -k test_positive_foremanctl_tuning_profile --external-logging
Test Result : ========== 19 deselected, 10 warnings, 1 error in 1528.91s (0:25:28) ===========

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No-CherryPick PR doesnt need CherryPick to previous branches PRT-Failed Indicates that latest PRT run is failed for the PR Stream Introduced in or relating directly to Satellite Stream/Master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants