Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit 6bed8f6

Browse files
committed
Add basic tests
Both examples are converted into unit tests to ensure they fully compile with all dependencies. Based on https://github.com/garethr/puppet-module-skeleton
1 parent c48e34e commit 6bed8f6

File tree

8 files changed

+143
-0
lines changed

8 files changed

+143
-0
lines changed

.fixtures.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fixtures:
2+
repositories:
3+
lokkit: "git://github.com/rharrison10/puppet-lokkit.git"
4+
ntp: "git://github.com/puppetlabs/puppetlabs-ntp.git"
5+
selinux_types: "git://github.com/blentz/puppet-selinux_types.git"
6+
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
7+
sysctl: "git://github.com/duritong/puppet-sysctl.git"
8+
symlinks:
9+
openshift_origin: "#{source_dir}"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ metadata.json
55
*~
66
*.swp
77
pkg
8+
Gemfile.lock

Gemfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
source "https://rubygems.org"
2+
3+
group :test do
4+
gem "rake"
5+
gem "puppet", ENV['PUPPET_VERSION'] || '>= 2.7.0'
6+
gem "puppet-lint"
7+
gem "rspec-puppet"
8+
gem "puppet-syntax"
9+
gem "puppetlabs_spec_helper"
10+
end

Rakefile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'puppetlabs_spec_helper/rake_tasks'
2+
require 'puppet-lint/tasks/puppet-lint'
3+
require 'puppet-syntax/tasks/puppet-syntax'
4+
5+
PuppetLint.configuration.send("disable_80chars")
6+
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}"
7+
PuppetLint.configuration.fail_on_warnings = true
8+
9+
# Forsake support for Puppet 2.6.2 for the benefit of cleaner code.
10+
# http://puppet-lint.com/checks/class_parameter_defaults/
11+
PuppetLint.configuration.send('disable_class_parameter_defaults')
12+
# http://puppet-lint.com/checks/class_inherits_from_params_class/
13+
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
14+
15+
exclude_paths = [
16+
"pkg/**/*",
17+
"vendor/**/*",
18+
"spec/**/*",
19+
]
20+
PuppetLint.configuration.ignore_paths = exclude_paths
21+
PuppetSyntax.exclude_paths = exclude_paths
22+
23+
desc "Run syntax, lint, and spec tests."
24+
task :test => [
25+
:syntax,
26+
:lint,
27+
:spec,
28+
]

spec/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fixtures

spec/.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--format documentation
2+
--color

spec/classes/init_spec.rb

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
require 'spec_helper'
2+
3+
describe 'openshift_origin' do
4+
let :facts do {
5+
:osfamily => 'RedHat',
6+
} end
7+
8+
describe 'with minimal parameters' do
9+
let :params do {
10+
:bind_key => 'something',
11+
} end
12+
13+
it { should compile.with_all_deps }
14+
end
15+
16+
describe 'broker example' do
17+
let :params do {
18+
# Components to install on this host:
19+
:roles => ['broker','nameserver','msgserver','datastore'],
20+
21+
# BIND / named config
22+
# This is the key for updating the OpenShift BIND server
23+
:bind_key => 'something',
24+
# The domain under which applications should be created.
25+
:domain => 'example.com',
26+
# Apps would be named <app>-<namespace>.example.com
27+
# This also creates hostnames for local components under our domain
28+
:register_host_with_nameserver => true,
29+
# Forward requests for other domains (to Google by default)
30+
:conf_nameserver_upstream_dns => ['8.8.8.8', '8.8.4.4'],
31+
32+
# NTP Servers for OpenShift hosts to sync time
33+
:ntp_servers => ['ntp.example.com iburst'],
34+
35+
# The FQDNs of the OpenShift component hosts
36+
:broker_hostname => 'broker.example.com',
37+
:nameserver_hostname => 'broker.example.com',
38+
:datastore_hostname => 'broker.example.com',
39+
:msgserver_hostname => 'broker.example.com',
40+
41+
# Auth OpenShift users created with htpasswd tool in /etc/openshift/htpasswd
42+
:broker_auth_plugin => 'htpasswd',
43+
# Username and password for initial openshift user
44+
:openshift_user1 => 'openshift',
45+
:openshift_password1 => 'password',
46+
47+
#Enable development mode for more verbose logs
48+
:development_mode => true,
49+
} end
50+
51+
it { should compile.with_all_deps }
52+
end
53+
54+
describe 'node example' do
55+
let :params do {
56+
# Components to install on this host:
57+
:roles => ['node'],
58+
59+
# BIND / named config
60+
# This is the key for updating the OpenShift BIND server
61+
:bind_key => 'something',
62+
# The domain under which applications should be created.
63+
:domain => 'example.com',
64+
# Apps would be named <app>-<namespace>.example.com
65+
# This also creates hostnames for local components under our domain
66+
:register_host_with_nameserver => true,
67+
# Forward requests for other domains (to Google by default)
68+
:conf_nameserver_upstream_dns => ['8.8.8.8', '8.8.4.4'],
69+
70+
# NTP Servers for OpenShift hosts to sync time
71+
:ntp_servers => ['ntp.example.com iburst'],
72+
73+
# The FQDNs of the OpenShift component hosts
74+
:broker_hostname => 'broker.example.com',
75+
:msgserver_hostname => 'broker.example.com',
76+
:node_hostname => 'node.example.com',
77+
78+
# To enable installing the Jenkins cartridge:
79+
:install_method => 'yum',
80+
:jenkins_repo_base => 'http://pkg.jenkins-ci.org/redhat',
81+
82+
# Cartridges to install on Node hosts
83+
:install_cartridges => ['php', 'mysql'],
84+
85+
#Enable development mode for more verbose logs
86+
:development_mode => true,
87+
} end
88+
89+
it { should compile.with_all_deps }
90+
end
91+
end

spec/spec_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require 'puppetlabs_spec_helper/module_spec_helper'

0 commit comments

Comments
 (0)