cucumber-chef 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -12,6 +12,8 @@ gem "cucumber-nagios", ">= 0"
12
12
  gem "rspec", ">= 0"
13
13
  gem "fog", ">= 0"
14
14
  gem "thor", ">= 0"
15
+ gem "awesome_print", ">= 0"
16
+ gem "net-scp", ">= 0"
15
17
 
16
18
  group :development do
17
19
  gem "bundler", "~> 1.0.0"
data/README.md CHANGED
@@ -1,36 +1,44 @@
1
1
  Cucumber-chef is a library of tools to enable the emerging discipline of infrastructure as code to practice test driven development. It provides a testing platform within which cucumber tests can be run which provision lightweight virtual machines, configure them by applying the appriporaite Chef roles to them, and then run acceptance and integration tests against the environment.
2
2
 
3
- ## Installation
3
+ ## Overview
4
4
 
5
- Cucumber-chef is distributed as a gem. Until it's published on Rubygems, you'll need to build the gem yourself. Check the project out, and then build and install the gem.
5
+ Cucumber-chef begins with a very simple premise. If we are framing our infratructure as code - if we're writing cookbooks, recipes and other pieces of automation in a high level programming language, such as Ruby, then it makes sense to follow the current wisdom across the software development world to maximise the quality, maintainability and reusability of our code, providing maximum chance that we'll deliver value with it. One area which has been shown to have a very positive effect is the practive of 'test-driven' development. In this paradigm, the developer begins by writing a test that captures the intended behaviour of the code they are going to write. This test will start out by failing. The developer then writes code to make the test pass, and iterates thereafter.
6
6
 
7
- First ensure you have bundler available, and then run:
7
+ Cucumber-chef provides a framework to make it easier to do test-driven development for infrastructure. It does this by providing a test infrastructure, in the cloud, which provides a very fast, lightweight and cheap way to fire up virtual machines for testing. We call this the "test lab".
8
8
 
9
- $ bundle install
9
+ As you might have guessed from the name, we're going to write high level acceptance tests using Cucumber. Cucumber-Chef provides step definitions and helper methods to make it easy to provision and manage machines with Chef, and then build end-to-end tests.
10
10
 
11
- Cucumber-chef uses Jeweler (see https://github.com/technicalpickles/jeweler) for managing gem builds , publishing and dependencies. To build the gem simply run:
11
+ ## Getting started
12
12
 
13
- $ rake build
13
+ Getting started with Cucumber-Chef is a simple, three step process:
14
14
 
15
- This will result in the gem appearing in pkg/. Install it:
15
+ 1) Install Cucumber-Chef
16
+ 2) Integrate with Hosted Chef and Amazon EC2
17
+ 3) Run cucumber-chef setup
16
18
 
17
- $ gem install pkg/cucumber-chef-0.0.4.gem
19
+ ### Installing Cucumber-Chef
18
20
 
19
- ## Overview
21
+ Installing Cucumber-Chef is simple. It's distributed as a RubyGem, so you can simply run:
20
22
 
21
- Cucumber-chef begins with a very simple premise. If we are framing our infratructure as code - if we're writing cookbooks, recipes and other pieces of automation in a high level programming language, such as Ruby, then it makes sense to follow the current wisdom across the software development world to maximise the quality, maintainability and reusability of our code, providing maximum chance that we'll deliver value with it. One area which has been shown to have a very positive effect is the practive of 'test-driven' development. In this paradigm, the developer begins by writing a test that captures the intended behaviour of the code they are going to write. This test will start out by failing. The developer then writes code to make the test pass, and iterates thereafter.
22
-
23
- Cucumber-chef provides a framework to make it easier to do test-driven development for infrastructure.
23
+ $ gem install cucumber-chef
24
24
 
25
- ### Vocabulary
25
+ Once installed, you can run cucumber-chef on the command line to get an overview of the tasks it can carry out.
26
26
 
27
- Throughout this documentation, a few terms will crop up regularly. It makes sense to define these up front, as they're just terms we've been using since we started writing cucumber-chef. They may even change, but in the meantime, so we're all n the same page, here are some of the terms we use:
27
+ $ cucumber-chef
28
+ Tasks:
29
+ cucumber-chef connect # Connect to a container in your test lab
30
+ cucumber-chef destroy # Destroy running test labs
31
+ cucumber-chef displayconfig # Display the current config from knife.rb
32
+ cucumber-chef help [TASK] # Describe available tasks or one specific task
33
+ cucumber-chef info # Display information about the current test lab
34
+ cucumber-chef project <project name> # Create a project template for testing an infrastructure
35
+ cucumber-chef setup # Set up a cucumber-chef test lab in Amazon EC2
36
+ cucumber-chef test # Run a cucumber-chef test suite from a workstation.
37
+ cucumber-chef upload <project name> # Upload a cucumber-chef test
28
38
 
29
- * Test Lab: An environment made up (at present) of an EC2 instance, configured to be an LXC host. This machine does nothing other than provide space in which Linux containers can be created and destroyed.
30
- * Controller: One special Linux container which acts as the central point from which tests are run. This machine is where the tests run, and has connectivity and credentials to connect to the machines that are created as part of a test run.
31
- * Container: A container is a lightweight virtual machine - it is entirely self-contained, with its own process tree, resource constraints, filesystem and network stack. It shares a kernel with the Test Lab host server.
39
+ ### Integrate with Hosted Chef and Amazon EC2
32
40
 
33
- ## Getting started
41
+ In it's current incarnation, Cucumber-Chef makes two important assumptions. Firstly, it assumes you're using Opscode Hosted Chef rather than your own Chef server. Secondly, it assume that you are comfortable with using Amazon's EC2 service for providing the 'bare metal' on which we set up the test lab.
34
42
 
35
43
  Cucumber-chef is tightly integrated with Chef - it uses your knife.rb for credentials, and any cucumber-chef-specific configuration goes in knife.rb under the cucumber-chef namespace.
36
44
 
@@ -40,28 +48,84 @@ On installation, the first thing you should do is run:
40
48
 
41
49
  This will look for your knife.rb, and extract the relevant sections, check them, and display them on the screen. If any entries are missing, it will alert you.
42
50
 
43
- The current recommendation is to keep your knife.rb inside your organisation's chef repository, in .chef, and use environment variables to specify username, organisation name and cloud provider credentials. Cucumber-chef supports and encourages this approach. It will search for a directory called .chef in your current directory, and then carry on going up the directory tree until it finds one. In practice this means that if you stay within the chef-repo directory for the organisation on which you're working, cucumber-chef will use the knife.rb; if your elsewhere in the filesystem rooted in your home directory, and have .chef in your home directory, cucumber-chef will use that. Otherwise you'll need to either change into a directory where a .chef can be found, or copy, creatre or link accordingly. In most cases we anticipate that you'll be inside the chef-repo of your organisation, and the documentation is written from this perspective.
51
+ The recommended best practice for Chef is to keep your knife.rb inside your organisation's Chef repository, inside the .chef directory, and use environment variables to specify username, organisation name and cloud provider credentials. Cucumber-chef supports and encourages this approach. It will search for a directory called .chef in your current directory, and then carry on going up the directory tree until it finds one. In practice this means that if you stay within the chef-repo directory for the organisation on which you're working, cucumber-chef will use the knife.rb; if your elsewhere in the filesystem rooted in your home directory, and have .chef in your home directory, cucumber-chef will use that. Otherwise you'll need to either change into a directory where a .chef can be found, or copy, creatre or link accordingly. In most cases we anticipate that you'll be inside the chef-repo of your organisation, and the documentation is written from this perspective.
44
52
 
45
- In its current incarnation, cucumber-chef makes two important assumptions. Firstly, we assume you're using the Opscode platform rather than your own Chef server. Secondly, we assume that you are comfortable with using Amazon's EC2 service for providing the 'bare metal' on which we set up the test lab. Future releases may well allow you to use your own Chef server, and will definitely look at offering alternative cloud providers. In the meantime, we welcome patches and pull requests!
53
+ If you haven't already, refactor your knife.rb to look like this:
46
54
 
47
- Set your environment variables:
55
+ current_dir = File.dirname(__FILE__)
56
+ user = ENV['OPSCODE_USER'] || ENV['USER']
57
+ log_level :info
58
+ log_location STDOUT
59
+ node_name user
60
+ client_key "#{ENV['HOME']}/.chef/#{user}.pem"
61
+ validation_client_name "#{ENV['ORGNAME']}-validator"
62
+ validation_key "#{ENV['HOME']}/.chef/#{ENV['ORGNAME']}-validator.pem"
63
+ chef_server_url "https://api.opscode.com/organizations/#{ENV['ORGNAME']}"
64
+ cache_type 'BasicFile'
65
+ cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
66
+ cookbook_path ["#{current_dir}/../cookbooks"]
67
+
68
+ Now set your Hosted Chef username and organization name using environment variables:
48
69
 
49
70
  $ export OPSCODE_USER=platform_user_name
50
71
  $ export ORGNAME=platform_organisation
72
+
73
+ Now put your validator and client keys in $HOME/.chef. Verify that everything still works:
74
+
75
+ $ knife client list
76
+
77
+ If you get results back, we're in business.
78
+
79
+ Now add the EC2 configuration:
80
+
81
+ knife[:aws_access_key_id] = ENV['AWS_ACCESS_KEY_ID']
82
+ knife[:aws_secret_access_key] = ENV['AWS_SECRET_ACCESS_KEY']
83
+ knife[:aws_ssh_key_id] = ENV['AWS_SSH_KEY_ID']
84
+ knife[:identity_file] = "/path/to/aws_ssh_key.pem"
85
+ knife[:availability_zone] = "eu-west-1a"
86
+ knife[:region] = "eu-west-1"
87
+ knife[:aws_image_id] = "ami-339ca947"
88
+
89
+ Note that right now Cucumber-Chef only supports Ubuntu-based test labs.
90
+
91
+ And set your environment variables:
92
+
51
93
  $ export AWS_ACCESS_KEY_ID=SEKRITKEY
52
94
  $ export AWS_SECRET_ACCESS_KEY=REELYSEKRITKEY
95
+ $ export AWS_SSH_KEY_ID
96
+
97
+ And then ensure your AWS ssh key is in place.
53
98
 
54
99
  Now check your config again, with cucumber-chef display config. If you get no complaints, you're ready to set up a test lab.
55
100
 
101
+
102
+ ### Run cucumber-chef setup
103
+
104
+
56
105
  $ cucumber-chef setup
57
106
 
58
- This command will set up a complete test lab environment, including a controller. As long as you've provided valid AWS and Opscode credentials, it will do this automatically. The process takes about 12 minutes, after which you'll have a fully cuntioning platform available for you to use.
107
+ This command will set up a complete test lab environment, As long as you've provided valid AWS and Opscode credentials, it will do this automatically. The process takes about 15 minutes, after which you'll have a fully funtioning platform available for you to use. Let's just quickly review what that means. You will have an EC2 machine, fully managed by Chef, and providing the following:
108
+
109
+ * The ability to provision LXC containers
110
+ * The ability to run tests against LXC containers
111
+ * A dedicated container for certain kinds of testing scenarios
59
112
 
60
113
  The next stage is to set up a project. A project is simply a directory structure for containing your cucumber features and steps, already set up with an appropriate environment to make use of the step definitions provided with cucumber-chef. We think it makes most sense to have this in your organisation's chef repo. Cucumber-chef provides a task which will create a the directory for you, and populate it with a README and an example feature and step.
61
114
 
62
- $ cucumber-chef project someproject
63
115
 
64
- **TO DO: fix this....**
116
+ $ cd /path/to/chef-repo
117
+ $ cucumber-chef project example
118
+
119
+ This will create a directory, cucumber-chef, and a subdirectory, example.
120
+
121
+ └── example
122
+ ├── README
123
+ └── features
124
+ ├── example.feature
125
+ ├── step_definitions
126
+ │   └── example_step.rb
127
+ └── support
128
+ └── env.rb
65
129
 
66
130
  ## Writing tests
67
131
 
@@ -78,6 +142,12 @@ You can write the tests and Chef code wherever you like. We're assuming you pre
78
142
 
79
143
  $ cucumber-chef test myproject
80
144
 
81
- At the moment cucumber-chef doesn't pass though clever filtering and tagging options that cucumber supports - you run all te tests. We're going to improve that soon, again, patches and pull requests very welcome.
145
+ At the moment cucumber-chef doesn't pass though clever filtering and tagging options that cucumber supports - you run all the tests. We're going to improve that soon, again, patches and pull requests very welcome.
146
+
147
+ Running the test task will upload your current project to the test lab, and run the tests, reporting the results back to the screen. Cucumber-chef also provides an upload task, so you can push the current project to the test lab, and then connect to test lab yourself to run tests in a more granular way. To do this, you need to know the IP of the test lab. You can find this out by running:
148
+
149
+ $ cucumber-chef info
150
+
151
+ At present, Cucumber-Chef only allows one test lab per AWS account and Opscode Hosted Chef account.
152
+
82
153
 
83
- Running the test task will upload your current project to the controller, and run the tests.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cucumber-chef}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Stephen Nelson-Smith"]
12
- s.date = %q{2011-06-14}
12
+ s.date = %q{2011-06-21}
13
13
  s.default_executable = %q{cucumber-chef}
14
14
  s.description = %q{Framework for behaviour-drive infrastructure development.}
15
15
  s.email = %q{stephen@atalanta-systems.com}
@@ -94,6 +94,8 @@ Gem::Specification.new do |s|
94
94
  s.add_runtime_dependency(%q<rspec>, [">= 0"])
95
95
  s.add_runtime_dependency(%q<fog>, [">= 0"])
96
96
  s.add_runtime_dependency(%q<thor>, [">= 0"])
97
+ s.add_runtime_dependency(%q<awesome_print>, [">= 0"])
98
+ s.add_runtime_dependency(%q<net-scp>, [">= 0"])
97
99
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
98
100
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
99
101
  s.add_development_dependency(%q<rcov>, [">= 0"])
@@ -104,6 +106,8 @@ Gem::Specification.new do |s|
104
106
  s.add_dependency(%q<rspec>, [">= 0"])
105
107
  s.add_dependency(%q<fog>, [">= 0"])
106
108
  s.add_dependency(%q<thor>, [">= 0"])
109
+ s.add_dependency(%q<awesome_print>, [">= 0"])
110
+ s.add_dependency(%q<net-scp>, [">= 0"])
107
111
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
108
112
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
109
113
  s.add_dependency(%q<rcov>, [">= 0"])
@@ -115,6 +119,8 @@ Gem::Specification.new do |s|
115
119
  s.add_dependency(%q<rspec>, [">= 0"])
116
120
  s.add_dependency(%q<fog>, [">= 0"])
117
121
  s.add_dependency(%q<thor>, [">= 0"])
122
+ s.add_dependency(%q<awesome_print>, [">= 0"])
123
+ s.add_dependency(%q<net-scp>, [">= 0"])
118
124
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
119
125
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
120
126
  s.add_dependency(%q<rcov>, [">= 0"])
@@ -40,7 +40,7 @@ module Cucumber
40
40
  @config
41
41
  end
42
42
 
43
- def test_config
43
+ def self.test_config
44
44
  config = self.new
45
45
  config[:mode] = "test"
46
46
  config
@@ -17,7 +17,7 @@ module Cucumber
17
17
  raise TestLabError.new("A test lab already exists using the AWS credentials you supplied")
18
18
  end
19
19
  server_definition = {
20
- :image_id => "ami-339ca947",
20
+ :image_id => @config[:knife][:aws_image_id],
21
21
  :groups => "default",
22
22
  :flavor_id => "m1.small",
23
23
  :key_name => @config[:knife][:aws_ssh_key_id],
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cucumber-chef
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Stephen Nelson-Smith
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-14 00:00:00 +01:00
13
+ date: 2011-06-21 00:00:00 +01:00
14
14
  default_executable: cucumber-chef
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -80,8 +80,30 @@ dependencies:
80
80
  prerelease: false
81
81
  version_requirements: *id006
82
82
  - !ruby/object:Gem::Dependency
83
- name: bundler
83
+ name: awesome_print
84
84
  requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: net-scp
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ type: :runtime
102
+ prerelease: false
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: bundler
106
+ requirement: &id009 !ruby/object:Gem::Requirement
85
107
  none: false
86
108
  requirements:
87
109
  - - ~>
@@ -89,10 +111,10 @@ dependencies:
89
111
  version: 1.0.0
90
112
  type: :development
91
113
  prerelease: false
92
- version_requirements: *id007
114
+ version_requirements: *id009
93
115
  - !ruby/object:Gem::Dependency
94
116
  name: jeweler
95
- requirement: &id008 !ruby/object:Gem::Requirement
117
+ requirement: &id010 !ruby/object:Gem::Requirement
96
118
  none: false
97
119
  requirements:
98
120
  - - ~>
@@ -100,10 +122,10 @@ dependencies:
100
122
  version: 1.6.2
101
123
  type: :development
102
124
  prerelease: false
103
- version_requirements: *id008
125
+ version_requirements: *id010
104
126
  - !ruby/object:Gem::Dependency
105
127
  name: rcov
106
- requirement: &id009 !ruby/object:Gem::Requirement
128
+ requirement: &id011 !ruby/object:Gem::Requirement
107
129
  none: false
108
130
  requirements:
109
131
  - - ">="
@@ -111,7 +133,7 @@ dependencies:
111
133
  version: "0"
112
134
  type: :development
113
135
  prerelease: false
114
- version_requirements: *id009
136
+ version_requirements: *id011
115
137
  description: Framework for behaviour-drive infrastructure development.
116
138
  email: stephen@atalanta-systems.com
117
139
  executables:
@@ -194,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
216
  requirements:
195
217
  - - ">="
196
218
  - !ruby/object:Gem::Version
197
- hash: 1974008823645017826
219
+ hash: 1485817935090543312
198
220
  segments:
199
221
  - 0
200
222
  version: "0"