cucumber-chef 2.1.0.rc.6 → 2.1.0.rc.7

Sign up to get free protection for your applications and to get access to all the features.
data/bin/cc-knife CHANGED
@@ -4,12 +4,12 @@ require 'cucumber-chef'
4
4
  # if we have bundler binstubs use that; otherwise attempt to detect
5
5
  knife = (Cucumber::Chef.locate(:file, "bin", "knife") rescue "/usr/bin/env knife")
6
6
 
7
- message = "cc-knife v#{Cucumber::Chef::VERSION}"
8
- puts(message)
9
- Cucumber::Chef.logger.info { message }
7
+ tag = Cucumber::Chef.tag("cc-knife")
8
+ puts(tag)
9
+ Cucumber::Chef.boot(tag)
10
10
 
11
- Cucumber::Chef::Config.load
12
- if (test_lab = Cucumber::Chef::TestLab.new) && test_lab.alive?
11
+ ui = ZTK::UI.new(:logger => Cucumber::Chef.logger)
12
+ if (test_lab = Cucumber::Chef::TestLab.new(ui)) && test_lab.alive?
13
13
 
14
14
  knife_rb = Cucumber::Chef.knife_rb
15
15
  if File.exists?(knife_rb)
data/bin/cc-push CHANGED
@@ -4,14 +4,14 @@ require 'cucumber-chef'
4
4
  tag = Cucumber::Chef.tag("cc-push")
5
5
  puts(tag)
6
6
  Cucumber::Chef.boot(tag)
7
- $logger = Cucumber::Chef.logger
8
7
 
9
- if ($test_lab = Cucumber::Chef::TestLab.new) && $test_lab.alive?
8
+ ui = ZTK::UI.new(:logger => Cucumber::Chef.logger)
9
+ if (test_lab = Cucumber::Chef::TestLab.new(ui)) && test_lab.alive?
10
10
  gem_name = "cucumber-chef-#{Cucumber::Chef::VERSION}.gem"
11
11
  gem_path = File.join(Cucumber::Chef.root_dir, gem_name)
12
12
 
13
- $logger.info { "gem_name == '#{gem_name}'" }
14
- $logger.info { "gem_path == '#{gem_path}'" }
13
+ ui.logger.info { "gem_name == '#{gem_name}'" }
14
+ ui.logger.info { "gem_path == '#{gem_path}'" }
15
15
 
16
16
  if !File.exists?(gem_path)
17
17
  puts
@@ -21,13 +21,13 @@ if ($test_lab = Cucumber::Chef::TestLab.new) && $test_lab.alive?
21
21
  puts
22
22
  else
23
23
  local_file = File.join(Cucumber::Chef.root_dir, gem_name)
24
- remote_file = File.join("/", "home", $test_lab.ssh.config.user, gem_name)
25
- $logger.info { "#{local_file} -> #{$test_lab.ssh.config.user}@#{$test_lab.ip}:#{remote_file}" }
24
+ remote_file = File.join("/", "home", test_lab.bootstrap_ssh.config.user, gem_name)
25
+ ui.logger.info { "#{local_file} -> #{test_lab.bootstrap_ssh.config.user}@#{test_lab.ip}:#{remote_file}" }
26
26
 
27
- $test_lab.ssh.upload(local_file, remote_file)
27
+ test_lab.bootstrap_ssh.upload(local_file, remote_file)
28
28
  FileUtils.rm_f(File.join(Cucumber::Chef.root_dir, "*.gem"))
29
29
 
30
- $test_lab.ssh.exec(<<-EOH
30
+ test_lab.bootstrap_ssh.exec(<<-EOH
31
31
  sudo /bin/bash -c '
32
32
  pkill -9 cc-server
33
33
  cd #{File.dirname(remote_file)}
@@ -36,11 +36,11 @@ gem uninstall cucumber-chef ztk --all --ignore-dependencies --executables --back
36
36
  rm -fv /usr/lib/ruby/gems/1.8/cache/#{gem_name}
37
37
  gem cleanup cucumber-chef --backtrace
38
38
  gem install #{remote_file} --backtrace
39
- rm -fv /home/#{$test_lab.ssh.config.user}/*.gem
39
+ rm -fv /home/#{test_lab.bootstrap_ssh.config.user}/*.gem
40
40
  exit 0'
41
41
  EOH
42
42
  )
43
- File.exists?(gem_path) && File.delete(gem_path)
43
+ File.exists?(gem_path) and File.delete(gem_path)
44
44
  end
45
45
 
46
46
  else
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
51
51
  s.add_dependency("rake", ">= 0.9.2")
52
52
  s.add_dependency("thor", ">= 0.15.2")
53
53
  s.add_dependency("ubuntu_ami", ">= 0.4.0")
54
- s.add_dependency("ztk", ">= 0.0.15")
54
+ s.add_dependency("ztk", ">= 1.0.0")
55
55
 
56
56
  s.add_development_dependency("simplecov", ">= 0.6.4")
57
57
  s.add_development_dependency("pry", ">= 0")
@@ -24,15 +24,13 @@ module Cucumber
24
24
  class ClientError < Error; end
25
25
 
26
26
  class Client
27
- attr_accessor :test_lab, :stdout, :stderr, :stdin, :logger
27
+ attr_accessor :test_lab
28
28
 
29
29
  ################################################################################
30
30
 
31
- def initialize(test_lab, stdout=STDOUT, stderr=STDERR, stdin=STDIN, logger=$logger)
32
- @stdout, @stderr, @stdin, @logger = stdout, stderr, stdin, logger
33
- @stdout.sync = true if @stdout.respond_to?(:sync=)
34
-
31
+ def initialize(test_lab, ui=ZTK::UI.new)
35
32
  @test_lab = test_lab
33
+ @ui = ui
36
34
  end
37
35
 
38
36
  ################################################################################
@@ -124,7 +122,7 @@ module Cucumber
124
122
  ################################################################################
125
123
 
126
124
  def at_exit
127
- @logger.fatal { "Waiting for cc-server to shutdown." }
125
+ @ui.logger.fatal { "Waiting for cc-server to shutdown." }
128
126
  self.down
129
127
  @background.wait
130
128
  end
@@ -184,7 +184,8 @@ module Cucumber
184
184
  vagrant ({:lab_user => "vagrant",
185
185
  :lxc_user => "root"})
186
186
 
187
- chef ({:amqp_password => "p@ssw0rd1",
187
+ chef ({:version => "10.18.2",
188
+ :amqp_password => "p@ssw0rd1",
188
189
  :admin_password => "p@ssw0rd1"})
189
190
 
190
191
  test_lab ({:hostname => "cucumber-chef",
@@ -73,7 +73,8 @@ module Cucumber::Chef::Helpers::Container
73
73
  commands << "yum --nogpgcheck --installroot=#{cache_rootfs} -y install wget openssh-server"
74
74
  end
75
75
  commands << "chroot #{cache_rootfs} /bin/bash -c 'locale-gen en_US'"
76
- commands << "chroot #{cache_rootfs} /bin/bash -c 'wget http://www.opscode.com/chef/install.sh -O - | bash'"
76
+ commands << "chroot #{cache_rootfs} /bin/bash -c 'wget http://www.opscode.com/chef/install.sh'"
77
+ commands << "chroot #{cache_rootfs} /bin/bash -c 'bash install.sh -v #{Cucumber::Chef::Config.chef[:version]}'"
77
78
  if distro.downcase == "fedora"
78
79
  commands << "chroot #{cache_rootfs} /bin/bash -c 'rpm -Uvh --nodeps /tmp/*rpm'"
79
80
  end
@@ -27,21 +27,18 @@ module Cucumber
27
27
  class ProviderError < Error; end
28
28
 
29
29
  class Provider
30
- attr_accessor :stdout, :stderr, :stdin, :logger
31
-
32
30
  PROXY_METHODS = %w(create destroy up halt reload status id state username ip port chef_server_api chef_server_webui alive? dead? exists?)
33
31
 
34
32
  ################################################################################
35
33
 
36
- def initialize(stdout=STDOUT, stderr=STDERR, stdin=STDIN, logger=$logger)
37
- @stdout, @stderr, @stdin, @logger = stdout, stderr, stdin, logger
38
- @stdout.sync = true if @stdout.respond_to?(:sync=)
34
+ def initialize(ui=ZTK::UI.new)
35
+ @ui = ui
39
36
 
40
37
  @provider = case Cucumber::Chef::Config.provider
41
38
  when :aws then
42
- Cucumber::Chef::Provider::AWS.new(@stdout, @stderr, @stdin, @logger)
39
+ Cucumber::Chef::Provider::AWS.new(@ui)
43
40
  when :vagrant then
44
- Cucumber::Chef::Provider::Vagrant.new(@stdout, @stderr, @stdin, @logger)
41
+ Cucumber::Chef::Provider::Vagrant.new(@ui)
45
42
  end
46
43
  end
47
44
 
@@ -79,8 +76,8 @@ module Cucumber
79
76
  end
80
77
 
81
78
  rescue Exception => e
82
- Cucumber::Chef.logger.fatal { e.message }
83
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
79
+ @ui.logger.fatal { e.message }
80
+ @ui.logger.fatal { e.backtrace.join("\n") }
84
81
  raise ProviderError, e.message
85
82
  end
86
83
 
@@ -90,7 +87,7 @@ module Cucumber
90
87
  if Cucumber::Chef::Provider::PROXY_METHODS.include?(method_name.to_s)
91
88
  result = @provider.send(method_name.to_sym, *method_args)
92
89
  splat = [method_name, *method_args].flatten.compact
93
- Cucumber::Chef.logger.debug { "Provider: #{splat.inspect}=#{result.inspect}" }
90
+ @ui.logger.debug { "Provider: #{splat.inspect}=#{result.inspect}" }
94
91
  result
95
92
  else
96
93
  super(method_name, *method_args)
@@ -25,7 +25,7 @@ module Cucumber
25
25
  class AWSError < Error; end
26
26
 
27
27
  class AWS
28
- attr_accessor :connection, :server, :stdout, :stderr, :stdin, :logger
28
+ attr_accessor :connection, :server
29
29
 
30
30
  INVALID_STATES = %w(terminated pending).map(&:to_sym)
31
31
  RUNNING_STATES = %w(running starting-up).map(&:to_sym)
@@ -34,9 +34,8 @@ module Cucumber
34
34
 
35
35
  ################################################################################
36
36
 
37
- def initialize(stdout=STDOUT, stderr=STDERR, stdin=STDIN, logger=$logger)
38
- @stdout, @stderr, @stdin, @logger = stdout, stderr, stdin, logger
39
- @stdout.sync = true if @stdout.respond_to?(:sync=)
37
+ def initialize(ui=ZTK::UI.new)
38
+ @ui = ui
40
39
 
41
40
  @connection = Fog::Compute.new(
42
41
  :provider => 'AWS',
@@ -55,7 +54,7 @@ module Cucumber
55
54
 
56
55
  def create
57
56
  if (exists? && alive?)
58
- @stdout.puts("A test lab already exists using the #{Cucumber::Chef::Config.provider.upcase} credentials you have supplied; attempting to reprovision it.")
57
+ @ui.stdout.puts("A test lab already exists using the #{Cucumber::Chef::Config.provider.upcase} credentials you have supplied; attempting to reprovision it.")
59
58
  else
60
59
  server_definition = {
61
60
  :image_id => Cucumber::Chef::Config.aws_image_id,
@@ -68,7 +67,7 @@ module Cucumber
68
67
  }
69
68
 
70
69
  if (@server = @connection.servers.create(server_definition))
71
- ZTK::Benchmark.bench(:message => "Creating #{Cucumber::Chef::Config.provider.upcase} instance", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
70
+ ZTK::Benchmark.bench(:message => "Creating #{Cucumber::Chef::Config.provider.upcase} instance", :mark => "completed in %0.4f seconds.", :ui => @ui) do
72
71
  @server.wait_for { ready? }
73
72
  tag_server
74
73
  ZTK::TCPSocketCheck.new(:host => self.ip, :port => self.port, :wait => 120).wait
@@ -79,8 +78,8 @@ module Cucumber
79
78
  self
80
79
 
81
80
  rescue Exception => e
82
- Cucumber::Chef.logger.fatal { e.message }
83
- Cucumber::Chef.logger.fatal { "Backtrace:\n#{e.backtrace.join("\n")}" }
81
+ @ui.logger.fatal { e.message }
82
+ @ui.logger.fatal { "Backtrace:\n#{e.backtrace.join("\n")}" }
84
83
  raise AWSError, e.message
85
84
  end
86
85
 
@@ -96,8 +95,8 @@ module Cucumber
96
95
  end
97
96
 
98
97
  rescue Exception => e
99
- Cucumber::Chef.logger.fatal { e.message }
100
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
98
+ @ui.logger.fatal { e.message }
99
+ @ui.logger.fatal { e.backtrace.join("\n") }
101
100
  raise AWSError, e.message
102
101
  end
103
102
 
@@ -118,8 +117,8 @@ module Cucumber
118
117
  end
119
118
 
120
119
  rescue Exception => e
121
- Cucumber::Chef.logger.fatal { e.message }
122
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
120
+ @ui.logger.fatal { e.message }
121
+ @ui.logger.fatal { e.backtrace.join("\n") }
123
122
  raise AWSError, e.message
124
123
  end
125
124
 
@@ -137,8 +136,8 @@ module Cucumber
137
136
  end
138
137
 
139
138
  rescue Exception => e
140
- Cucumber::Chef.logger.fatal { e.message }
141
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
139
+ @ui.logger.fatal { e.message }
140
+ @ui.logger.fatal { e.backtrace.join("\n") }
142
141
  raise AWSError, e.message
143
142
  end
144
143
 
@@ -156,8 +155,8 @@ module Cucumber
156
155
  end
157
156
 
158
157
  rescue Exception => e
159
- Cucumber::Chef.logger.fatal { e.message }
160
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
158
+ @ui.logger.fatal { e.message }
159
+ @ui.logger.fatal { e.backtrace.join("\n") }
161
160
  raise AWSError, e.message
162
161
  end
163
162
 
@@ -203,16 +202,16 @@ module Cucumber
203
202
  ################################################################################
204
203
 
205
204
  def filter_servers(servers, states=VALID_STATES)
206
- Cucumber::Chef.logger.debug("states") { states.collect{ |s| s.inspect }.join(", ") }
205
+ @ui.logger.debug("states") { states.collect{ |s| s.inspect }.join(", ") }
207
206
  results = servers.select do |server|
208
- Cucumber::Chef.logger.debug("candidate") { "id=#{server.id.inspect}, state=#{server.state.inspect}, tags=#{server.tags.inspect}" }
207
+ @ui.logger.debug("candidate") { "id=#{server.id.inspect}, state=#{server.state.inspect}, tags=#{server.tags.inspect}" }
209
208
 
210
209
  ( server.tags['cucumber-chef-mode'] == Cucumber::Chef::Config.mode.to_s &&
211
210
  server.tags['cucumber-chef-user'] == Cucumber::Chef::Config.user.to_s &&
212
211
  states.any?{ |state| state.to_s == server.state } )
213
212
  end
214
213
  results.each do |server|
215
- Cucumber::Chef.logger.debug("results") { "id=#{server.id.inspect}, state=#{server.state.inspect}" }
214
+ @ui.logger.debug("results") { "id=#{server.id.inspect}, state=#{server.state.inspect}" }
216
215
  end
217
216
  results.first
218
217
  end
@@ -25,7 +25,7 @@ module Cucumber
25
25
  class VagrantError < Error; end
26
26
 
27
27
  class Vagrant
28
- attr_accessor :env, :vm, :stdout, :stderr, :stdin, :logger
28
+ attr_accessor :env, :vm
29
29
 
30
30
  INVALID_STATES = %w(not_created aborted).map(&:to_sym)
31
31
  RUNNING_STATES = %w(running).map(&:to_sym)
@@ -34,9 +34,8 @@ module Cucumber
34
34
 
35
35
  ################################################################################
36
36
 
37
- def initialize(stdout=STDOUT, stderr=STDERR, stdin=STDIN, logger=$logger)
38
- @stdout, @stderr, @stdin, @logger = stdout, stderr, stdin, logger
39
- @stdout.sync = true if @stdout.respond_to?(:sync=)
37
+ def initialize(ui=ZTK::UI.new)
38
+ @ui = ui
40
39
 
41
40
  @env = ::Vagrant::Environment.new
42
41
  @vm = @env.primary_vm
@@ -55,8 +54,8 @@ module Cucumber
55
54
  self
56
55
 
57
56
  rescue Exception => e
58
- Cucumber::Chef.logger.fatal { e.message }
59
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
57
+ @ui.logger.fatal { e.message }
58
+ @ui.logger.fatal { e.backtrace.join("\n") }
60
59
  raise VagrantError, e.message
61
60
  end
62
61
 
@@ -72,8 +71,8 @@ module Cucumber
72
71
  end
73
72
 
74
73
  rescue Exception => e
75
- Cucumber::Chef.logger.fatal { e.message }
76
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
74
+ @ui.logger.fatal { e.message }
75
+ @ui.logger.fatal { e.backtrace.join("\n") }
77
76
  raise VagrantError, e.message
78
77
  end
79
78
 
@@ -90,8 +89,8 @@ module Cucumber
90
89
  end
91
90
 
92
91
  rescue Exception => e
93
- Cucumber::Chef.logger.fatal { e.message }
94
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
92
+ @ui.logger.fatal { e.message }
93
+ @ui.logger.fatal { e.backtrace.join("\n") }
95
94
  raise VagrantError, e.message
96
95
  end
97
96
 
@@ -107,8 +106,8 @@ module Cucumber
107
106
  end
108
107
 
109
108
  rescue Exception => e
110
- Cucumber::Chef.logger.fatal { e.message }
111
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
109
+ @ui.logger.fatal { e.message }
110
+ @ui.logger.fatal { e.backtrace.join("\n") }
112
111
  raise VagrantError, e.message
113
112
  end
114
113
 
@@ -124,8 +123,8 @@ module Cucumber
124
123
  end
125
124
 
126
125
  rescue Exception => e
127
- Cucumber::Chef.logger.fatal { e.message }
128
- Cucumber::Chef.logger.fatal { e.backtrace.join("\n") }
126
+ @ui.logger.fatal { e.message }
127
+ @ui.logger.fatal { e.backtrace.join("\n") }
129
128
  raise VagrantError, e.message
130
129
  end
131
130
 
@@ -25,15 +25,15 @@ module Cucumber
25
25
  class ProvisionerError < Error; end
26
26
 
27
27
  class Provisioner
28
- attr_accessor :test_lab, :stdout, :stderr, :stdin
28
+ attr_accessor :test_lab
29
29
 
30
30
  ################################################################################
31
31
 
32
- def initialize(test_lab, stdout=STDOUT, stderr=STDERR, stdin=STDIN)
33
- @stdout, @stderr, @stdin = stdout, stderr, stdin
34
- @stdout.sync = true if @stdout.respond_to?(:sync=)
32
+ def initialize(test_lab, ui=ZTK::UI.new)
33
+ test_lab.nil? and raise ProvisionerError, "You must supply a test lab!"
35
34
 
36
35
  @test_lab = test_lab
36
+ @ui = ui
37
37
 
38
38
  @cookbooks_path = File.join(Cucumber::Chef.root_dir, "chef_repo", "cookbooks")
39
39
  @roles_path = File.join(Cucumber::Chef.root_dir, "chef_repo", "roles")
@@ -69,7 +69,7 @@ module Cucumber
69
69
  def bootstrap
70
70
  raise ProvisionerError, "You must have the environment variable 'USER' set." if !Cucumber::Chef::Config.user
71
71
 
72
- ZTK::Benchmark.bench(:message => "Bootstrapping #{Cucumber::Chef::Config.provider.upcase} instance", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
72
+ ZTK::Benchmark.bench(:message => "Bootstrapping #{Cucumber::Chef::Config.provider.upcase} instance", :mark => "completed in %0.4f seconds.", :ui => @ui) do
73
73
  chef_client_attributes = {
74
74
  "run_list" => "role[test_lab]",
75
75
  "cucumber_chef" => {
@@ -86,7 +86,8 @@ module Cucumber
86
86
  :admin_password => Cucumber::Chef::Config.chef[:admin_password],
87
87
  :user => Cucumber::Chef::Config.user,
88
88
  :hostname_short => Cucumber::Chef.lab_hostname_short,
89
- :hostname_full => Cucumber::Chef.lab_hostname_full
89
+ :hostname_full => Cucumber::Chef.lab_hostname_full,
90
+ :chef_version => Cucumber::Chef::Config.chef[:version]
90
91
  }
91
92
 
92
93
  local_bootstrap_file = Tempfile.new("bootstrap")
@@ -108,7 +109,7 @@ module Cucumber
108
109
  ################################################################################
109
110
 
110
111
  def download_chef_credentials
111
- ZTK::Benchmark.bench(:message => "Downloading chef-server credentials", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
112
+ ZTK::Benchmark.bench(:message => "Downloading chef-server credentials", :mark => "completed in %0.4f seconds.", :ui => @ui) do
112
113
  local_path = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config.provider.to_s)
113
114
  remote_path = File.join(Cucumber::Chef.lab_user_home_dir, ".chef")
114
115
 
@@ -122,7 +123,7 @@ module Cucumber
122
123
  ################################################################################
123
124
 
124
125
  def download_proxy_ssh_credentials
125
- ZTK::Benchmark.bench(:message => "Downloading proxy SSH credentials", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
126
+ ZTK::Benchmark.bench(:message => "Downloading proxy SSH credentials", :mark => "completed in %0.4f seconds.", :ui => @ui) do
126
127
  local_path = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config.provider.to_s)
127
128
  remote_path = File.join(Cucumber::Chef.lab_user_home_dir, ".ssh")
128
129
 
@@ -139,7 +140,7 @@ module Cucumber
139
140
  ################################################################################
140
141
 
141
142
  def render_knife_rb
142
- ZTK::Benchmark.bench(:message => "Building 'cc-knife' configuration", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
143
+ ZTK::Benchmark.bench(:message => "Building 'cc-knife' configuration", :mark => "completed in %0.4f seconds.", :ui => @ui) do
143
144
  template_file = File.join(Cucumber::Chef.root_dir, "lib", "cucumber", "chef", "templates", "cucumber-chef", "knife-rb.erb")
144
145
 
145
146
  context = {
@@ -157,8 +158,8 @@ module Cucumber
157
158
  ################################################################################
158
159
 
159
160
  def upload_cookbook
160
- Cucumber::Chef.logger.debug { "Uploading cucumber-chef cookbooks..." }
161
- ZTK::Benchmark.bench(:message => "Uploading 'cucumber-chef' cookbooks", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
161
+ @ui.logger.debug { "Uploading cucumber-chef cookbooks..." }
162
+ ZTK::Benchmark.bench(:message => "Uploading 'cucumber-chef' cookbooks", :mark => "completed in %0.4f seconds.", :ui => @ui) do
162
163
  @test_lab.knife_cli(%Q{cookbook upload cucumber-chef -o #{@cookbooks_path}}, :silence => true)
163
164
  end
164
165
  end
@@ -166,8 +167,8 @@ module Cucumber
166
167
  ################################################################################
167
168
 
168
169
  def upload_role
169
- Cucumber::Chef.logger.debug { "Uploading cucumber-chef test lab role..." }
170
- ZTK::Benchmark.bench(:message => "Uploading 'cucumber-chef' roles", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
170
+ @ui.logger.debug { "Uploading cucumber-chef test lab role..." }
171
+ ZTK::Benchmark.bench(:message => "Uploading 'cucumber-chef' roles", :mark => "completed in %0.4f seconds.", :ui => @ui) do
171
172
  @test_lab.knife_cli(%Q{role from file #{File.join(@roles_path, "test_lab.rb")}}, :silence => true)
172
173
  end
173
174
  end
@@ -175,8 +176,8 @@ module Cucumber
175
176
  ################################################################################
176
177
 
177
178
  def tag_node
178
- Cucumber::Chef.logger.debug { "Tagging cucumber-chef test lab node..." }
179
- ZTK::Benchmark.bench(:message => "Tagging 'cucumber-chef' node", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
179
+ @ui.logger.debug { "Tagging cucumber-chef test lab node..." }
180
+ ZTK::Benchmark.bench(:message => "Tagging 'cucumber-chef' node", :mark => "completed in %0.4f seconds.", :ui => @ui) do
180
181
  @test_lab.knife_cli(%Q{tag create #{Cucumber::Chef.lab_hostname_full} #{Cucumber::Chef::Config.mode}}, :silence => true)
181
182
  end
182
183
  end
@@ -184,8 +185,8 @@ module Cucumber
184
185
  ################################################################################
185
186
 
186
187
  def add_node_role
187
- Cucumber::Chef.logger.debug { "Setting up cucumber-chef test lab run list..." }
188
- ZTK::Benchmark.bench(:message => "Setting 'cucumber-chef' run list", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
188
+ @ui.logger.debug { "Setting up cucumber-chef test lab run list..." }
189
+ ZTK::Benchmark.bench(:message => "Setting 'cucumber-chef' run list", :mark => "completed in %0.4f seconds.", :ui => @ui) do
189
190
  @test_lab.knife_cli(%Q{node run_list add #{Cucumber::Chef.lab_hostname_full} "role[test_lab]"}, :silence => true)
190
191
  end
191
192
  end
@@ -193,7 +194,7 @@ module Cucumber
193
194
  ################################################################################
194
195
 
195
196
  def chef_first_run
196
- ZTK::Benchmark.bench(:message => "Performing chef-client run", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
197
+ ZTK::Benchmark.bench(:message => "Performing chef-client run", :mark => "completed in %0.4f seconds.", :ui => @ui) do
197
198
  command = "/usr/bin/chef-client -j /etc/chef/first-boot.json -l debug"
198
199
  command = "sudo #{command}"
199
200
  @test_lab.bootstrap_ssh.exec(command, :silence => true)
@@ -203,11 +204,11 @@ module Cucumber
203
204
  ################################################################################
204
205
 
205
206
  def wait_for_chef_server
206
- ZTK::Benchmark.bench(:message => "Waiting for the chef-server", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
207
+ ZTK::Benchmark.bench(:message => "Waiting for the chef-server", :mark => "completed in %0.4f seconds.", :ui => @ui) do
207
208
  ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4000, :data => "GET", :wait => 120).wait
208
209
  end
209
210
 
210
- ZTK::Benchmark.bench(:message => "Waiting for the chef-server-webui", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
211
+ ZTK::Benchmark.bench(:message => "Waiting for the chef-server-webui", :mark => "completed in %0.4f seconds.", :ui => @ui) do
211
212
  ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4040, :data => "GET", :wait => 120).wait
212
213
  end
213
214
  end
@@ -215,7 +216,7 @@ module Cucumber
215
216
  ################################################################################
216
217
 
217
218
  def reboot_test_lab
218
- ZTK::Benchmark.bench(:message => "Rebooting the test lab", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
219
+ ZTK::Benchmark.bench(:message => "Rebooting the test lab", :mark => "completed in %0.4f seconds.", :ui => @ui) do
219
220
  command = "sudo reboot"
220
221
  @test_lab.bootstrap_ssh.exec(command, :silence => true)
221
222
  ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => @test_lab.port, :wait => 120).wait
@@ -22,11 +22,12 @@ tag = Cucumber::Chef.tag("cucumber-chef")
22
22
  puts(" * #{tag}")
23
23
  Cucumber::Chef.boot(tag)
24
24
 
25
- if (($test_lab = Cucumber::Chef::TestLab.new) && $test_lab.alive?)
25
+ $ui = ZTK::UI.new(:logger => Cucumber::Chef.logger)
26
+ if (($test_lab = Cucumber::Chef::TestLab.new($ui)) && $test_lab.alive?)
26
27
  $test_lab.cc_client.up
27
28
  else
28
29
  message = "No running cucumber-chef test labs to connect to!"
29
- Cucumber::Chef.logger.fatal { message }
30
+ $ui.logger.fatal { message }
30
31
  raise message
31
32
  end
32
33
 
@@ -25,15 +25,14 @@ module Cucumber
25
25
  class TestLabError < Error; end
26
26
 
27
27
  class TestLab
28
- attr_accessor :provider, :stdout, :stderr, :stdin, :logger
28
+ attr_accessor :provider
29
29
 
30
30
  ################################################################################
31
31
 
32
- def initialize(stdout=STDOUT, stderr=STDERR, stdin=STDIN, logger=$logger)
33
- @stdout, @stderr, @stdin, @logger = stdout, stderr, stdin, logger
34
- @stdout.sync = true if @stdout.respond_to?(:sync=)
32
+ def initialize(ui=ZTK::UI.new)
33
+ @ui = ui
35
34
 
36
- @provider = Cucumber::Chef::Provider.new(@stdout, @stderr, @stdin, @logger)
35
+ @provider = Cucumber::Chef::Provider.new(@ui)
37
36
  end
38
37
 
39
38
  ################################################################################
@@ -42,7 +41,7 @@ module Cucumber
42
41
  dead? and raise TestLabError, "The test lab must be running in order to start a bootstrap SSH session!"
43
42
 
44
43
  if (!defined?(@ssh) || @ssh.nil?)
45
- @ssh ||= ZTK::SSH.new(:stdout => @stdout, :stderr => @stderr, :stdin => @stdin, :timeout => Cucumber::Chef::Config.command_timeout)
44
+ @ssh ||= ZTK::SSH.new(:ui => @ui, :timeout => Cucumber::Chef::Config.command_timeout)
46
45
 
47
46
  @ssh.config.host_name = self.ip
48
47
  @ssh.config.port = self.port
@@ -58,7 +57,7 @@ module Cucumber
58
57
  dead? and raise TestLabError, "The test lab must be running in order to start an SSH session!"
59
58
 
60
59
  if (!defined?(@ssh) || @ssh.nil?)
61
- @ssh ||= ZTK::SSH.new(:stdout => @stdout, :stderr => @stderr, :stdin => @stdin, :timeout => Cucumber::Chef::Config.command_timeout)
60
+ @ssh ||= ZTK::SSH.new(:ui => @ui, :timeout => Cucumber::Chef::Config.command_timeout)
62
61
 
63
62
  @ssh.config.host_name = self.ip
64
63
  @ssh.config.port = self.port
@@ -76,7 +75,7 @@ module Cucumber
76
75
  container = container.to_sym
77
76
  @proxy_ssh ||= Hash.new
78
77
  if (!defined?(@proxy_ssh[container]) || @proxy_ssh[container].nil?)
79
- @proxy_ssh[container] ||= ZTK::SSH.new(:stdout => @stdout, :stderr => @stderr, :stdin => @stdin, :timeout => Cucumber::Chef::Config.command_timeout)
78
+ @proxy_ssh[container] ||= ZTK::SSH.new(:ui => @ui, :timeout => Cucumber::Chef::Config.command_timeout)
80
79
 
81
80
  @proxy_ssh[container].config.proxy_host_name = self.ip
82
81
  @proxy_ssh[container].config.proxy_port = self.port
@@ -95,7 +94,7 @@ module Cucumber
95
94
  def cc_client
96
95
  dead? and raise TestLabError, "The test lab must be running in order to start the cc-server/client session!"
97
96
 
98
- @cc_client ||= Cucumber::Chef::Client.new(self, @stdout, @stderr, @stdin, @logger)
97
+ @cc_client ||= Cucumber::Chef::Client.new(self, @ui)
99
98
  @cc_client
100
99
  end
101
100
 
@@ -130,7 +129,7 @@ module Cucumber
130
129
  if Cucumber::Chef::Provider::PROXY_METHODS.include?(method_name.to_s)
131
130
  result = @provider.send(method_name.to_sym, *method_args)
132
131
  splat = [method_name, *method_args].flatten.compact
133
- Cucumber::Chef.logger.debug { "TestLab: #{splat.inspect}=#{result.inspect}" }
132
+ @ui.logger.debug { "TestLab: #{splat.inspect}=#{result.inspect}" }
134
133
  result
135
134
  else
136
135
  super(method_name, *method_args)
@@ -24,7 +24,7 @@ module Cucumber
24
24
 
25
25
  ################################################################################
26
26
 
27
- VERSION = "2.1.0.rc.6" unless const_defined?(:VERSION)
27
+ VERSION = "2.1.0.rc.7" unless const_defined?(:VERSION)
28
28
 
29
29
  ################################################################################
30
30
 
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: 2.1.0.rc.6
4
+ version: 2.1.0.rc.7
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-03 00:00:00.000000000 Z
13
+ date: 2013-02-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: chef
@@ -179,7 +179,7 @@ dependencies:
179
179
  requirements:
180
180
  - - ! '>='
181
181
  - !ruby/object:Gem::Version
182
- version: 0.0.15
182
+ version: 1.0.0
183
183
  type: :runtime
184
184
  prerelease: false
185
185
  version_requirements: !ruby/object:Gem::Requirement
@@ -187,7 +187,7 @@ dependencies:
187
187
  requirements:
188
188
  - - ! '>='
189
189
  - !ruby/object:Gem::Version
190
- version: 0.0.15
190
+ version: 1.0.0
191
191
  - !ruby/object:Gem::Dependency
192
192
  name: simplecov
193
193
  requirement: !ruby/object:Gem::Requirement