Skip to content

Commit 3508427

Browse files
author
Richard Pijnenburg
committed
Initial structure for acceptance testing and adding a simple test
1 parent 88c787d commit 3508427

17 files changed

+299
-2
lines changed

.gitignore

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
*.swp
2-
spec/fixtures
1+
.swp
2+
spec/fixtures/manifests
3+
spec/fixtures/modules
4+
.bundle
5+
.vendor
6+
.vagrant
7+
.ruby-version
8+
pkg/
9+
spec/reports/
10+
log
11+
*.lock

.pmtignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
spec/
2+
Rakefile

Gemfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
source 'https://rubygems.org'
2+
3+
puppetversion = ENV['PUPPET_VERSION'] || '~> 3.7.0'
4+
gem 'puppet', puppetversion, :require => false
5+
6+
gem 'beaker', :git => '[email protected]:puppetlabs/beaker.git', :branch => 'master'
7+
gem 'beaker-rspec', :git => '[email protected]:puppetlabs/beaker-rspec.git', :branch => 'master'
8+
gem 'metadata-json-lint', :git => 'https://github.com/nibalizer/metadata-json-lint.git', :branch => 'master'
9+
gem 'rspec-puppet', :git => 'https://github.com/rodjek/rspec-puppet.git', :branch => 'master'
10+
11+
gem 'pry'
12+
gem 'docker-api', '~> 1.0'
13+
gem 'rubysl-securerandom'
14+
gem 'ci_reporter_rspec'
15+
gem 'rspec', '~> 3.0'
16+
gem 'rake'
17+
gem 'puppet-doc-lint'
18+
gem 'puppet-lint'
19+
gem 'puppetlabs_spec_helper'
20+
gem 'puppet-syntax'
21+
gem 'rspec-puppet-facts'
22+
gem 'webmock'

Rakefile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'rubygems'
2+
require 'puppetlabs_spec_helper/rake_tasks'
3+
4+
exclude_paths = [
5+
"pkg/**/*",
6+
"vendor/**/*",
7+
"spec/**/*",
8+
]
9+
10+
require 'puppet-doc-lint/rake_task'
11+
PuppetDocLint.configuration.ignore_paths = exclude_paths
12+
13+
require 'puppet-lint/tasks/puppet-lint'
14+
require 'puppet-syntax/tasks/puppet-syntax'
15+
16+
PuppetSyntax.exclude_paths = exclude_paths
17+
PuppetSyntax.future_parser = true if ENV['FUTURE_PARSER'] == 'true'
18+
19+
disable_checks = [
20+
'80chars',
21+
'class_inherits_from_params_class',
22+
'class_parameter_defaults',
23+
'documentation',
24+
'single_quote_string_with_variables'
25+
].each { |check| PuppetLint.configuration.send("disable_#{check}") }
26+
27+
PuppetLint.configuration.ignore_paths = exclude_paths
28+
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}"

spec/acceptance/001_basic_spec.rb

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require 'spec_helper_acceptance'
2+
3+
# Here we put the more basic fundamental tests, ultra obvious stuff.
4+
describe "File Concat" do
5+
6+
describe "file fragment content" do
7+
8+
it 'should run successfully' do
9+
pp = "file_fragment { 'fragment_1': content => 'mycontent', tag => 'mytag' }
10+
file_concat { 'myfile': ensure => 'present', tag => 'mytag', path => '/tmp/concat' }
11+
"
12+
apply_manifest(pp, :catch_failures => true)
13+
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
14+
15+
end
16+
17+
describe file('/tmp/concat') do
18+
it { should be_file }
19+
its(:content) { should match /mycontent/ }
20+
end
21+
end
22+
end
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
HOSTS:
2+
centos-6-x64:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: el-6-x86_64
8+
image: electrical/centos:6.4
9+
hypervisor: docker
10+
docker_cmd: '["/sbin/init"]'
11+
docker_image_commands:
12+
- 'yum install -y wget ntpdate rubygems ruby-augeas ruby-devel augeas-devel'
13+
- 'touch /etc/sysconfig/network'
14+
docker_preserve_image: true
15+
CONFIG:
16+
type: foss
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
HOSTS:
2+
debian-6:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: debian-6-amd64
8+
image: electrical/debian:6.0.8
9+
hypervisor: docker
10+
docker_cmd: '["/sbin/init"]'
11+
docker_image_commands:
12+
- 'apt-get install -yq lsb-release wget net-tools ruby rubygems ruby1.8-dev libaugeas-dev libaugeas-ruby ntpdate locales-all'
13+
- 'REALLY_GEM_UPDATE_SYSTEM=1 gem update --system --no-ri --no-rdoc'
14+
docker_preserve_image: true
15+
CONFIG:
16+
type: foss
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
HOSTS:
2+
debian-7:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: debian-7-amd64
8+
image: electrical/debian:7.3
9+
hypervisor: docker
10+
docker_cmd: '["/sbin/init"]'
11+
docker_image_commands:
12+
- 'apt-get install -yq lsb-release wget net-tools ruby rubygems ruby1.8-dev libaugeas-dev libaugeas-ruby ntpdate locales-all'
13+
- 'REALLY_GEM_UPDATE_SYSTEM=1 gem update --system --no-ri --no-rdoc'
14+
docker_preserve_image: true
15+
CONFIG:
16+
type: foss
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HOSTS:
2+
opensuse-121-x64:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: sles-12-x64
8+
box: opensuse-121-x64
9+
box_url: https://s3.amazonaws.com/circlejtp/OpenSuseVagrant/OpenSuse12_1x64_July14.box
10+
hypervisor: vagrant
11+
CONFIG:
12+
type: foss
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HOSTS:
2+
opensuse-131-x64:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: sles-13-x64
8+
box: opensuse-13.1-test
9+
box_url: https://s3-eu-west-1.amazonaws.com/users.eu.elasticsearch.org/electrical/opensuse-131.box
10+
hypervisor: vagrant
11+
CONFIG:
12+
type: foss
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HOSTS:
2+
sles-11-x64:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: sles-11-x86_64
8+
box: sles-11sp3-x64
9+
box_url: https://s3-eu-west-1.amazonaws.com/users.eu.elasticsearch.org/electrical/sles-11sp3-x64.box
10+
hypervisor: vagrant
11+
CONFIG:
12+
type: foss
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
HOSTS:
2+
ubuntu-12-04:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: ubuntu-12.04-amd64
8+
image: electrical/ubuntu:12.04
9+
hypervisor: docker
10+
docker_cmd: '["/sbin/init"]'
11+
docker_image_commands:
12+
- 'apt-get install -yq ruby1.8-dev libaugeas-dev libaugeas-ruby ruby rubygems lsb-release wget net-tools curl'
13+
docker_preserve_image: true
14+
CONFIG:
15+
type: foss
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
HOSTS:
2+
ubuntu-12-10:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: ubuntu-12.10-amd64
8+
image: electrical/ubuntu:12.10
9+
hypervisor: docker
10+
docker_cmd: '["/sbin/init"]'
11+
docker_image_commands:
12+
- 'apt-get install -yq ruby1.8-dev libaugeas-dev libaugeas-ruby ruby rubygems lsb-release wget net-tools curl'
13+
docker_preserve_image: true
14+
CONFIG:
15+
type: foss
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
HOSTS:
2+
ubuntu-13-04:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: ubuntu-13.04-amd64
8+
image: electrical/ubuntu:13.04
9+
hypervisor: docker
10+
docker_cmd: '["/sbin/init"]'
11+
docker_image_commands:
12+
- 'apt-get install -yq ruby1.8-dev libaugeas-dev libaugeas-ruby ruby rubygems lsb-release wget net-tools curl'
13+
docker_preserve_image: true
14+
CONFIG:
15+
type: foss
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
HOSTS:
2+
ubuntu-13-10:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: ubuntu-13.10-amd64
8+
image: electrical/ubuntu:13.10
9+
hypervisor: docker
10+
docker_cmd: '["/sbin/init"]'
11+
docker_image_commands:
12+
- 'apt-get install -yq ruby1.8-dev libaugeas-dev libaugeas-ruby ruby rubygems lsb-release wget net-tools curl'
13+
docker_preserve_image: true
14+
CONFIG:
15+
type: foss
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
HOSTS:
2+
ubuntu-14-04:
3+
roles:
4+
- master
5+
- database
6+
- dashboard
7+
platform: ubuntu-14.04-amd64
8+
image: electrical/ubuntu:14.04
9+
hypervisor: docker
10+
docker_cmd: '["/sbin/init"]'
11+
docker_image_commands:
12+
- 'apt-get install -yq ruby ruby1.9.1-dev libaugeas-dev libaugeas-ruby lsb-release wget net-tools curl'
13+
docker_preserve_image: true
14+
CONFIG:
15+
type: foss

spec/spec_helper_acceptance.rb

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
require 'beaker-rspec'
2+
3+
files_dir = ENV['files_dir'] || '/home/jenkins/puppet'
4+
5+
proxy_host = ENV['BEAKER_PACKAGE_PROXY'] || ''
6+
7+
if !proxy_host.empty?
8+
gem_proxy = "http_proxy=#{proxy_host}" unless proxy_host.empty?
9+
10+
hosts.each do |host|
11+
on host, "echo 'export http_proxy='#{proxy_host}'' >> /root/.bashrc"
12+
on host, "echo 'export https_proxy='#{proxy_host}'' >> /root/.bashrc"
13+
on host, "echo 'export no_proxy=\"localhost,127.0.0.1,localaddress,.localdomain.com,#{host.name}\"' >> /root/.bashrc"
14+
end
15+
else
16+
gem_proxy = ''
17+
end
18+
19+
hosts.each do |host|
20+
# Install Puppet
21+
if host.is_pe?
22+
install_pe
23+
else
24+
puppetversion = ENV['VM_PUPPET_VERSION']
25+
on host, "#{gem_proxy} gem install puppet --no-ri --no-rdoc --version '~> #{puppetversion}'"
26+
on host, "mkdir -p #{host['distmoduledir']}"
27+
28+
if fact('osfamily') == 'Suse'
29+
install_package host, 'rubygems ruby-devel augeas-devel libxml2-devel'
30+
on host, "#{gem_proxy} gem install ruby-augeas --no-ri --no-rdoc"
31+
end
32+
33+
end
34+
35+
# on debian/ubuntu nodes ensure we get the latest info
36+
# Can happen we have stalled data in the images
37+
if fact('osfamily') == 'Debian'
38+
on host, "apt-get update"
39+
end
40+
41+
end
42+
43+
RSpec.configure do |c|
44+
# Project root
45+
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
46+
47+
# Readable test descriptions
48+
c.formatter = :documentation
49+
50+
# Configure all nodes in nodeset
51+
c.before :suite do
52+
# Install module and dependencies
53+
puppet_module_install(:source => proj_root, :module_name => 'file_concat')
54+
end
55+
end

0 commit comments

Comments
 (0)