summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-10-07 10:53:53 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-10-07 10:53:53 -0700
commit8b6ba0b0e988544886e9f70e33dfc066e87dce80 (patch)
tree69b83d535626fed18572baca6c0612df4e5dc2d7
parentcbb9ae97e2d3d90b28764fbb23cb8eab4dda4ec8 (diff)
downloadchef-8b6ba0b0e988544886e9f70e33dfc066e87dce80.tar.gz
serverspec 2 fixes to e2e tests
also some cleanup in the os-detection
-rw-r--r--kitchen-tests/test/fixtures/serverspec_helper.rb79
-rw-r--r--kitchen-tests/test/integration/webapp/serverspec/localhost/default_spec.rb6
2 files changed, 21 insertions, 64 deletions
diff --git a/kitchen-tests/test/fixtures/serverspec_helper.rb b/kitchen-tests/test/fixtures/serverspec_helper.rb
index 3a2c05f9cf..6e6d71e79b 100644
--- a/kitchen-tests/test/fixtures/serverspec_helper.rb
+++ b/kitchen-tests/test/fixtures/serverspec_helper.rb
@@ -5,70 +5,27 @@
require 'serverspec'
require 'json'
-include SpecInfra::Helper::Exec
-include SpecInfra::Helper::DetectOS
-include SpecInfra::Helper::Properties
+set :backend, :exec
-# http://serverspec.org/advanced_tips.html
-# os[:family] # RedHat, Ubuntu, Debian and so on
-# os[:release] # OS release version (cleaned up in v2)
-# os[:arch]
-osmapping = {
-# 'RedHat' => {
-# :platform_family => 'rhel',
-# :platform => 'centos',
-# :platform_version => '6.5'
-# },
-# 'RedHat7' => {
-# :platform_family => 'rhel',
-# :platform => 'centos',
-# :platform_version => '7.0'
-# },
-# 'Fedora' => {
-# :platform_family => 'rhel',
-# :platform => 'fedora',
-# :platform_version => '20'
-# },
- 'Ubuntu' => {
- :platform_family => 'debian',
- :platform => 'ubuntu',
- :platform_version => '12.04'
- }
-# 'Debian' => {
-# :platform_family => 'debian',
-# :platform => 'debian',
-# :platform_version => '7.4'
-# },
-# 'FreeBSD' => {
-# :platform_family => 'freebsd',
-# :platform => 'freebsd',
-# :platform_version => '9.2'
-# }
-}
+include Specinfra::Helper::Properties
-def ohai_platform(os, osmapping)
- puts "serverspec os detected as: #{os[:family]} #{os[:release]} [#{os[:arch]}]"
- ohaistub = {}
- ohaistub[:platform_family] = osmapping[os[:family]][:platform_family]
- ohaistub[:platform] = osmapping[os[:family]][:platform]
- if os[:release]
- ohaistub[:platform_version] = os[:release]
- else
- ohaistub[:platform_version] = osmapping[os[:family]][:platform_version]
+require 'pp'
+pp os
+
+def load_nodestub
+ case os[:family]
+ when 'ubuntu', 'debian'
+ platform = os[:family]
+ platform_version = os[:release]
+ when 'redhat'
+ platform = 'centos'
+ platform_version = os[:release].to_i
end
- ohaistub
+ JSON.parse(IO.read("#{ENV['BUSSER_ROOT']}/../kitchen/data/platforms/#{platform}/#{platform_version}.json"), :symbolize_names => true)
end
-def load_nodestub(ohai)
- puts "loading #{ohai[:platform]}/#{ohai[:platform_version]}"
- JSON.parse(IO.read("#{ENV['BUSSER_ROOT']}/../kitchen/data/platforms/#{ohai[:platform]}/#{ohai[:platform_version]}.json"), :symbolize_names => true)
-end
+# centos-59 doesn't have /sbin in the default path,
+# so we must ensure it's on serverspec's path
+set :path, '$PATH:/sbin'
-RSpec.configure do |config|
- set_property load_nodestub(ohai_platform(backend.check_os, osmapping))
- config.before(:all) do
- # centos-59 doesn't have /sbin in the default path,
- # so we must ensure it's on serverspec's path
- config.path = '/sbin'
- end
-end
+set_property load_nodestub
diff --git a/kitchen-tests/test/integration/webapp/serverspec/localhost/default_spec.rb b/kitchen-tests/test/integration/webapp/serverspec/localhost/default_spec.rb
index f8e83829a4..05da3ff337 100644
--- a/kitchen-tests/test/integration/webapp/serverspec/localhost/default_spec.rb
+++ b/kitchen-tests/test/integration/webapp/serverspec/localhost/default_spec.rb
@@ -67,13 +67,13 @@ describe "webapp::default", :end_to_end => true do
let(:db_query) { "mysql -u root -pilikerandompasswordstoo -e \"#{statement}\"" }
let(:statement) { "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='webapp'" }
it "creates a database called 'webapp'" do
- expect(command(db_query)).to return_stdout(/webapp/)
+ expect(command(db_query).stdout).to match /webapp/
end
describe "mysql database user 'webapp'" do
let(:statement) { "SELECT Host, Db FROM mysql.db WHERE User='webapp'\\G" }
it "adds user 'webapp' to database 'webapp@localhost'" do
- expect(command(db_query)).to return_stdout(/Host: localhost\n Db: webapp/)
+ expect(command(db_query).stdout).to match /Host: localhost\n Db: webapp/
end
describe "grants" do
@@ -86,7 +86,7 @@ describe "webapp::default", :end_to_end => true do
let(:priv_query) { "#{priv.capitalize}_priv" }
it "has privilege #{priv} on 'webapp@localhost'" do
- expect(command(db_query)).to return_stdout(/#{priv_query}: Y/)
+ expect(command(db_query).stdout).to match /#{priv_query}: Y/
end
end