cucumber-chef 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Build Status](https://secure.travis-ci.org/zpatten/cucumber-chef.png)](http://travis-ci.org/zpatten/cucumber-chef)
|
1
|
+
[![Build Status](https://secure.travis-ci.org/zpatten/cucumber-chef.png)](http://travis-ci.org/zpatten/cucumber-chef) [![Dependency Status](https://gemnasium.com/jovelabs/cucumber-chef.png)](https://gemnasium.com/jovelabs/cucumber-chef)
|
2
2
|
|
3
3
|
Cucumber-chef is a library of tools to enable the emerging discipline of infrastructure as code to practice test driven development. It provides a testing platform within which Cucumber tests can be run which provision virtual machines, configure them by applying the appropriate Chef roles to them, and then run acceptance and integration tests against the environment.
|
4
4
|
|
data/bin/cucumber-chef
CHANGED
@@ -178,30 +178,67 @@ class CucumberChef < Thor
|
|
178
178
|
|
179
179
|
################################################################################
|
180
180
|
|
181
|
-
desc "teardown", "Teardown cucumber-chef test lab in Amazon EC2"
|
181
|
+
desc "teardown [container]", "Teardown the cucumber-chef test lab in Amazon EC2 or a test lab [container] if specified."
|
182
182
|
method_option :test, :type => :boolean, :desc => "INTERNAL USE ONLY"
|
183
|
-
def teardown
|
183
|
+
def teardown(*args)
|
184
184
|
load_config
|
185
185
|
|
186
186
|
puts
|
187
187
|
if (test_lab = Cucumber::Chef::TestLab.new)
|
188
|
-
if
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
188
|
+
if args.count == 0
|
189
|
+
if yes?(set_color("Are you sure you want to teardown your cucumber-chef test lab?", :red, true))
|
190
|
+
count_down_colors = { 5 => :green, 4 => :yellow, 3 => :yellow, 2 => :red, 1 => :red }
|
191
|
+
puts
|
192
|
+
puts(set_color("You have 5 seconds to abort!", :green, true))
|
193
|
+
puts
|
194
|
+
print(set_color("Self-destructing in", :green, true))
|
195
|
+
5.downto(1) do |x|
|
196
|
+
print(set_color("...#{x}", count_down_colors[x], true))
|
197
|
+
sleep(1)
|
198
|
+
end
|
199
|
+
puts(set_color("...BOOM!", :red, true))
|
200
|
+
puts
|
201
|
+
test_lab.destroy
|
202
|
+
else
|
203
|
+
puts
|
204
|
+
puts(set_color("Whew! That was close!", :green, true))
|
197
205
|
end
|
198
|
-
puts(set_color("...BOOM!", :red, true))
|
199
|
-
puts
|
200
|
-
test_lab.destroy
|
201
206
|
else
|
202
|
-
|
203
|
-
|
207
|
+
container = args[0]
|
208
|
+
if yes?(set_color("Are you sure you want to teardown the test lab containter '#{container}'?", :red, true))
|
209
|
+
count_down_colors = { 5 => :green, 4 => :yellow, 3 => :yellow, 2 => :red, 1 => :red }
|
210
|
+
puts
|
211
|
+
puts(set_color("You have 5 seconds to abort!", :green, true))
|
212
|
+
puts
|
213
|
+
print(set_color("Self-destructing in", :green, true))
|
214
|
+
5.downto(1) do |x|
|
215
|
+
print(set_color("...#{x}", count_down_colors[x], true))
|
216
|
+
sleep(1)
|
217
|
+
end
|
218
|
+
puts(set_color("...BOOM!", :red, true))
|
219
|
+
puts
|
220
|
+
|
221
|
+
ssh = ZTK::SSH.new
|
222
|
+
ssh.config.host_name = test_lab.labs_running.first.public_ip_address
|
223
|
+
ssh.config.user = "ubuntu"
|
224
|
+
ssh.config.keys = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{ssh.config.user}")
|
225
|
+
ssh.exec("nohup sudo pkill -9 -f cc-server")
|
226
|
+
ssh.exec("nohup sudo BACKGROUND=yes cc-server #{Cucumber::Chef.external_ip}")
|
227
|
+
Cucumber::Chef.spinner do
|
228
|
+
ZTK::TCPSocketCheck.new(:host => test_lab.labs_running.first.public_ip_address, :port => 8787, :data => "\n\n").wait
|
229
|
+
end
|
230
|
+
|
231
|
+
# initialize our drb object
|
232
|
+
test_lab_drb ||= DRbObject.new_with_uri("druby://#{test_lab.labs_running.first.public_ip_address}:8787")
|
233
|
+
test_lab_drb and DRb.start_service
|
234
|
+
test_lab_drb.servers = Hash.new(nil)
|
235
|
+
test_lab_drb.server_destroy(container)
|
236
|
+
else
|
237
|
+
puts
|
238
|
+
puts(set_color("Whew! That was close!", :green, true))
|
239
|
+
end
|
204
240
|
end
|
241
|
+
|
205
242
|
else
|
206
243
|
puts(set_color("Could not find a cucumber-chef test lab to teardown!", :red, true))
|
207
244
|
end
|
data/lib/cucumber/chef.rb
CHANGED
@@ -26,7 +26,6 @@ module Cucumber::Chef::Helpers::ChefClient
|
|
26
26
|
# call this in a Before hook
|
27
27
|
def chef_set_client_config(config={})
|
28
28
|
@chef_client_config = (@chef_client_config || {
|
29
|
-
:environment => "_default",
|
30
29
|
:log_level => :debug,
|
31
30
|
:log_location => "/var/log/chef/client.log",
|
32
31
|
:chef_server_url => "https://api.opscode.com/organizations/#{config[:orgname]}",
|
@@ -66,7 +65,7 @@ module Cucumber::Chef::Helpers::ChefClient
|
|
66
65
|
f.puts("ssl_verify_mode :verify_none")
|
67
66
|
f.puts("validation_client_name \"#{@chef_client_config[:validation_client_name]}\"")
|
68
67
|
f.puts("node_name \"#{name}\"")
|
69
|
-
f.puts("environment \"#{@chef_client_config[:environment]}\"")
|
68
|
+
f.puts("environment \"#{@chef_client_config[:environment]}\"") if @chef_client_config[:environment]
|
70
69
|
f.puts
|
71
70
|
f.puts("Mixlib::Log::Formatter.show_time = true")
|
72
71
|
end
|
@@ -8,6 +8,9 @@ Feature: Perform test driven infrastructure with Cucumber-Chef
|
|
8
8
|
* I have a server called "<%= @project %>"
|
9
9
|
* "<%= @project %>" is running "ubuntu" "precise"
|
10
10
|
* "<%= @project %>" has been provisioned
|
11
|
+
* the following cookbooks have been uploaded:
|
12
|
+
| cookbook | cookbook_path |
|
13
|
+
| chef-client | ./cookbooks |
|
11
14
|
* the "chef-client::service" recipe has been added to the "<%= @project %>" run list
|
12
15
|
* the chef-client has been run on "<%= @project %>"
|
13
16
|
* I ssh to "<%= @project %>" with the following credentials:
|
@@ -24,7 +24,7 @@ module Cucumber
|
|
24
24
|
|
25
25
|
################################################################################
|
26
26
|
|
27
|
-
VERSION = "2.0.
|
27
|
+
VERSION = "2.0.7" unless const_defined?(:VERSION)
|
28
28
|
|
29
29
|
################################################################################
|
30
30
|
|