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

Add CU scenario for puma worker count #13544

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

Griffin-Sullivan
Copy link
Contributor

Problem Statement

Missing coverage for BZ 2025760.

Solution

Add new test to cover the scenario for changing the puma worker count.

Related Issues

@Griffin-Sullivan Griffin-Sullivan requested a review from a team as a code owner December 21, 2023 18:56
@Griffin-Sullivan Griffin-Sullivan added CherryPick PR needs CherryPick to previous branches AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 QETestCoverage Issues and PRs relating to a Satellite bug labels Dec 21, 2023
@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/destructive/test_installer.py::test_positive_installer_puma_worker_count

@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/destructive/test_installer.py::test_positive_installer_puma_worker_count

@Griffin-Sullivan Griffin-Sullivan marked this pull request as ready for review January 2, 2024 13:43
@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/destructive/test_installer.py::test_positive_installer_puma_worker_count

:customerscenario: true
"""
result = target_sat.execute('ps aux | grep -v grep | grep -e USER -e puma')
for i in range(9):
Copy link
Contributor

Choose a reason for hiding this comment

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

this feels a bit fragile towards future default value changes, would it make sense to first source the default setting from the answer file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The answer file is blank which is what makes this create 9 puma workers by default. We could instead count the amount of puma workers and then range off of the len?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok so I learned this piece of code determines worker count https://github.com/theforeman/puppet-foreman/blob/908ed638790f3cfc6e2f5f62e1b023c907a9913c/manifests/config.pp#L83C1-L92. Therefore, I changed the test to record what the current worker count is, run the installer with worker count set to a number less than that count, and then assert it worked.

Copy link
Contributor

@pondrejk pondrejk left a comment

Choose a reason for hiding this comment

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

minor comment

@Griffin-Sullivan
Copy link
Contributor Author

@Gauravtalreja1 sorry didn't mean to request review. The GH page I was looking at was outdated.

@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/destructive/test_installer.py::test_positive_installer_puma_worker_count

@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/destructive/test_installer.py::test_positive_installer_puma_worker_count

@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/destructive/test_installer.py::test_positive_installer_puma_worker_count

Comment on lines 161 to 163
1. Check how many puma workers there are by default (9)
2. Change answer's file to have 5 puma workers
3. Run satellite-installer --foreman-foreman-service-puma-workers 5 --foreman-foreman-service-puma-threads-max 5
Copy link
Member

Choose a reason for hiding this comment

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

Are these steps still accurate, or should they be updated based on the newest version of the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No....

Comment on lines 176 to 177
numbers = range(1, count)[:-1]
worker_count = str(random.choice(numbers))
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment line explaining what these are doing?
also, if you just need a string number, would this also work?

Suggested change
numbers = range(1, count)[:-1]
worker_count = str(random.choice(numbers))
worker_count = str(random.randint(1, count))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I'll add your suggestion and a comment

Comment on lines 171 to 175
result = target_sat.execute('ps aux | grep -v grep | grep -e USER -e puma')
count = 0
for line in result.stdout.splitlines():
if 'puma: cluster worker' in line:
count += 1
Copy link
Member

Choose a reason for hiding this comment

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

likely easier to do it this way

Suggested change
result = target_sat.execute('ps aux | grep -v grep | grep -e USER -e puma')
count = 0
for line in result.stdout.splitlines():
if 'puma: cluster worker' in line:
count += 1
count = int(target_sat.execute('pgrep --full "puma: cluster worker" | wc -l').stdout)

Comment on lines +187 to +188
result = target_sat.execute('ps aux | grep -v grep | grep -e USER -e puma')
for i in range(count):
if i < int(worker_count):
assert f'cluster worker {i}' in result.stdout
else:
assert f'cluster worker {i}' not in result.stdout
Copy link
Member

Choose a reason for hiding this comment

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

see above for better process counting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I liked about this loop is it also asserted that there were certain workers not in the output

@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/destructive/test_installer.py::test_positive_installer_puma_worker_count

@JacobCallahan JacobCallahan merged commit 40c6b46 into SatelliteQE:master Jan 11, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches QETestCoverage Issues and PRs relating to a Satellite bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants