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

Integrate FAM pipeline into robottelo #14028

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

Griffin-Sullivan
Copy link
Contributor

@Griffin-Sullivan Griffin-Sullivan commented Feb 9, 2024

Problem Statement

Current FAM misc pipeline has been broken for a couple releases. This is due to some version changes, but also we were not testing things as accurately as possible. For instance, we were cloning upstream and running the develop branch.

Solution

Integrate the FAM pipeline into robottelo. This now runs everything on the satellite against itself, so we know that the collection being packaged in Satellite is working correctly.

Note

The expectation is not that this will pass 100%. Getting all of the modules and roles to pass will take individual setup that needs to be done in robottelo, AAP, or upstream in the test playbook itself. For now I would like to see that the tests are executing as expected and the results show helpful output on failure (ie: the actual ansible tasking logs). After merging, we will need to evaluate as teams how to remediate the issues based on component and team.

@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/sys/test_fam.py::test_positive_run_modules_and_roles

@Griffin-Sullivan Griffin-Sullivan added CherryPick PR needs CherryPick to previous branches 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 labels Feb 9, 2024
@Griffin-Sullivan
Copy link
Contributor Author

Not a terrible start (30/86 failed). You can see though that the failure output is not very helpful since it doesn't give you the full ansible play logs. I'm gonna research if there's a way to force Jenkins or pytest to show everything.

Comment on lines 58 to 76
# Edit config file
config_file = f'{FAM_ROOT_DIR}/tests/test_playbooks/vars/server.yml'
module_target_sat.execute(
f'cp {FAM_ROOT_DIR}/tests/test_playbooks/vars/server.yml.example {config_file}'
)
module_target_sat.execute(
f'sed -i "s/foreman.example.com/{module_target_sat.hostname}/g" {config_file}'
)
module_target_sat.execute(
f'sed -i "s/rhsm_pool_id:.*/rhsm_pool_id: {settings.subscription.rhn_poolid}/g" {config_file}'
)
module_target_sat.execute(
f'''sed -i 's/rhsm_username:.*/rhsm_username: "{settings.subscription.rhn_username}"/g' {config_file}'''
)
module_target_sat.execute(
f'''sed -i 's|subscription_manifest_path:.*|subscription_manifest_path: "data/{module_sca_manifest.name}.zip"|g' {config_file}'''
)
module_target_sat.execute(
f'''sed -i 's/rhsm_password:.*/rhsm_password: "{settings.subscription.rhn_password}"/g' {config_file}'''
)
Copy link
Member

Choose a reason for hiding this comment

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

given the amount of changes we need to perform here, would it be easier/cleaner if we'd deploy this file (server.yml) from a template and completely ignore the example we ship in the package?

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 would the process of deploying the file from a template look like?

Copy link
Member

Choose a reason for hiding this comment

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

No idea ;)
I was hoping there is just a way in robotello?

Copy link
Member

Choose a reason for hiding this comment

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

I've found

def put(self, local_path, remote_path=None):
"""Put a local file to the broker virtual machine.
If local_path is a manifest object, write its contents to a temporary file
then continue with the upload.
"""
if 'utils.manifest' in str(local_path):
with NamedTemporaryFile(dir=robottelo_tmp_dir) as content_file:
content_file.write(local_path.content.read())
content_file.flush()
self.session.sftp_write(source=content_file.name, destination=remote_path)
else:
self.session.sftp_write(source=local_path, destination=remote_path)

Copy link
Member

Choose a reason for hiding this comment

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

or

robottelo/robottelo/hosts.py

Lines 1003 to 1018 in 97d9117

puppet_conf = (
'[main]\n'
'vardir = /opt/puppetlabs/puppet/cache\n'
'logdir = /var/log/puppetlabs/puppet\n'
'rundir = /var/run/puppetlabs\n'
'ssldir = /etc/puppetlabs/puppet/ssl\n'
'[agent]\n'
'pluginsync = true\n'
'report = true\n'
'ignoreschedules = true\n'
f'ca_server = {proxy_hostname}\n'
f'certname = {cert_name}\n'
'environment = production\n'
f'server = {proxy_hostname}\n'
)
self.execute(f'echo "{puppet_conf}" >> /etc/puppetlabs/puppet/puppet.conf')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would still have to replace the hostname and manifest name during the test setup. For now I'd leave this as is even though it's ugly and we can change in the future.

)

# Handle color output formatting
module_target_sat.execute('export ANSIBLE_NOCOLOR=True && export PY_COLORS=0')
Copy link
Member

Choose a reason for hiding this comment

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

does .execute() always start a new ssh/shell process? if so, those exports won't do anything

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually not sure. Good question for @JacobCallahan

Copy link
Member

Choose a reason for hiding this comment

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

Looking at https://github.com/SatelliteQE/broker/blob/master/broker/hosts.py, it seems the ssh session is kept alive (if possible).

I'd probably still move that to the actual test invocation below.

@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/sys/test_fam.py::test_positive_run_modules_and_roles

@Griffin-Sullivan
Copy link
Contributor Author

Reran cause I realized I needed to add some more test_playbooks to run. This is now running the right amount of tests.

# Handle color output formatting
module_target_sat.execute('export ANSIBLE_NOCOLOR=True && export PY_COLORS=0')
module_target_sat.execute(
f"sed -i 's/pytest -vv/pytest -v --color=no /g' {FAM_ROOT_DIR}/Makefile"
Copy link
Member

Choose a reason for hiding this comment

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

you want -vv here, which will make it output all ansible output (as you wanted)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like that didn't change the output for how Jenkins parsed the logs.

@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/sys/test_fam.py::test_positive_run_modules_and_roles

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 5705
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/sys/test_fam.py::test_positive_run_modules_and_roles
Test Result : =========== 41 failed, 69 passed, 138 warnings in 3719.12s (1:01:59) ===========

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Feb 13, 2024

# Handle color output formatting
module_target_sat.execute(
f"sed -i 's/pytest -vv/pytest -vv --color=no /g' {FAM_ROOT_DIR}/Makefile"
Copy link
Member

Choose a reason for hiding this comment

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

setting PY_COLORS=0 below should be sufficient to force colors off. Sure this is required?

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 and I'm not sure. I never made those changes originally

"""
# Execute test_playbook
result = module_target_sat.execute(
'export ANSIBLE_NOCOLOR=True && export PY_COLORS=0 && '
Copy link
Member

Choose a reason for hiding this comment

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

Both Ansible and Pytest support NO_COLOR so it should be sufficient to set NO_COLOR=True

'export ANSIBLE_NOCOLOR=True && export PY_COLORS=0 && '
f'. ~/localenv/bin/activate && cd {FAM_ROOT_DIR} && make livetest_{ansible_module}'
)
assert 'PASSED' 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.

I think you want to also assert exit code being zero, just to be sure?

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 works for me

@evgeni
Copy link
Member

evgeni commented Feb 14, 2024

I think I know why we're missing the "real" output in the test results.

The pytest that is running the "outer" tests is not called with -vv:

18:36:18  + pytest tests/foreman/sys/test_fam.py::test_positive_run_modules_and_roles --external-logging --junit-xml=sat-results.xml -o junit_suite_name=sat-result

@Griffin-Sullivan
Copy link
Contributor Author

I think I know why we're missing the "real" output in the test results.

The pytest that is running the "outer" tests is not called with -vv:

18:36:18  + pytest tests/foreman/sys/test_fam.py::test_positive_run_modules_and_roles --external-logging --junit-xml=sat-results.xml -o junit_suite_name=sat-result

Interesting. I'll try changing it. Let me update everything and we'll rerun.

@Griffin-Sullivan
Copy link
Contributor Author

trigger: test-robottelo
pytest: -vv tests/foreman/sys/test_fam.py::test_positive_run_modules_and_roles

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 5721
Build Status: UNSTABLE
PRT Comment: pytest -vv tests/foreman/sys/test_fam.py::test_positive_run_modules_and_roles
Test Result : =========== 41 failed, 69 passed, 137 warnings in 3850.63s (1:04:10) ===========

@evgeni
Copy link
Member

evgeni commented Feb 14, 2024

Well, at least it didn't eat up the output now

@Griffin-Sullivan
Copy link
Contributor Author

Yeah we can at least scroll to the bottom for the failure. Works for me.

Copy link
Member

@JacobCallahan JacobCallahan left a comment

Choose a reason for hiding this comment

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

great addition! just one minor thing

module_target_sat.execute(f"sed -i '/^live/ s/$(MANIFEST)//' {FAM_ROOT_DIR}/Makefile")

# Upload manifest to test playbooks directory
module_target_sat.put(f'{module_sca_manifest.path}', f'{module_sca_manifest.name}')
Copy link
Member

Choose a reason for hiding this comment

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

why the f-strings here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed.

Copy link
Member

@ogajduse ogajduse left a comment

Choose a reason for hiding this comment

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

Co-reviewed with @jameerpathan111
LGTM, let's see how it behaves in the production.

@jameerpathan111 jameerpathan111 merged commit 7aca395 into SatelliteQE:master Feb 21, 2024
6 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 21, 2024
github-actions bot pushed a commit that referenced this pull request Feb 21, 2024
github-actions bot pushed a commit that referenced this pull request Feb 21, 2024
Griffin-Sullivan added a commit that referenced this pull request Mar 15, 2024
Integrate FAM pipeline into robottelo (#14028)

(cherry picked from commit 7aca395)

Co-authored-by: Griffin Sullivan <48397354+Griffin-Sullivan@users.noreply.github.com>
Griffin-Sullivan added a commit that referenced this pull request Mar 15, 2024
* Integrate FAM pipeline into robottelo (#14028)

(cherry picked from commit 7aca395)

* Fix manifest file transer for fam

---------

Co-authored-by: Griffin Sullivan <48397354+Griffin-Sullivan@users.noreply.github.com>
Co-authored-by: Griffin-Sullivan <gsulliva@redhat.com>
damoore044 pushed a commit to damoore044/robottelo that referenced this pull request Mar 18, 2024
Integrate FAM pipeline into robottelo (SatelliteQE#14028)

(cherry picked from commit 7aca395)

Co-authored-by: Griffin Sullivan <48397354+Griffin-Sullivan@users.noreply.github.com>
shweta83 pushed a commit to shweta83/robottelo that referenced this pull request Apr 10, 2024
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 PRT-Failed Indicates that latest PRT run is failed for the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants