Skip to content

Commit

Permalink
Merge pull request Atalanta#13 from zts/fix-test_lab_tests
Browse files Browse the repository at this point in the history
Fix test failures in test_lab_spec.rb
  • Loading branch information
Bix27 committed Jun 24, 2011
2 parents 335da81 + 1ae7e9f commit a96a502
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
16 changes: 7 additions & 9 deletions lib/cucumber/chef/test_lab.rb
Expand Up @@ -38,12 +38,12 @@ def build(output)

def destroy
running_labs.each do |server|
#server.destroy
puts server.public_ip_address
puts "Destroying Server: #{server.public_ip_address}"
server.destroy
end
nodes.each do |node|
puts "Not destroying Node: #{node[:ec2][:public_ipv4]}"
# node.destroy
puts node[:ec2][:public_ipv4]
end
end

Expand All @@ -52,21 +52,19 @@ def exists?
end

def info
"#{node.name}: #{node[:ec2][:public_ipv4]}"
running_labs.first.public_ip_address
end

def public_hostname
node.cloud.public_hostname
nodes.first.cloud.public_hostname
end

def node
@node ||= begin
def nodes
search = ::Chef::Search::Query.new
mode = @config[:mode]
query = "roles:test_lab_test AND tags:#{mode}"
nodes, offset, total = search.search("node", URI.escape(query))
nodes.compact.first
end
nodes.compact
end

def running_labs
Expand Down
20 changes: 19 additions & 1 deletion spec/unit/test_lab_spec.rb
Expand Up @@ -2,6 +2,24 @@
require "bundler/setup"
require File.join(File.dirname(__FILE__), "../../lib/cucumber-chef")

def tcp_test_ssh(hostname)
tcp_socket = TCPSocket.new(hostname, 22)
IO.select([tcp_socket], nil, nil, 5)
rescue Errno::ETIMEDOUT
false
rescue Errno::EPERM
false
rescue Errno::ECONNREFUSED
sleep 2
false
# This happens on EC2 quite often
rescue Errno::EHOSTUNREACH
sleep 2
false
ensure
tcp_socket && tcp_socket.close
end

describe Cucumber::Chef::TestLab do
before(:all) do
@config = Cucumber::Chef::Config.test_config
Expand Down Expand Up @@ -47,7 +65,7 @@
sleep(10)
provisioner.upload_cookbook(@config)
provisioner.upload_role(@config)
provisioner.bootstrap_node(@dns_name, @config).run
provisioner.bootstrap_node(@dns_name, @config)
end

after(:each) { subject.destroy }
Expand Down

0 comments on commit a96a502

Please sign in to comment.