Skip to content

(MAINT) Use shared examples for facts + other spec cleanups #2120

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

Merged
merged 13 commits into from
Feb 15, 2021

Conversation

ekohl
Copy link
Collaborator

@ekohl ekohl commented Feb 6, 2021

This extracts common sets of facts to shared examples to reduce duplication. It also makes it easier to actually provide correct OS facts and use modern facts.

It also has 2 other commits that slightly improve the specs.

I realize this is a large PR and that's why I haven't even started with making actual changes. It should have a net effect that it's the same coverage but with less code duplication. It's a preparation for #2110.

@ekohl ekohl requested a review from a team as a code owner February 6, 2021 23:29
@codecov-io
Copy link

codecov-io commented Feb 6, 2021

Codecov Report

Merging #2120 (8df676e) into main (13f55bd) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2120   +/-   ##
=======================================
  Coverage   56.36%   56.36%           
=======================================
  Files          12       12           
  Lines         220      220           
=======================================
  Hits          124      124           
  Misses         96       96           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1a830b...8df676e. Read the comment docs.

@ekohl ekohl force-pushed the use-shared-examples-for-facts branch 3 times, most recently from 8df676e to 145aa54 Compare February 8, 2021 10:59
ekohl added 12 commits February 8, 2021 14:48
Shared examples have the benefit that they are a bit more native in
rspec.
This uses a lot more inheritance to reduce duplication. It also makes it
easier to read the results due to the test hierarchy.
This extracts common sets of facts to shared examples to reduce
duplication. It also makes it easier to actually provide correct OS
facts and use modern facts.
These operating systems are listed in metadata.json and thus can use
facts from rspec-puppet-facts.
Using `it_behaves_like` creates a new scope and runs those tests in them.
`a mod class, including apache` is a shared context and doesn't contain
any tests. When using `include_examples`, you can actually inherit the
context.

It then goes a step further and reuses that context in every test. This
works because the Apache version is a parameter so it doesn't matter.

After that, nothing refers to the Debian 7 facts anymore and can be
cleaned up.
Debian 6 is no longer supported according to metadata.json so it doesn't
make sense to test it. Debian 8 is. This cleans it up.
Red Hat 5 is EOL and not supported according to metadata.json while Red
Hat 8 is supported.
Prior to this patch the runtime was ~21 seconds, after ~18 seconds. A
huge part of that is actually initializing facts from
rspec-puppet-facts.
@ekohl ekohl force-pushed the use-shared-examples-for-facts branch from 37cdf54 to 675ba83 Compare February 8, 2021 13:48
@ekohl
Copy link
Collaborator Author

ekohl commented Feb 8, 2021

I don't see why this would fail on acceptance tests. I changed nothing in those nor in manifests.

@sanfrancrisko
Copy link
Contributor

I don't see why this would fail on acceptance tests. I changed nothing in those nor in manifests.

Thanks for embarking on this campaign - it'll definitely makes the tests a lot more legible and easier to maintain. 😃

We've still got a few robustness issues with test execution, but we're constantly chipping away at those. I think you may have been unlucky with some network issues, etc...

I've given this a first pass - will do another one too whilst a re-run of these tests goes, but, as you have already hinted at, none of your changes should have any effect on existing tests.

@ekohl
Copy link
Collaborator Author

ekohl commented Feb 15, 2021

We've still got a few robustness issues with test execution, but we're constantly chipping away at those. I think you may have been unlucky with some network issues, etc...

Looks like provision_service is a private repository so I can't see any milestones.

@sanfrancrisko
Copy link
Contributor

We've still got a few robustness issues with test execution, but we're constantly chipping away at those. I think you may have been unlucky with some network issues, etc...

Looks like provision_service is a private repository so I can't see any milestones.

D'oh, sorry....yes it is. My bad.

The TL;DR - it's the service that is responsible for provisioning the test environment running on the PRs via Github runners

@sanfrancrisko sanfrancrisko changed the title Use shared examples for facts + other spec cleanups (MAINT) Use shared examples for facts + other spec cleanups Feb 15, 2021
@sanfrancrisko sanfrancrisko merged commit b54431d into puppetlabs:main Feb 15, 2021
@ekohl ekohl deleted the use-shared-examples-for-facts branch February 15, 2021 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants