From 756e439447a9d9e948eab420818cd2ce944e69c5 Mon Sep 17 00:00:00 2001 From: Rianol Jou Date: Fri, 2 Dec 2016 18:43:58 +0800 Subject: [PATCH] Fix acceptance test --- spec/acceptance/standard_spec.rb | 27 +++++++++++++++++---------- spec/acceptance/unsupported_spec.rb | 10 ---------- spec/spec_helper_acceptance.rb | 3 ++- tests/init.pp | 14 +------------- 4 files changed, 20 insertions(+), 34 deletions(-) delete mode 100644 spec/acceptance/unsupported_spec.rb diff --git a/spec/acceptance/standard_spec.rb b/spec/acceptance/standard_spec.rb index 13d8085..f74102c 100644 --- a/spec/acceptance/standard_spec.rb +++ b/spec/acceptance/standard_spec.rb @@ -3,17 +3,24 @@ describe 'nomad class' do context 'default parameters' do - # Using puppet_apply as a helper + apply_manifest_opts = { + :catch_failures => true, + :debug => true, + } it 'should work with no errors based on the example' do pp = <<-EOS + package { 'unzip': } + -> class { 'nomad': - version => '0.2.3', + version => '0.5.0', config_hash => { - "region" => 'us-west', - "datacenter" => 'ptk', - "log_level" => 'INFO', - "bind_dir" => "0.0.0.0", - "data_dir" => "/var/lib/nomad", + "bind_addr" => "0.0.0.0", + "data_dir" => "/opt/nomad", + "advertise" => { + "http" => "127.0.0.1:4646", + "rpc" => "127.0.0.1:4647", + "serf" => "127.0.0.1:4648", + }, "server" => { "enabled" => true, "bootstrap_expect" => 1 @@ -23,8 +30,8 @@ class { 'nomad': EOS # Run it twice and test for idempotency - expect(apply_manifest(pp).exit_code).to_not eq(1) - expect(apply_manifest(pp).exit_code).to eq(0) + expect(apply_manifest(pp, apply_manifest_opts).exit_code).to_not eq(1) + expect(apply_manifest(pp, apply_manifest_opts).exit_code).to eq(0) end describe file('/opt/nomad') do @@ -36,7 +43,7 @@ class { 'nomad': end describe command('nomad version') do - its(:stdout) { should match /Nomad v0\.2\.3/ } + its(:stdout) { should match /Nomad v0\.5\.0/ } end end diff --git a/spec/acceptance/unsupported_spec.rb b/spec/acceptance/unsupported_spec.rb deleted file mode 100644 index 801d72e..0000000 --- a/spec/acceptance/unsupported_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -#require 'spec_helper_acceptance' -# -#describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do -# it 'should fail' do -# pp = <<-EOS -# class { 'nomad': } -# EOS -# expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i) -# end -#end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 5b44adc..0bdfc8d 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -14,8 +14,9 @@ # Configure all nodes in nodeset c.before :suite do # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'nomad') + puppet_module_install(:source => proj_root, :module_name => 'nomad', :target_module_path => '/etc/puppetlabs/code/modules') hosts.each do |host| + puts host on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } on host, puppet('module', 'install', 'puppet-archive'), { :acceptable_exit_codes => [0,1] } end diff --git a/tests/init.pp b/tests/init.pp index a95a060..1817370 100644 --- a/tests/init.pp +++ b/tests/init.pp @@ -9,16 +9,4 @@ # Learn more about module testing here: # http://docs.puppetlabs.com/guides/tests_smoke.html # -class { 'nomad': - config_hash => { - "region" => 'us-west', - "datacenter" => 'ptk', - "log_level" => 'INFO', - "bind_dir" => "0.0.0.0", - "data_dir" => "/var/lib/nomad", - "server" => { - "enabled" => true, - "bootstrap_expect" => 1 - } - } -} +include nomad