Skip to content

Instantly share code, notes, and snippets.

@johnduarte
Created September 1, 2016 03:28
Show Gist options
  • Save johnduarte/da7efd7ac303cb5c5136cdb7c1063f68 to your computer and use it in GitHub Desktop.
Save johnduarte/da7efd7ac303cb5c5136cdb7c1063f68 to your computer and use it in GitHub Desktop.
Patching and running puppet tests with puppetstein
# get puppetstein
# the commands below assume that you are running
# puppetstein from its repo directory and
# using bundler to manage it rather than
# installing it for your default environment
git clone https://github.com/whopper/puppetstein.git
cd puppetstein
bundle install
bundle exec gem install bundler
# Patch puppetstein to ensure that the puppetserver
# is started when using the `with_puppet_running_on`
# method rather than attempting to spin up a passenger
# based master
cat > use-service.patch <<EOS
diff --git a/puppetstein.rb b/puppetstein.rb
index ce15d6c..df4c2fd 100755
--- a/puppetstein.rb
+++ b/puppetstein.rb
@@ -244,9 +244,9 @@ end
def create_host_config(hosts, config)
if hosts[0].hostname && hosts[1].hostname
- targets = "#{hosts[0].flavor}#{hosts[0].version}-64a{hostname=#{hosts[0].hostname}}-#{hosts[1].flavor}#{hosts[1].version}-64m{hostname=#{hosts[1].hostname}}"
+ targets = "#{hosts[0].flavor}#{hosts[0].version}-64a{hostname=#{hosts[0].hostname}}-#{hosts[1].flavor}#{hosts[1].version}-64m{hostname=#{hosts[1].hostname}\,use-service=true}"
else
- targets = "#{hosts[0].flavor}#{hosts[0].version}-64a-#{hosts[1].flavor}#{hosts[1].version}-64m"
+ targets = "#{hosts[0].flavor}#{hosts[0].version}-64a-#{hosts[1].flavor}#{hosts[1].version}-64m{use-service=true}"
end
cli = BeakerHostGenerator::CLI.new([targets, '--disable-default-role', '--osinfo-version', '1'])
EOS
git apply use-service.patch
# Run initial deploy and test given
# a github account and topic branch
# for the puppet component. Puppetstein
# will patch in the changes from this
# branch and run the test(s)
# Puppetstein does not use repo clones for
# tests, to the `acceptancedir` point to
# a local checkout with the desired test
bundle exec ruby puppetstein.rb \
--puppet=thallgren:issue/pup-6241/fail-when-env-is-unreadable \
--acceptancedir=/home/john.duarte/Documents/puppetcode/jrd-puppet/acceptance \
--tests=puppet:tests/environment/negative/agent_run_should_fail_if_env_unreadable.rb \
--platform=centos-7-x86_64
# There is a --use_last flag that can be used to re-use hosts. However,
# is looks like it cannot be used if you are using a topic branch for a
# component. So, I don't know how useful that would be unless you are simply changing
# the test locally and want to run it against the provisioned hosts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment