cucumber-chef 2.1.0.rc.11 → 2.1.0.rc.12
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.
- data/bin/cucumber-chef +10 -24
- data/chef_repo/cookbooks/cucumber-chef/recipes/lxc.rb +1 -65
- data/chef_repo/cookbooks/cucumber-chef/recipes/test_lab.rb +1 -41
- data/cucumber-chef.gemspec +1 -2
- data/lib/cucumber/chef/client.rb +50 -60
- data/lib/cucumber/chef/containers.rb +519 -0
- data/lib/cucumber/chef/providers/aws.rb +0 -2
- data/lib/cucumber/chef/providers/vagrant.rb +1 -1
- data/lib/cucumber/chef/steps/provision_steps.rb +11 -13
- data/lib/cucumber/chef/test_lab.rb +15 -40
- data/lib/cucumber/chef/version.rb +1 -1
- data/lib/cucumber/chef.rb +1 -4
- metadata +4 -17
- data/bin/cc-push +0 -49
- data/bin/cc-server +0 -84
- data/chef_repo/cookbooks/cucumber-chef/templates/default/gemrc.erb +0 -10
- data/lib/cucumber/chef/helpers/chef_client.rb +0 -167
- data/lib/cucumber/chef/helpers/chef_server.rb +0 -42
- data/lib/cucumber/chef/helpers/command.rb +0 -60
- data/lib/cucumber/chef/helpers/container.rb +0 -187
- data/lib/cucumber/chef/helpers/minitest.rb +0 -35
- data/lib/cucumber/chef/helpers/server.rb +0 -115
- data/lib/cucumber/chef/helpers/test_lab.rb +0 -52
- data/lib/cucumber/chef/helpers/utility.rb +0 -71
- data/lib/cucumber/chef/helpers.rb +0 -50
data/bin/cucumber-chef
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'thor'
|
4
4
|
require 'cucumber-chef'
|
5
5
|
|
6
|
+
|
6
7
|
# $logger = Cucumber::Chef.logger
|
7
8
|
|
8
9
|
class CucumberChef < Thor
|
@@ -55,7 +56,7 @@ class CucumberChef < Thor
|
|
55
56
|
|
56
57
|
def boot
|
57
58
|
tag = Cucumber::Chef.tag("cucumber-chef")
|
58
|
-
puts(
|
59
|
+
puts(tag)
|
59
60
|
Cucumber::Chef.boot(tag)
|
60
61
|
$logger = Cucumber::Chef.logger
|
61
62
|
|
@@ -204,23 +205,14 @@ class CucumberChef < Thor
|
|
204
205
|
puts("BOOM!")
|
205
206
|
puts
|
206
207
|
|
207
|
-
ZTK::Benchmark.bench(:message => "Start cc-server", :mark => "completed in %0.4f seconds.") do
|
208
|
-
test_lab.cc_client.up(:silence => true)
|
209
|
-
end
|
210
|
-
|
211
208
|
args.each do |container|
|
212
209
|
ZTK::Benchmark.bench(:message => "Destroy container '#{container}'", :mark => "completed in %0.4f seconds.") do
|
213
|
-
test_lab.
|
214
|
-
test_lab.
|
215
|
-
test_lab.
|
216
|
-
test_lab.drb.save_containers
|
210
|
+
test_lab.containers.load
|
211
|
+
test_lab.containers.destroy(container)
|
212
|
+
test_lab.containers.save
|
217
213
|
end
|
218
214
|
end
|
219
215
|
|
220
|
-
ZTK::Benchmark.bench(:message => "Stop cc-server", :mark => "completed in %0.4f seconds.") do
|
221
|
-
test_lab.cc_client.down
|
222
|
-
end
|
223
|
-
|
224
216
|
else
|
225
217
|
puts
|
226
218
|
puts(set_color("Whew! That was close!", :green, true))
|
@@ -318,19 +310,16 @@ class CucumberChef < Thor
|
|
318
310
|
if (test_lab = Cucumber::Chef::TestLab.new)
|
319
311
|
if @options.containers?
|
320
312
|
if test_lab.alive?
|
321
|
-
ZTK::Benchmark.bench(:message => "Start cc-server", :mark => "completed in %0.4f seconds.") do
|
322
|
-
test_lab.cc_client.up(:silence => true)
|
323
|
-
end
|
324
313
|
|
325
|
-
test_lab.
|
314
|
+
test_lab.containers.load
|
326
315
|
|
327
|
-
if test_lab.
|
316
|
+
if test_lab.containers.count > 0
|
328
317
|
headers = [:name, :alive, :arch, :distro, :ip, :mac, :"chef version", :persist]
|
329
|
-
results = ZTK::Report.new.spreadsheet(test_lab.
|
318
|
+
results = ZTK::Report.new.spreadsheet(test_lab.containers.to_a, headers) do |name, detail|
|
330
319
|
chef_version = "N/A"
|
331
|
-
alive = (test_lab.
|
320
|
+
alive = (test_lab.bootstrap_ssh(:ignore_exit_status => true).exec(%Q{ping -n -c 1 -W 1 #{detail[:ip]}}, :silence => true).exit_code == 0)
|
332
321
|
if alive
|
333
|
-
chef_version = test_lab.
|
322
|
+
chef_version = test_lab.proxy_ssh(name, :ignore_exit_status => true).exec(%Q{/usr/bin/env chef-client -v}, :silence => true).output.chomp
|
334
323
|
end
|
335
324
|
|
336
325
|
OpenStruct.new(
|
@@ -359,9 +348,6 @@ class CucumberChef < Thor
|
|
359
348
|
raise Cucumber::Chef::Error, "We could not find any containers!"
|
360
349
|
end
|
361
350
|
|
362
|
-
ZTK::Benchmark.bench(:message => "Stop cc-server", :mark => "completed in %0.4f seconds.") do
|
363
|
-
test_lab.cc_client.down
|
364
|
-
end
|
365
351
|
else
|
366
352
|
raise Cucumber::Chef::Error, "We could not find a running test lab."
|
367
353
|
end
|
@@ -19,7 +19,7 @@
|
|
19
19
|
################################################################################
|
20
20
|
|
21
21
|
|
22
|
-
%w(
|
22
|
+
%w(lxc bridge-utils debootstrap yum isc-dhcp-server bind9 ntpdate ntp).each do |p|
|
23
23
|
package p
|
24
24
|
end
|
25
25
|
|
@@ -220,25 +220,6 @@ end
|
|
220
220
|
service "lxc-net"
|
221
221
|
service "lxc"
|
222
222
|
|
223
|
-
#directory "create cgroup mount point" do
|
224
|
-
# path "/cgroup"
|
225
|
-
#
|
226
|
-
# not_if { File.exists?("/cgroup") && File.directory?("/cgroup") }
|
227
|
-
#end
|
228
|
-
|
229
|
-
#mount "mount cgroup device" do
|
230
|
-
# mount_point "/cgroup"
|
231
|
-
# device "cgroup"
|
232
|
-
# fstype "cgroup"
|
233
|
-
# pass 0
|
234
|
-
# action [:mount, :enable]
|
235
|
-
|
236
|
-
# not_if do
|
237
|
-
# %x( mount | grep "cgroup" )
|
238
|
-
# ($? == 0)
|
239
|
-
# end
|
240
|
-
#end
|
241
|
-
|
242
223
|
execute "set LXC_AUTO to false" do
|
243
224
|
command "sed -i \"s/LXC_AUTO=\\\"true\\\"/LXC_AUTO=\\\"false\\\"/\" /etc/default/lxc"
|
244
225
|
|
@@ -266,48 +247,3 @@ directory "create lxc configuration directory" do
|
|
266
247
|
|
267
248
|
not_if { File.exists?("/etc/lxc") && File.directory?("/etc/lxc") }
|
268
249
|
end
|
269
|
-
|
270
|
-
# # load the chef client into our distro lxc cache
|
271
|
-
# install_chef_sh = "/tmp/install-chef.sh"
|
272
|
-
# distros = { "ubuntu" => [ "lucid", "maverick", "natty", "oneiric", "precise" ] }
|
273
|
-
# arch = (%x( arch ).include?("i686") ? "i386" : "amd64")
|
274
|
-
|
275
|
-
# template "create lxc initializer container configuration" do
|
276
|
-
# path "/etc/lxc/initializer"
|
277
|
-
# source "lxc-initializer-config.erb"
|
278
|
-
|
279
|
-
# not_if { File.exists?("/etc/lxc/initializer") }
|
280
|
-
# end
|
281
|
-
|
282
|
-
# distros.each do |distro, releases|
|
283
|
-
# releases.each do |release|
|
284
|
-
# cache_rootfs = File.join("/", "var", "cache", "lxc", release, "rootfs-#{arch}")
|
285
|
-
# initializer_rootfs = File.join("/", "var", "lib", "lxc", "initializer", "rootfs")
|
286
|
-
|
287
|
-
# execute "create the lxc initializer container for #{distro}/#{release}" do
|
288
|
-
# command "lxc-create -n initializer -f /etc/lxc/initializer -t #{distro} -- -r #{release}"
|
289
|
-
|
290
|
-
# not_if { File.exists?(cache_rootfs) && File.directory?(cache_rootfs) }
|
291
|
-
# end
|
292
|
-
|
293
|
-
# execute "destroy the lxc initializer container for #{distro}/#{release}" do
|
294
|
-
# command "lxc-destroy -n initializer"
|
295
|
-
|
296
|
-
# only_if { File.exists?(initializer_rootfs) && File.directory?(initializer_rootfs) }
|
297
|
-
# end
|
298
|
-
|
299
|
-
# template "create opscode omnibus installer in lxc container cache for #{distro}/#{release}" do
|
300
|
-
# path "#{cache_rootfs}#{install_chef_sh}"
|
301
|
-
# source "lxc-install-chef.erb"
|
302
|
-
# mode "0755"
|
303
|
-
|
304
|
-
# not_if { File.exists?(File.join(cache_rootfs, install_chef_sh)) }
|
305
|
-
# end
|
306
|
-
|
307
|
-
# execute "install chef-client using omnibus in lxc container cache for #{distro}/#{release}" do
|
308
|
-
# command "chroot #{cache_rootfs} /bin/bash -c '#{install_chef_sh}'"
|
309
|
-
|
310
|
-
# not_if { File.exists?(File.join(cache_rootfs, "opt", "opscode", "bin", "chef-client")) }
|
311
|
-
# end
|
312
|
-
# end
|
313
|
-
# end
|
@@ -23,7 +23,7 @@
|
|
23
23
|
# SYSTEM TWEAKS
|
24
24
|
################################################################################
|
25
25
|
|
26
|
-
%w(
|
26
|
+
%w(build-essential wget chkconfig).each do |p|
|
27
27
|
package p
|
28
28
|
end
|
29
29
|
|
@@ -49,16 +49,6 @@ end
|
|
49
49
|
not_if { File.exists?(File.join(home_dir, ".ssh", "config")) }
|
50
50
|
end
|
51
51
|
|
52
|
-
template "create .gemrc for #{user}" do
|
53
|
-
path "#{home_dir}/.gemrc"
|
54
|
-
source "gemrc.erb"
|
55
|
-
owner user
|
56
|
-
group user
|
57
|
-
mode "0644"
|
58
|
-
|
59
|
-
not_if { File.exists?(File.join(home_dir, ".gemrc")) }
|
60
|
-
end
|
61
|
-
|
62
52
|
execute "generate ssh keypair for #{user}" do
|
63
53
|
command "ssh-keygen -q -N '' -f #{home_dir}/.ssh/id_rsa"
|
64
54
|
|
@@ -106,36 +96,6 @@ template "install cucumber-chef motd" do
|
|
106
96
|
end
|
107
97
|
|
108
98
|
|
109
|
-
################################################################################
|
110
|
-
# RUBY
|
111
|
-
################################################################################
|
112
|
-
bash "install rubygems" do
|
113
|
-
code <<-EOH
|
114
|
-
cd /tmp
|
115
|
-
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.19.tgz
|
116
|
-
tar zxf rubygems-1.8.19.tgz
|
117
|
-
cd rubygems-1.8.19
|
118
|
-
ruby setup.rb --no-format-executable
|
119
|
-
EOH
|
120
|
-
end
|
121
|
-
|
122
|
-
gem_package "cucumber-chef" do
|
123
|
-
gem_binary("/usr/bin/gem")
|
124
|
-
|
125
|
-
version(node['cucumber_chef']['version'])
|
126
|
-
|
127
|
-
if node['cucumber_chef']['prerelease']
|
128
|
-
options("--prerelease")
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
%w( rspec ).each do |g|
|
133
|
-
gem_package g do
|
134
|
-
gem_binary("/usr/bin/gem")
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
|
139
99
|
################################################################################
|
140
100
|
# CHEF-CLIENT
|
141
101
|
################################################################################
|
data/cucumber-chef.gemspec
CHANGED
@@ -39,7 +39,6 @@ Gem::Specification.new do |s|
|
|
39
39
|
|
40
40
|
# Providers
|
41
41
|
s.add_dependency("fog", ">= 1.3.1")
|
42
|
-
# s.add_dependency("vagrant", ">= 1.0.5")
|
43
42
|
|
44
43
|
# TDD
|
45
44
|
s.add_dependency("cucumber", ">= 1.2.0")
|
@@ -50,7 +49,7 @@ Gem::Specification.new do |s|
|
|
50
49
|
s.add_dependency("rake", ">= 0.9.2")
|
51
50
|
s.add_dependency("thor", ">= 0.15.2")
|
52
51
|
s.add_dependency("ubuntu_ami", ">= 0.4.0")
|
53
|
-
s.add_dependency("ztk", ">= 1.0.
|
52
|
+
s.add_dependency("ztk", ">= 1.0.1")
|
54
53
|
|
55
54
|
s.add_development_dependency("simplecov", ">= 0.6.4")
|
56
55
|
s.add_development_dependency("pry", ">= 0")
|
data/lib/cucumber/chef/client.rb
CHANGED
@@ -36,44 +36,44 @@ module Cucumber
|
|
36
36
|
################################################################################
|
37
37
|
|
38
38
|
def up(options={})
|
39
|
-
user = Cucumber::Chef.lab_user
|
40
|
-
home_dir = Cucumber::Chef.lab_user_home_dir
|
41
|
-
provider = Cucumber::Chef::Config.provider.to_s
|
42
|
-
@test_lab.ssh.exec("sudo mkdir -p #{File.join(home_dir, ".cucumber-chef", provider)}")
|
43
|
-
@test_lab.ssh.exec("sudo cp -f #{File.join(home_dir, ".chef", "knife.rb")} #{File.join(home_dir, ".cucumber-chef", provider, "knife.rb")}")
|
44
|
-
@test_lab.ssh.exec("sudo chown -R #{user}:#{user} #{File.join(home_dir, ".cucumber-chef")}")
|
45
|
-
|
46
|
-
local_file = Cucumber::Chef.config_rb
|
47
|
-
remote_file = File.join(home_dir, ".cucumber-chef", "config.rb")
|
48
|
-
@test_lab.ssh.upload(local_file, remote_file)
|
49
|
-
|
50
|
-
begin
|
51
|
-
|
52
|
-
rescue
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
ZTK::RescueRetry.try(:tries => 30) do
|
75
|
-
|
76
|
-
end
|
39
|
+
# user = Cucumber::Chef.lab_user
|
40
|
+
# home_dir = Cucumber::Chef.lab_user_home_dir
|
41
|
+
# provider = Cucumber::Chef::Config.provider.to_s
|
42
|
+
# @test_lab.ssh.exec("sudo mkdir -p #{File.join(home_dir, ".cucumber-chef", provider)}")
|
43
|
+
# @test_lab.ssh.exec("sudo cp -f #{File.join(home_dir, ".chef", "knife.rb")} #{File.join(home_dir, ".cucumber-chef", provider, "knife.rb")}")
|
44
|
+
# @test_lab.ssh.exec("sudo chown -R #{user}:#{user} #{File.join(home_dir, ".cucumber-chef")}")
|
45
|
+
|
46
|
+
# local_file = Cucumber::Chef.config_rb
|
47
|
+
# remote_file = File.join(home_dir, ".cucumber-chef", "config.rb")
|
48
|
+
# @test_lab.ssh.upload(local_file, remote_file)
|
49
|
+
|
50
|
+
# begin
|
51
|
+
# self.ping
|
52
|
+
# rescue
|
53
|
+
# @background = ZTK::Background.new
|
54
|
+
# @background.process do
|
55
|
+
# self.down
|
56
|
+
|
57
|
+
# environment = Array.new
|
58
|
+
# %w(PURGE VERBOSE LOG_LEVEL).each do |env_var|
|
59
|
+
# environment << "#{env_var}=#{ENV[env_var].inspect}" if (!ENV[env_var].nil? && !ENV[env_var].empty?)
|
60
|
+
# end
|
61
|
+
# environment = environment.join(" ")
|
62
|
+
# external_ip = Cucumber::Chef.external_ip
|
63
|
+
|
64
|
+
# command = %Q{nohup sudo #{environment} /usr/bin/env cc-server #{external_ip} &}
|
65
|
+
|
66
|
+
# @test_lab.ssh.exec(command, options)
|
67
|
+
# end
|
68
|
+
|
69
|
+
# Kernel.at_exit do
|
70
|
+
# self.at_exit
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
|
74
|
+
# ZTK::RescueRetry.try(:tries => 30) do
|
75
|
+
# self.drb.ping
|
76
|
+
# end
|
77
77
|
|
78
78
|
true
|
79
79
|
end
|
@@ -81,17 +81,17 @@ module Cucumber
|
|
81
81
|
################################################################################
|
82
82
|
|
83
83
|
def down
|
84
|
-
(@test_lab.drb.shutdown rescue nil)
|
84
|
+
# (@test_lab.drb.shutdown rescue nil)
|
85
85
|
end
|
86
86
|
|
87
87
|
################################################################################
|
88
88
|
|
89
|
-
def drb
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
89
|
+
# def drb
|
90
|
+
# @drb and DRb.stop_service
|
91
|
+
# @drb = DRbObject.new_with_uri("druby://#{@test_lab.ip}:8787")
|
92
|
+
# @drb and DRb.start_service
|
93
|
+
# @drb
|
94
|
+
# end
|
95
95
|
|
96
96
|
################################################################################
|
97
97
|
|
@@ -100,30 +100,20 @@ module Cucumber
|
|
100
100
|
# we use various aspects of the scenario to name our artifacts
|
101
101
|
$scenario = scenario
|
102
102
|
|
103
|
-
@test_lab.drb.load_containers
|
104
|
-
|
105
|
-
@test_lab.drb.chef_set_client_config(:chef_server_url => "http://192.168.255.254:4000",
|
106
|
-
:validation_client_name => "chef-validator")
|
107
103
|
end
|
108
104
|
|
109
105
|
################################################################################
|
110
106
|
|
111
107
|
def after(scenario)
|
112
|
-
@test_lab.drb.save_containers
|
113
|
-
|
114
|
-
# cleanup non-persistent lxc containers after tests
|
115
|
-
@test_lab.drb.containers.select{ |name, attributes| !attributes[:persist] }.each do |name, attributes|
|
116
|
-
@test_lab.drb.server_destroy(name)
|
117
|
-
end
|
118
108
|
end
|
119
109
|
|
120
110
|
################################################################################
|
121
111
|
|
122
|
-
def at_exit
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
end
|
112
|
+
# def at_exit
|
113
|
+
# @ui.logger.fatal { "Waiting for cc-server to shutdown." }
|
114
|
+
# self.down
|
115
|
+
# @background.wait
|
116
|
+
# end
|
127
117
|
|
128
118
|
################################################################################
|
129
119
|
|