Permalink
Browse files

Integration testing that asserts apache is up and running.

Only using on Ubuntu for now.
  • Loading branch information...
1 parent 6a4e0ea commit f71a596a825e3a8a9f72d24da08feaed9e971aba @matschaffer committed May 14, 2012
Showing with 51 additions and 6 deletions.
  1. +8 −0 Gemfile.lock
  2. +1 −0 knife-solo.gemspec
  3. +1 −1 test/integration/ubuntu10_04_test.rb
  4. +41 −5 test/integration_helper.rb
View
@@ -3,12 +3,14 @@ PATH
specs:
knife-solo (0.1.0)
chef (~> 0.10.0)
+ librarian (~> 0.0.20)
net-ssh (>= 2.1.3, < 2.3.0)
GEM
remote: http://rubygems.org/
specs:
alias (0.2.2)
+ archive-tar-minitar (0.5.2)
awesome_print (0.4.0)
boson (0.3.3)
alias (>= 0.2.2)
@@ -82,6 +84,11 @@ GEM
wirb (>= 0.3.0)
zucker (>= 11)
json (1.6.1)
+ librarian (0.0.20)
+ archive-tar-minitar (>= 0.5.2)
+ chef (>= 0.10)
+ highline
+ thor
linecache (0.46)
rbx-require-relative (> 0.0.4)
method_source (0.6.7)
@@ -140,6 +147,7 @@ GEM
slop (2.1.0)
spoon (0.0.1)
systemu (2.5.0)
+ thor (0.15.0)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
View
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
s.add_dependency 'chef', '~> 0.10.0'
s.add_dependency 'net-ssh', '>= 2.1.3', '< 2.3.0'
+ s.add_dependency 'librarian', '~> 0.0.20'
s.files = Dir['lib/**/*']
@@ -9,5 +9,5 @@ def image_id
"ami-6936fb00"
end
- include IntegrationTest::BasicPrepareAndCook
+ include IntegrationTest::CookApache2
end
View
@@ -2,6 +2,7 @@
require 'pathname'
require 'logger'
require 'yaml'
+require 'net/http'
MiniTest::Parallel.processor_count = 5
@@ -113,17 +114,52 @@ def teardown
super
end
- def run_subcommand(subcommand)
+ def assert_subcommand(subcommand)
verbose = ENV['VERBOSE'] && "-VV"
system "knife #{subcommand} -i #{key_file} #{user}@#{server.public_ip_address} #{verbose} >> #{log_file}"
+ assert $?.success?
end
def test_prepare_and_cook
Dir.chdir(@kitchen) do
- run_subcommand("prepare")
- assert $?.success?
- run_subcommand("cook")
- assert $?.success?
+ assert_subcommand "prepare"
+ assert_subcommand "cook"
+ end
+ end
+ end
+
+ module CookApache2
+ include BasicPrepareAndCook
+
+ def write_cheffile
+ File.open('Cheffile', 'w') do |f|
+ f.print <<-CHEF
+ site 'http://community.opscode.com/api/v1'
+ cookbook 'apache2'
+ CHEF
+ end
+ end
+
+ def write_nodefile
+ File.open("nodes/#{server.public_ip_address}.json", 'w') do |f|
+ f.print <<-JSON
+ { "run_list": ["recipe[apache2]"] }
+ JSON
+ end
+ end
+
+ def http_response
+ Net::HTTP.get(URI.parse("http://"+server.public_ip_address))
+ end
+
+ def test_apache2
+ Dir.chdir(@kitchen) do
+ write_cheffile
+ system "librarian-chef install >> #{log_file}"
+ assert_subcommand "prepare"
+ write_nodefile
+ assert_subcommand "cook"
+ assert_match http_response, 'It works!'
end
end
end

0 comments on commit f71a596

Please sign in to comment.