-
Notifications
You must be signed in to change notification settings - Fork 193
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
(MODULES-8348) Acceptance scaffold with beaker-puppet #371
(MODULES-8348) Acceptance scaffold with beaker-puppet #371
Conversation
CLA signed by all contributors. |
04d2b93
to
eb450c3
Compare
|
||
beaker("init -h #{hosts_file} -o options.rb") | ||
beaker("provision") | ||
beaker("exec ./pre_suite") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found during my work adding only-fails to beaker(-puppet) that if one of the beaker subcommands fails, it will kill the rake run right then and there, so no subsequent beaker subcommands (or indeed anything else in the Rakefile in question) will be executed. This means that provisioned machines will wait for their timeout before they are reaped.
I addressed this by wrapping things with a begin/rescue/ensure
block, as illustrated here: https://github.com/puppetlabs/beaker-puppet/blob/1d269589adbb9c47888e47797e63c749133a58a7/tasks/ci.rake#L275-L297
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I would want that to happen as a developer using these tests -- I would want to look at the SUTs and see what happened and then manually destroy them -- but I'll add that to the CI task now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point. Would we want to add the complexity of making that conditional, along the line of the --preserve-hosts
flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that an option to destroy the hosts would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the many places where the beaker-with-subcommands vs. beaker-without-subcommands workflows diverge. --preserve-hosts
does not make a lot of sense with subcommands unless you're running the entire test suite with one invocation, since beaker destroy
is already available and intended to be called separately. I'm hoping this is something we can refine in subsequent PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not call the option destroy-hosts-on-failure
? Then it'd be read as
rake prepare --destroy-hosts-on-failure
eb450c3
to
da23f9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for the most part. Should there be a test for puppet4 => puppet6 upgrades?
acceptance/helpers.rb
Outdated
else | ||
agent_install_options = { | ||
puppet_agent_version: initial_package_version_or_collection, | ||
puppet_collection: puppet_collection_for_puppet_agent_version(initial_package_version_or_collection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be changed to puppet_collection_of
? Then things will read as puppet_collection_of(package_version)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are options passed into beaker-puppet's install_puppet_agent_on
directly -- you'd have to change them there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, you meant puppet_collection_for_puppet_agent_version -- same problem, though
# Wraps {Beaker::DSL::PuppetHelpers.with_puppet_running_on} to apply a default | ||
# manifest to all nodes and execute a block. Behaves as follows: | ||
# | ||
# 1. Set up a `site.pp` file in the production environment on the master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
apply_node_manifest_on(agents, manifest, master_opts)
That way, this can be something that could be extracted to beaker or beaker-puppet. You should be able to reference the agents' fqdns and construct something like what's specified in https://docs.oracle.com/cd/E53394_01/html/E77676/gqqtf.html#scrolltoc for the site.pp contents
I don't know if a block makes sense here. with_puppet_running_on
takes in a block b/c you want to clean-up the state after doing stuff with the running node, but what else can you do here with a site_pp aside from applying it?
Also, it would be better to restore the site.pp after each method call instead of each test so that it can have the flexibility of being used multiple times in the same test.
# | ||
# @param [String] initial_package_version_or_collection Either a version | ||
# of puppet-agent or the name of a puppet collection to install the agent from. | ||
def prepare_upgrade_with(initial_package_version_or_collection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prepare_upgrade_with
is too specific and should be something left to the tests instead of handled at the helper level. How about
setup_puppet_agent_on(hosts, package_version_or_collection, options = {})
and you can specify the master as an option so that the SSL cert-sign stuff can be conditionally triggered. This way, you ca re-use this helper in the master set-up stage without losing the clarity (since you're basically doing the same thing there).
# @param [String] initial_package_version_or_collection Either a version | ||
# of puppet-agent or the name of a puppet collection to install on agent hosts | ||
# @param [String] upgrade_manifest A manifest to apply to all agent nodes | ||
def run_foss_upgrade_with_manifest(initial_package_version_or_collection, upgrade_manifest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the code here's short enough and that there are enough useful helpers already that it would be good enough to leave this code to the individual test files, especially when we'll start adding more complicated tests where the preparation's likely going to be more involved (like Windows service stuff).
end | ||
|
||
upgrade_to = '6.0.0' | ||
manifest = "class { puppet_agent: package_version => '#{upgrade_to}' }" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful to add a puppet_agent_manifest
helper? Would be nice for tests where we're declaring a lot of parameters.
da23f9d
to
cac0723
Compare
(I've updated with a bugfix from sean and a few of the simpler renaming comments, but the design feedback will take me longer to address) |
cac0723
to
d12a36e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll address my comments in a follow-up PR since this is too foundational to wait on any longer.
945b8c7
to
e800c07
Compare
Ok, I believe this is ready to merge, but first:
I'll remove the do not merge label once that's done. |
Actually, we need to wait until puppetlabs/beaker-puppet#100 is merged, too, since it rewrites a few helpers |
e800c07
to
d1fb83e
Compare
(ok, updated this code to use the new puppet_collection_for helper) |
d1fb83e
to
6d365f1
Compare
I've updated this PR with a bugfix discussed out-of-band with @ekinanp and manually tested the results with the linked beaker-puppet PR. Once that PR is merged and released, I believe this is ready. |
beaker-puppet PR was merged, now just need to wait on a beaker-puppet release before this can be merged. |
Adds an acceptance directory containing a set of scaffold test files and helpers to allow for testing this module with beaker-puppet instead of beaker-puppet_install_helper (which is no longer supported). The README in the acceptance directory describes how to run the new tests. This leaves the existing tests in spec/acceptance intact for now; in the future these old tests will either be migrated to the acceptance directory, or (if they test puppet 3 functionality) removed. Take note that this process will also eventually remove beaker-rspec, since it is incompatible with the use of subcommands in beaker 4.
6d365f1
to
10f6331
Compare
beaker-puppet 1.15.0 has been released with the changes needed for these tests -- I've updated the Gemfile version here and removed the "don't merge" label. |
Adds an acceptance directory containing a set of scaffold test files
and helpers to allow for testing this module with beaker-puppet instead
of beaker-puppet_install_helper (which is no longer supported). The
README in the acceptance directory describes how to run the new tests.
This leaves the existing tests in spec/acceptance intact for now; in the
future these old tests will either be migrated to the acceptance
directory, or (if they test puppet 3 functionality) removed.
Take note that this process will also eventually remove beaker-rspec,
since it is incompatible with the use of subcommands in beaker 4.
Do not merge until puppetlabs/beaker-puppet#97 has been merged and released. I will need to update the beaker version in the Gemfile once that happens to require a new enough beaker release.