aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/acceptance/hosts.rb75
-rw-r--r--spec/acceptance/nodesets/default.yml13
-rw-r--r--spec/acceptance/puppet.rb43
-rw-r--r--spec/acceptance/services.rb72
-rw-r--r--spec/acceptance/tests/hosts_spec.rb60
-rw-r--r--spec/acceptance/tests/puppet_spec.rb39
-rw-r--r--spec/acceptance/tests/services_spec.rb60
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/spec_helper_acceptance.rb13
9 files changed, 185 insertions, 191 deletions
diff --git a/spec/acceptance/hosts.rb b/spec/acceptance/hosts.rb
deleted file mode 100644
index 297d923..0000000
--- a/spec/acceptance/hosts.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-test_name 'Augeas hosts file' do
- tag 'risk:medium',
- 'audit:medium',
- 'audit:acceptance',
- 'audit:refactor' # move to puppet types test directory, this is not testing puppet apply
- # reduce to a single manifest and apply
-
- skip_test 'requires augeas which is included in AIO' if @options[:type] != 'aio'
-
- confine :except, platform: [
- 'windows',
- 'cisco_ios', # PUP-7380
- ]
- confine(:to, {}, hosts.reject { |host| host[:roles].include?('master') })
-
- step 'Backup the hosts file' do
- on hosts, 'cp /etc/hosts /tmp/hosts.bak'
- end
-
- # We have a begin/ensure block here to clean up the hosts file in case
- # of test failure.
- begin
- step 'Create an entry in the hosts file' do
- manifest = <<EOF
-augeas { 'add_hosts_entry':
- context => '/files/etc/hosts',
- incl => '/etc/hosts',
- lens => 'Hosts.lns',
- changes => [
- 'set 01/ipaddr 192.168.0.1',
- 'set 01/canonical pigiron.example.com',
- 'set 01/alias[1] pigiron',
- 'set 01/alias[2] piggy'
- ]
-}
-EOF
- on hosts, puppet_apply('--verbose'), stdin: manifest
- on hosts, "fgrep '192.168.0.1\tpigiron.example.com pigiron piggy' /etc/hosts"
- end
-
- step 'Modify an entry in the hosts file' do
- manifest = <<EOF
-augeas { 'mod_hosts_entry':
- context => '/files/etc/hosts',
- incl => '/etc/hosts',
- lens => 'Hosts.lns',
- changes => [
- 'set *[canonical = "pigiron.example.com"]/alias[last()+1] oinker'
- ]
-}
-EOF
-
- on hosts, puppet_apply('--verbose'), stdin: manifest
- on hosts, "fgrep '192.168.0.1\tpigiron.example.com pigiron piggy oinker' /etc/hosts"
- end
-
- step 'Remove an entry from the hosts file' do
- manifest = <<EOF
-augeas { 'del_hosts_entry':
- context => '/files/etc/hosts',
- incl => '/etc/hosts',
- lens => 'Hosts.lns',
- changes => [
- 'rm *[canonical = "pigiron.example.com"]'
- ]
-}
-EOF
-
- on hosts, puppet_apply('--verbose'), stdin: manifest
- on hosts, "fgrep 'pigiron.example.com' /etc/hosts", acceptable_exit_codes: [1]
- end
- ensure
- on hosts, 'cat /tmp/hosts.bak > /etc/hosts && rm /tmp/hosts.bak'
- end
-end
diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml
new file mode 100644
index 0000000..3757da6
--- /dev/null
+++ b/spec/acceptance/nodesets/default.yml
@@ -0,0 +1,13 @@
+---
+HOSTS:
+ ubuntu1604-64-1:
+ hypervisor: vmpooler
+ platform: ubuntu-16.04-amd64
+ packaging_platform: ubuntu-16.04-amd64
+ template: ubuntu-1604-x86_64
+ roles:
+ - agent
+ - default
+CONFIG:
+ type: agent
+ pooling_api: http://vmpooler.delivery.puppetlabs.net/ \ No newline at end of file
diff --git a/spec/acceptance/puppet.rb b/spec/acceptance/puppet.rb
deleted file mode 100644
index 2c17238..0000000
--- a/spec/acceptance/puppet.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-test_name 'Augeas puppet configuration' do
- tag 'risk:medium',
- 'audit:medium',
- 'audit:acceptance',
- 'audit:refactor' # move to types test dir
-
- skip_test 'requires augeas which is included in AIO' if @options[:type] != 'aio'
-
- confine :except, platform: 'windows'
- confine(:to, {}, hosts.reject { |host| host[:roles].include?('master') })
-
- teardown do
- agents.each do |agent|
- on agent, "cat /tmp/puppet.conf.bak > #{agent.puppet['confdir']}/puppet.conf && rm /tmp/puppet.conf.bak"
- end
- end
-
- agents.each do |agent|
- step 'Backup the puppet config' do
- on agent, "mv #{agent.puppet['confdir']}/puppet.conf /tmp/puppet.conf.bak"
- end
- step 'Create a new puppet config that has a master and agent section' do
- puppet_conf = <<-CONF
- [main]
- CONF
- on agent, "echo \"#{puppet_conf}\" >> #{agent.puppet['confdir']}/puppet.conf"
- end
-
- step 'Modify the puppet.conf file' do
- manifest = <<-EOF
- augeas { 'puppet agent noop mode':
- context => "/files#{agent.puppet['confdir']}/puppet.conf/agent",
- incl => "/etc/puppetlabs/puppet/puppet.conf",
- lens => 'Puppet.lns',
- changes => 'set noop true',
- }
- EOF
- on agent, puppet_apply('--verbose'), stdin: manifest
-
- on agent, "grep 'noop=true' #{agent.puppet['confdir']}/puppet.conf"
- end
- end
-end
diff --git a/spec/acceptance/services.rb b/spec/acceptance/services.rb
deleted file mode 100644
index 523b953..0000000
--- a/spec/acceptance/services.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-test_name 'Augeas services file' do
- tag 'risk:medium',
- 'audit:medium',
- 'audit:acceptance',
- 'audit:refactor' # move to types test dir
- # use single manifest/apply
-
- skip_test 'requires augeas which is included in AIO' if @options[:type] != 'aio'
-
- confine :except, platform: 'windows'
- confine :except, platform: 'osx'
- confine(:to, {}, hosts.reject { |host| host[:roles].include?('master') })
-
- step 'Backup the services file' do
- on hosts, 'cp /etc/services /tmp/services.bak'
- end
-
- begin
- step 'Add an entry to the services file' do
- manifest = <<EOF
-augeas { 'add_services_entry':
- context => '/files/etc/services',
- incl => '/etc/services',
- lens => 'Services.lns',
- changes => [
- 'ins service-name after service-name[last()]',
- 'set service-name[last()] "Doom"',
- 'set service-name[. = "Doom"]/port "666"',
- 'set service-name[. = "Doom"]/protocol "udp"'
- ]
-}
-EOF
-
- on hosts, puppet_apply('--verbose'), stdin: manifest
- on hosts, "fgrep 'Doom 666/udp' /etc/services"
- end
-
- step 'Change the protocol to udp' do
- manifest = <<EOF
-augeas { 'change_service_protocol':
- context => '/files/etc/services',
- incl => '/etc/services',
- lens => 'Services.lns',
- changes => [
- 'set service-name[. = "Doom"]/protocol "tcp"'
- ]
-}
-EOF
-
- on hosts, puppet_apply('--verbose'), stdin: manifest
- on hosts, "fgrep 'Doom 666/tcp' /etc/services"
- end
-
- step 'Remove the services entry' do
- manifest = <<EOF
-augeas { 'del_service_entry':
- context => '/files/etc/services',
- incl => '/etc/services',
- lens => 'Services.lns',
- changes => [
- 'rm service-name[. = "Doom"]'
- ]
-}
-EOF
-
- on hosts, puppet_apply('--verbose'), stdin: manifest
- on hosts, "fgrep 'Doom 666/tcp' /etc/services", acceptable_exit_codes: [1]
- end
- ensure
- on hosts, 'mv /tmp/services.bak /etc/services'
- end
-end
diff --git a/spec/acceptance/tests/hosts_spec.rb b/spec/acceptance/tests/hosts_spec.rb
new file mode 100644
index 0000000..db05f69
--- /dev/null
+++ b/spec/acceptance/tests/hosts_spec.rb
@@ -0,0 +1,60 @@
+require 'spec_helper_acceptance'
+
+RSpec.context 'Augeas hosts file' do
+ before(:all) do
+ on agents, 'cp /etc/hosts /tmp/hosts.bak'
+ end
+
+ after(:all) do
+ on agents, 'cat /tmp/hosts.bak > /etc/hosts && rm /tmp/hosts.bak'
+ end
+
+ agents.each do |agent|
+ context "on #{agent}" do
+ it 'creates an entry in the hosts file' do
+ on(agent, puppet_apply('--verbose'), stdin: <<MANIFEST)
+augeas { 'add_hosts_entry':
+ context => '/files/etc/hosts',
+ incl => '/etc/hosts',
+ lens => 'Hosts.lns',
+ changes => [
+ 'set 01/ipaddr 192.168.0.1',
+ 'set 01/canonical pigiron.example.com',
+ 'set 01/alias[1] pigiron',
+ 'set 01/alias[2] piggy'
+ ]
+}
+MANIFEST
+ on agent, "fgrep '192.168.0.1\tpigiron.example.com pigiron piggy' /etc/hosts"
+ end
+
+ it 'modifies an entry in the hosts file' do
+ on(hosts, puppet_apply('--verbose'), stdin: <<MANIFEST)
+augeas { 'mod_hosts_entry':
+ context => '/files/etc/hosts',
+ incl => '/etc/hosts',
+ lens => 'Hosts.lns',
+ changes => [
+ 'set *[canonical = "pigiron.example.com"]/alias[last()+1] oinker'
+ ]
+}
+MANIFEST
+ on hosts, "fgrep '192.168.0.1\tpigiron.example.com pigiron piggy oinker' /etc/hosts"
+ end
+
+ it 'removes an entry from the hosts file' do
+ on(hosts, puppet_apply('--verbose'), stdin: <<MANIFEST)
+augeas { 'del_hosts_entry':
+ context => '/files/etc/hosts',
+ incl => '/etc/hosts',
+ lens => 'Hosts.lns',
+ changes => [
+ 'rm *[canonical = "pigiron.example.com"]'
+ ]
+}
+MANIFEST
+ on hosts, "fgrep 'pigiron.example.com' /etc/hosts", acceptable_exit_codes: [1]
+ end
+ end
+ end
+end
diff --git a/spec/acceptance/tests/puppet_spec.rb b/spec/acceptance/tests/puppet_spec.rb
new file mode 100644
index 0000000..a65df19
--- /dev/null
+++ b/spec/acceptance/tests/puppet_spec.rb
@@ -0,0 +1,39 @@
+require 'spec_helper_acceptance'
+
+RSpec.context 'Augeas puppet configuration' do
+ before(:all) do
+ agents.each do |agent|
+ on agent, "mv #{agent.puppet['confdir']}/puppet.conf /tmp/puppet.conf.bak"
+ end
+ end
+
+ after(:all) do
+ agents.each do |agent|
+ on agent, "cat /tmp/puppet.conf.bak > #{agent.puppet['confdir']}/puppet.conf && rm /tmp/puppet.conf.bak"
+ end
+ end
+
+ agents.each do |agent|
+ context "on #{agent}" do
+ it 'creates a new puppet config that has a master and agent section' do
+ puppet_conf = <<CONF
+[main]
+CONF
+ on agent, "echo \"#{puppet_conf}\" >> #{agent.puppet['confdir']}/puppet.conf"
+ end
+
+ it 'modifies an existing puppet config' do
+ on(agent, puppet_apply('--verbose'), stdin: <<MANIFEST)
+augeas { 'puppet agent noop mode':
+ context => "/files#{agent.puppet['confdir']}/puppet.conf/agent",
+ incl => "/etc/puppetlabs/puppet/puppet.conf",
+ lens => 'Puppet.lns',
+ changes => 'set noop true',
+}
+MANIFEST
+
+ on agent, "grep 'noop=true' #{agent.puppet['confdir']}/puppet.conf"
+ end
+ end
+ end
+end
diff --git a/spec/acceptance/tests/services_spec.rb b/spec/acceptance/tests/services_spec.rb
new file mode 100644
index 0000000..03175e3
--- /dev/null
+++ b/spec/acceptance/tests/services_spec.rb
@@ -0,0 +1,60 @@
+require 'spec_helper_acceptance'
+
+RSpec.context 'Augeas services file' do
+ before(:all) do
+ on agents, 'cp /etc/services /tmp/services.bak'
+ end
+
+ after(:all) do
+ on agents, 'cat /tmp/services.bak > /etc/services && rm /tmp/services.bak'
+ end
+
+ agents.each do |agent|
+ context "on #{agent}" do
+ it 'adds an entry to the services file' do
+ on(hosts, puppet_apply('--verbose'), stdin: <<MANIFEST)
+augeas { 'add_services_entry':
+ context => '/files/etc/services',
+ incl => '/etc/services',
+ lens => 'Services.lns',
+ changes => [
+ 'ins service-name after service-name[last()]',
+ 'set service-name[last()] "Doom"',
+ 'set service-name[. = "Doom"]/port "666"',
+ 'set service-name[. = "Doom"]/protocol "udp"'
+ ]
+}
+MANIFEST
+ on hosts, "fgrep 'Doom 666/udp' /etc/services"
+ end
+
+ it 'changes the protocol to udp' do
+ on(hosts, puppet_apply('--verbose'), stdin: <<MANIFEST)
+augeas { 'change_service_protocol':
+ context => '/files/etc/services',
+ incl => '/etc/services',
+ lens => 'Services.lns',
+ changes => [
+ 'set service-name[. = "Doom"]/protocol "tcp"'
+ ]
+}
+MANIFEST
+ on hosts, "fgrep 'Doom 666/tcp' /etc/services"
+ end
+
+ it 'removes the services entry' do
+ on(hosts, puppet_apply('--verbose'), stdin: <<MANIFEST)
+augeas { 'del_service_entry':
+ context => '/files/etc/services',
+ incl => '/etc/services',
+ lens => 'Services.lns',
+ changes => [
+ 'rm service-name[. = "Doom"]'
+ ]
+}
+MANIFEST
+ on hosts, "fgrep 'Doom 666/tcp' /etc/services", acceptable_exit_codes: [1]
+ end
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index e117192..2d5f003 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,4 +1,3 @@
-
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
new file mode 100644
index 0000000..848f7d9
--- /dev/null
+++ b/spec/spec_helper_acceptance.rb
@@ -0,0 +1,13 @@
+require 'beaker-rspec'
+require 'beaker/module_install_helper'
+require 'beaker/puppet_install_helper'
+
+RSpec.configure do |c|
+ c.before :suite do
+ unless ENV['BEAKER_provision'] == 'no'
+ run_puppet_install_helper
+ install_module_on(hosts_as('default'))
+ install_module_dependencies_on(hosts)
+ end
+ end
+end