Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit a566c08

Browse files
author
Jarret Lavallee
committed
Add basic spec and acceptance testing
Prior to this commit the spec testing was minimal. This commit adds acceptance testing for docker instances locally and a travis.yml
1 parent c620e75 commit a566c08

18 files changed

+231
-54
lines changed

.fixtures.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ fixtures:
1010
ref: 4.3.0
1111
grafana:
1212
repo: https://github.com/voxpupuli/puppet-grafana.git
13-
ref: 4.0.2
1413
forge_modules:

.gitignore

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@ doc
22
pkg
33
.bundle
44
.yardoc
5-
Gemfile.lock
6-
*.swp
75
.vagrant
8-
.rspec
6+
Gemfile.lock
7+
Gemfile.local
8+
vendor/
9+
spec/fixtures/manifests/
10+
spec/fixtures/modules/
11+
junit/
12+
coverage/
13+
log/
14+
.idea/
15+
.metadata
16+
*.iml
17+
.*.sw[op]
18+
.yardwarns
19+
.DS_Store
20+
tmp/

.rspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--format documentation

.travis.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
sudo: false
3+
language: ruby
4+
cache: bundler
5+
script: "bundle exec rake release_checks"
6+
#Inserting below due to the following issue: https://github.com/travis-ci/travis-ci/issues/3531#issuecomment-88311203
7+
before_install:
8+
- gem update bundler
9+
matrix:
10+
fast_finish: true
11+
include:
12+
- rvm: 2.3.1
13+
dist: xenial
14+
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04
15+
script: bundle exec rake beaker
16+
services: docker
17+
sudo: required
18+
- rvm: 2.3.1
19+
dist: trusty
20+
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7
21+
script: bundle exec rake beaker
22+
services: docker
23+
sudo: required
24+
- rvm: 2.3.1
25+
bundler_args: --without system_tests
26+
env: PUPPET_GEM_VERSION="~> 4.0"
27+
- rvm: 2.1.7
28+
bundler_args: --without system_tests
29+
env: PUPPET_GEM_VERSION="~> 4.0"
30+
notifications:
31+
email: false

Gemfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
33
puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['4.10.4']
44
gem 'metadata-json-lint'
55
gem 'puppet', puppetversion
6-
gem 'puppetlabs_spec_helper', '>= 1.0.0'
6+
gem 'puppetlabs_spec_helper', '>= 1.2.1'
77
gem 'puppet-lint', '>= 1.0.0'
88
gem 'facter', '>= 1.7.0'
9-
gem 'rspec-puppet'
9+
gem 'rspec-puppet', '>= 2.3.2'
10+
gem 'beaker'
11+
gem 'beaker-rspec'
12+
gem 'beaker-puppet_install_helper'
13+
gem 'beaker-module_install_helper'
14+
gem 'semantic_puppet'
1015

1116
# rspec must be v2 for ruby 1.8.7
1217
if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'
@@ -16,3 +21,4 @@ else
1621
# rubocop requires ruby >= 1.9
1722
gem 'rubocop'
1823
end
24+

Rakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ task :test do
3030
Rake::Task[test].invoke
3131
end
3232
end
33+
34+
desc "Run acceptance tests"
35+
RSpec::Core::RakeTask.new(:acceptance) do |t|
36+
t.pattern = 'spec/acceptance'
37+
end

spec/acceptance/install_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'pe_metrics_dashboard::install class' do
4+
context 'default parameters' do
5+
it 'should install grafana and influxdb' do
6+
pp = <<-EOS
7+
class {'pe_metrics_dashboard::install': }
8+
EOS
9+
10+
# Run it twice and test for idempotency
11+
expect(apply_manifest(pp).exit_code).to_not eq(1)
12+
expect(apply_manifest(pp).exit_code).to eq(0)
13+
end
14+
# Grafana should be running
15+
# describe service('grafana-server') do
16+
# it { should be_running }
17+
# end
18+
describe port('3000') do
19+
it { should be_listening }
20+
end
21+
22+
# Influxdb should be listening on port 8086 by default
23+
describe port('8086') do
24+
it { should be_listening }
25+
end
26+
end
27+
end

spec/acceptance/nodesets/centos-6.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
HOSTS:
2+
centos-6-x64:
3+
roles:
4+
- agent
5+
- default
6+
platform: el-6-x86_64
7+
hypervisor: vagrant
8+
box: puppetlabs/centos-6.6-64-nocm
9+
CONFIG:
10+
type: foss

spec/acceptance/nodesets/default.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
HOSTS:
2+
centos-7-x64:
3+
roles:
4+
- agent
5+
- default
6+
platform: el-7-x86_64
7+
hypervisor: vagrant
8+
box: puppetlabs/centos-7.2-64-nocm
9+
CONFIG:
10+
type: foss
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HOSTS:
2+
centos-6-x64:
3+
platform: el-6-x86_64
4+
hypervisor: docker
5+
image: centos:6
6+
docker_preserve_image: true
7+
docker_cmd: '["/usr/sbin/init"]'
8+
# install various tools required to get the image up to usable levels
9+
docker_image_commands:
10+
- 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts'
11+
CONFIG:
12+
trace_limit: 200

0 commit comments

Comments
 (0)