cucumber-chef 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
data/WIKI.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
[![Build Status](https://secure.travis-ci.org/
|
2
|
-
[![Dependency Status](https://gemnasium.com/
|
1
|
+
[![Build Status](https://secure.travis-ci.org/zpatten/cucumber-chef.png)](http://travis-ci.org/zpatten/cucumber-chef)
|
2
|
+
[![Dependency Status](https://gemnasium.com/zpatten/cucumber-chef.png)](https://gemnasium.com/zpatten/cucumber-chef)
|
3
3
|
|
4
4
|
I was not particularly happy with the state of the 2.x documents and considering workflow changes, etc it made sense to me to start over with the documentation. Since most things are the same the 2.x documentation will remain available in the repo as `WIKI.2.x.md`. This is WIP.
|
5
5
|
|
@@ -20,10 +20,15 @@ Your Chef-Repo should be setup in a manner as follows:
|
|
20
20
|
|
21
21
|
* Use something like RVM for your ruby with your chef-repo
|
22
22
|
* Use something like bundler for your rubygems with your chef-repo
|
23
|
-
* Use something like berkshelf for your chef cookbooks with your chef-repo
|
23
|
+
* Use something like librarian-chef or berkshelf for your chef cookbooks with your chef-repo
|
24
24
|
|
25
25
|
If you do not use these patterns you will have an unplesant time in general.
|
26
26
|
|
27
|
+
You also need the latest versions of:
|
28
|
+
|
29
|
+
* VirtualBox (https://www.virtualbox.org/)
|
30
|
+
* Vagrant (http://www.vagrantup.com/)
|
31
|
+
|
27
32
|
When using Cucumber-Chef, especially at first, I highly recommend you tail the log. Open another terminal, naviagate to your Chef-Repo root directory and run `tail -f .cucumber-chef/cucumber-chef.log`. You'll have a much better idea what's going on in the background this way, especially during bootstrapping and provisioning. And root causes of issues that are not so obvious on the console will hopefully be very obvious in the log.
|
28
33
|
|
29
34
|
# Workflow
|
@@ -33,6 +38,26 @@ When using Cucumber-Chef, especially at first, I highly recommend you tail the l
|
|
33
38
|
3. `cucumber-chef` runs the chef-client across the ecosystem using attributes from the `Labfile` (optionally executed)
|
34
39
|
4. `cucumber`/`rspec` resumes execution
|
35
40
|
|
41
|
+
# First-Time Execution
|
42
|
+
|
43
|
+
1. Ensure you have the latest vagrant and virtualbox installed.
|
44
|
+
2. `cucumber-chef init` to initalize a disabled config template.
|
45
|
+
3. `cucumber-chef create test` to create a blank test feature.
|
46
|
+
4. `cucumber-chef setup` is executed to ensure your test lab is provisioned.
|
47
|
+
5. `cucumber` to execute features located in your `chef-repo`.
|
48
|
+
|
49
|
+
# Other Execution Examples
|
50
|
+
|
51
|
+
For example when I am testing, I often use this command sequence (I use binstubs, so everything will be prefixed with bin/):
|
52
|
+
|
53
|
+
echo "yes" | bin/cucumber-chef destroy && bin/cucumber-chef setup && bin/cucumber
|
54
|
+
|
55
|
+
This will destroy the current test lab (if one exists), setup a new test (since we destroyed any existing labs), then execute the cucumber features.
|
56
|
+
|
57
|
+
To force destruction of the containers when running cucumber place `PURGE=1` before your cucumber command like so:
|
58
|
+
|
59
|
+
PURGE=1 bin/cucumber
|
60
|
+
|
36
61
|
# Configuration
|
37
62
|
|
38
63
|
Cucumber-Chef creates a home directory for itself named `.cucumber-chef` off the root of your Chef-Repo. Here you can find the configuration files as well as logs and artifacts from test runs. There are two main configuration files for Cucumber-Chef. The `Labfile` in the Chef-Repo directory and `config.rb` in the Cucumber-Chef home directory.
|
@@ -41,6 +66,8 @@ Cucumber-Chef creates a home directory for itself named `.cucumber-chef` off the
|
|
41
66
|
|
42
67
|
When doing integration testing it makes sense that one generally wants to test across an entire ecosystem of servers. You typically acquire a set of virtual or bare metal servers, provision those servers acordingly, put them into play then rinse and repeat. I introduce the `Labfile`, the concept is simple if you haven't already guessed it. You define a set of servers, i.e. an ecosystem, also dictating the settings and configuration. Part of this change is because a) it makes alot of sense to me and b) it greatly decreases runtimes. Also in cucumber-chef 2.x, we had insane background sections which bothered me tremendously and this change cleans up all of that mess as well. The ultimate goal is to support configuration of multiple ecosystems, but we've got other ground to cover first so that feature will have to wait for a bit. The `Labfile` should reside in the root of your Chef-Repo.
|
43
68
|
|
69
|
+
https://github.com/zpatten/cc-chef-repo/blob/master/Labfile
|
70
|
+
|
44
71
|
Here is a sample of what a `Labfile` might look like:
|
45
72
|
|
46
73
|
#!/usr/bin/env ruby
|
@@ -108,6 +135,122 @@ Here is a sample of what a `Labfile` might look like:
|
|
108
135
|
|
109
136
|
## `config.rb`
|
110
137
|
|
138
|
+
https://github.com/zpatten/cc-chef-repo/blob/master/.cucumber-chef/config.rb
|
139
|
+
|
140
|
+
You can customize your configuration by editing your `<chef-repo>/.cucumber-chef/config.rb` file. Here's an example of the current one I'm using for testing:
|
141
|
+
|
142
|
+
provider :vagrant
|
143
|
+
|
144
|
+
vagrant.merge!( :identity_file => "#{ENV['HOME']}/.vagrant.d/insecure_private_key",
|
145
|
+
:ssh => {
|
146
|
+
:lab_ip => "192.168.33.10",
|
147
|
+
:lab_port => 22,
|
148
|
+
:lxc_port => 22
|
149
|
+
},
|
150
|
+
:cpus => 4,
|
151
|
+
:memory => 4096 )
|
152
|
+
|
153
|
+
aws.merge!( :identity_file => ENV['AWS_IDENTITY'],
|
154
|
+
:ssh => {
|
155
|
+
:lab_port => 22,
|
156
|
+
:lxc_port => 22
|
157
|
+
},
|
158
|
+
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
|
159
|
+
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
|
160
|
+
:aws_ssh_key_id => ENV['AWS_SSH_KEY_ID'],
|
161
|
+
:region => "us-west-2",
|
162
|
+
:availability_zone => "us-west-2a",
|
163
|
+
:aws_instance_arch => "i386",
|
164
|
+
:aws_instance_type => "c1.medium" )
|
165
|
+
|
166
|
+
artifacts ({ "chef-client-log" => "/var/log/chef/client.log",
|
167
|
+
"chef-client-stacktrace" => "/var/chef/cache/chef-stacktrace.out" })
|
168
|
+
|
169
|
+
chef.merge!( :version => "10.24.0",
|
170
|
+
:container_version => "10.18.2",
|
171
|
+
:cookbook_paths => %w(cookbooks site-cookbooks))
|
172
|
+
|
173
|
+
# chef.merge!( :version => "10.24.0")
|
174
|
+
# chef.merge!( :version => "11.4.0")
|
175
|
+
# chef.merge!( :version => "latest")
|
176
|
+
|
177
|
+
If you want to see how your cucumber-chef installation is configured run `cucumber-chef displayconfig`:
|
178
|
+
|
179
|
+
$ cucumber-chef displayconfig
|
180
|
+
cucumber-chef v3.0.3
|
181
|
+
--------------------------------------------------------------------------------
|
182
|
+
---
|
183
|
+
:mode: :user
|
184
|
+
:prerelease: false
|
185
|
+
:user: zpatten
|
186
|
+
:artifacts:
|
187
|
+
chef-client-log: /var/log/chef/client.log
|
188
|
+
chef-client-stacktrace: /var/chef/cache/chef-stacktrace.out
|
189
|
+
:chef:
|
190
|
+
:version: 10.24.0
|
191
|
+
:container_version: 10.18.2
|
192
|
+
:default_password: p@ssw0rd1
|
193
|
+
:render_client_rb: true
|
194
|
+
:cookbook_paths:
|
195
|
+
- cookbooks
|
196
|
+
- site-cookbooks
|
197
|
+
:test_lab:
|
198
|
+
:hostname: cucumber-chef
|
199
|
+
:tld: test-lab
|
200
|
+
:command_timeout: 1800
|
201
|
+
:provider: :vagrant
|
202
|
+
:aws:
|
203
|
+
:bootstrap_user: ubuntu
|
204
|
+
:lab_user: cucumber-chef
|
205
|
+
:lxc_user: root
|
206
|
+
:ssh:
|
207
|
+
:lab_port: 22
|
208
|
+
:lxc_port: 22
|
209
|
+
:ubuntu_release: precise
|
210
|
+
:aws_instance_arch: i386
|
211
|
+
:aws_instance_disk_store: ebs
|
212
|
+
:aws_instance_type: c1.medium
|
213
|
+
:aws_security_group: cucumber-chef
|
214
|
+
:identity_file:
|
215
|
+
:aws_access_key_id:
|
216
|
+
:aws_secret_access_key:
|
217
|
+
:aws_ssh_key_id:
|
218
|
+
:region: us-west-2
|
219
|
+
:availability_zone: us-west-2a
|
220
|
+
:vagrant:
|
221
|
+
:bootstrap_user: vagrant
|
222
|
+
:lab_user: cucumber-chef
|
223
|
+
:lxc_user: root
|
224
|
+
:ssh:
|
225
|
+
:lab_ip: 192.168.33.10
|
226
|
+
:lab_port: 22
|
227
|
+
:lxc_port: 22
|
228
|
+
:cpus: 4
|
229
|
+
:memory: 4096
|
230
|
+
:identity_file: /home/zpatten/.vagrant.d/insecure_private_key
|
231
|
+
|
232
|
+
--------------------------------------------------------------------------------
|
233
|
+
root_dir = "/home/zpatten/code/cc-chef-repo/vendor/checkouts/cucumber-chef"
|
234
|
+
home_dir = "/home/zpatten/code/cc-chef-repo/.cucumber-chef"
|
235
|
+
log_file = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/cucumber-chef.log"
|
236
|
+
artifacts_dir = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/vagrant/artifacts"
|
237
|
+
config_rb = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/config.rb"
|
238
|
+
labfile = "/home/zpatten/code/cc-chef-repo/Labfile"
|
239
|
+
chef_repo = "/home/zpatten/code/cc-chef-repo"
|
240
|
+
chef_user = "zpatten"
|
241
|
+
chef_identity = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/vagrant/zpatten.pem"
|
242
|
+
bootstrap_user = "vagrant"
|
243
|
+
bootstrap_user_home_dir = "/home/vagrant"
|
244
|
+
bootstrap_identity = "/home/zpatten/.vagrant.d/insecure_private_key"
|
245
|
+
lab_user = "cucumber-chef"
|
246
|
+
lab_user_home_dir = "/home/cucumber-chef"
|
247
|
+
lab_identity = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/vagrant/id_rsa-cucumber-chef"
|
248
|
+
lxc_user = "root"
|
249
|
+
lxc_user_home_dir = "/root"
|
250
|
+
lxc_identity = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/vagrant/id_rsa-root"
|
251
|
+
chef_pre_11 = true
|
252
|
+
--------------------------------------------------------------------------------
|
253
|
+
|
111
254
|
# Cucumber-Chef Tasks
|
112
255
|
|
113
256
|
All tasks should function in a similar manner across all providers.
|
data/lib/cucumber/chef/config.rb
CHANGED
@@ -175,11 +175,15 @@ module Cucumber
|
|
175
175
|
artifacts ({"chef-client-log" => "/var/log/chef/client.log",
|
176
176
|
"chef-client-stacktrace" => "/var/chef/cache/chef-stacktrace.out"})
|
177
177
|
|
178
|
-
chef ({
|
178
|
+
chef ({
|
179
|
+
:version => "latest",
|
179
180
|
:container_version => "latest",
|
180
181
|
:default_password => "p@ssw0rd1",
|
181
182
|
:render_client_rb => true,
|
182
|
-
:cookbook_paths => %w(cookbooks)
|
183
|
+
:cookbook_paths => %w(cookbooks),
|
184
|
+
:prereleases => false,
|
185
|
+
:nightlies => false
|
186
|
+
})
|
183
187
|
|
184
188
|
test_lab ({:hostname => "cucumber-chef",
|
185
189
|
:tld => "test-lab"})
|
@@ -87,6 +87,7 @@ module Cucumber
|
|
87
87
|
raise ProvisionerError, "You must have the environment variable 'USER' set." if !Cucumber::Chef::Config.user
|
88
88
|
|
89
89
|
ZTK::Benchmark.bench(:message => "Bootstrapping #{Cucumber::Chef::Config.provider.upcase} instance", :mark => "completed in %0.4f seconds.", :ui => @ui) do
|
90
|
+
server_name = @test_lab.ip
|
90
91
|
|
91
92
|
chef_solo_attributes = case Cucumber::Chef.chef_pre_11
|
92
93
|
when true then
|
@@ -99,14 +100,24 @@ module Cucumber
|
|
99
100
|
when false then
|
100
101
|
{
|
101
102
|
"chef-server" => {
|
103
|
+
"api_fqdn" => server_name,
|
102
104
|
"nginx" => {
|
103
105
|
"enable_non_ssl" => true,
|
104
|
-
"server_name" =>
|
105
|
-
"url" => "
|
106
|
+
"server_name" => server_name,
|
107
|
+
"url" => "https://#{server_name}"
|
108
|
+
},
|
109
|
+
"lb" => {
|
110
|
+
"fqdn" => server_name
|
111
|
+
},
|
112
|
+
"bookshelf" => {
|
113
|
+
"vip" => server_name
|
106
114
|
},
|
107
115
|
"chef_server_webui" => {
|
108
116
|
"enable" => true
|
109
|
-
}
|
117
|
+
},
|
118
|
+
"version" => Cucumber::Chef::Config.chef[:version],
|
119
|
+
"prereleases" => Cucumber::Chef::Config.chef[:prereleases],
|
120
|
+
"nightlies" => Cucumber::Chef::Config.chef[:nightlies]
|
110
121
|
},
|
111
122
|
"run_list" => %w(recipe[chef-server::default] role[test_lab])
|
112
123
|
}
|
@@ -122,6 +133,7 @@ module Cucumber
|
|
122
133
|
)
|
123
134
|
|
124
135
|
context = {
|
136
|
+
:server_name => server_name,
|
125
137
|
:lab_user => Cucumber::Chef.lab_user,
|
126
138
|
:chef_pre_11 => Cucumber::Chef.chef_pre_11,
|
127
139
|
:chef_solo_attributes => chef_solo_attributes,
|
@@ -63,6 +63,23 @@ bin/berks install --path ${CHEF_SOLO_ROOT}/cookbooks/
|
|
63
63
|
<% end -%>
|
64
64
|
|
65
65
|
chef-solo --config /etc/chef/solo.rb --json-attributes ${CHEF_SOLO_ROOT}/attributes.json --logfile /var/log/chef/chef-solo.log --log_level debug
|
66
|
+
<% if (@chef_pre_11 == false) -%>
|
67
|
+
|
68
|
+
cat << EOF | tee /etc/chef-server/chef-server.rb
|
69
|
+
#
|
70
|
+
# Auto-generated by Cucumber-Chef v#{Cucumber::Chef::VERSION} -- DO NOT EDIT!
|
71
|
+
#
|
72
|
+
server_name = "<%= @server_name %>"
|
73
|
+
#
|
74
|
+
topology "standalone"
|
75
|
+
api_fqdn server_name
|
76
|
+
nginx['url'] = "https://#{server_name}"
|
77
|
+
nginx['server_name'] = server_name
|
78
|
+
lb['fqdn'] = server_name
|
79
|
+
bookshelf['vip'] = server_name
|
80
|
+
EOF
|
81
|
+
sudo chef-server-ctl reconfigure
|
82
|
+
<% end -%>
|
66
83
|
|
67
84
|
echo -n "Waiting on <%= File.basename(@chef_validator) %> and <%= File.basename(@chef_webui) %> to appear..."
|
68
85
|
until [ -f <%= @chef_validator %> ] && [ -f <%= @chef_webui %> ]; do
|
@@ -72,8 +89,8 @@ done
|
|
72
89
|
echo "done."
|
73
90
|
|
74
91
|
cp -v <%= @chef_validator %> <%= @chef_webui %> ~/.chef
|
75
|
-
|
76
92
|
<% if (@chef_pre_11 == false) -%>
|
93
|
+
|
77
94
|
ln -sv <%= @chef_validator %> /etc/chef/validation.pem
|
78
95
|
ln -sv <%= @chef_admin %> /etc/chef/admin.pem
|
79
96
|
<% end -%>
|
@@ -24,7 +24,7 @@ module Cucumber
|
|
24
24
|
|
25
25
|
################################################################################
|
26
26
|
|
27
|
-
VERSION = "3.0.
|
27
|
+
VERSION = "3.0.4" unless const_defined?(:VERSION)
|
28
28
|
|
29
29
|
################################################################################
|
30
30
|
|