-
Notifications
You must be signed in to change notification settings - Fork 1.1k
(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
(MAINT) Use shared examples for facts + other spec cleanups #2120
Conversation
Codecov Report
@@ 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.
|
8df676e
to
145aa54
Compare
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.
37cdf54
to
675ba83
Compare
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. |
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 |
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.