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.
- data/.gitignore +8 -35
- data/.rspec +1 -0
- data/.rvmrc.template +2 -0
- data/.travis.yml +22 -0
- data/Gemfile +2 -15
- data/LICENSE +202 -201
- data/NOTICE +9 -0
- data/README.md +696 -92
- data/Rakefile +39 -25
- data/TODO.md +28 -0
- data/bin/cc-knife +32 -0
- data/bin/cucumber-chef +409 -79
- data/chef_repo/cookbooks/cucumber-chef/LICENSE +202 -0
- data/chef_repo/cookbooks/cucumber-chef/README.md +69 -0
- data/chef_repo/cookbooks/cucumber-chef/attributes/default.rb +27 -0
- data/chef_repo/cookbooks/cucumber-chef/metadata.rb +13 -0
- data/chef_repo/cookbooks/cucumber-chef/recipes/default.rb +23 -0
- data/chef_repo/cookbooks/cucumber-chef/recipes/lxc.rb +315 -0
- data/chef_repo/cookbooks/cucumber-chef/recipes/test_lab.rb +146 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/db-168-192.erb +15 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/db-test-lab.erb +15 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/dhcpd-conf.erb +44 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/gemrc.erb +10 -0
- data/{cookbooks/cucumber-chef/files/default/cucumber-net → chef_repo/cookbooks/cucumber-chef/templates/default/lxc-initializer-config.erb} +1 -1
- data/chef_repo/cookbooks/cucumber-chef/templates/default/lxc-install-chef.erb +3 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/motd.erb +10 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/named-conf-local.erb +25 -0
- data/{cookbooks/cucumber-chef/files/default/permissive-ssh-config → chef_repo/cookbooks/cucumber-chef/templates/default/ssh-config.erb} +3 -1
- data/chef_repo/roles/test_lab.rb +24 -0
- data/cucumber-chef.gemspec +50 -123
- data/examples/README.md +7 -0
- data/examples/users_add.feature +51 -0
- data/examples/users_auto_remove.feature +50 -0
- data/features/support/env.rb +3 -2
- data/lib/cucumber/chef/bootstrap.rb +94 -0
- data/lib/cucumber/chef/command.rb +78 -0
- data/lib/cucumber/chef/config.rb +143 -93
- data/lib/cucumber/chef/helpers/chef_client.rb +87 -0
- data/lib/cucumber/chef/helpers/chef_server.rb +90 -0
- data/lib/cucumber/chef/helpers/command.rb +57 -0
- data/lib/cucumber/chef/helpers/container.rb +154 -0
- data/lib/cucumber/chef/helpers/minitest.rb +35 -0
- data/lib/cucumber/chef/helpers/server.rb +81 -0
- data/lib/cucumber/chef/helpers/test_lab.rb +46 -0
- data/lib/cucumber/chef/helpers/utility.rb +73 -0
- data/lib/cucumber/chef/helpers.rb +56 -0
- data/lib/cucumber/chef/logger.rb +90 -0
- data/lib/cucumber/chef/provisioner.rb +275 -69
- data/lib/cucumber/chef/ssh.rb +190 -0
- data/lib/cucumber/chef/steps/chef_steps.rb +32 -0
- data/lib/cucumber/chef/steps/minitest_steps.rb +29 -0
- data/lib/cucumber/chef/steps/provision_steps.rb +60 -0
- data/lib/cucumber/chef/steps/ssh_steps.rb +95 -0
- data/lib/cucumber/chef/steps.rb +27 -0
- data/lib/cucumber/chef/tcp_socket.rb +83 -0
- data/lib/cucumber/chef/template.rb +57 -0
- data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-test-lab.erb +99 -0
- data/lib/cucumber/chef/templates/cucumber/env.rb +56 -0
- data/lib/cucumber/chef/templates/cucumber/example_feature.erb +49 -0
- data/lib/cucumber/chef/templates/cucumber/example_steps.erb +11 -0
- data/lib/cucumber/chef/templates/cucumber/readme-data_bags.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme-keys.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme-roles.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme.erb +18 -0
- data/lib/cucumber/chef/templates/cucumber-chef/config-rb.erb +33 -0
- data/lib/cucumber/chef/templates/cucumber-chef/cucumber-yml.erb +2 -0
- data/lib/cucumber/chef/templates/cucumber-chef/knife-rb.erb +18 -0
- data/lib/cucumber/chef/test_lab.rb +308 -52
- data/lib/cucumber/chef/test_runner.rb +86 -15
- data/lib/cucumber/chef/utility.rb +128 -0
- data/lib/cucumber/chef/version.rb +30 -1
- data/lib/cucumber/chef.rb +53 -20
- data/lib/cucumber-chef.rb +24 -1
- data/spec/cucumber/chef/config_spec.rb +144 -78
- data/spec/cucumber/chef/provisioner_spec.rb +60 -16
- data/spec/cucumber/chef/test_lab_spec.rb +62 -19
- data/spec/spec_helper.rb +30 -26
- data/todo.org +17 -0
- metadata +267 -163
- data/.document +0 -5
- data/VERSION +0 -1
- data/cookbooks/cucumber-chef/README.rdoc +0 -8
- data/cookbooks/cucumber-chef/files/default/add-git-identity +0 -2
- data/cookbooks/cucumber-chef/files/default/controller-first-boot +0 -1
- data/cookbooks/cucumber-chef/files/default/cucumber-private-key +0 -27
- data/cookbooks/cucumber-chef/files/default/cucumber-run_list +0 -1
- data/cookbooks/cucumber-chef/files/default/git-private-key +0 -27
- data/cookbooks/cucumber-chef/files/default/install-chef +0 -1
- data/cookbooks/cucumber-chef/files/default/lxc-controller-network-config +0 -5
- data/cookbooks/cucumber-chef/files/default/lxc-lucid-chef +0 -378
- data/cookbooks/cucumber-chef/metadata.rb +0 -6
- data/cookbooks/cucumber-chef/recipes/controller.rb +0 -51
- data/cookbooks/cucumber-chef/recipes/lxc.rb +0 -35
- data/cookbooks/cucumber-chef/recipes/test_lab.rb +0 -23
- data/cookbooks/cucumber-chef/recipes/testrunner.rb +0 -46
- data/cookbooks/cucumber-chef/roles/controller.rb +0 -7
- data/cookbooks/cucumber-chef/roles/test_lab_test.rb +0 -9
- data/cookbooks/cucumber-chef/templates/default/controller-client.erb +0 -5
- data/cookbooks/cucumber-chef/templates/default/lxc-lucid-chef +0 -385
- data/lib/cucumber/chef/handy.rb +0 -90
- data/lib/cucumber/chef/templates/controller.erb +0 -35
- data/lib/cucumber/chef/templates/env.rb +0 -16
- data/lib/cucumber/chef/templates/example_feature.erb +0 -11
- data/lib/cucumber/chef/templates/example_step.erb +0 -19
- data/lib/cucumber/chef/templates/readme.erb +0 -14
- data/lib/cucumber/chef/templates/ubuntu10.04-gems.erb +0 -43
- data/lib/cucumber/ec2_server_create.rb +0 -99
- data/website/website.html +0 -385
data/lib/cucumber/chef.rb
CHANGED
@@ -1,33 +1,66 @@
|
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Stephen Nelson-Smith <stephen@atalanta-systems.com>
|
4
|
+
# Author: Zachary Patten <zachary@jovelabs.com>
|
5
|
+
# Copyright: Copyright (c) 2011-2012 Atalanta Systems Ltd
|
6
|
+
# License: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
################################################################################
|
21
|
+
|
1
22
|
require 'readline'
|
2
23
|
require 'socket'
|
3
24
|
require 'stringio'
|
4
25
|
|
26
|
+
################################################################################
|
27
|
+
|
5
28
|
require 'chef'
|
6
29
|
require 'chef/cookbook_uploader'
|
7
|
-
require '
|
8
|
-
require 'chef/knife/bootstrap'
|
9
|
-
require 'chef/knife/core/bootstrap_context'
|
10
|
-
require 'chef/knife/ssh'
|
30
|
+
require 'erubis'
|
11
31
|
require 'fog'
|
12
|
-
require '
|
13
|
-
require '
|
32
|
+
require 'json'
|
33
|
+
require 'mixlib/config'
|
34
|
+
require 'net/ssh'
|
35
|
+
require 'net/ssh/proxy/command'
|
36
|
+
require 'net/sftp'
|
37
|
+
require 'ubuntu_ami'
|
38
|
+
|
39
|
+
################################################################################
|
14
40
|
|
15
41
|
module Cucumber
|
16
42
|
module Chef
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
43
|
+
|
44
|
+
class Error < StandardError; end
|
45
|
+
|
46
|
+
require 'cucumber/chef/utility'
|
47
|
+
extend(Cucumber::Chef::Utility)
|
48
|
+
|
23
49
|
end
|
24
50
|
end
|
25
51
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
52
|
+
################################################################################
|
53
|
+
|
54
|
+
require 'cucumber/chef/bootstrap'
|
55
|
+
require 'cucumber/chef/command'
|
56
|
+
require 'cucumber/chef/config'
|
57
|
+
require 'cucumber/chef/logger'
|
58
|
+
require 'cucumber/chef/provisioner'
|
59
|
+
require 'cucumber/chef/ssh'
|
60
|
+
require 'cucumber/chef/tcp_socket'
|
61
|
+
require 'cucumber/chef/template'
|
62
|
+
require 'cucumber/chef/test_lab'
|
63
|
+
require 'cucumber/chef/test_runner'
|
64
|
+
require 'cucumber/chef/version'
|
65
|
+
|
66
|
+
################################################################################
|
data/lib/cucumber-chef.rb
CHANGED
@@ -1 +1,24 @@
|
|
1
|
-
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Stephen Nelson-Smith <stephen@atalanta-systems.com>
|
4
|
+
# Author: Zachary Patten <zachary@jovelabs.com>
|
5
|
+
# Copyright: Copyright (c) 2011-2012 Atalanta Systems Ltd
|
6
|
+
# License: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
################################################################################
|
21
|
+
|
22
|
+
require 'cucumber/chef'
|
23
|
+
|
24
|
+
################################################################################
|
@@ -1,114 +1,180 @@
|
|
1
|
-
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Stephen Nelson-Smith <stephen@atalanta-systems.com>
|
4
|
+
# Author: Zachary Patten <zachary@jovelabs.com>
|
5
|
+
# Copyright: Copyright (c) 2011-2012 Atalanta Systems Ltd
|
6
|
+
# License: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
################################################################################
|
21
|
+
|
22
|
+
require 'spec_helper'
|
23
|
+
|
24
|
+
VALID_RELEASES = %w( precise )
|
25
|
+
VALID_REGIONS = %w( us-west-1 us-east-1 eu-west-1 )
|
26
|
+
VALID_ARCHS = %w( i386 amd64 )
|
27
|
+
VALID_DISK_STORES = %w( instance-store ebs )
|
2
28
|
|
3
29
|
describe Cucumber::Chef::Config do
|
4
|
-
|
5
|
-
|
6
|
-
|
30
|
+
|
31
|
+
################################################################################
|
32
|
+
|
33
|
+
before(:each) do
|
34
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "cucumber", "chef", "config.rb"))
|
7
35
|
end
|
8
36
|
|
9
37
|
after(:each) do
|
10
|
-
|
11
|
-
ENV["OPSCODE_USER"] = @opscode_user
|
38
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb"))
|
12
39
|
end
|
13
40
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}.to raise_error(Cucumber::Chef::ConfigError, /ORGNAME/)
|
21
|
-
end
|
41
|
+
################################################################################
|
42
|
+
|
43
|
+
describe "Cucumber::Chef::Config default values" do
|
44
|
+
|
45
|
+
it "Cucumber::Chef::Config[:mode] defaults to :user" do
|
46
|
+
Cucumber::Chef::Config[:mode].should == :user
|
22
47
|
end
|
23
48
|
|
24
|
-
|
25
|
-
|
26
|
-
ENV["OPSCODE_USER"] = ""
|
27
|
-
expect {
|
28
|
-
subject.verify
|
29
|
-
}.to raise_error(Cucumber::Chef::ConfigError, /OPSCODE_USER/)
|
30
|
-
end
|
49
|
+
it "Cucumber::Chef::Config[:provider] defaults to :aws" do
|
50
|
+
Cucumber::Chef::Config[:provider].should == :aws
|
31
51
|
end
|
32
52
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
expect {
|
38
|
-
subject.verify
|
39
|
-
}.to raise_error(Cucumber::Chef::ConfigError, /chef_server_url.*aws_access_key_id/)
|
53
|
+
context "Cucumber::Chef::Config[:aws] default values" do
|
54
|
+
|
55
|
+
it "Cucumber::Chef::Config[:aws][:aws_security_group] defaults to 'cucumber-chef'" do
|
56
|
+
Cucumber::Chef::Config[:aws][:aws_security_group].should == "cucumber-chef"
|
40
57
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
ENV["OPSCODE_USER"] = "REALLYBOGUSORGNAME"
|
45
|
-
expect {
|
46
|
-
subject.verify
|
47
|
-
}.to raise_error(Cucumber::Chef::ConfigError, /Opscode platform credentials/)
|
48
|
-
end
|
58
|
+
|
59
|
+
it "Cucumber::Chef::Config[:aws][:ubuntu_release] defaults to 'precise'" do
|
60
|
+
Cucumber::Chef::Config[:aws][:ubuntu_release].should == "precise"
|
49
61
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
62
|
+
|
63
|
+
it "Cucumber::Chef::Config[:aws][:aws_instance_arch] defaults to 'i386'" do
|
64
|
+
Cucumber::Chef::Config[:aws][:aws_instance_arch].should == "i386"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "Cucumber::Chef::Config[:aws][:aws_instance_disk_store] defaults to 'ebs'" do
|
68
|
+
Cucumber::Chef::Config[:aws][:aws_instance_disk_store].should == "ebs"
|
58
69
|
end
|
59
|
-
end
|
60
70
|
|
61
|
-
|
62
|
-
|
63
|
-
subject.verify
|
71
|
+
it "Cucumber::Chef::Config[:aws][:aws_instance_type] defaults to 'm1.small'" do
|
72
|
+
Cucumber::Chef::Config[:aws][:aws_instance_type].should == "m1.small"
|
64
73
|
end
|
74
|
+
|
65
75
|
end
|
76
|
+
|
66
77
|
end
|
67
78
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
79
|
+
################################################################################
|
80
|
+
|
81
|
+
describe "class method: aws_image_id" do
|
82
|
+
|
83
|
+
it "should return ami_image_id if Cucumber::Chef::Config[:aws][:aws_image_id] is set" do
|
84
|
+
aws_image_id = "ami-12345678"
|
85
|
+
Cucumber::Chef::Config[:aws][:aws_image_id] = aws_image_id
|
86
|
+
Cucumber::Chef::Config.aws_image_id.should == aws_image_id
|
87
|
+
end
|
88
|
+
|
89
|
+
VALID_RELEASES.each do |release|
|
90
|
+
VALID_REGIONS.each do |region|
|
91
|
+
VALID_ARCHS.each do |arch|
|
92
|
+
VALID_DISK_STORES.each do |disk_store|
|
93
|
+
|
94
|
+
it "should return an ami_image_id if release='#{release}', region='#{region}', arch='#{arch}', disk_store='#{disk_store}'" do
|
95
|
+
Cucumber::Chef::Config[:aws][:ubuntu_release] = release
|
96
|
+
Cucumber::Chef::Config[:aws][:region] = region
|
97
|
+
Cucumber::Chef::Config[:aws][:aws_instance_arch] = arch
|
98
|
+
Cucumber::Chef::Config[:aws][:aws_instance_disk_store] = disk_store
|
99
|
+
|
100
|
+
expect{ Cucumber::Chef::Config.aws_image_id }.to_not raise_error(Cucumber::Chef::ConfigError)
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
77
105
|
end
|
78
106
|
end
|
107
|
+
|
79
108
|
end
|
80
109
|
|
110
|
+
################################################################################
|
111
|
+
|
81
112
|
describe "when configuration is valid" do
|
82
|
-
it "should list the configuration values" do
|
83
|
-
output = subject.list.join("\n")
|
84
|
-
output.should match(/node_name:/)
|
85
|
-
output.should match(/knife\[:aws_secret_access_key\]:/)
|
86
|
-
end
|
87
113
|
|
88
|
-
it "should
|
89
|
-
|
90
|
-
|
114
|
+
it "should allow changing providers" do
|
115
|
+
Cucumber::Chef::Config[:provider] = :aws
|
116
|
+
expect{ Cucumber::Chef::Config.verify_keys }.to_not raise_error(Cucumber::Chef::ConfigError)
|
117
|
+
|
118
|
+
Cucumber::Chef::Config[:provider] = :vagrant
|
119
|
+
expect{ Cucumber::Chef::Config.verify_keys }.to_not raise_error(Cucumber::Chef::ConfigError)
|
91
120
|
end
|
92
121
|
|
93
|
-
it "should allow
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
122
|
+
it "should allow changing modes" do
|
123
|
+
Cucumber::Chef::Config[:mode] = :test
|
124
|
+
expect{ Cucumber::Chef::Config.verify_keys }.to_not raise_error(Cucumber::Chef::ConfigError)
|
125
|
+
|
126
|
+
Cucumber::Chef::Config[:mode] = :user
|
127
|
+
expect{ Cucumber::Chef::Config.verify_keys }.to_not raise_error(Cucumber::Chef::ConfigError)
|
98
128
|
end
|
99
129
|
|
100
|
-
|
101
|
-
|
102
|
-
|
130
|
+
# this explodes in CI because we won't have our secret values set
|
131
|
+
context "when provider is aws" do
|
132
|
+
it "should verify the configuration" do
|
133
|
+
user = ENV['OPSCODE_USER'] || ENV['USER']
|
134
|
+
Cucumber::Chef::Config[:provider] = :aws
|
135
|
+
Cucumber::Chef::Config[:aws][:aws_access_key_id] = ENV['AWS_ACCESS_KEY_ID']
|
136
|
+
Cucumber::Chef::Config[:aws][:aws_secret_access_key] = ENV['AWS_SECRET_ACCESS_KEY']
|
137
|
+
Cucumber::Chef::Config[:aws][:aws_ssh_key_id] = ENV['AWS_SSH_KEY_ID'] || user
|
138
|
+
Cucumber::Chef::Config[:aws][:identity_file] = "#{ENV['HOME']}/.chef/#{user}.pem"
|
139
|
+
Cucumber::Chef::Config[:aws][:region] = "us-west-2"
|
140
|
+
Cucumber::Chef::Config[:aws][:availability_zone] = "us-west-2a"
|
141
|
+
expect{ Cucumber::Chef::Config.verify }.to_not raise_error(Cucumber::Chef::ConfigError)
|
142
|
+
end
|
143
|
+
end if !ENV['CI'] && !ENV['TRAVIS']
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
################################################################################
|
148
|
+
|
149
|
+
describe "when configuration is invalid" do
|
150
|
+
|
151
|
+
it "should complain about missing configuration keys" do
|
152
|
+
Cucumber::Chef::Config[:provider] = nil
|
153
|
+
expect{ Cucumber::Chef::Config.verify_keys }.to raise_error(Cucumber::Chef::ConfigError)
|
154
|
+
|
155
|
+
Cucumber::Chef::Config[:mode] = nil
|
156
|
+
expect{ Cucumber::Chef::Config.verify_keys }.to raise_error(Cucumber::Chef::ConfigError)
|
103
157
|
end
|
104
158
|
|
105
|
-
it "should
|
106
|
-
Cucumber::Chef::Config
|
159
|
+
it "should complain about invalid configuration key values" do
|
160
|
+
Cucumber::Chef::Config[:provider] = :awss
|
161
|
+
expect{ Cucumber::Chef::Config.verify_keys }.to raise_error(Cucumber::Chef::ConfigError)
|
162
|
+
|
163
|
+
Cucumber::Chef::Config[:mode] = :userr
|
164
|
+
expect{ Cucumber::Chef::Config.verify_keys }.to raise_error(Cucumber::Chef::ConfigError)
|
107
165
|
end
|
108
166
|
|
109
|
-
|
110
|
-
|
167
|
+
describe "when provider is aws" do
|
168
|
+
|
169
|
+
it "should complain about missing provider configuration keys" do
|
170
|
+
Cucumber::Chef::Config[:provider] = :aws
|
171
|
+
expect{ Cucumber::Chef::Config.verify_provider_keys }.to raise_error(Cucumber::Chef::ConfigError)
|
172
|
+
end
|
173
|
+
|
111
174
|
end
|
175
|
+
|
112
176
|
end
|
113
|
-
end
|
114
177
|
|
178
|
+
################################################################################
|
179
|
+
|
180
|
+
end
|
@@ -1,10 +1,35 @@
|
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Stephen Nelson-Smith <stephen@atalanta-systems.com>
|
4
|
+
# Author: Zachary Patten <zachary@jovelabs.com>
|
5
|
+
# Copyright: Copyright (c) 2011-2012 Atalanta Systems Ltd
|
6
|
+
# License: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
################################################################################
|
21
|
+
|
22
|
+
require 'spec_helper'
|
23
|
+
=begin
|
1
24
|
require File.join(File.dirname(__FILE__), "../../spec_helper.rb")
|
2
25
|
|
3
26
|
describe Cucumber::Chef::Provisioner do
|
4
27
|
before(:all) do
|
5
|
-
@config = Cucumber::Chef::Config.test_config
|
28
|
+
@config = Cucumber::Chef::Config.test_config(StringIO.new, StringIO.new, StringIO.new)
|
6
29
|
end
|
7
30
|
|
31
|
+
subject { Cucumber::Chef::Provisioner.new(@config, StringIO.new, StringIO.new, StringIO.new) }
|
32
|
+
|
8
33
|
describe "upload_cookbook" do
|
9
34
|
before(:each) do
|
10
35
|
begin
|
@@ -18,7 +43,7 @@ describe Cucumber::Chef::Provisioner do
|
|
18
43
|
end
|
19
44
|
|
20
45
|
it "should upload the cucumber-chef cookbook" do
|
21
|
-
subject.upload_cookbook
|
46
|
+
subject.upload_cookbook
|
22
47
|
::Chef::CookbookVersion.list["cucumber-chef"].should be
|
23
48
|
end
|
24
49
|
end
|
@@ -28,38 +53,57 @@ describe Cucumber::Chef::Provisioner do
|
|
28
53
|
begin
|
29
54
|
role_path = File.expand_path("cookbooks/cucumber-chef/roles")
|
30
55
|
::Chef::Config[:role_path] = role_path
|
31
|
-
role = ::Chef::Role.from_disk("
|
56
|
+
role = ::Chef::Role.from_disk("test_lab")
|
32
57
|
role.destroy
|
33
58
|
rescue Net::HTTPServerException => err
|
34
59
|
end
|
35
60
|
end
|
36
61
|
|
37
62
|
it "should upload the test_lab role" do
|
38
|
-
subject.upload_role
|
39
|
-
::Chef::Role.list["
|
63
|
+
subject.upload_role
|
64
|
+
::Chef::Role.list["test_lab"].should be
|
40
65
|
end
|
41
66
|
end
|
42
67
|
|
43
68
|
describe "bootstrap_node" do
|
69
|
+
before(:all) do
|
70
|
+
subject.upload_cookbook
|
71
|
+
subject.upload_role
|
72
|
+
end
|
73
|
+
|
44
74
|
before(:each) do
|
45
|
-
@test_lab = Cucumber::Chef::TestLab.new(@config)
|
75
|
+
@test_lab = Cucumber::Chef::TestLab.new(@config, StringIO.new, StringIO.new, StringIO.new)
|
46
76
|
@test_lab.destroy
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
77
|
+
begin
|
78
|
+
@server = @test_lab.create
|
79
|
+
rescue
|
80
|
+
puts("Output from #create:")
|
81
|
+
subject.stdout.rewind
|
82
|
+
puts(subject.stdout.read)
|
83
|
+
raise
|
84
|
+
end
|
52
85
|
end
|
53
|
-
|
86
|
+
|
54
87
|
after(:each) do
|
55
88
|
@test_lab.destroy
|
56
89
|
end
|
57
90
|
|
58
|
-
it "should assign a random name to the node" do
|
59
|
-
|
60
|
-
|
91
|
+
it "should assign a random name to the node", :slow => true do
|
92
|
+
begin
|
93
|
+
subject.bootstrap_node(@server)
|
94
|
+
rescue
|
95
|
+
subject.stdout.rewind; subject.stderr.rewind
|
96
|
+
puts("Output from #bootstrap_node:")
|
97
|
+
puts(" STDOUT:\n", subject.stdout.read, "\n\n")
|
98
|
+
puts(" STDERR:\n", subject.stderr.read, "\n\n")
|
99
|
+
raise
|
100
|
+
end
|
101
|
+
sleep(30)
|
102
|
+
found_node = !!@test_lab.nodes.detect do |node|
|
61
103
|
node.name.match /^cucumber-chef-[0-9a-f]{8}$/
|
62
|
-
end
|
104
|
+
end
|
105
|
+
found_node.should be
|
63
106
|
end
|
64
107
|
end
|
65
108
|
end
|
109
|
+
=end
|
@@ -1,47 +1,90 @@
|
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Stephen Nelson-Smith <stephen@atalanta-systems.com>
|
4
|
+
# Author: Zachary Patten <zachary@jovelabs.com>
|
5
|
+
# Copyright: Copyright (c) 2011-2012 Atalanta Systems Ltd
|
6
|
+
# License: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
################################################################################
|
21
|
+
|
22
|
+
require 'spec_helper'
|
23
|
+
=begin
|
1
24
|
require File.join(File.dirname(__FILE__), "../../spec_helper.rb")
|
2
25
|
|
3
26
|
describe Cucumber::Chef::TestLab do
|
4
27
|
before(:all) do
|
5
|
-
@config = Cucumber::Chef::Config.test_config
|
28
|
+
@config = Cucumber::Chef::Config.test_config(StringIO.new, StringIO.new, StringIO.new)
|
29
|
+
end
|
30
|
+
|
31
|
+
subject { Cucumber::Chef::TestLab.new(@config, StringIO.new, StringIO.new, StringIO.new) }
|
32
|
+
|
33
|
+
it "should create a cucumber-chef security group" do
|
34
|
+
existing_group = subject.connection.security_groups.get("cucumber-chef")
|
35
|
+
existing_group && existing_group.destroy
|
36
|
+
subject.connection.security_groups.get("cucumber-chef").should_not be
|
37
|
+
lab = Cucumber::Chef::TestLab.new(@config, StringIO.new, StringIO.new, StringIO.new)
|
38
|
+
permissions = lab.connection.security_groups.get("cucumber-chef").ip_permissions
|
39
|
+
permissions.size.should == 1
|
40
|
+
permissions.first["fromPort"].should == 22
|
41
|
+
permissions.first["toPort"].should == 22
|
42
|
+
permissions.first["fromPort"].should == 4000
|
43
|
+
permissions.first["toPort"].should == 4000
|
44
|
+
permissions.first["fromPort"].should == 4040
|
45
|
+
permissions.first["toPort"].should == 4040
|
6
46
|
end
|
7
47
|
|
8
|
-
subject { Cucumber::Chef::TestLab.new(@config) }
|
9
|
-
|
10
48
|
describe "with no running labs" do
|
11
49
|
it "should not return any info" do
|
12
|
-
subject.info
|
50
|
+
subject.info
|
51
|
+
subject.stdout.rewind
|
52
|
+
subject.stdout.read.should match(/no test labs/)
|
13
53
|
end
|
14
54
|
end
|
15
55
|
|
16
|
-
describe "
|
56
|
+
describe "create" do
|
17
57
|
after(:each) { subject.destroy }
|
18
58
|
|
19
59
|
it "should spin up an ec2 instance", :slow => true do
|
20
|
-
|
21
|
-
subject.
|
22
|
-
|
23
|
-
output.read.should match(/Platform provisioned/)
|
60
|
+
subject.create
|
61
|
+
subject.stdout.rewind
|
62
|
+
subject.stdout.read.should match(/Instance provisioned/)
|
24
63
|
end
|
25
64
|
|
26
|
-
it "should
|
27
|
-
subject.
|
28
|
-
|
29
|
-
|
30
|
-
|
65
|
+
it "should attempt reprovision if ec2 instance already exists", :slow => true do
|
66
|
+
subject.create
|
67
|
+
subject.stdout.truncate(0)
|
68
|
+
subject.create
|
69
|
+
subject.stdout.rewind
|
70
|
+
subject.stdout.read.should match(/attempting to reprovision/)
|
31
71
|
end
|
32
72
|
|
33
73
|
it "should report its public ip address", :slow => true do
|
34
|
-
server = subject.
|
35
|
-
subject.info
|
74
|
+
server = subject.create
|
75
|
+
subject.info
|
76
|
+
subject.stdout.rewind
|
77
|
+
subject.stdout.read.should match(/#{server.public_ip_address}/)
|
36
78
|
end
|
37
79
|
end
|
38
80
|
|
39
81
|
describe "destroy" do
|
40
82
|
it "should destroy the running ec2 instance", :slow => true do
|
41
|
-
subject.
|
83
|
+
server = subject.create
|
42
84
|
subject.destroy
|
43
|
-
subject.
|
85
|
+
subject.stdout.rewind
|
86
|
+
subject.stdout.read.should match(/Destroying Server: #{server.public_ip_address}/)
|
44
87
|
end
|
45
88
|
end
|
46
89
|
end
|
47
|
-
|
90
|
+
=end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,28 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Stephen Nelson-Smith <stephen@atalanta-systems.com>
|
4
|
+
# Author: Zachary Patten <zachary@jovelabs.com>
|
5
|
+
# Copyright: Copyright (c) 2011-2012 Atalanta Systems Ltd
|
6
|
+
# License: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
################################################################################
|
4
21
|
|
5
|
-
|
6
|
-
tcp_socket = TCPSocket.new(hostname, 22)
|
7
|
-
IO.select([tcp_socket], nil, nil, 5)
|
8
|
-
rescue Errno::ETIMEDOUT
|
9
|
-
false
|
10
|
-
rescue Errno::EPERM
|
11
|
-
false
|
12
|
-
rescue Errno::ECONNREFUSED
|
13
|
-
sleep 2
|
14
|
-
false
|
15
|
-
# This happens on EC2 quite often
|
16
|
-
rescue Errno::EHOSTUNREACH
|
17
|
-
sleep 2
|
18
|
-
false
|
19
|
-
ensure
|
20
|
-
tcp_socket && tcp_socket.close
|
21
|
-
end
|
22
|
+
require 'cucumber-chef'
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
dev_null = File.open("/dev/null", "w")
|
25
|
+
$logger = Cucumber::Chef::Logger.new(dev_null)
|
26
|
+
|
27
|
+
require 'simplecov'
|
28
|
+
SimpleCov.start do
|
29
|
+
add_filter '/spec/'
|
30
|
+
end if ENV["COVERAGE"]
|
31
|
+
|
32
|
+
################################################################################
|