-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dylan Ratcliffe
committed
Mar 8, 2018
1 parent
aee1579
commit 22b36cf
Showing
18 changed files
with
214 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.onceover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'onceover' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
forge "http://forge.puppetlabs.com" | ||
# | ||
# I want to download some modules to check if r10k feature in Onceover works correctly. | ||
# | ||
|
||
# Versions should be updated to be the latest at the time you start | ||
mod "puppetlabs/stdlib", '4.11.0' | ||
|
||
# Modules from Git | ||
# Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples | ||
mod 'apache', | ||
:git => 'https://github.com/puppetlabs/puppetlabs-apache', | ||
:commit => '83401079053dca11d61945bd9beef9ecf7576cbf' | ||
|
||
#mod 'apache', | ||
# :git => 'https://github.com/puppetlabs/puppetlabs-apache', | ||
# :branch => 'docs_experiment' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'onceover/rake_tasks' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
modulepath = site:modules:$basemodulepath | ||
config_version = 'scripts/config_version.sh $environmentpath $environment' |
2 changes: 2 additions & 0 deletions
2
spec/fixtures/controlrepos/function_mocking/hieradata/common.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
message: "This node is using common data" |
1 change: 1 addition & 0 deletions
1
spec/fixtures/controlrepos/function_mocking/hieradata/nodes/example-node.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
32 changes: 32 additions & 0 deletions
32
spec/fixtures/controlrepos/function_mocking/manifests/site.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## site.pp ## | ||
|
||
# This file (/etc/puppetlabs/puppet/manifests/site.pp) is the main entry point | ||
# used when an agent connects to a master and asks for an updated configuration. | ||
# | ||
# Global objects like filebuckets and resource defaults should go in this file, | ||
# as should the default node definition. (The default node can be omitted | ||
# if you use the console and don't define any other nodes in site.pp. See | ||
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on | ||
# node definitions.) | ||
|
||
## Active Configurations ## | ||
|
||
# Disable filebucket by default for all File resources: | ||
#https://docs.puppet.com/pe/2015.3/release_notes.html#filebucket-resource-no-longer-created-by-default | ||
File { backup => false } | ||
|
||
# DEFAULT NODE | ||
# Node definitions in this file are merged with node data from the console. See | ||
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on | ||
# node definitions. | ||
|
||
# The default node definition matches any node lacking a more specific node | ||
# definition. If there are no other nodes in this file, classes declared here | ||
# will be included in every node's catalog, *in addition* to any classes | ||
# specified in the console for that node. | ||
|
||
node default { | ||
# This is where you can declare classes for all nodes. | ||
# Example: | ||
# class { 'my_class': } | ||
} |
5 changes: 5 additions & 0 deletions
5
spec/fixtures/controlrepos/function_mocking/site/profile/manifests/base.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class profile::base { | ||
|
||
#the base profile should include component modules that will be on all nodes | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
spec/fixtures/controlrepos/function_mocking/site/profile/manifests/example.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class profile::example { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
spec/fixtures/controlrepos/function_mocking/site/role/manifests/database_server.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class role::database_server { | ||
|
||
#This role would be made of all the profiles that need to be included to make a database server work | ||
#All roles should include the base profile | ||
include profile::base | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
spec/fixtures/controlrepos/function_mocking/site/role/manifests/example.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class role::example { | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
spec/fixtures/controlrepos/function_mocking/site/role/manifests/test_functions.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# == Class: role::test_functions | ||
# | ||
class role::test_functions { | ||
unless string('foo') =~ String { | ||
fail('string() did not return a string') | ||
} | ||
unless number('foo') =~ Numeric { | ||
fail('string() did not return a string') | ||
} | ||
unless boolean('foo') =~ Boolean { | ||
fail('string() did not return a string') | ||
} | ||
unless array('foo') =~ Array { | ||
fail('string() did not return a string') | ||
} | ||
unless hash('foo') =~ Hash { | ||
fail('string() did not return a string') | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
spec/fixtures/controlrepos/function_mocking/site/role/manifests/webserver.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class role::webserver { | ||
|
||
#This role would be made of all the profiles that need to be included to make a webserver work | ||
#All roles should include the base profile | ||
include profile::base | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
spec/fixtures/controlrepos/function_mocking/spec/factsets/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Factsets | ||
|
||
This directory is where we put any custom factsets that we want to use. They can be generated by running `puppet facts` on the target system. | ||
|
||
**Hot tip:** If you already have factsets in here when you run `onceover init` they will be picked up and added to the config file Automatically | ||
|
||
More info: https://github.com/dylanratcliffe/onceover#factsets |
74 changes: 74 additions & 0 deletions
74
spec/fixtures/controlrepos/function_mocking/spec/onceover.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Classes to be tested | ||
classes: | ||
- role::database_server | ||
- role::webserver | ||
- role::example | ||
|
||
# Nodes to tests classes on, this refers to a 'factset' or 'nodeset' | ||
# depending on weather you are running 'spec' or 'acceptance' tests | ||
nodes: | ||
- AIX-7.1-powerpc | ||
- SLES-12.1-64 | ||
- Debian-6.0.10-32 | ||
- CentOS-6.6-64 | ||
- Ubuntu-12.04-32 | ||
- Ubuntu-12.04-64 | ||
- CentOS-6.6-32 | ||
- Debian-6.0.10-64 | ||
- AIX-6.1-powerpc | ||
- Windows_Server-2012r2-64 | ||
- Debian-7.8-32 | ||
- Windows_Server-2008r2-64 | ||
- SLES-11.3-64 | ||
- Debian-7.8-64 | ||
- solaris-10_u9-sparc-64 | ||
- solaris-11.2-sparc-64 | ||
- Ubuntu-14.04-32 | ||
- CentOS-5.11-64 | ||
- CentOS-5.11-32 | ||
- CentOS-7.0-64 | ||
- Ubuntu-14.04-64 | ||
|
||
# You can group classes here to save typing | ||
class_groups: | ||
|
||
# You can group nodes here to save typing | ||
# We have created a 'non_windows_nodes' group because we can't | ||
# give you Windows vagrant boxes to test with because licensing, | ||
# we can give you fact sets though so go crazy with spec testing! | ||
node_groups: | ||
windows_nodes: | ||
- Windows_Server-2012r2-64 | ||
- Windows_Server-2008r2-64 | ||
non_windows_nodes: | ||
include: 'all_nodes' | ||
exclude: 'windows_nodes' | ||
|
||
test_matrix: | ||
- all_nodes: | ||
classes: 'all_classes' | ||
tests: 'spec' | ||
- non_windows_nodes: | ||
classes: 'all_classes' | ||
tests: 'acceptance' | ||
|
||
functions: | ||
string: | ||
type: rvalue | ||
returns: "string" | ||
number: | ||
type: rvalue | ||
returns: 400 | ||
boolean: | ||
type: rvalue | ||
returns: true | ||
array: | ||
type: rvalue | ||
returns: | ||
- 1 | ||
- 2 | ||
- 3 | ||
hash: | ||
type: rvalue | ||
returns: | ||
foo: bar |
24 changes: 24 additions & 0 deletions
24
spec/fixtures/controlrepos/function_mocking/spec/pre_conditions/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Pre Conditions | ||
|
||
This folder should contain any \*.pp files that you want to be included in every test. | ||
|
||
A common use of this is defining resources that may not exist in the catalog when you are running tests. For example, if we are using a resource that tries to restart the `pe-puppetserver` service, unless it is compiled on a Puppet Maser the `pe-puppetserver` service will not exist and the catalog will fail to compile. To get around this we can create a .pp file and define the resource like so: | ||
|
||
``` puppet | ||
# We are not going to actually have this service anywhere on our servers but | ||
# our code needs to refresh it. This is to trick puppet into doing nothing | ||
service { 'pe-puppetserver': | ||
ensure => 'running', | ||
enable => false, | ||
hasrestart => false, # Force Puppet to use start and stop to restart | ||
start => 'echo "Start"', # This will always exit 0 | ||
stop => 'echo "Stop"', # This will also always exit 0 | ||
hasstatus => false, # Force puppet to use our command for status | ||
status => 'echo "Status"', # This will always exit 0 and therefore Puppet will think the service is running | ||
provider => 'base', | ||
} | ||
``` | ||
|
||
This will mean that the `pe-puppetserver` service is in the catalog for spec testing and will even allow you to try to restart it during acceptance tests without the service actually being present. | ||
|
||
More info: https://github.com/dylanratcliffe/onceover#using-workarounds |