cucumber-chef 3.0.0.rc.0 → 3.0.0.rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,12 +24,12 @@ module Cucumber::Chef::Helpers::Chef
24
24
  ################################################################################
25
25
 
26
26
  def create_data_bag(data_bag, data_bag_path)
27
- $test_lab.knife_cli(%Q{data bag create "#{data_bag}"}, :silence => true)
28
- $test_lab.knife_cli(%Q{data bag from file "#{data_bag}" "#{data_bag_path}"}, :silence => true)
27
+ $cc_client.test_lab.knife_cli(%(data bag create "#{data_bag}"), :silence => true)
28
+ $cc_client.test_lab.knife_cli(%(data bag from file "#{data_bag}" "#{data_bag_path}"), :silence => true)
29
29
  end
30
30
 
31
31
  def delete_data_bag(data_bag)
32
- $test_lab.knife_cli(%Q{data bag delete "#{data_bag}" --yes}, :silence => true)
32
+ $cc_client.test_lab.knife_cli(%(data bag delete "#{data_bag}" --yes), :silence => true)
33
33
  end
34
34
 
35
35
  ################################################################################
@@ -37,10 +37,10 @@ module Cucumber::Chef::Helpers::Chef
37
37
  def role_from_file(role, role_path)
38
38
  if File.extname(role).empty?
39
39
  Dir.glob(File.join(role_path, "#{role}.*")).each do |role_file|
40
- $test_lab.knife_cli(%Q{role from file #{role_file}}, :silence => true)
40
+ $cc_client.test_lab.knife_cli(%(role from file #{role_file}), :silence => true)
41
41
  end
42
42
  else
43
- $test_lab.knife_cli(%Q{role from file #{File.join(role_path, role)}}, :silence => true)
43
+ $cc_client.test_lab.knife_cli(%(role from file #{File.join(role_path, role)}), :silence => true)
44
44
  end
45
45
  end
46
46
 
@@ -27,7 +27,7 @@ module Cucumber
27
27
  class ProviderError < Error; end
28
28
 
29
29
  class Provider
30
- PROXY_METHODS = %w(create destroy up halt reload status id state username ip port chef_server_api chef_server_webui alive? dead? exists?)
30
+ PROXY_METHODS = %w(create destroy up down reload status id state username ip port chef_server_api chef_server_webui alive? dead? exists?)
31
31
 
32
32
  ################################################################################
33
33
 
@@ -126,7 +126,7 @@ module Cucumber
126
126
  # HALT
127
127
  ################################################################################
128
128
 
129
- def halt
129
+ def down
130
130
  if (exists? && alive?)
131
131
  if !@server.stop
132
132
  raise AWSError, "Failed to halt the test lab!"
@@ -98,7 +98,7 @@ module Cucumber
98
98
  # HALT
99
99
  ################################################################################
100
100
 
101
- def halt
101
+ def down
102
102
  if (exists? && alive?)
103
103
  self.vagrant_cli("halt")
104
104
  else
@@ -139,7 +139,7 @@ module Cucumber
139
139
  def upload_cookbook
140
140
  @ui.logger.debug { "Uploading cucumber-chef cookbooks..." }
141
141
  ZTK::Benchmark.bench(:message => "Uploading 'cucumber-chef' cookbooks", :mark => "completed in %0.4f seconds.", :ui => @ui) do
142
- @test_lab.knife_cli(%Q{cookbook upload cucumber-chef -o #{@cookbooks_path}}, :silence => true)
142
+ @test_lab.knife_cli(%(cookbook upload cucumber-chef -o #{@cookbooks_path}), :silence => true)
143
143
  end
144
144
  end
145
145
 
@@ -148,7 +148,7 @@ module Cucumber
148
148
  def upload_role
149
149
  @ui.logger.debug { "Uploading cucumber-chef test lab role..." }
150
150
  ZTK::Benchmark.bench(:message => "Uploading 'cucumber-chef' roles", :mark => "completed in %0.4f seconds.", :ui => @ui) do
151
- @test_lab.knife_cli(%Q{role from file #{File.join(@roles_path, "test_lab.rb")}}, :silence => true)
151
+ @test_lab.knife_cli(%(role from file #{File.join(@roles_path, "test_lab.rb")}), :silence => true)
152
152
  end
153
153
  end
154
154
 
@@ -182,6 +182,7 @@ module Cucumber
182
182
  ZTK::Benchmark.bench(:message => "Rebooting the test lab", :mark => "completed in %0.4f seconds.", :ui => @ui) do
183
183
  command = "sudo reboot"
184
184
  @test_lab.bootstrap_ssh.exec(command, :silence => true)
185
+ sleep(10)
185
186
  ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => @test_lab.port, :wait => 120).wait
186
187
  end
187
188
 
@@ -50,12 +50,12 @@ And /^the following (cookbook|cookbooks) (has|have) been (updated|uploaded):$/ d
50
50
  end
51
51
 
52
52
  cookbooks.each do |cookbook_path, cookbooks|
53
- $test_lab.knife_cli(%Q{cookbook upload #{cookbooks.join(" ")} -o #{cookbook_path}}, :silence => true)
53
+ $cc_client.test_lab.knife_cli(%(cookbook upload #{cookbooks.join(" ")} -o #{cookbook_path}), :silence => true)
54
54
  end
55
55
  end
56
56
 
57
57
  And /^all of the cookbooks in "([^\"]*)" (has|have) been (updated|uploaded)$/ do |cookbook_path, ignore0, ignore1|
58
- $test_lab.knife_cli(%Q{cookbook upload -a -o #{cookbook_path}}, :silence => true)
58
+ $cc_client.test_lab.knife_cli(%(cookbook upload -a -o #{cookbook_path}), :silence => true)
59
59
  end
60
60
 
61
61
  ################################################################################
@@ -67,10 +67,10 @@ And /^the following (environment|environments) (has|have) been (updated|uploaded
67
67
 
68
68
  if File.extname(environment).empty?
69
69
  Dir.glob(File.join(environment_path, "#{environment}.*")).each do |environment_file|
70
- $test_lab.knife_cli(%Q{environment from file #{environment_file}}, :silence => true)
70
+ $cc_client.test_lab.knife_cli(%(environment from file #{environment_file}), :silence => true)
71
71
  end
72
72
  else
73
- $test_lab.knife_cli(%Q{environment from file #{File.join(environment_path, environment)}}, :silence => true)
73
+ $cc_client.test_lab.knife_cli(%(environment from file #{File.join(environment_path, environment)}), :silence => true)
74
74
  end
75
75
  end
76
76
  end
@@ -20,10 +20,10 @@
20
20
  ################################################################################
21
21
 
22
22
  When /^I enable the running of MiniTest suites for "(.*?)"$/ do |name|
23
- $test_lab.drb.enable_minitest(name)
23
+ $cc_client.test_lab.drb.enable_minitest(name)
24
24
  end
25
25
 
26
26
  Then /^the tests should run and pass on "(.*?)"$/ do |name|
27
- results = $test_lab.drb.run_minitests(name)
27
+ results = $cc_client.test_lab.drb.run_minitests(name)
28
28
  results.last.scan(/assertions.*(\d).*failures.*(\d).*errors.*(\d).*skips/).flatten.map { |v| v.to_i }.should == [0,0,0]
29
29
  end
@@ -11,7 +11,7 @@ When /^I have the following SSH sessions:$/ do |table|
11
11
  @ssh_sessions[id] and !@ssh_sessions[id].closed? and @ssh_sessions[id].close
12
12
  @ssh_sessions[id] = ZTK::SSH.new
13
13
 
14
- @ssh_sessions[id].config.proxy_host_name = $test_lab.ip
14
+ @ssh_sessions[id].config.proxy_host_name = $cc_client.test_lab.ip
15
15
  @ssh_sessions[id].config.proxy_user = Cucumber::Chef.lab_user
16
16
  @ssh_sessions[id].config.proxy_keys = Cucumber::Chef.lab_identity
17
17
 
@@ -32,8 +32,8 @@ When /^I ssh to "([^\"]*)" with the following credentials:$/ do |hostname, table
32
32
  @connection and @connection.ssh.shutdown!
33
33
  @connection = ZTK::SSH.new(:timeout => 120, :ignore_exit_status => true)
34
34
 
35
- @connection.config.proxy_host_name = $test_lab.ip
36
- @connection.config.proxy_port = $test_lab.port
35
+ @connection.config.proxy_host_name = $cc_client.test_lab.ip
36
+ @connection.config.proxy_port = $cc_client.test_lab.port
37
37
  @connection.config.proxy_user = Cucumber::Chef.lab_user
38
38
  @connection.config.proxy_keys = Cucumber::Chef.lab_identity
39
39
 
@@ -70,20 +70,20 @@ knife client create <%= @user %> -d -a -f ${HOME}/.chef/<%= @user %>.pem
70
70
 
71
71
  chown -R ${SUDO_USER}:${SUDO_USER} ${HOME}
72
72
 
73
- nc -w 1 127.0.0.1 4040
74
- if [ $? -ne 0 ]; then
75
- /etc/init.d/chef-server-webui stop && sleep 3
76
- /usr/sbin/chef-server-webui -e production &
77
- while true; do
78
- nc -w 1 127.0.0.1 4040
79
- if [ $? -eq 0 ]; then
80
- break
81
- fi
82
- sleep 1
83
- done
84
- kill `jobs -p` && sleep 3
85
- /etc/init.d/chef-server-webui start && sleep 3
86
- fi
73
+ # nc -w 1 127.0.0.1 4040
74
+ # if [ $? -ne 0 ]; then
75
+ # /etc/init.d/chef-server-webui stop && sleep 3
76
+ # /usr/sbin/chef-server-webui -e production &
77
+ # while true; do
78
+ # nc -w 1 127.0.0.1 4040
79
+ # if [ $? -eq 0 ]; then
80
+ # break
81
+ # fi
82
+ # sleep 1
83
+ # done
84
+ # kill `jobs -p` && sleep 3
85
+ # /etc/init.d/chef-server-webui start && sleep 3
86
+ # fi
87
87
 
88
88
  if [ ! -f /etc/chef/client.pem ]; then
89
89
  /etc/init.d/chef-client restart
@@ -18,79 +18,26 @@
18
18
  #
19
19
  ################################################################################
20
20
 
21
- tag = Cucumber::Chef.tag("cucumber-chef")
22
- puts(">>> #{tag}")
23
- Cucumber::Chef.boot(tag)
24
-
25
- $ui = ZTK::UI.new(:logger => Cucumber::Chef.logger)
26
- if !(($test_lab = Cucumber::Chef::TestLab.new($ui)) && $test_lab.alive?)
27
- message = "No running cucumber-chef test labs to connect to!"
28
- $ui.logger.fatal { message }
29
- raise message
30
- end
31
-
32
- if ENV['PURGE'] == 'YES'
33
- $ui.logger.warn { "PURGING CONTAINERS! Container attributes will be reset!" }
34
- $test_lab.containers.list.each do |name|
35
- ZTK::Benchmark.bench(:message => ">>> Destroying container '#{name}'", :mark => "completed in %0.4f seconds.") do
36
- $test_lab.containers.destroy(name)
37
- end
38
- end
39
- else
40
- $ui.logger.info { "Allowing existing containers to persist." }
41
- end
42
-
43
- $test_lab.containers.chef_set_client_config(:chef_server_url => "http://192.168.255.254:4000",
44
- :validation_client_name => "chef-validator")
45
-
46
- if ENV['SETUP'] == 'YES'
47
- # Upload all of the chef-repo environments
48
- ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo environments to the test lab", :mark => "completed in %0.4f seconds.") do
49
- $test_lab.knife_cli(%Q{environment from file ./environments/*.rb}, :silence => true)
50
- end
51
-
52
- # Upload all of the chef-repo cookbooks
53
- ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo cookbooks to the test lab", :mark => "completed in %0.4f seconds.") do
54
- cookbook_paths = ["./cookbooks"]
55
- cookbook_paths << "./site-cookbooks" if Cucumber::Chef::Config.librarian_chef
56
- $test_lab.knife_cli(%Q{cookbook upload --all --cookbook-path #{cookbook_paths.join(':')} --force}, :silence => true)
57
- end
58
-
59
- # Upload all of the chef-repo roles
60
- ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo roles to the test lab", :mark => "completed in %0.4f seconds.") do
61
- $test_lab.knife_cli(%Q{role from file ./roles/*.rb}, :silence => true)
62
- end
63
-
64
- # Upload all of our chef-repo data bags
65
- Dir.glob("./data_bags/*").each do |data_bag_path|
66
- next if !File.directory?(data_bag_path)
67
- ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo data bag '#{File.basename(data_bag_path)}' to the test lab", :mark => "completed in %0.4f seconds.") do
68
- data_bag = File.basename(data_bag_path)
69
- $test_lab.knife_cli(%Q{data bag create "#{data_bag}"}, :silence => true)
70
- $test_lab.knife_cli(%Q{data bag from file "#{data_bag}" "#{data_bag_path}"}, :silence => true)
71
- end
72
- end
73
-
74
- Cucumber::Chef::Container.all.each do |container|
75
- ZTK::Benchmark.bench(:message => ">>> Creating container '#{container.name}'", :mark => "completed in %0.4f seconds.") do
76
- $test_lab.containers.create(container)
77
- end
78
- ZTK::Benchmark.bench(:message => ">>> Provisioning container '#{container.name}'", :mark => "completed in %0.4f seconds.") do
79
- $test_lab.containers.chef_run_client(container)
80
- end
81
- end
82
- end
83
-
21
+ $cc_client = Cucumber::Chef::Client.new
22
+ $cc_client.up
84
23
 
85
24
  ################################################################################
86
25
  # HOOKS
87
26
  ################################################################################
88
27
 
89
28
  Before do |scenario|
29
+ $cc_client.before(scenario)
90
30
  end
91
31
 
92
32
  After do |scenario|
93
33
  @connection and @connection.ssh.shutdown!
34
+ $cc_client.after(scenario)
35
+ end
36
+
37
+ ################################################################################
38
+
39
+ Kernel.at_exit do
40
+ $cc_client.at_exit
94
41
  end
95
42
 
96
43
  ################################################################################
@@ -24,7 +24,7 @@ module Cucumber
24
24
 
25
25
  ################################################################################
26
26
 
27
- VERSION = "3.0.0.rc.0" unless const_defined?(:VERSION)
27
+ VERSION = "3.0.0.rc.1" unless const_defined?(:VERSION)
28
28
 
29
29
  ################################################################################
30
30
 
@@ -12,9 +12,9 @@ namespace :cc do
12
12
  puts("feature_dir(#{dir.inspect})")
13
13
  puts("=" * 80)
14
14
 
15
- system(%Q{echo "<li /><p>#{File.basename(dir)}<ul>" | tee -a #{@index_html}})
15
+ system(%(echo "<li /><p>#{File.basename(dir)}<ul>" | tee -a #{@index_html}))
16
16
  block.call
17
- system(%Q{echo "</p></ul>" | tee -a #{@index_html}})
17
+ system(%(echo "</p></ul>" | tee -a #{@index_html}))
18
18
  end
19
19
 
20
20
  def run_feature(feature_file)
@@ -25,9 +25,9 @@ namespace :cc do
25
25
  filename = feature_file.gsub(/(\w*).feature/, '\1.html')
26
26
  puts("#{feature_file} -> public/#{filename}")
27
27
 
28
- system(%Q{mkdir -pv #{File.dirname("public/#{filename}")}})
28
+ system(%(mkdir -pv #{File.dirname("public/#{filename}")}))
29
29
 
30
- push = (@pushed ? nil : %Q{SETUP="YES"})
30
+ push = (@pushed ? nil : %(PUSH="YES"))
31
31
  output_file = File.join(@output_dir, filename)
32
32
  command = [push, "bundle exec cucumber", "features/support", feature_file, ENV['EXTRA_CUCUMBER_ARGS'], "--format html", "--out", output_file].flatten.compact.join(" ")
33
33
  @pushed = true if !@pushed
@@ -39,7 +39,7 @@ namespace :cc do
39
39
  failed = "<font style='font-weight: bold; color: red;'>FAILED</font>"
40
40
  status = ((@exit_codes[-1] == 0) ? passed : failed)
41
41
 
42
- system(%Q{echo "<li /><a href='#{filename}'>#{File.basename(filename.gsub('.html', ''))}</a> (#{status})" | tee -a #{@index_html}})
42
+ system(%(echo "<li /><a href='#{filename}'>#{File.basename(filename.gsub('.html', ''))}</a> (#{status})" | tee -a #{@index_html}))
43
43
  end
44
44
 
45
45
  @output_dir = File.join(Dir.pwd, "public")
@@ -48,14 +48,14 @@ namespace :cc do
48
48
  @exit_codes = Array.new
49
49
 
50
50
  puts("Cleaning up...")
51
- system(%Q{rm -rfv .cucumber-chef/aws/artifacts})
52
- system(%Q{rm -rfv public})
53
- system(%Q{mkdir -v public})
51
+ system(%(rm -rfv .cucumber-chef/aws/artifacts))
52
+ system(%(rm -rfv public))
53
+ system(%(mkdir -v public))
54
54
 
55
55
  puts("Generating Cucumber-Chef html reports...")
56
56
 
57
- system(%Q{echo "<html><head><title>Cucumber-Chef Report</title></head><body>" | tee public/index.html})
58
- system(%Q{echo "<h2>Cucumber-Chef Report</h2><ul>" | tee -a public/index.html})
57
+ system(%(echo "<html><head><title>Cucumber-Chef Report</title></head><body>" | tee public/index.html))
58
+ system(%(echo "<h2>Cucumber-Chef Report</h2><ul>" | tee -a public/index.html))
59
59
  Dir.glob("features/*").each do |fdir|
60
60
  if File.directory?(fdir)
61
61
  if (ffiles = Dir.glob("#{fdir}/*.feature")).count > 0
@@ -69,7 +69,7 @@ namespace :cc do
69
69
  run_feature(fdir)
70
70
  end
71
71
  end
72
- system(%Q{echo "</ul></body></html>" | tee -a public/index.html})
72
+ system(%(echo "</ul></body></html>" | tee -a public/index.html))
73
73
 
74
74
  # If we had a failure be sure to surface it
75
75
  exit_code = (@exit_codes.any?{ |ec| ec != 0 } ? 1 : 0)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc.0
4
+ version: 3.0.0.rc.1
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-13 00:00:00.000000000 Z
13
+ date: 2013-03-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog
@@ -131,7 +131,7 @@ dependencies:
131
131
  requirements:
132
132
  - - ! '>='
133
133
  - !ruby/object:Gem::Version
134
- version: 1.0.3
134
+ version: 1.0.8
135
135
  type: :runtime
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
@@ -139,7 +139,7 @@ dependencies:
139
139
  requirements:
140
140
  - - ! '>='
141
141
  - !ruby/object:Gem::Version
142
- version: 1.0.3
142
+ version: 1.0.8
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: simplecov
145
145
  requirement: !ruby/object:Gem::Requirement
@@ -225,6 +225,7 @@ files:
225
225
  - README.md
226
226
  - Rakefile
227
227
  - TODO.md
228
+ - WIKI.2.x.md
228
229
  - WIKI.md
229
230
  - bin/cc-console
230
231
  - bin/cc-knife