48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/cucumber/chef/client.rb', line 48
def up(options={})
ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo environments to the test lab", :mark => "completed in %0.4f seconds.") do
@test_lab.knife_cli(%(environment from file ./environments/*.rb), :silence => true)
end
ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo cookbooks to the test lab", :mark => "completed in %0.4f seconds.") do
cookbook_paths = Cucumber::Chef::Config.chef[:cookbook_paths]
@test_lab.knife_cli(%(cookbook upload --all --cookbook-path #{cookbook_paths.join(':')} --force), :silence => true)
end
ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo roles to the test lab", :mark => "completed in %0.4f seconds.") do
@test_lab.knife_cli(%(role from file ./roles/*.rb), :silence => true)
end
Dir.glob("./data_bags/*").each do |data_bag_path|
next if !File.directory?(data_bag_path)
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
data_bag = File.basename(data_bag_path)
@test_lab.knife_cli(%(data bag create "#{data_bag}"), :silence => true)
@test_lab.knife_cli(%(data bag from file "#{data_bag}" "#{data_bag_path}"), :silence => true)
end
end
if environment_variable_set?("PURGE")
@ui.logger.warn { "PURGING CONTAINERS! Container attributes will be reset!" }
@test_lab.containers.list.each do |name|
ZTK::Benchmark.bench(:message => ">>> Destroying container '#{name}'", :mark => "completed in %0.4f seconds.") do
@test_lab.containers.destroy(name)
end
end
else
@ui.logger.info { "Allowing existing containers to persist." }
end
Cucumber::Chef::Container.all.each do |container|
ZTK::Benchmark.bench(:message => ">>> Creating container '#{container.id}'", :mark => "completed in %0.4f seconds.") do
@test_lab.containers.create(container)
end
end
@test_lab.containers.chef_set_client_config(:chef_server_url => "https://192.168.255.254",
:validation_client_name => "chef-validator")
Cucumber::Chef::Container.all.each do |container|
ZTK::Benchmark.bench(:message => ">>> Provisioning container '#{container.id}'", :mark => "completed in %0.4f seconds.") do
@test_lab.containers.provision(container)
end
end
true
end
|