Skip to content

Commit

Permalink
Improve package acceptance tests
Browse files Browse the repository at this point in the history
- Add proxy support
- Add extra sleep times
- Add extra checks
  • Loading branch information
electrical committed Apr 15, 2014
1 parent a0aedea commit 652a91c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
20 changes: 18 additions & 2 deletions acceptance_spec/acceptance/install_spec.rb
Expand Up @@ -24,6 +24,7 @@

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
sleep 20
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero

end
Expand All @@ -35,7 +36,7 @@
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
end

describe file(pid_file) do
it { should be_file }
Expand All @@ -44,11 +45,26 @@

describe port(2000) do
it {
sleep 5
sleep 30
should be_listening
}
end

end

context "ensure we are still running" do

describe service(service_name) do
it {
sleep 30
should be_running
}
end

describe port(2000) do
it { should be_listening }
end

end

end
19 changes: 14 additions & 5 deletions acceptance_spec/spec_helper_acceptance.rb
Expand Up @@ -4,14 +4,19 @@

files_dir = ENV['files_dir'] || '/home/jenkins/puppet'

proxy_host = ENV['proxy_host'] || ''

gem_proxy = ''
gem_proxy = "http_proxy=http://#{proxy_host}" unless proxy_host.empty?

hosts.each do |host|
# Install Puppet
if host.is_pe?
install_pe
else
puppetversion = ENV['VM_PUPPET_VERSION'] || '3.4.0'
install_package host, 'rubygems'
on host, "gem install puppet --no-ri --no-rdoc --version '~> #{puppetversion}'"
on host, "#{gem_proxy} gem install puppet --no-ri --no-rdoc --version '~> #{puppetversion}'"
on host, "mkdir -p #{host['distmoduledir']}"

if fact('osfamily') == 'Suse'
Expand All @@ -21,6 +26,14 @@

end

# Setup proxy if its enabled
if fact('osfamily') == 'Debian'
on host, "echo 'Acquire::http::Proxy \"http://#{proxy_host}/\";' >> /etc/apt/apt.conf.d/10proxy" unless proxy_host.empty?
end
if fact('osfamily') == 'RedHat'
on host, "echo 'proxy=http://#{proxy_host}/' >> /etc/yum.conf" unless proxy_host.empty?
end

end

RSpec.configure do |c|
Expand All @@ -38,10 +51,6 @@

on host, puppet('module','install','elasticsearch-logstash'), { :acceptable_exit_codes => [0,1] }

if !host.is_pe?
scp_to(host, "#{files_dir}/puppetlabs-stdlib-3.2.0.tar.gz", '/tmp/puppetlabs-stdlib-3.2.0.tar.gz')
on host, puppet('module','install','/tmp/puppetlabs-stdlib-3.2.0.tar.gz'), { :acceptable_exit_codes => [0,1] }
end
if fact('osfamily') == 'Debian'
scp_to(host, "#{files_dir}/puppetlabs-apt-1.4.2.tar.gz", '/tmp/puppetlabs-apt-1.4.2.tar.gz')
on host, puppet('module','install','/tmp/puppetlabs-apt-1.4.2.tar.gz'), { :acceptable_exit_codes => [0,1] }
Expand Down

0 comments on commit 652a91c

Please sign in to comment.