This commit is contained in:
Henry Wang 2020-04-06 13:11:51 +08:00
parent a41d947878
commit 73005f3953
10 changed files with 262 additions and 12 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
modules/ modules/
.onceover

8
Gemfile Normal file
View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# gem "rails"
gem "onceover"

133
Gemfile.lock Normal file
View File

@ -0,0 +1,133 @@
GEM
remote: https://rubygems.org/
specs:
backticks (1.0.2)
blockenspiel (0.5.0)
colored (1.2)
colored2 (3.1.2)
concurrent-ruby (1.1.6)
cri (2.15.10)
deep_merge (1.2.1)
diff-lcs (1.3)
facter (2.5.7)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.14.0)
faraday (>= 0.7.4, < 1.0)
fast_gettext (1.1.2)
gettext (3.2.9)
locale (>= 2.0.5)
text (>= 1.3.0)
gettext-setup (0.34)
fast_gettext (~> 1.1.0)
gettext (>= 3.0.2, < 3.3.0)
locale
git (1.6.0)
rchardet (~> 1.8)
hiera (3.6.0)
hocon (1.3.0)
httpclient (2.8.3)
little-plugger (1.1.4)
locale (2.1.3)
log4r (1.1.10)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
minitar (0.9)
mocha (1.11.2)
multi_json (1.14.1)
multipart-post (2.1.1)
onceover (3.15.2)
backticks (>= 1.0.2)
colored (~> 1.2)
cri (>= 2.6)
deep_merge (>= 1.0.0)
facter (< 4.0.0)
git
logging (>= 2.0.0)
multi_json (~> 1.10)
parallel_tests (>= 2.0.0)
puppet (>= 3.4.0)
puppetlabs_spec_helper (>= 0.4.0)
r10k (>= 2.1.0)
rake (>= 10.0.0)
rspec (>= 3.0.0)
rspec-puppet (>= 2.4.0)
rspec_junit_formatter (>= 0.2.0)
table_print (>= 1.0.0)
versionomy (>= 0.5.0)
parallel (1.19.1)
parallel_tests (2.32.0)
parallel
pathspec (0.2.1)
puppet (6.14.0)
concurrent-ruby (~> 1.0)
deep_merge (~> 1.0)
facter (> 2.0.1, < 5)
fast_gettext (~> 1.1)
hiera (>= 3.2.1, < 4)
httpclient (~> 2.8)
locale (~> 2.1)
multi_json (~> 1.10)
puppet-resource_api (~> 1.5)
semantic_puppet (~> 1.0)
puppet-lint (2.4.2)
puppet-resource_api (1.8.12)
hocon (>= 1.0)
puppet-syntax (2.6.1)
puppet (>= 5)
rake
puppet_forge (2.3.4)
faraday (>= 0.9.0, < 0.18.0, != 0.13.1)
faraday_middleware (>= 0.9.0, < 0.15.0)
gettext-setup (~> 0.11)
minitar
semantic_puppet (~> 1.0)
puppetlabs_spec_helper (2.14.1)
mocha (~> 1.0)
pathspec (~> 0.2.1)
puppet-lint (~> 2.0)
puppet-syntax (~> 2.0)
rspec-puppet (~> 2.0)
r10k (3.4.1)
colored2 (= 3.1.2)
cri (>= 2.15.10, < 3.0.0)
fast_gettext (~> 1.1.0)
gettext (>= 3.0.2, < 3.3.0)
gettext-setup (~> 0.24)
log4r (= 1.1.10)
multi_json (~> 1.10)
puppet_forge (~> 2.3.0)
rake (13.0.1)
rchardet (1.8.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.1)
rspec-support (~> 3.9.1)
rspec-expectations (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-puppet (2.7.8)
rspec
rspec-support (3.9.2)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
semantic_puppet (1.0.2)
table_print (1.5.6)
text (1.3.1)
versionomy (0.5.0)
blockenspiel (~> 0.5)
PLATFORMS
ruby
DEPENDENCIES
onceover
BUNDLED WITH
2.1.4

View File

@ -26,9 +26,6 @@ mod 'puppetlabs/apt','7.1.0'
mod 'puppetlabs/facts','0.6.0' mod 'puppetlabs/facts','0.6.0'
mod 'puppetlabs/inifile','2.4.0' mod 'puppetlabs/inifile','2.4.0'
mod 'danieldreier-autosign','0.2.0' mod 'danieldreier-autosign','0.2.0'
mod 'tkishel-unlock_puppet',
:git => 'ssh://git@github.com/tkishel/unlock_puppet.git',
:branch => 'master'
mod 'puppetlabs-firewall', '2.0.0' mod 'puppetlabs-firewall', '2.0.0'
mod 'puppetlabs-satellite_pe_tools', '2.0.0' mod 'puppetlabs-satellite_pe_tools', '2.0.0'
mod 'puppetlabs-puppet_metrics_collector', '5.2.0' mod 'puppetlabs-puppet_metrics_collector', '5.2.0'

1
Rakefile Normal file
View File

@ -0,0 +1 @@
require 'onceover/rake_tasks'

View File

@ -10,6 +10,7 @@ class role::windowsnode {
name => 'testuser111', name => 'testuser111',
ensure => present, ensure => present,
groups => 'testgroup111', groups => 'testgroup111',
# require => Group['testgroup'],
} }
### ###

7
spec/factsets/README.md Normal file
View File

@ -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

78
spec/onceover.yaml Normal file
View File

@ -0,0 +1,78 @@
# Classes to be tested
classes:
- role::database_server
- role::windowsnode
- role::webserver
- role::goldload_server
- role::loadbalancer
- role::example
- role::callaugeas
# Nodes to tests classes on, this refers to a 'factset' or 'nodeset'
# depending on whether 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
- Amazon-2018.03
- Ubuntu-12.04-64
- CentOS-6.6-32
- Debian-6.0.10-64
# - AIX-6.1-powerpc
- Windows_Server-2012r2-64
- RHEL-7.4
- Debian-7.8-32
- windows-10-64
- 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
- RHEL-6.7
- CentOS-7.0-64
- Ubuntu-14.04-64
# You can group classes here to save typing
class_groups:
special_classes:
- 'role::callaugeas'
- 'role::loadbalancer'
general_classes:
include: 'all_classes'
exclude: 'special_classes'
non_windows_classes:
include: 'all_classes'
exclude: 'role::callaugeas'
# 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-10-64
- Windows_Server-2008r2-64
non_windows_nodes:
include: 'all_nodes'
exclude: 'windows_nodes'
test_callaugeas_nodes:
- RHEL-7.4
- RHEL-6.7
test_matrix:
- all_nodes:
classes: 'general_classes'
tests: 'spec'
- non_windows_nodes:
classes: 'non_windows_classes'
tests: 'spec'
- test_callaugeas_nodes:
classes: 'role::callaugeas'
tests: 'spec'

View File

@ -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