cucumber-chef 1.0.3 → 2.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/.gitignore +8 -35
  2. data/.rspec +1 -0
  3. data/.rvmrc.template +2 -0
  4. data/.travis.yml +22 -0
  5. data/Gemfile +2 -15
  6. data/LICENSE +202 -201
  7. data/NOTICE +9 -0
  8. data/README.md +696 -92
  9. data/Rakefile +39 -25
  10. data/TODO.md +28 -0
  11. data/bin/cc-knife +32 -0
  12. data/bin/cucumber-chef +409 -79
  13. data/chef_repo/cookbooks/cucumber-chef/LICENSE +202 -0
  14. data/chef_repo/cookbooks/cucumber-chef/README.md +69 -0
  15. data/chef_repo/cookbooks/cucumber-chef/attributes/default.rb +27 -0
  16. data/chef_repo/cookbooks/cucumber-chef/metadata.rb +13 -0
  17. data/chef_repo/cookbooks/cucumber-chef/recipes/default.rb +23 -0
  18. data/chef_repo/cookbooks/cucumber-chef/recipes/lxc.rb +315 -0
  19. data/chef_repo/cookbooks/cucumber-chef/recipes/test_lab.rb +146 -0
  20. data/chef_repo/cookbooks/cucumber-chef/templates/default/db-168-192.erb +15 -0
  21. data/chef_repo/cookbooks/cucumber-chef/templates/default/db-test-lab.erb +15 -0
  22. data/chef_repo/cookbooks/cucumber-chef/templates/default/dhcpd-conf.erb +44 -0
  23. data/chef_repo/cookbooks/cucumber-chef/templates/default/gemrc.erb +10 -0
  24. data/{cookbooks/cucumber-chef/files/default/cucumber-net → chef_repo/cookbooks/cucumber-chef/templates/default/lxc-initializer-config.erb} +1 -1
  25. data/chef_repo/cookbooks/cucumber-chef/templates/default/lxc-install-chef.erb +3 -0
  26. data/chef_repo/cookbooks/cucumber-chef/templates/default/motd.erb +10 -0
  27. data/chef_repo/cookbooks/cucumber-chef/templates/default/named-conf-local.erb +25 -0
  28. data/{cookbooks/cucumber-chef/files/default/permissive-ssh-config → chef_repo/cookbooks/cucumber-chef/templates/default/ssh-config.erb} +3 -1
  29. data/chef_repo/roles/test_lab.rb +24 -0
  30. data/cucumber-chef.gemspec +50 -123
  31. data/examples/README.md +7 -0
  32. data/examples/users_add.feature +51 -0
  33. data/examples/users_auto_remove.feature +50 -0
  34. data/features/support/env.rb +3 -2
  35. data/lib/cucumber/chef/bootstrap.rb +94 -0
  36. data/lib/cucumber/chef/command.rb +78 -0
  37. data/lib/cucumber/chef/config.rb +143 -93
  38. data/lib/cucumber/chef/helpers/chef_client.rb +87 -0
  39. data/lib/cucumber/chef/helpers/chef_server.rb +90 -0
  40. data/lib/cucumber/chef/helpers/command.rb +57 -0
  41. data/lib/cucumber/chef/helpers/container.rb +154 -0
  42. data/lib/cucumber/chef/helpers/minitest.rb +35 -0
  43. data/lib/cucumber/chef/helpers/server.rb +81 -0
  44. data/lib/cucumber/chef/helpers/test_lab.rb +46 -0
  45. data/lib/cucumber/chef/helpers/utility.rb +73 -0
  46. data/lib/cucumber/chef/helpers.rb +56 -0
  47. data/lib/cucumber/chef/logger.rb +90 -0
  48. data/lib/cucumber/chef/provisioner.rb +275 -69
  49. data/lib/cucumber/chef/ssh.rb +190 -0
  50. data/lib/cucumber/chef/steps/chef_steps.rb +32 -0
  51. data/lib/cucumber/chef/steps/minitest_steps.rb +29 -0
  52. data/lib/cucumber/chef/steps/provision_steps.rb +60 -0
  53. data/lib/cucumber/chef/steps/ssh_steps.rb +95 -0
  54. data/lib/cucumber/chef/steps.rb +27 -0
  55. data/lib/cucumber/chef/tcp_socket.rb +83 -0
  56. data/lib/cucumber/chef/template.rb +57 -0
  57. data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-test-lab.erb +99 -0
  58. data/lib/cucumber/chef/templates/cucumber/env.rb +56 -0
  59. data/lib/cucumber/chef/templates/cucumber/example_feature.erb +49 -0
  60. data/lib/cucumber/chef/templates/cucumber/example_steps.erb +11 -0
  61. data/lib/cucumber/chef/templates/cucumber/readme-data_bags.erb +1 -0
  62. data/lib/cucumber/chef/templates/cucumber/readme-keys.erb +1 -0
  63. data/lib/cucumber/chef/templates/cucumber/readme-roles.erb +1 -0
  64. data/lib/cucumber/chef/templates/cucumber/readme.erb +18 -0
  65. data/lib/cucumber/chef/templates/cucumber-chef/config-rb.erb +33 -0
  66. data/lib/cucumber/chef/templates/cucumber-chef/cucumber-yml.erb +2 -0
  67. data/lib/cucumber/chef/templates/cucumber-chef/knife-rb.erb +18 -0
  68. data/lib/cucumber/chef/test_lab.rb +308 -52
  69. data/lib/cucumber/chef/test_runner.rb +86 -15
  70. data/lib/cucumber/chef/utility.rb +128 -0
  71. data/lib/cucumber/chef/version.rb +30 -1
  72. data/lib/cucumber/chef.rb +53 -20
  73. data/lib/cucumber-chef.rb +24 -1
  74. data/spec/cucumber/chef/config_spec.rb +144 -78
  75. data/spec/cucumber/chef/provisioner_spec.rb +60 -16
  76. data/spec/cucumber/chef/test_lab_spec.rb +62 -19
  77. data/spec/spec_helper.rb +30 -26
  78. data/todo.org +17 -0
  79. metadata +267 -163
  80. data/.document +0 -5
  81. data/VERSION +0 -1
  82. data/cookbooks/cucumber-chef/README.rdoc +0 -8
  83. data/cookbooks/cucumber-chef/files/default/add-git-identity +0 -2
  84. data/cookbooks/cucumber-chef/files/default/controller-first-boot +0 -1
  85. data/cookbooks/cucumber-chef/files/default/cucumber-private-key +0 -27
  86. data/cookbooks/cucumber-chef/files/default/cucumber-run_list +0 -1
  87. data/cookbooks/cucumber-chef/files/default/git-private-key +0 -27
  88. data/cookbooks/cucumber-chef/files/default/install-chef +0 -1
  89. data/cookbooks/cucumber-chef/files/default/lxc-controller-network-config +0 -5
  90. data/cookbooks/cucumber-chef/files/default/lxc-lucid-chef +0 -378
  91. data/cookbooks/cucumber-chef/metadata.rb +0 -6
  92. data/cookbooks/cucumber-chef/recipes/controller.rb +0 -51
  93. data/cookbooks/cucumber-chef/recipes/lxc.rb +0 -35
  94. data/cookbooks/cucumber-chef/recipes/test_lab.rb +0 -23
  95. data/cookbooks/cucumber-chef/recipes/testrunner.rb +0 -46
  96. data/cookbooks/cucumber-chef/roles/controller.rb +0 -7
  97. data/cookbooks/cucumber-chef/roles/test_lab_test.rb +0 -9
  98. data/cookbooks/cucumber-chef/templates/default/controller-client.erb +0 -5
  99. data/cookbooks/cucumber-chef/templates/default/lxc-lucid-chef +0 -385
  100. data/lib/cucumber/chef/handy.rb +0 -90
  101. data/lib/cucumber/chef/templates/controller.erb +0 -35
  102. data/lib/cucumber/chef/templates/env.rb +0 -16
  103. data/lib/cucumber/chef/templates/example_feature.erb +0 -11
  104. data/lib/cucumber/chef/templates/example_step.erb +0 -19
  105. data/lib/cucumber/chef/templates/readme.erb +0 -14
  106. data/lib/cucumber/chef/templates/ubuntu10.04-gems.erb +0 -43
  107. data/lib/cucumber/ec2_server_create.rb +0 -99
  108. data/website/website.html +0 -385
@@ -1,99 +0,0 @@
1
- require 'fog'
2
- require 'socket'
3
- require 'chef/knife'
4
- require 'chef/knife/bootstrap'
5
- require 'chef/json_compat'
6
-
7
- class Chef
8
- class Knife
9
- class Ec2ServerCreate < Knife
10
-
11
- attr_accessor :initial_sleep_delay
12
-
13
- def tcp_test_ssh(hostname)
14
- tcp_socket = TCPSocket.new(hostname, 22)
15
- readable = IO.select([tcp_socket], nil, nil, 5)
16
- if readable
17
- Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")
18
- yield
19
- true
20
- else
21
- false
22
- end
23
- rescue Errno::ETIMEDOUT
24
- false
25
- rescue Errno::ECONNREFUSED
26
- sleep 2
27
- false
28
- ensure
29
- tcp_socket && tcp_socket.close
30
- end
31
-
32
- def run
33
- require 'fog'
34
- require 'highline'
35
- require 'net/ssh/multi'
36
- require 'readline'
37
-
38
- $stdout.sync = true
39
-
40
- connection = Fog::Compute.new(
41
- :provider => 'AWS',
42
- :aws_access_key_id => Chef::Config[:knife][:aws_access_key_id],
43
- :aws_secret_access_key => Chef::Config[:knife][:aws_secret_access_key],
44
- :region => #REGION
45
- )
46
-
47
- # WHAT IS THIS FOR?
48
- ami = connection.images.get(locate_config_value(:image))
49
-
50
- server_def = {
51
- :image_id => locate_config_value(:image),
52
- :groups => config[:security_groups],
53
- :flavor_id => locate_config_value(:flavor),
54
- :key_name => Chef::Config[:knife][:aws_ssh_key_id],
55
- :availability_zone => Chef::Config[:knife][:availability_zone]
56
- }
57
-
58
- server = connection.servers.create(server_def)
59
-
60
- puts "Instance ID: #{server.id}"
61
- print "\n#{h.color("Waiting for server", :magenta)}"
62
-
63
- # wait for it to be ready to do stuff
64
- server.wait_for { print "."; ready? }
65
-
66
- puts("\n")
67
-
68
- puts "Public IP Address #{server.public_ip_address}"
69
-
70
- print "\n#{h.color("Waiting for sshd", :magenta)}"
71
-
72
- print(".") until tcp_test_ssh(server.dns_name) { sleep @initial_sleep_delay ||= 10; puts("done") }
73
-
74
- bootstrap_for_node(server).run
75
-
76
- end
77
-
78
- def bootstrap_for_node(server)
79
- bootstrap = Chef::Knife::Bootstrap.new
80
- bootstrap.name_args = [server.dns_name]
81
- bootstrap.config[:run_list] = config[:run_list]
82
- bootstrap.config[:ssh_user] = config[:ssh_user]
83
- bootstrap.config[:identity_file] = config[:identity_file]
84
- bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id
85
- bootstrap.config[:prerelease] = config[:prerelease]
86
- bootstrap.config[:distro] = locate_config_value(:distro)
87
- bootstrap.config[:use_sudo] = true
88
- bootstrap.config[:template_file] = locate_config_value(:template_file)
89
- bootstrap.config[:environment] = config[:environment]
90
- bootstrap
91
- end
92
-
93
- def locate_config_value(key)
94
- key = key.to_sym
95
- Chef::Config[:knife][key] || config[key]
96
- end
97
- end
98
- end
99
- end
data/website/website.html DELETED
@@ -1,385 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
- "http://www.w3.org/TR/html4/strict.dtd">
3
-
4
- <html lang="en">
5
- <head>
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
- <title>Cucumber-chef</title>
8
- <!-- Typekit service section -->
9
- <script type="text/javascript"
10
- src="http://use.typekit.com/jmb0kkz.js"></script>
11
-
12
- <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
13
- <!-- End of typekit service section -->
14
-
15
- <!-- Framework CSS --> <link rel="stylesheet" href="style/style.css"
16
- type="text/css" media="screen, projection"> </head>
17
-
18
-
19
- <body> <div class="container">
20
-
21
-
22
- <div id="nav">
23
- <ul>
24
- <li class="selected">Main</li>
25
- <li>Docs</li>
26
- </ul>
27
- </div>
28
-
29
- <div id="header">
30
- <img src="images/cucumber-chef-logo.png" width="380" height="46"
31
- alt="Cucumber Chef Logo"/>
32
-
33
- <h3>A library of tools to enable test driven development</h3>
34
- </div>
35
-
36
- <div class="page">
37
-
38
- <div id="panel">
39
- <a href="https://github.com/Atalanta/cucumber-chef"><img
40
- src="images/large-button.png" width="252" height="52" class="imgpad"
41
- alt="Git Hub" /></a>
42
-
43
- <a href="http://oreilly.com/catalog/0636920020042"><img
44
- src="images/book-cover.png" width="252" height="330" alt="Book
45
- Cover"/></a>
46
-
47
- <p class="book-description">Test-Driven Infrastructure with
48
- Chef<br/>by Stephen Nelson-Smith<br/>Published by O’Reilly</p>
49
-
50
- <a href="http://oreilly.com/catalog/0636920020042"><img
51
- src="images/buy-button.png" width="62" height="27" alt="Buy
52
- Button"/></a>
53
-
54
- </div>
55
-
56
- <h2>Overview</h2>
57
-
58
- <p><strong>Cucumber-chef</strong>is a library of tools to enable the
59
- emerging discipline of infrastructure as code to practice test driven
60
- development. It provides a testing platform within which cucumber
61
- tests can be run which provision lightweight virtual machines,
62
- configure them by applying the appriporaite Chef roles to them, and
63
- then run acceptance and integration tests against the environment.</p>
64
-
65
-
66
-
67
- <p>It begins with a very simple premise. with a very simple
68
- premise. If we are framing our infratructure as code - if we're
69
- writing cookbooks, recipes and other pieces of automation in a high
70
- level programming language, such as Ruby, then it makes sense to
71
- follow the current wisdom across the software development world to
72
- maximise the quality, maintainability and reusability of our code,
73
- providing maximum chance that we'll deliver value with it. One
74
- area which has been shown to have a very positive effect is the
75
- practive of 'test-driven' development. In this paradigm, the
76
- developer begins by writing a test that captures the intended
77
- behaviour of the code they are going to write. This test will
78
- start out by failing. The developer then writes code to make the
79
- test pass, and iterates thereafter.</p>
80
-
81
- <strong>Cucumber-Chef</strong> provides a framework to make it easier
82
- to do test-driven development for infrastructure. It does this by
83
- providing a test infrastructure, in the cloud, which provides a very
84
- fast, lightweight and cheap way to fire up virtual machines for
85
- testing. We call this the "test lab".</p>
86
-
87
-
88
- <p>As you might have guessed from the name, we're going to write high
89
- level acceptance tests using Cucumber. Cucumber-Chef provides step
90
- definitions and helper methods to make it easy to provision and manage
91
- machines with Chef, and then build end-to-end tests.</p>
92
-
93
-
94
- <ul> <li><strong>Test Lab:</strong> An environment made up (at
95
- present) of an EC2 instance, configured to be an LXC host. This
96
- machine does nothing other than provide space in which Linux
97
- containers can be created and destroyed.</li>
98
-
99
- <li><strong>Controller:</strong> One special Linux container which
100
- acts as the central point from which tests are run. This machine is
101
- where the tests run, and has connectivity and credentials to connect
102
- to the machines that are created as part of a test run.</li>
103
-
104
- <li><strong>Container:</strong> A container is a lightweight virtual
105
- machine - it is entirely self-contained, with its own process tree,
106
- resource constraints, filesystem and network stack. It shares a
107
- kernel with the Test Lab host server.</li> </ul>
108
-
109
-
110
- <h3>Getting Started</h3>
111
-
112
- <p>Getting started with <strong>Cucumber-Chef</strong> is a simple,
113
- three step process:</p>
114
-
115
-
116
-
117
- <ul>
118
- <li>1) Install Cucumber-Chef</li>
119
- <li>2) Integrate with Hosted Chef and Amazon EC2</li>
120
- <li>3) Run cucumber-chef setup</li>
121
- </ul>
122
-
123
- <h3>Installing Cucumber-Chef</h3>
124
-
125
- <p>Installing Cucumber-Chef is simple. It's distributed as a
126
- RubyGem, so you can simply run:</p>
127
-
128
-
129
- <div class="inset-box">
130
- <pre><code>$ gem install cucumber-chef
131
- </code></pre>
132
- </div>
133
-
134
- <p>Once installed, you can run cucumber-chef on the command line to
135
- get an overview of the tasks it can carry out.</p>
136
-
137
-
138
- <div class="inset-box">
139
- <pre><code>$ cucumber-chef
140
- Tasks:
141
- cucumber-chef connect # Connect to a container in your test lab
142
- cucumber-chef destroy # Destroy running test labs
143
- cucumber-chef displayconfig # Display the current config from knife.rb
144
- cucumber-chef help [TASK] # Describe available tasks or one specific task
145
- cucumber-chef info # Display information about the current test lab
146
- cucumber-chef project &lt;project name&gt; # Create a project template for testing an infrastructure
147
- cucumber-chef setup # Set up a cucumber-chef test lab in Amazon EC2
148
- cucumber-chef test # Run a cucumber-chef test suite from a workstation.
149
- cucumber-chef upload &lt;project name&gt; # Upload a cucumber-chef test
150
- </code></pre>
151
- </div>
152
-
153
- <h3>Integrate with Hosted Chef and Amazon EC2</h3>
154
-
155
- <p>In it's current incarnation, Cucumber-Chef makes two important
156
- assumptions. Firstly, it assumes you're using Opscode Hosted Chef
157
- rather than your own Chef server. Secondly, it assume that you are
158
- comfortable with using Amazon's EC2 service for providing the 'bare
159
- metal' on which we set up the test lab. </p>
160
-
161
-
162
-
163
- <p><strong>Cucumber-chef</strong> is tightly integrated with Chef - it
164
- uses your knife.rb for credentials, and any cucumber-chef-specific
165
- configuration goes in knife.rb under the cucumber-chef namespace.</p>
166
-
167
-
168
- <p>On installation, the first thing you should do is run:</p>
169
-
170
- <div class="inset-box">
171
- <pre>
172
- $ cucumber-chef displayconfig
173
- </pre>
174
- </div>
175
-
176
- <p>This will look for your knife.rb, and extract the relevant
177
- sections, check them, and display them on the screen. If any entries
178
- are missing, it will alert you.</p>
179
-
180
-
181
- <p>The recommended best practice for Chef is to keep your knife.rb
182
- inside your organisation's Chef repository, inside the .chef
183
- directory, and use environment variables to specify username,
184
- organisation name and cloud provider credentials. Cucumber-chef
185
- supports and encourages this approach. It will search for a
186
- directory called .chef in your current directory, and then carry on
187
- going up the directory tree until it finds one. In practice this
188
- means that if you stay within the chef-repo directory for the
189
- organisation on which you're working, cucumber-chef will use the
190
- knife.rb; if your elsewhere in the filesystem rooted in your home
191
- directory, and have .chef in your home directory, cucumber-chef
192
- will use that. Otherwise you'll need to either change into a
193
- directory where a .chef can be found, or copy, creatre or link
194
- accordingly. In most cases we anticipate that you'll be inside the
195
- chef-repo of your organisation, and the documentation is written
196
- from this perspective.</p>
197
-
198
- <p>If you haven't already, refactor your knife.rb to look like this:</p>
199
-
200
- <div class="inset-box">
201
- <pre><code>current_dir = File.dirname(__FILE__)
202
- user = ENV['OPSCODE_USER'] || ENV['USER']
203
- log_level :info
204
- log_location STDOUT
205
- node_name user
206
- client_key "#{ENV['HOME']}/.chef/#{user}.pem"
207
- validation_client_name "#{ENV['ORGNAME']}-validator"
208
- validation_key "#{ENV['HOME']}/.chef/#{ENV['ORGNAME']}-validator.pem"
209
- chef_server_url "https://api.opscode.com/organizations/#{ENV['ORGNAME']}"
210
- cache_type 'BasicFile'
211
- cache_options( :path =&gt; "#{ENV['HOME']}/.chef/checksums" )
212
- cookbook_path ["#{current_dir}/../cookbooks"]
213
- </code></pre>
214
- </div>
215
-
216
- <p>Now set your Hosted Chef username and organization name using
217
- environment variables:</p>
218
-
219
-
220
- <div class="inset-box">
221
- <pre><code>$ export OPSCODE_USER=platform_user_name
222
- $ export ORGNAME=platform_organisation
223
- </code></pre>
224
- </div>
225
-
226
- <p>Now put your validator and client keys in $HOME/.chef. Verify that
227
- everything still works:</p>
228
-
229
-
230
- <div class="inset-box">
231
- <pre><code>$ knife client list
232
- </code></pre>
233
- </div>
234
-
235
- <p>If you get results back, we're in business.</p>
236
-
237
- <p>Now add the EC2 configuration:</p>
238
-
239
- <div class="inset-box">
240
- <pre><code>knife[:aws_access_key_id] = ENV['AWS_ACCESS_KEY_ID']
241
- knife[:aws_secret_access_key] = ENV['AWS_SECRET_ACCESS_KEY']
242
- knife[:aws_ssh_key_id] = ENV['AWS_SSH_KEY_ID']
243
- knife[:identity_file] = "/path/to/aws_ssh_key.pem"
244
- knife[:availability_zone] = "eu-west-1a"
245
- knife[:region] = "eu-west-1"
246
- knife[:aws_image_id] = "ami-339ca947"
247
- </code></pre>
248
- </div>
249
-
250
- <p>Note that right now Cucumber-Chef only supports Ubuntu-based test
251
- labs.</p>
252
-
253
-
254
- <p>And set your environment variables:</p>
255
-
256
- <div class="inset-box">
257
- <pre><code>$ export AWS_ACCESS_KEY_ID=SEKRITKEY
258
- $ export AWS_SECRET_ACCESS_KEY=REELYSEKRITKEY
259
- $ export AWS_SSH_KEY_ID
260
- </code></pre>
261
- </div>
262
-
263
- <p>And then ensure your AWS ssh key is in place.</p>
264
-
265
- <p>Now check your config again, with cucumber-chef display config. If
266
- you get no complaints, you're ready to set up a test lab.</p>
267
-
268
-
269
- <h3>Run cucumber-chef setup</h3>
270
-
271
- <div class="inset-box">
272
- <pre><code>$ cucumber-chef setup
273
- </code></pre>
274
- </div>
275
-
276
- <p>This command will set up a complete test lab environment, As long
277
- as you've provided valid AWS and Opscode credentials, it will do this
278
- automatically. The process takes about 15 minutes, after which you'll
279
- have a fully funtioning platform available for you to use. Let's just
280
- quickly review what that means. You will have an EC2 machine, fully
281
- managed by Chef, and providing the following:</p>
282
-
283
-
284
- <ul>
285
- <li>The ability to provision LXC containers</li>
286
- <li>The ability to run tests against LXC containers</li>
287
- <li>A dedicated container for certain kinds of testing scenarios</li>
288
- </ul>
289
-
290
- <p>The next stage is to set up a project. A project is simply a
291
- directory structure for containing your cucumber features and steps,
292
- already set up with an appropriate environment to make use of the
293
- step definitions provided with cucumber-chef. We think it makes
294
- most sense to have this in your organisation's chef repo.
295
- Cucumber-chef provides a task which will create a the directory for
296
- you, and populate it with a README and an example feature and
297
- step.</p>
298
-
299
-
300
- <div class="inset-box">
301
- <pre><code>$ cd /path/to/chef-repo
302
- $ cucumber-chef project example
303
- </code></pre>
304
- </div>
305
-
306
- <p>This will create a directory, cucumber-chef, and a subdirectory, example.</p>
307
-
308
- <div class="inset-box">
309
- <pre><code>└── example
310
- ├── README
311
- └── features
312
- ├── example.feature
313
- ├── step_definitions
314
- │ └── example_step.rb
315
- └── support
316
- └── env.rb
317
- </code></pre>
318
- </div>
319
-
320
- <h2>Writing tests</h2>
321
-
322
- <p>Once you've got your test lab set up, and you've generated a
323
- project, it's time to crack on with writing a test. The basic idea is
324
- this:</p>
325
-
326
-
327
-
328
- <p>
329
- <ul>
330
- <li>1) An infrastructure requirement is established</li>
331
- <li>2) Write a cucumber feature that expresses the required
332
- behaviour of the infrastructure requirement</li>
333
-
334
- <li>3) Write steps that will build this infrastructure environment
335
- on the test lab, using the step definitions provided - these include
336
- the ability to create a container, apply roles to it, and destroy it
337
- again.</li>
338
-
339
- <li>4) Write cookbooks and recipes and supporting code to make
340
- the test pass</li>
341
- </ul></p>
342
-
343
- <h2>Running tests</h2>
344
-
345
- <p>You can write the tests and Chef code wherever you like. We're
346
- assuming you prefer working on your local machine, and checking into
347
- version control. But we don't really care. When it's time to run
348
- tests, cucumber-chef provides a task which handles this:</p>
349
-
350
-
351
- <div class="inset-box">
352
- <pre><code>$ cucumber-chef test myproject
353
- </code></pre>
354
- </div>
355
-
356
- <p>At the moment cucumber-chef doesn't pass though clever filtering
357
- and tagging options that cucumber supports - you run all the tests.
358
- We're going to improve that soon, again, patches and pull requests
359
- very welcome.</p>
360
-
361
-
362
- <p>Running the test task will upload your current project to the test
363
- lab, and run the tests, reporting the results back to the screen.
364
- Cucumber-chef also provides an upload task, so you can push the
365
- current project to the test lab, and then connect to test lab yourself
366
- to run tests in a more granular way. To do this, you need to know the
367
- IP of the test lab. You can find this out by running:</p>
368
-
369
-
370
- <div class="inset-box">
371
- <pre><code>$ cucumber-chef info
372
- </code></pre>
373
- </div>
374
-
375
- <p>At present, Cucumber-Chef only allows one test lab per AWS account
376
- and Opscode Hosted Chef account.</p>
377
-
378
-
379
- </div>
380
-
381
- </div>
382
-
383
- </body>
384
-
385
- </html>