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

prepare puppet classes needed for FAM tests in setup_fam #16728

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Oct 22, 2024

Problem Statement

  • FAM tests need Puppet modules for two things:
    • Testing of assignment of Puppet classes to hosts and hostgroups (host and hostgroup tests)
    • Testing of import of Puppet classes (puppetclasses_import test)
  • For assignment, those Puppet classes need to be already imported into Foreman
  • For importing "obviously" not
  • Additionally, puppet module install <module> requires access to Puppet Forge, which might or might not be present during the fam-test-setup workflow

Solution

  • Instead of handling this in the fam-test-setup workflow, move the whole setup to robottelo
  • Use puppetlabs-ntp from https://github.com/SatelliteQE/fedorapeople-repos/, as we use parameters from that module to test parameter assignment
  • Fake puppet-prometheus as we don't use anything of the module, just the fact that the classes are present
  • Fake another fakemodule that can be imported when the tests run.

Example

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

@evgeni evgeni force-pushed the prepare-puppet-classes branch 2 times, most recently from 84e1f22 to 85d750f Compare October 22, 2024 08:16
@evgeni evgeni 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 6.16.z Introduced in or relating directly to Satellite 6.16 labels Oct 22, 2024
@evgeni evgeni force-pushed the prepare-puppet-classes branch 4 times, most recently from b84e2f1 to dc23b5a Compare October 22, 2024 11:07
@evgeni evgeni marked this pull request as ready for review October 22, 2024 12:58
@evgeni evgeni requested a review from a team as a code owner October 22, 2024 12:58
@evgeni evgeni force-pushed the prepare-puppet-classes branch from dc23b5a to d22ba4f Compare October 22, 2024 12:58
)
smart_proxy.import_puppetclasses()

create_fake_module(module_target_sat, 'fakemodule', ['init'])
Copy link
Member Author

Choose a reason for hiding this comment

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

One could argue this should rather happen inside test_positive_run_modules_and_roles when testing the puppetclasses_import module.

Copy link
Contributor

@jameerpathan111 jameerpathan111 left a comment

Choose a reason for hiding this comment

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

Looks alright to me, left small nitpick.

tests/foreman/sys/test_fam.py Outdated Show resolved Hide resolved
@evgeni evgeni force-pushed the prepare-puppet-classes branch from d22ba4f to b9c24a8 Compare October 24, 2024 14:36
f'puppet module install --ignore-dependencies {local_path}/{module_tarball}'
)

def create_fake_module(module_target_sat, module_name, module_classes):
Copy link
Member Author

Choose a reason for hiding this comment

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

Jameer asked via Slack what's exactly happening here, and I think we can write it down here in the PR for anyone who will come back and read it later:

I need puppet modules for the tests. 1/ the prometheus module (with those exporter subclasses) and 2/ "some rando module, just something that can be imported"
in both cases, I don't actually care about them to have any working puppet code in them, as long as the names (of modules/classes) are as I want them to

a trivial Puppet class definition is:

class some_name(){
}

or also

class some_name(){}

if I want to ignore newlines/readability

so the code (create_fake_module) goes and given the name of a module (e.g. prometheus) and classes inside that module (e.g. ['init', 'haproxy_exporter', 'redis_exporter', 'statsd_exporter']) it:

  1. creates the folder where these files would live (/etc/puppetlabs/code/environments/production/modules/prometheus/manifests) (and it's parents, mkdir -p does that for us)
  2. in this folder it creates "empty" class files, an init.pp with class prometheus(){}, a haproxy_exporter.pp with class prometheus::haproxy_exporter(){}, etc…

For Puppet/Foreman this looks like totally legit normal Puppet modules, they can be imported into Foreman and applied to Hosts/Hostsgroups, and that's all we care about

@jameerpathan111 jameerpathan111 added the Stream Introduced in or relating directly to Satellite Stream/Master label Oct 24, 2024
@jameerpathan111 jameerpathan111 merged commit 3b5cfa0 into SatelliteQE:master Oct 24, 2024
9 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 24, 2024
github-actions bot pushed a commit that referenced this pull request Oct 24, 2024
github-actions bot pushed a commit that referenced this pull request Oct 24, 2024
jameerpathan111 pushed a commit that referenced this pull request Oct 24, 2024
…6762)

prepare puppet classes needed for FAM tests in setup_fam (#16728)

(cherry picked from commit 3b5cfa0)

Co-authored-by: Evgeni Golov <[email protected]>
jameerpathan111 pushed a commit that referenced this pull request Oct 24, 2024
…6760)

prepare puppet classes needed for FAM tests in setup_fam (#16728)

(cherry picked from commit 3b5cfa0)

Co-authored-by: Evgeni Golov <[email protected]>
jameerpathan111 pushed a commit that referenced this pull request Oct 24, 2024
…6763)

prepare puppet classes needed for FAM tests in setup_fam (#16728)

(cherry picked from commit 3b5cfa0)

Co-authored-by: Evgeni Golov <[email protected]>
@evgeni evgeni deleted the prepare-puppet-classes branch October 24, 2024 17:22
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 6.16.z Introduced in or relating directly to Satellite 6.16 CherryPick PR needs CherryPick to previous branches Stream Introduced in or relating directly to Satellite Stream/Master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants