Skip to content

Commit

Permalink
issue #36 - add acceptance test for puppet4 environment use case
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Nov 18, 2015
1 parent 5da05f4 commit 9644676
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/acceptance/skeletons/puppet4/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

#require 'vagrant-vmware-workstation'
puts ENV

Vagrant.configure("2") do |config|
config.vm.box = "vagrantr10kspec"
config.vm.network "private_network", type: "dhcp"

# r10k plugin to deploy puppet modules
config.r10k.puppet_dir = "environments/myenv"
config.r10k.puppetfile_path = "environments/myenv/Puppetfile"
config.r10k.module_path = "environments/myenv/modules"

# Provision the machine with the appliction
config.vm.provision "puppet" do |puppet|
puppet.environment = "myenv"
puppet.environment_path = "environments"
end
end
Empty file.
12 changes: 12 additions & 0 deletions spec/acceptance/skeletons/puppet4/environments/myenv/Puppetfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This is currently a noop but will be supported in the future.
forge 'forge.puppetlabs.com'

# v1.0.1 -> cdb8d7a186846b49326cec1cfb4623bd77529b04
mod 'reviewboard',
:git => 'https://github.com/jantman/puppet-reviewboard.git',
:ref => 'v1.0.1'

# 0.1.0 -> 3a504b5f66ebe1853bda4ee065fce18118958d84
mod 'nodemeister',
:git => 'https://github.com/jantman/puppet-nodemeister.git',
:ref => '0.1.0'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
notify {'vagrant-r10k puppet run': }
Empty file.
20 changes: 20 additions & 0 deletions spec/acceptance/skeletons/puppet4/gitcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# helper script to determine if a git clone is checked out to a
# PR, tag, or branch, and then output some information about the status
if [ $# -gt 0 ]; then
cd $1
fi
origin=$(git remote show -n origin | grep 'Fetch URL:' | awk '{print $3}')
if tmp=$(git status | grep "refs/pull/origin"); then
foo=$(echo "$tmp" | awk '{print $4}' | awk -F / '{print $4}')
echo "PR: ${foo} @ $(git rev-parse HEAD) (origin: ${origin})"
elif tagname=$(git describe --exact-match --tags $(git log -n1 --pretty='%h') 2>/dev/null); then
echo "tag: ${tagname} @ $(git rev-parse HEAD) (origin: ${origin})"
elif git symbolic-ref -q HEAD &>/dev/null; then
branch_name=$(git symbolic-ref -q HEAD)
branch_name=${branch_name##refs/heads/}
branch_name=${branch_name:-HEAD}
echo "branch: ${branch_name} @ $(git rev-parse HEAD) (origin: ${origin})"
else
echo "sha: $(git rev-parse HEAD) (origin: ${origin})"
fi
28 changes: 28 additions & 0 deletions spec/acceptance/vagrant-r10k/vagrant-r10k_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@
end
end

describe 'configured correctly - puppet4 environment' do
before do
setup_before('puppet4', options)
end
after do
assert_execute("vagrant", "destroy", "--force")
end

it 'deploys Puppetfile modules in an environment' do
status("Test: vagrant up")
up_result = assert_execute('vagrant', 'up', "--provider=#{provider}", '--debug')
ensure_successful_run(up_result, environment.workdir)
status("Test: reviewboard module")
rb_dir = File.join(environment.workdir, 'puppet', 'modules', 'reviewboard')
expect(File.directory?(rb_dir)).to be_truthy
rb_result = assert_execute('bash', 'gitcheck.sh', 'puppet/modules/reviewboard')
expect(rb_result).to exit_with(0)
expect(rb_result.stdout).to match(/tag: v1\.0\.1 @ cdb8d7a186846b49326cec1cfb4623bd77529b04 \(origin: https:\/\/github\.com\/jantman\/puppet-reviewboard\.git\)/)

status("Test: nodemeister module")
nm_dir = File.join(environment.workdir, 'puppet', 'modules', 'nodemeister')
expect(File.directory?(nm_dir)).to be_truthy
nm_result = assert_execute('bash', 'gitcheck.sh', 'puppet/modules/nodemeister')
expect(nm_result).to exit_with(0)
expect(nm_result.stdout).to match(/tag: 0\.1\.0 @ 3a504b5f66ebe1853bda4ee065fce18118958d84 \(origin: https:\/\/github\.com\/jantman\/puppet-nodemeister\.git\)/)
end
end

describe 'destroy when configured correctly' do
before do
setup_before('correct', options)
Expand Down

0 comments on commit 9644676

Please sign in to comment.