test-kitchen 1.0.0.beta.4 → 1.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -1
- data/Gemfile +1 -1
- data/README.md +18 -7
- data/Rakefile +8 -1
- data/features/kitchen_init_command.feature +90 -11
- data/features/step_definitions/git_steps.rb +3 -0
- data/lib/kitchen/busser.rb +79 -45
- data/lib/kitchen/cli.rb +14 -13
- data/lib/kitchen/config.rb +79 -138
- data/lib/kitchen/data_munger.rb +224 -0
- data/lib/kitchen/driver/base.rb +4 -31
- data/lib/kitchen/driver/ssh_base.rb +6 -16
- data/lib/kitchen/driver.rb +4 -0
- data/lib/kitchen/generator/init.rb +20 -9
- data/lib/kitchen/instance.rb +53 -58
- data/lib/kitchen/lazy_hash.rb +50 -0
- data/lib/kitchen/platform.rb +2 -31
- data/lib/kitchen/provisioner/base.rb +55 -9
- data/lib/kitchen/provisioner/chef/berkshelf.rb +76 -0
- data/lib/kitchen/provisioner/chef/librarian.rb +72 -0
- data/lib/kitchen/provisioner/chef_base.rb +159 -78
- data/lib/kitchen/provisioner/chef_solo.rb +6 -36
- data/lib/kitchen/provisioner/chef_zero.rb +70 -59
- data/lib/kitchen/provisioner/dummy.rb +28 -0
- data/lib/kitchen/provisioner.rb +6 -4
- data/lib/kitchen/shell_out.rb +2 -5
- data/lib/kitchen/ssh.rb +1 -1
- data/lib/kitchen/suite.rb +10 -79
- data/lib/kitchen/util.rb +2 -2
- data/lib/kitchen/version.rb +2 -2
- data/lib/kitchen.rb +5 -0
- data/spec/kitchen/config_spec.rb +84 -123
- data/spec/kitchen/data_munger_spec.rb +1412 -0
- data/spec/kitchen/driver/base_spec.rb +30 -0
- data/spec/kitchen/instance_spec.rb +868 -86
- data/spec/kitchen/lazy_hash_spec.rb +63 -0
- data/spec/kitchen/platform_spec.rb +0 -22
- data/spec/kitchen/provisioner/base_spec.rb +210 -0
- data/spec/kitchen/provisioner_spec.rb +70 -0
- data/spec/kitchen/suite_spec.rb +25 -38
- data/spec/spec_helper.rb +1 -0
- data/support/chef-client-zero.rb +51 -35
- data/support/dummy-validation.pem +27 -0
- data/templates/init/kitchen.yml.erb +10 -22
- data/test-kitchen.gemspec +1 -2
- metadata +20 -18
data/lib/kitchen/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
4
|
#
|
5
|
-
# Copyright (C) 2012, Fletcher Nichol
|
5
|
+
# Copyright (C) 2012, 2013, Fletcher Nichol
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
# you may not use this file except in compliance with the License.
|
@@ -18,5 +18,5 @@
|
|
18
18
|
|
19
19
|
module Kitchen
|
20
20
|
|
21
|
-
VERSION = "1.0.0.
|
21
|
+
VERSION = "1.0.0.rc.1"
|
22
22
|
end
|
data/lib/kitchen.rb
CHANGED
@@ -31,6 +31,7 @@ require 'kitchen/busser'
|
|
31
31
|
require 'kitchen/color'
|
32
32
|
require 'kitchen/collection'
|
33
33
|
require 'kitchen/config'
|
34
|
+
require 'kitchen/data_munger'
|
34
35
|
require 'kitchen/driver'
|
35
36
|
require 'kitchen/driver/base'
|
36
37
|
require 'kitchen/driver/proxy'
|
@@ -85,6 +86,10 @@ module Kitchen
|
|
85
86
|
|
86
87
|
# Default log level verbosity
|
87
88
|
DEFAULT_LOG_LEVEL = :info
|
89
|
+
|
90
|
+
DEFAULT_TEST_DIR = "test/integration".freeze
|
91
|
+
|
92
|
+
DEFAULT_LOG_DIR = ".kitchen/logs".freeze
|
88
93
|
end
|
89
94
|
|
90
95
|
# Initialize the base logger
|
data/spec/kitchen/config_spec.rb
CHANGED
@@ -25,6 +25,7 @@ require 'kitchen/config'
|
|
25
25
|
require 'kitchen/driver'
|
26
26
|
require 'kitchen/instance'
|
27
27
|
require 'kitchen/platform'
|
28
|
+
require 'kitchen/provisioner'
|
28
29
|
require 'kitchen/suite'
|
29
30
|
require 'kitchen/util'
|
30
31
|
|
@@ -45,189 +46,149 @@ end
|
|
45
46
|
describe Kitchen::Config do
|
46
47
|
|
47
48
|
let(:loader) { Kitchen::DummyLoader.new }
|
48
|
-
let(:config) { Kitchen::Config.new(
|
49
|
+
let(:config) { Kitchen::Config.new(opts) }
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
let(:opts) do
|
52
|
+
{ :loader => loader, :kitchen_root => "/tmp/that/place",
|
53
|
+
:log_root => "/tmp/logs", :test_base_path => "/testing/yo",
|
54
|
+
:log_level => :debug }
|
53
55
|
end
|
54
56
|
|
55
|
-
|
56
|
-
FakeFS.deactivate!
|
57
|
-
FakeFS::FileSystem.clear
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#platforms" do
|
57
|
+
describe "#loader" do
|
61
58
|
|
62
|
-
it "returns
|
63
|
-
|
64
|
-
|
65
|
-
config.platforms.size.must_equal 2
|
66
|
-
config.platforms[0].name.must_equal 'one'
|
67
|
-
config.platforms[1].name.must_equal 'two'
|
59
|
+
it "returns its loader" do
|
60
|
+
config.loader.must_equal loader
|
68
61
|
end
|
69
62
|
|
70
|
-
it "
|
71
|
-
|
63
|
+
it "creates a Kitchen::Loader::YAML loader by default" do
|
64
|
+
opts.delete(:loader)
|
72
65
|
|
73
|
-
config.
|
66
|
+
config.loader.must_be_kind_of Kitchen::Loader::YAML
|
74
67
|
end
|
75
68
|
end
|
76
69
|
|
77
|
-
describe "#
|
78
|
-
|
79
|
-
it "returns suites loaded from a kitchen.yml" do
|
80
|
-
stub_data!({ :suites => [
|
81
|
-
{ :name => 'one', :run_list => [] },
|
82
|
-
{ :name => 'two', :run_list => [] },
|
83
|
-
] })
|
70
|
+
describe "#kitchen_root" do
|
84
71
|
|
85
|
-
|
86
|
-
config.
|
87
|
-
config.suites[1].name.must_equal 'two'
|
72
|
+
it "returns its kitchen root" do
|
73
|
+
config.kitchen_root.must_equal "/tmp/that/place"
|
88
74
|
end
|
89
75
|
|
90
|
-
it "
|
91
|
-
|
76
|
+
it "uses Dir.pwd by default" do
|
77
|
+
opts.delete(:kitchen_root)
|
92
78
|
|
93
|
-
config.
|
79
|
+
config.kitchen_root.must_equal Dir.pwd
|
94
80
|
end
|
81
|
+
end
|
95
82
|
|
96
|
-
|
97
|
-
suite.extend(Kitchen::Suite::Cheflike)
|
98
|
-
end
|
83
|
+
describe "#log_root" do
|
99
84
|
|
100
|
-
it "returns
|
101
|
-
|
102
|
-
cheflike_suite(config.suites.first).data_bags_path.must_be_nil
|
85
|
+
it "returns its log root" do
|
86
|
+
config.log_root.must_equal "/tmp/logs"
|
103
87
|
end
|
104
88
|
|
105
|
-
it "
|
106
|
-
|
107
|
-
config.test_base_path = "/tmp/base"
|
108
|
-
FileUtils.mkdir_p "/tmp/base/data_bags"
|
89
|
+
it "calculates a default log root using kitchen_root" do
|
90
|
+
opts.delete(:log_root)
|
109
91
|
|
110
|
-
|
111
|
-
must_equal "/tmp/base/data_bags"
|
92
|
+
config.log_root.must_equal "/tmp/that/place/.kitchen/logs"
|
112
93
|
end
|
94
|
+
end
|
113
95
|
|
114
|
-
|
115
|
-
stub_data!({ :suites => [{ :name => 'cool', :run_list => [] }] })
|
116
|
-
config.test_base_path = "/tmp/base"
|
117
|
-
FileUtils.mkdir_p "/tmp/base/cool/data_bags"
|
96
|
+
describe "#test_base_path" do
|
118
97
|
|
119
|
-
|
120
|
-
|
98
|
+
it "returns its base test path" do
|
99
|
+
config.test_base_path.must_equal "/testing/yo"
|
121
100
|
end
|
122
101
|
|
123
|
-
it "
|
124
|
-
|
125
|
-
:data_bags_path => 'shared/data_bags' }] })
|
126
|
-
config.kitchen_root = "/tmp/base"
|
127
|
-
FileUtils.mkdir_p "/tmp/base/shared/data_bags"
|
102
|
+
it "calculates a default base using kitchen_root" do
|
103
|
+
opts.delete(:test_base_path)
|
128
104
|
|
129
|
-
|
130
|
-
must_equal "/tmp/base/shared/data_bags"
|
105
|
+
config.test_base_path.must_equal "/tmp/that/place/test/integration"
|
131
106
|
end
|
107
|
+
end
|
132
108
|
|
133
|
-
|
134
|
-
stub_data!({ :suites => [{ :name => 'one', :run_list => [] }] })
|
109
|
+
describe "#log_level" do
|
135
110
|
|
136
|
-
|
111
|
+
it "returns its log level" do
|
112
|
+
config.log_level.must_equal :debug
|
137
113
|
end
|
138
114
|
|
139
|
-
it "
|
140
|
-
|
141
|
-
config.test_base_path = "/tmp/base"
|
142
|
-
FileUtils.mkdir_p "/tmp/base/roles"
|
115
|
+
it "uses :info by default" do
|
116
|
+
opts.delete(:log_level)
|
143
117
|
|
144
|
-
|
145
|
-
must_equal "/tmp/base/roles"
|
118
|
+
config.log_level.must_equal :info
|
146
119
|
end
|
120
|
+
end
|
147
121
|
|
148
|
-
|
149
|
-
stub_data!({ :suites => [{ :name => 'mysuite', :run_list => [] }] })
|
150
|
-
config.test_base_path = "/tmp/base"
|
151
|
-
FileUtils.mkdir_p "/tmp/base/mysuite/roles"
|
122
|
+
describe "#platforms" do
|
152
123
|
|
153
|
-
|
154
|
-
|
124
|
+
it "returns an array of platforms" do
|
125
|
+
stub_data!({
|
126
|
+
:platforms => [
|
127
|
+
{ :name => 'one' },
|
128
|
+
{ :name => 'two' }
|
129
|
+
]
|
130
|
+
})
|
131
|
+
|
132
|
+
config.platforms.size.must_equal 2
|
133
|
+
config.platforms[0].name.must_equal 'one'
|
134
|
+
config.platforms[1].name.must_equal 'two'
|
155
135
|
end
|
156
136
|
|
157
|
-
it "returns
|
158
|
-
stub_data!({
|
159
|
-
:roles_path => 'shared/roles' }] })
|
160
|
-
config.kitchen_root = "/tmp/base"
|
161
|
-
FileUtils.mkdir_p "/tmp/base/shared/roles"
|
137
|
+
it "returns an empty Array if no platforms are given" do
|
138
|
+
stub_data!({})
|
162
139
|
|
163
|
-
|
164
|
-
must_equal "/tmp/base/shared/roles"
|
140
|
+
config.platforms.must_equal []
|
165
141
|
end
|
166
142
|
end
|
167
143
|
|
168
|
-
describe "#
|
144
|
+
describe "#suites" do
|
169
145
|
|
170
|
-
it "returns
|
146
|
+
it "returns an array of suites" do
|
171
147
|
stub_data!({
|
172
|
-
:platforms => [
|
173
|
-
{ :name => 'p1' },
|
174
|
-
{ :name => 'p2' },
|
175
|
-
],
|
176
148
|
:suites => [
|
177
|
-
{ :name => '
|
178
|
-
{ :name => '
|
179
|
-
{ :name => 's3', :run_list => [], :excludes => ['p1'] }
|
149
|
+
{ :name => 'one' },
|
150
|
+
{ :name => 'two' }
|
180
151
|
]
|
181
152
|
})
|
182
|
-
|
183
|
-
|
184
|
-
|
153
|
+
|
154
|
+
config.suites.size.must_equal 2
|
155
|
+
config.suites[0].name.must_equal 'one'
|
156
|
+
config.suites[1].name.must_equal 'two'
|
185
157
|
end
|
186
158
|
|
187
|
-
it "returns an
|
188
|
-
stub_data!({
|
189
|
-
|
190
|
-
|
191
|
-
})
|
192
|
-
config.instances.first.driver.must_be_instance_of Kitchen::Driver::Dummy
|
159
|
+
it "returns an empty Array if no suites are given" do
|
160
|
+
stub_data!({})
|
161
|
+
|
162
|
+
config.suites.must_equal []
|
193
163
|
end
|
164
|
+
end
|
194
165
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
config.instances.first.driver[:kitchen_root].must_equal "/tmp"
|
166
|
+
describe "#instances" do
|
167
|
+
|
168
|
+
it "returns an empty Array if no suites and platforms are given" do
|
169
|
+
stub_data!({})
|
170
|
+
|
171
|
+
config.instances.must_equal []
|
202
172
|
end
|
203
173
|
|
204
|
-
it "returns an
|
174
|
+
it "returns an array of instances" do
|
175
|
+
skip "much more needed here"
|
176
|
+
|
205
177
|
stub_data!({
|
206
178
|
:platforms => [
|
207
|
-
{ :name =>
|
208
|
-
|
209
|
-
}
|
179
|
+
{ :name => "p1" },
|
180
|
+
{ :name => "p2" }
|
210
181
|
],
|
211
|
-
:suites => [
|
182
|
+
:suites => [
|
183
|
+
{ :name => 's1' },
|
184
|
+
{ :name => 's2' }
|
185
|
+
]
|
212
186
|
})
|
213
|
-
config.instances.first.driver[:foo].must_equal "bar"
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
describe "#log_level" do
|
218
187
|
|
219
|
-
|
220
|
-
config.log_level.must_equal :info
|
221
|
-
end
|
222
|
-
|
223
|
-
it "returns an overridden log_level" do
|
224
|
-
config.log_level = :error
|
225
|
-
config.log_level.must_equal :error
|
188
|
+
config.instances
|
226
189
|
end
|
227
190
|
end
|
228
191
|
|
229
|
-
private
|
230
|
-
|
231
192
|
def stub_data!(hash)
|
232
193
|
loader.data = hash
|
233
194
|
end
|
@@ -0,0 +1,1412 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2013, Fletcher Nichol
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../spec_helper'
|
20
|
+
|
21
|
+
require 'kitchen/data_munger'
|
22
|
+
|
23
|
+
module Kitchen
|
24
|
+
|
25
|
+
describe DataMunger do
|
26
|
+
|
27
|
+
describe "#platform_data" do
|
28
|
+
|
29
|
+
it "returns an array of platform data" do
|
30
|
+
DataMunger.new({
|
31
|
+
:platforms => [
|
32
|
+
{
|
33
|
+
:name => "one",
|
34
|
+
:stuff => "junk"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
:name => "two",
|
38
|
+
:misc => "things"
|
39
|
+
}
|
40
|
+
]
|
41
|
+
}).platform_data.must_equal([
|
42
|
+
{
|
43
|
+
:name => "one",
|
44
|
+
:stuff => "junk"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
:name => "two",
|
48
|
+
:misc => "things"
|
49
|
+
}
|
50
|
+
])
|
51
|
+
end
|
52
|
+
|
53
|
+
it "returns an empty array if platforms is not defined" do
|
54
|
+
DataMunger.new({}).platform_data.must_equal([])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#suite_data" do
|
59
|
+
|
60
|
+
it "returns an array of suite data" do
|
61
|
+
DataMunger.new({
|
62
|
+
:suites => [
|
63
|
+
{
|
64
|
+
:name => "one",
|
65
|
+
:stuff => "junk"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
:name => "two",
|
69
|
+
:misc => "things"
|
70
|
+
}
|
71
|
+
]
|
72
|
+
}).suite_data.must_equal([
|
73
|
+
{
|
74
|
+
:name => "one",
|
75
|
+
:stuff => "junk"
|
76
|
+
},
|
77
|
+
{
|
78
|
+
:name => "two",
|
79
|
+
:misc => "things"
|
80
|
+
}
|
81
|
+
])
|
82
|
+
end
|
83
|
+
|
84
|
+
it "returns an empty array if suites is not defined" do
|
85
|
+
DataMunger.new({}).suite_data.must_equal([])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
DATA_KEYS = {
|
90
|
+
:driver => :name,
|
91
|
+
:provisioner => :name,
|
92
|
+
:busser => :version
|
93
|
+
}
|
94
|
+
|
95
|
+
DATA_KEYS.each_pair do |key, default_key|
|
96
|
+
|
97
|
+
describe "##{key}" do
|
98
|
+
|
99
|
+
describe "from single source" do
|
100
|
+
|
101
|
+
it "returns empty hash if no common #{key} hash is provided" do
|
102
|
+
DataMunger.new({
|
103
|
+
}).public_send("#{key}_data_for", "suite", "platform").must_equal({
|
104
|
+
})
|
105
|
+
end
|
106
|
+
|
107
|
+
it "drops common #{key} if hash is nil" do
|
108
|
+
DataMunger.new({
|
109
|
+
key => nil
|
110
|
+
}).public_send("#{key}_data_for", "suite", "plat").must_equal({})
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns kitchen config #{key} name" do
|
114
|
+
DataMunger.new({
|
115
|
+
}, {
|
116
|
+
:defaults => {
|
117
|
+
key => "thenoseknows"
|
118
|
+
}
|
119
|
+
}).public_send("#{key}_data_for", "suite", "platform").must_equal({
|
120
|
+
default_key => "thenoseknows"
|
121
|
+
})
|
122
|
+
end
|
123
|
+
|
124
|
+
it "returns common #{key} name" do
|
125
|
+
DataMunger.new({
|
126
|
+
key => "starship"
|
127
|
+
}).public_send("#{key}_data_for", "suite", "platform").must_equal({
|
128
|
+
default_key => "starship"
|
129
|
+
})
|
130
|
+
end
|
131
|
+
|
132
|
+
it "returns common #{key} config" do
|
133
|
+
DataMunger.new({
|
134
|
+
key => {
|
135
|
+
default_key => "starship",
|
136
|
+
:speed => 42
|
137
|
+
}
|
138
|
+
}).public_send("#{key}_data_for", "suite", "platform").must_equal({
|
139
|
+
default_key => "starship",
|
140
|
+
:speed => 42
|
141
|
+
})
|
142
|
+
end
|
143
|
+
|
144
|
+
it "returns empty hash if platform config doesn't have #{key} hash" do
|
145
|
+
DataMunger.new({
|
146
|
+
:platforms => [
|
147
|
+
{ :name => "plat" }
|
148
|
+
]
|
149
|
+
}).public_send("#{key}_data_for", "suite", "plat").must_equal({})
|
150
|
+
end
|
151
|
+
|
152
|
+
it "drops platform #{key} if hash is nil" do
|
153
|
+
DataMunger.new({
|
154
|
+
:platforms => [
|
155
|
+
{
|
156
|
+
:name => "plat",
|
157
|
+
key => nil
|
158
|
+
}
|
159
|
+
]
|
160
|
+
}).public_send("#{key}_data_for", "suite", "plat").must_equal({})
|
161
|
+
end
|
162
|
+
|
163
|
+
it "returns platform #{key} name" do
|
164
|
+
DataMunger.new({
|
165
|
+
:platforms => [
|
166
|
+
{
|
167
|
+
:name => "plat",
|
168
|
+
key => "flip"
|
169
|
+
}
|
170
|
+
]
|
171
|
+
}).public_send("#{key}_data_for", "suite", "plat").must_equal({
|
172
|
+
default_key => "flip"
|
173
|
+
})
|
174
|
+
end
|
175
|
+
|
176
|
+
it "returns platform config containing #{key} hash" do
|
177
|
+
DataMunger.new({
|
178
|
+
:platforms => [
|
179
|
+
{
|
180
|
+
:name => "plat",
|
181
|
+
key => {
|
182
|
+
default_key => "flip",
|
183
|
+
:flop => "yep"
|
184
|
+
}
|
185
|
+
}
|
186
|
+
]
|
187
|
+
}).public_send("#{key}_data_for", "suite", "plat").must_equal({
|
188
|
+
default_key => "flip",
|
189
|
+
:flop => "yep"
|
190
|
+
})
|
191
|
+
end
|
192
|
+
|
193
|
+
it "returns empty hash if suite config doesn't have #{key} hash" do
|
194
|
+
DataMunger.new({
|
195
|
+
:suites => [
|
196
|
+
{ :name => "sweet" }
|
197
|
+
]
|
198
|
+
}).public_send("#{key}_data_for", "sweet", "platform").must_equal({
|
199
|
+
})
|
200
|
+
end
|
201
|
+
|
202
|
+
it "drops suite #{key} hash is nil" do
|
203
|
+
DataMunger.new({
|
204
|
+
:suites => [
|
205
|
+
{
|
206
|
+
:name => "suite",
|
207
|
+
key => nil
|
208
|
+
}
|
209
|
+
]
|
210
|
+
}).public_send("#{key}_data_for", "suite", "plat").must_equal({})
|
211
|
+
end
|
212
|
+
|
213
|
+
it "returns suite #{key} name" do
|
214
|
+
DataMunger.new({
|
215
|
+
:suites => [
|
216
|
+
{
|
217
|
+
:name => "sweet",
|
218
|
+
key => "waz"
|
219
|
+
}
|
220
|
+
]
|
221
|
+
}).public_send("#{key}_data_for", "sweet", "platform").must_equal({
|
222
|
+
default_key => "waz"
|
223
|
+
})
|
224
|
+
end
|
225
|
+
|
226
|
+
it "returns suite config containing #{key} hash" do
|
227
|
+
DataMunger.new({
|
228
|
+
:suites => [
|
229
|
+
{
|
230
|
+
:name => "sweet",
|
231
|
+
key => {
|
232
|
+
default_key => "waz",
|
233
|
+
:up => "nope"
|
234
|
+
}
|
235
|
+
}
|
236
|
+
]
|
237
|
+
}).public_send("#{key}_data_for", "sweet", "platform").must_equal({
|
238
|
+
default_key => "waz",
|
239
|
+
:up => "nope"
|
240
|
+
})
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
describe "from multiple sources merging" do
|
245
|
+
|
246
|
+
it "suite into platform into common" do
|
247
|
+
DataMunger.new({
|
248
|
+
key => {
|
249
|
+
default_key => "commony",
|
250
|
+
:color => "purple",
|
251
|
+
:fruit => ["apple", "pear"],
|
252
|
+
:deep => { :common => "junk" }
|
253
|
+
},
|
254
|
+
:platforms => [
|
255
|
+
{
|
256
|
+
:name => "plat",
|
257
|
+
key => {
|
258
|
+
default_key => "platformy",
|
259
|
+
:fruit => ["banana"],
|
260
|
+
:deep => { :platform => "stuff" }
|
261
|
+
}
|
262
|
+
}
|
263
|
+
],
|
264
|
+
:suites => [
|
265
|
+
{
|
266
|
+
:name => "sweet",
|
267
|
+
key => {
|
268
|
+
default_key => "suitey",
|
269
|
+
:vehicle => "car",
|
270
|
+
:deep => { :suite => "things" }
|
271
|
+
}
|
272
|
+
}
|
273
|
+
]
|
274
|
+
}).public_send("#{key}_data_for", "sweet", "plat").must_equal({
|
275
|
+
default_key => "suitey",
|
276
|
+
:color => "purple",
|
277
|
+
:fruit => ["banana"],
|
278
|
+
:vehicle => "car",
|
279
|
+
:deep => {
|
280
|
+
:common => "junk",
|
281
|
+
:platform => "stuff",
|
282
|
+
:suite => "things"
|
283
|
+
}
|
284
|
+
})
|
285
|
+
end
|
286
|
+
|
287
|
+
it "platform into common" do
|
288
|
+
DataMunger.new({
|
289
|
+
key => {
|
290
|
+
default_key => "commony",
|
291
|
+
:color => "purple",
|
292
|
+
:fruit => ["apple", "pear"],
|
293
|
+
:deep => { :common => "junk" }
|
294
|
+
},
|
295
|
+
:platforms => [
|
296
|
+
{
|
297
|
+
:name => "plat",
|
298
|
+
key => {
|
299
|
+
default_key => "platformy",
|
300
|
+
:fruit => ["banana"],
|
301
|
+
:deep => { :platform => "stuff" }
|
302
|
+
}
|
303
|
+
}
|
304
|
+
]
|
305
|
+
}).public_send("#{key}_data_for", "sweet", "plat").must_equal({
|
306
|
+
default_key => "platformy",
|
307
|
+
:color => "purple",
|
308
|
+
:fruit => ["banana"],
|
309
|
+
:deep => {
|
310
|
+
:common => "junk",
|
311
|
+
:platform => "stuff"
|
312
|
+
}
|
313
|
+
})
|
314
|
+
end
|
315
|
+
|
316
|
+
it "suite into common" do
|
317
|
+
DataMunger.new({
|
318
|
+
key => {
|
319
|
+
default_key => "commony",
|
320
|
+
:color => "purple",
|
321
|
+
:fruit => ["apple", "pear"],
|
322
|
+
:deep => { :common => "junk" }
|
323
|
+
},
|
324
|
+
:suites => [
|
325
|
+
{
|
326
|
+
:name => "sweet",
|
327
|
+
key => {
|
328
|
+
default_key => "suitey",
|
329
|
+
:vehicle => "car",
|
330
|
+
:deep => { :suite => "things" }
|
331
|
+
}
|
332
|
+
}
|
333
|
+
]
|
334
|
+
}).public_send("#{key}_data_for", "sweet", "plat").must_equal({
|
335
|
+
default_key => "suitey",
|
336
|
+
:color => "purple",
|
337
|
+
:fruit => ["apple", "pear"],
|
338
|
+
:vehicle => "car",
|
339
|
+
:deep => {
|
340
|
+
:common => "junk",
|
341
|
+
:suite => "things"
|
342
|
+
}
|
343
|
+
})
|
344
|
+
end
|
345
|
+
|
346
|
+
it "suite into platform" do
|
347
|
+
DataMunger.new({
|
348
|
+
:platforms => [
|
349
|
+
{
|
350
|
+
:name => "plat",
|
351
|
+
key => {
|
352
|
+
default_key => "platformy",
|
353
|
+
:fruit => ["banana"],
|
354
|
+
:deep => { :platform => "stuff" }
|
355
|
+
}
|
356
|
+
}
|
357
|
+
],
|
358
|
+
:suites => [
|
359
|
+
{
|
360
|
+
:name => "sweet",
|
361
|
+
key => {
|
362
|
+
default_key => "suitey",
|
363
|
+
:vehicle => "car",
|
364
|
+
:deep => { :suite => "things" }
|
365
|
+
}
|
366
|
+
}
|
367
|
+
]
|
368
|
+
}).public_send("#{key}_data_for", "sweet", "plat").must_equal({
|
369
|
+
default_key => "suitey",
|
370
|
+
:fruit => ["banana"],
|
371
|
+
:vehicle => "car",
|
372
|
+
:deep => {
|
373
|
+
:platform => "stuff",
|
374
|
+
:suite => "things"
|
375
|
+
}
|
376
|
+
})
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
describe "primary Chef data" do
|
383
|
+
|
384
|
+
describe "in a suite" do
|
385
|
+
|
386
|
+
it "moves attributes into provisioner" do
|
387
|
+
DataMunger.new({
|
388
|
+
:provisioner => "chefy",
|
389
|
+
:suites => [
|
390
|
+
{
|
391
|
+
:name => "sweet",
|
392
|
+
:attributes => { :one => "two" }
|
393
|
+
}
|
394
|
+
]
|
395
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
396
|
+
:name => "chefy",
|
397
|
+
:attributes => { :one => "two" }
|
398
|
+
})
|
399
|
+
end
|
400
|
+
|
401
|
+
it "moves run_list into provisioner" do
|
402
|
+
DataMunger.new({
|
403
|
+
:provisioner => "chefy",
|
404
|
+
:suites => [
|
405
|
+
{
|
406
|
+
:name => "sweet",
|
407
|
+
:run_list => ["one", "two"]
|
408
|
+
}
|
409
|
+
]
|
410
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
411
|
+
:name => "chefy",
|
412
|
+
:run_list => ["one", "two"]
|
413
|
+
})
|
414
|
+
end
|
415
|
+
|
416
|
+
it "maintains run_list in provisioner" do
|
417
|
+
DataMunger.new({
|
418
|
+
:provisioner => "chefy",
|
419
|
+
:suites => [
|
420
|
+
{
|
421
|
+
:name => "sweet",
|
422
|
+
:provisioner => {
|
423
|
+
:run_list => ["one", "two"]
|
424
|
+
}
|
425
|
+
}
|
426
|
+
]
|
427
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
428
|
+
:name => "chefy",
|
429
|
+
:run_list => ["one", "two"]
|
430
|
+
})
|
431
|
+
end
|
432
|
+
|
433
|
+
it "merge provisioner into attributes if provisioner exists" do
|
434
|
+
DataMunger.new({
|
435
|
+
:suites => [
|
436
|
+
{
|
437
|
+
:name => "sweet",
|
438
|
+
:attributes => { :one => "two" },
|
439
|
+
:provisioner => "chefy"
|
440
|
+
}
|
441
|
+
]
|
442
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
443
|
+
:name => "chefy",
|
444
|
+
:attributes => { :one => "two" }
|
445
|
+
})
|
446
|
+
end
|
447
|
+
|
448
|
+
it "merge provisioner into run_list if provisioner exists" do
|
449
|
+
DataMunger.new({
|
450
|
+
:suites => [
|
451
|
+
{
|
452
|
+
:name => "sweet",
|
453
|
+
:run_list => ["one", "two"],
|
454
|
+
:provisioner => "chefy"
|
455
|
+
}
|
456
|
+
]
|
457
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
458
|
+
:name => "chefy",
|
459
|
+
:run_list => ["one", "two"]
|
460
|
+
})
|
461
|
+
end
|
462
|
+
|
463
|
+
it "drops nil run_list" do
|
464
|
+
DataMunger.new({
|
465
|
+
:suites => [
|
466
|
+
{
|
467
|
+
:name => "sweet",
|
468
|
+
:run_list => nil,
|
469
|
+
:provisioner => "chefy"
|
470
|
+
}
|
471
|
+
]
|
472
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
473
|
+
:name => "chefy"
|
474
|
+
})
|
475
|
+
end
|
476
|
+
|
477
|
+
it "drops nil attributes" do
|
478
|
+
DataMunger.new({
|
479
|
+
:suites => [
|
480
|
+
{
|
481
|
+
:name => "sweet",
|
482
|
+
:attributes => nil,
|
483
|
+
:provisioner => "chefy"
|
484
|
+
}
|
485
|
+
]
|
486
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
487
|
+
:name => "chefy"
|
488
|
+
})
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
describe "in a platform" do
|
493
|
+
|
494
|
+
it "moves attributes into provisioner" do
|
495
|
+
DataMunger.new({
|
496
|
+
:provisioner => "chefy",
|
497
|
+
:platforms => [
|
498
|
+
{
|
499
|
+
:name => "plat",
|
500
|
+
:attributes => { :one => "two" }
|
501
|
+
}
|
502
|
+
]
|
503
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
504
|
+
:name => "chefy",
|
505
|
+
:attributes => { :one => "two" }
|
506
|
+
})
|
507
|
+
end
|
508
|
+
|
509
|
+
it "moves run_list into provisioner" do
|
510
|
+
DataMunger.new({
|
511
|
+
:provisioner => "chefy",
|
512
|
+
:platforms => [
|
513
|
+
{
|
514
|
+
:name => "plat",
|
515
|
+
:run_list => ["one", "two"]
|
516
|
+
}
|
517
|
+
]
|
518
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
519
|
+
:name => "chefy",
|
520
|
+
:run_list => ["one", "two"]
|
521
|
+
})
|
522
|
+
end
|
523
|
+
|
524
|
+
it "maintains run_list in provisioner" do
|
525
|
+
DataMunger.new({
|
526
|
+
:provisioner => "chefy",
|
527
|
+
:platforms => [
|
528
|
+
{
|
529
|
+
:name => "plat",
|
530
|
+
:provisioner => {
|
531
|
+
:run_list => ["one", "two"]
|
532
|
+
}
|
533
|
+
}
|
534
|
+
]
|
535
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
536
|
+
:name => "chefy",
|
537
|
+
:run_list => ["one", "two"]
|
538
|
+
})
|
539
|
+
end
|
540
|
+
|
541
|
+
it "merge provisioner into attributes if provisioner exists" do
|
542
|
+
DataMunger.new({
|
543
|
+
:platforms => [
|
544
|
+
{
|
545
|
+
:name => "plat",
|
546
|
+
:attributes => { :one => "two" },
|
547
|
+
:provisioner => "chefy"
|
548
|
+
}
|
549
|
+
]
|
550
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
551
|
+
:name => "chefy",
|
552
|
+
:attributes => { :one => "two" }
|
553
|
+
})
|
554
|
+
end
|
555
|
+
|
556
|
+
it "merge provisioner into run_list if provisioner exists" do
|
557
|
+
DataMunger.new({
|
558
|
+
:platforms => [
|
559
|
+
{
|
560
|
+
:name => "plat",
|
561
|
+
:run_list => ["one", "two"],
|
562
|
+
:provisioner => "chefy"
|
563
|
+
}
|
564
|
+
]
|
565
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
566
|
+
:name => "chefy",
|
567
|
+
:run_list => ["one", "two"]
|
568
|
+
})
|
569
|
+
end
|
570
|
+
|
571
|
+
it "drops nil run_list" do
|
572
|
+
DataMunger.new({
|
573
|
+
:platforms => [
|
574
|
+
{
|
575
|
+
:name => "plat",
|
576
|
+
:run_list => nil,
|
577
|
+
:provisioner => "chefy"
|
578
|
+
}
|
579
|
+
]
|
580
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
581
|
+
:name => "chefy"
|
582
|
+
})
|
583
|
+
end
|
584
|
+
|
585
|
+
it "drops nil attributes" do
|
586
|
+
DataMunger.new({
|
587
|
+
:platforms => [
|
588
|
+
{
|
589
|
+
:name => "plat",
|
590
|
+
:attributes => nil,
|
591
|
+
:provisioner => "chefy"
|
592
|
+
}
|
593
|
+
]
|
594
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
595
|
+
:name => "chefy"
|
596
|
+
})
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
600
|
+
describe "in a suite and platform" do
|
601
|
+
|
602
|
+
it "merges suite attributes into platform attributes" do
|
603
|
+
DataMunger.new({
|
604
|
+
:provisioner => "chefy",
|
605
|
+
:platforms => [
|
606
|
+
{
|
607
|
+
:name => "plat",
|
608
|
+
:attributes => {
|
609
|
+
:color => "blue",
|
610
|
+
:deep => { :platform => "much" }
|
611
|
+
}
|
612
|
+
}
|
613
|
+
],
|
614
|
+
:suites => [
|
615
|
+
{
|
616
|
+
:name => "sweet",
|
617
|
+
:attributes => {
|
618
|
+
:color => "pink",
|
619
|
+
:deep => { :suite => "wow" }
|
620
|
+
}
|
621
|
+
}
|
622
|
+
]
|
623
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
624
|
+
:name => "chefy",
|
625
|
+
:attributes => {
|
626
|
+
:color => "pink",
|
627
|
+
:deep => {
|
628
|
+
:suite => "wow",
|
629
|
+
:platform => "much"
|
630
|
+
}
|
631
|
+
}
|
632
|
+
})
|
633
|
+
end
|
634
|
+
|
635
|
+
it "concats suite run_list to platform run_list" do
|
636
|
+
DataMunger.new({
|
637
|
+
:provisioner => "chefy",
|
638
|
+
:platforms => [
|
639
|
+
{
|
640
|
+
:name => "plat",
|
641
|
+
:run_list => ["one", "two"]
|
642
|
+
}
|
643
|
+
],
|
644
|
+
:suites => [
|
645
|
+
{
|
646
|
+
:name => "sweet",
|
647
|
+
:run_list => ["three", "four"]
|
648
|
+
}
|
649
|
+
]
|
650
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
651
|
+
:name => "chefy",
|
652
|
+
:run_list => ["one", "two", "three", "four"]
|
653
|
+
})
|
654
|
+
end
|
655
|
+
|
656
|
+
it "concats suite run_list in provisioner to platform run_list" do
|
657
|
+
DataMunger.new({
|
658
|
+
:provisioner => "chefy",
|
659
|
+
:platforms => [
|
660
|
+
{
|
661
|
+
:name => "plat",
|
662
|
+
:run_list => ["one", "two"]
|
663
|
+
}
|
664
|
+
],
|
665
|
+
:suites => [
|
666
|
+
{
|
667
|
+
:name => "sweet",
|
668
|
+
:provisioner => {
|
669
|
+
:run_list => ["three", "four"]
|
670
|
+
}
|
671
|
+
}
|
672
|
+
]
|
673
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
674
|
+
:name => "chefy",
|
675
|
+
:run_list => ["one", "two", "three", "four"]
|
676
|
+
})
|
677
|
+
end
|
678
|
+
|
679
|
+
it "concats suite run_list to platform run_list in provisioner" do
|
680
|
+
DataMunger.new({
|
681
|
+
:provisioner => "chefy",
|
682
|
+
:platforms => [
|
683
|
+
{
|
684
|
+
:name => "plat",
|
685
|
+
:provisioner => {
|
686
|
+
:run_list => ["one", "two"]
|
687
|
+
}
|
688
|
+
}
|
689
|
+
],
|
690
|
+
:suites => [
|
691
|
+
{
|
692
|
+
:name => "sweet",
|
693
|
+
:run_list => ["three", "four"]
|
694
|
+
}
|
695
|
+
]
|
696
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
697
|
+
:name => "chefy",
|
698
|
+
:run_list => ["one", "two", "three", "four"]
|
699
|
+
})
|
700
|
+
end
|
701
|
+
|
702
|
+
it "concats to nil run_lists into an empty Array" do
|
703
|
+
DataMunger.new({
|
704
|
+
:provisioner => "chefy",
|
705
|
+
:platforms => [
|
706
|
+
{
|
707
|
+
:name => "plat",
|
708
|
+
:provisioner => {
|
709
|
+
:run_list => nil
|
710
|
+
}
|
711
|
+
}
|
712
|
+
],
|
713
|
+
:suites => [
|
714
|
+
{
|
715
|
+
:name => "sweet",
|
716
|
+
:run_list => nil
|
717
|
+
}
|
718
|
+
]
|
719
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
720
|
+
:name => "chefy",
|
721
|
+
:run_list => []
|
722
|
+
})
|
723
|
+
end
|
724
|
+
|
725
|
+
it "does not corrupt run_list data for multiple suite/platform pairs" do
|
726
|
+
munger = DataMunger.new({
|
727
|
+
:provisioner => "chefy",
|
728
|
+
:platforms => [
|
729
|
+
{
|
730
|
+
:name => "p1"
|
731
|
+
},
|
732
|
+
{
|
733
|
+
:name => "p2",
|
734
|
+
:run_list => ["one", "two"]
|
735
|
+
}
|
736
|
+
],
|
737
|
+
:suites => [
|
738
|
+
{
|
739
|
+
:name => "s1",
|
740
|
+
:run_list => ["alpha", "beta"]
|
741
|
+
},
|
742
|
+
{
|
743
|
+
:name => "s2",
|
744
|
+
:provisioner => {
|
745
|
+
:run_list => ["three", "four"]
|
746
|
+
}
|
747
|
+
}
|
748
|
+
]
|
749
|
+
})
|
750
|
+
|
751
|
+
# call munger for other data to cause any necessary internal
|
752
|
+
# data mutation
|
753
|
+
munger.provisioner_data_for("s1", "p1")
|
754
|
+
munger.provisioner_data_for("s1", "p2")
|
755
|
+
munger.provisioner_data_for("s2", "p1")
|
756
|
+
|
757
|
+
munger.provisioner_data_for("s2", "p2").must_equal({
|
758
|
+
:name => "chefy",
|
759
|
+
:run_list => ["one", "two", "three", "four"]
|
760
|
+
})
|
761
|
+
end
|
762
|
+
end
|
763
|
+
end
|
764
|
+
|
765
|
+
describe "kitchen config" do
|
766
|
+
|
767
|
+
[:kitchen_root, :test_base_path, :log_level].each do |key|
|
768
|
+
|
769
|
+
describe "for #{key}" do
|
770
|
+
|
771
|
+
describe "for #driver_data_for" do
|
772
|
+
|
773
|
+
it "is returned when provided" do
|
774
|
+
DataMunger.new({
|
775
|
+
:driver => "chefy",
|
776
|
+
:platforms => [
|
777
|
+
{ :name => "plat" }
|
778
|
+
],
|
779
|
+
:suites => [
|
780
|
+
{ :name => "sweet" }
|
781
|
+
]
|
782
|
+
}, {
|
783
|
+
key => "datvalue"
|
784
|
+
}).driver_data_for("sweet", "plat").must_equal({
|
785
|
+
:name => "chefy",
|
786
|
+
key => "datvalue"
|
787
|
+
})
|
788
|
+
end
|
789
|
+
|
790
|
+
it "is returned when provided in user data" do
|
791
|
+
DataMunger.new({
|
792
|
+
:kitchen => {
|
793
|
+
key => "datvalue"
|
794
|
+
},
|
795
|
+
:driver => "chefy",
|
796
|
+
:platforms => [
|
797
|
+
{ :name => "plat" }
|
798
|
+
],
|
799
|
+
:suites => [
|
800
|
+
{ :name => "sweet" }
|
801
|
+
]
|
802
|
+
}).driver_data_for("sweet", "plat").must_equal({
|
803
|
+
:name => "chefy",
|
804
|
+
key => "datvalue"
|
805
|
+
})
|
806
|
+
end
|
807
|
+
|
808
|
+
it "user data value beats provided value" do
|
809
|
+
DataMunger.new({
|
810
|
+
:kitchen => {
|
811
|
+
key => "datvalue"
|
812
|
+
},
|
813
|
+
:driver => "chefy",
|
814
|
+
:platforms => [
|
815
|
+
{ :name => "plat" }
|
816
|
+
],
|
817
|
+
:suites => [
|
818
|
+
{ :name => "sweet" }
|
819
|
+
]
|
820
|
+
}, {
|
821
|
+
key => "ilose"
|
822
|
+
}).driver_data_for("sweet", "plat").must_equal({
|
823
|
+
:name => "chefy",
|
824
|
+
key => "datvalue"
|
825
|
+
})
|
826
|
+
end
|
827
|
+
|
828
|
+
it "rejects any value in driver data" do
|
829
|
+
DataMunger.new({
|
830
|
+
:driver => {
|
831
|
+
:name => "chefy",
|
832
|
+
key => "imevil"
|
833
|
+
},
|
834
|
+
:platforms => [
|
835
|
+
{ :name => "plat" }
|
836
|
+
],
|
837
|
+
:suites => [
|
838
|
+
{ :name => "sweet" }
|
839
|
+
]
|
840
|
+
}).driver_data_for("sweet", "plat").must_equal({
|
841
|
+
:name => "chefy"
|
842
|
+
})
|
843
|
+
end
|
844
|
+
end
|
845
|
+
|
846
|
+
describe "for #provisioner_data_for" do
|
847
|
+
|
848
|
+
it "is returned when provided" do
|
849
|
+
DataMunger.new({
|
850
|
+
:provisioner => "chefy",
|
851
|
+
:platforms => [
|
852
|
+
{ :name => "plat" }
|
853
|
+
],
|
854
|
+
:suites => [
|
855
|
+
{ :name => "sweet" }
|
856
|
+
]
|
857
|
+
}, {
|
858
|
+
key => "datvalue"
|
859
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
860
|
+
:name => "chefy",
|
861
|
+
key => "datvalue"
|
862
|
+
})
|
863
|
+
end
|
864
|
+
|
865
|
+
it "is returned when provided in user data" do
|
866
|
+
DataMunger.new({
|
867
|
+
:kitchen => {
|
868
|
+
key => "datvalue"
|
869
|
+
},
|
870
|
+
:provisioner => "chefy",
|
871
|
+
:platforms => [
|
872
|
+
{ :name => "plat" }
|
873
|
+
],
|
874
|
+
:suites => [
|
875
|
+
{ :name => "sweet" }
|
876
|
+
]
|
877
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
878
|
+
:name => "chefy",
|
879
|
+
key => "datvalue"
|
880
|
+
})
|
881
|
+
end
|
882
|
+
|
883
|
+
it "user data value beats provided value" do
|
884
|
+
DataMunger.new({
|
885
|
+
:kitchen => {
|
886
|
+
key => "datvalue"
|
887
|
+
},
|
888
|
+
:provisioner => "chefy",
|
889
|
+
:platforms => [
|
890
|
+
{ :name => "plat" }
|
891
|
+
],
|
892
|
+
:suites => [
|
893
|
+
{ :name => "sweet" }
|
894
|
+
]
|
895
|
+
}, {
|
896
|
+
key => "ilose"
|
897
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
898
|
+
:name => "chefy",
|
899
|
+
key => "datvalue"
|
900
|
+
})
|
901
|
+
end
|
902
|
+
|
903
|
+
it "rejects any value in provisioner data" do
|
904
|
+
DataMunger.new({
|
905
|
+
:provisioner => {
|
906
|
+
:name => "chefy",
|
907
|
+
key => "imevil"
|
908
|
+
},
|
909
|
+
:platforms => [
|
910
|
+
{ :name => "plat" }
|
911
|
+
],
|
912
|
+
:suites => [
|
913
|
+
{ :name => "sweet" }
|
914
|
+
]
|
915
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
916
|
+
:name => "chefy"
|
917
|
+
})
|
918
|
+
end
|
919
|
+
end
|
920
|
+
|
921
|
+
describe "for #busser_data_for" do
|
922
|
+
|
923
|
+
it "is returned when provided" do
|
924
|
+
DataMunger.new({
|
925
|
+
:busser => "chefy",
|
926
|
+
:platforms => [
|
927
|
+
{ :name => "plat" }
|
928
|
+
],
|
929
|
+
:suites => [
|
930
|
+
{ :name => "sweet" }
|
931
|
+
]
|
932
|
+
}, {
|
933
|
+
key => "datvalue"
|
934
|
+
}).busser_data_for("sweet", "plat").must_equal({
|
935
|
+
:version => "chefy",
|
936
|
+
key => "datvalue"
|
937
|
+
})
|
938
|
+
end
|
939
|
+
|
940
|
+
it "is returned when provided in user data" do
|
941
|
+
DataMunger.new({
|
942
|
+
:kitchen => {
|
943
|
+
key => "datvalue"
|
944
|
+
},
|
945
|
+
:busser => "chefy",
|
946
|
+
:platforms => [
|
947
|
+
{ :name => "plat" }
|
948
|
+
],
|
949
|
+
:suites => [
|
950
|
+
{ :name => "sweet" }
|
951
|
+
]
|
952
|
+
}).busser_data_for("sweet", "plat").must_equal({
|
953
|
+
:version => "chefy",
|
954
|
+
key => "datvalue"
|
955
|
+
})
|
956
|
+
end
|
957
|
+
|
958
|
+
it "user data value beats provided value" do
|
959
|
+
DataMunger.new({
|
960
|
+
:kitchen => {
|
961
|
+
key => "datvalue"
|
962
|
+
},
|
963
|
+
:busser => "chefy",
|
964
|
+
:platforms => [
|
965
|
+
{ :name => "plat" }
|
966
|
+
],
|
967
|
+
:suites => [
|
968
|
+
{ :name => "sweet" }
|
969
|
+
]
|
970
|
+
}, {
|
971
|
+
key => "ilose"
|
972
|
+
}).busser_data_for("sweet", "plat").must_equal({
|
973
|
+
:version => "chefy",
|
974
|
+
key => "datvalue"
|
975
|
+
})
|
976
|
+
end
|
977
|
+
|
978
|
+
it "rejects any value in busser data" do
|
979
|
+
DataMunger.new({
|
980
|
+
:busser => {
|
981
|
+
:version => "chefy",
|
982
|
+
key => "imevil"
|
983
|
+
},
|
984
|
+
:platforms => [
|
985
|
+
{ :name => "plat" }
|
986
|
+
],
|
987
|
+
:suites => [
|
988
|
+
{ :name => "sweet" }
|
989
|
+
]
|
990
|
+
}).busser_data_for("sweet", "plat").must_equal({
|
991
|
+
:version => "chefy"
|
992
|
+
})
|
993
|
+
end
|
994
|
+
end
|
995
|
+
end
|
996
|
+
end
|
997
|
+
end
|
998
|
+
|
999
|
+
describe "legacy driver_config and driver_plugin" do
|
1000
|
+
|
1001
|
+
describe "from a single source" do
|
1002
|
+
|
1003
|
+
it "returns common driver name" do
|
1004
|
+
DataMunger.new({
|
1005
|
+
:driver_plugin => "starship"
|
1006
|
+
}).driver_data_for("suite", "platform").must_equal({
|
1007
|
+
:name => "starship"
|
1008
|
+
})
|
1009
|
+
end
|
1010
|
+
|
1011
|
+
it "merges driver into driver_plugin if driver exists" do
|
1012
|
+
DataMunger.new({
|
1013
|
+
:driver_plugin => "starship",
|
1014
|
+
:driver => "zappa"
|
1015
|
+
}).driver_data_for("suite", "platform").must_equal({
|
1016
|
+
:name => "zappa"
|
1017
|
+
})
|
1018
|
+
end
|
1019
|
+
|
1020
|
+
it "returns common driver config" do
|
1021
|
+
DataMunger.new({
|
1022
|
+
:driver_plugin => "starship",
|
1023
|
+
:driver_config => {
|
1024
|
+
:speed => 42
|
1025
|
+
}
|
1026
|
+
}).driver_data_for("suite", "platform").must_equal({
|
1027
|
+
:name => "starship",
|
1028
|
+
:speed => 42
|
1029
|
+
})
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
it "merges driver into driver_config if driver with name exists" do
|
1033
|
+
DataMunger.new({
|
1034
|
+
:driver_config => {
|
1035
|
+
:eh => "yep"
|
1036
|
+
},
|
1037
|
+
:driver => "zappa"
|
1038
|
+
}).driver_data_for("suite", "platform").must_equal({
|
1039
|
+
:name => "zappa",
|
1040
|
+
:eh => "yep"
|
1041
|
+
})
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
it "merges driver into driver_config if driver exists" do
|
1045
|
+
DataMunger.new({
|
1046
|
+
:driver_plugin => "imold",
|
1047
|
+
:driver_config => {
|
1048
|
+
:eh => "yep",
|
1049
|
+
:color => "pink"
|
1050
|
+
},
|
1051
|
+
:driver => {
|
1052
|
+
:name => "zappa",
|
1053
|
+
:color => "black"
|
1054
|
+
}
|
1055
|
+
}).driver_data_for("suite", "platform").must_equal({
|
1056
|
+
:name => "zappa",
|
1057
|
+
:eh => "yep",
|
1058
|
+
:color => "black"
|
1059
|
+
})
|
1060
|
+
end
|
1061
|
+
|
1062
|
+
it "returns platform driver name" do
|
1063
|
+
DataMunger.new({
|
1064
|
+
:platforms => [
|
1065
|
+
{
|
1066
|
+
:name => "plat",
|
1067
|
+
:driver_plugin => "flip"
|
1068
|
+
}
|
1069
|
+
]
|
1070
|
+
}).driver_data_for("suite", "plat").must_equal({
|
1071
|
+
:name => "flip"
|
1072
|
+
})
|
1073
|
+
end
|
1074
|
+
|
1075
|
+
it "returns platform config containing driver hash" do
|
1076
|
+
DataMunger.new({
|
1077
|
+
:platforms => [
|
1078
|
+
{
|
1079
|
+
:name => "plat",
|
1080
|
+
:driver_plugin => "flip",
|
1081
|
+
:driver_config => {
|
1082
|
+
:flop => "yep"
|
1083
|
+
}
|
1084
|
+
}
|
1085
|
+
]
|
1086
|
+
}).driver_data_for("suite", "plat").must_equal({
|
1087
|
+
:name => "flip",
|
1088
|
+
:flop => "yep"
|
1089
|
+
})
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
it "returns suite driver name" do
|
1093
|
+
DataMunger.new({
|
1094
|
+
:suites => [
|
1095
|
+
{
|
1096
|
+
:name => "sweet",
|
1097
|
+
:driver_plugin => "waz"
|
1098
|
+
}
|
1099
|
+
]
|
1100
|
+
}).driver_data_for("sweet", "platform").must_equal({
|
1101
|
+
:name => "waz"
|
1102
|
+
})
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
it "returns suite config containing driver hash" do
|
1106
|
+
DataMunger.new({
|
1107
|
+
:suites => [
|
1108
|
+
{
|
1109
|
+
:name => "sweet",
|
1110
|
+
:driver_plugin => "waz",
|
1111
|
+
:driver_config => {
|
1112
|
+
:up => "nope"
|
1113
|
+
}
|
1114
|
+
}
|
1115
|
+
]
|
1116
|
+
}).driver_data_for("sweet", "platform").must_equal({
|
1117
|
+
:name => "waz",
|
1118
|
+
:up => "nope"
|
1119
|
+
})
|
1120
|
+
end
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
describe "from multiple sources" do
|
1124
|
+
|
1125
|
+
it "suite into platform into common" do
|
1126
|
+
DataMunger.new({
|
1127
|
+
:driver_plugin => "commony",
|
1128
|
+
:driver_config => {
|
1129
|
+
:color => "purple",
|
1130
|
+
:fruit => ["apple", "pear"],
|
1131
|
+
:deep => { :common => "junk" }
|
1132
|
+
},
|
1133
|
+
:platforms => [
|
1134
|
+
{
|
1135
|
+
:name => "plat",
|
1136
|
+
:driver_plugin => "platformy",
|
1137
|
+
:driver_config => {
|
1138
|
+
:fruit => ["banana"],
|
1139
|
+
:deep => { :platform => "stuff" }
|
1140
|
+
}
|
1141
|
+
}
|
1142
|
+
],
|
1143
|
+
:suites => [
|
1144
|
+
{
|
1145
|
+
:name => "sweet",
|
1146
|
+
:driver_plugin => "suitey",
|
1147
|
+
:driver_config => {
|
1148
|
+
:vehicle => "car",
|
1149
|
+
:deep => { :suite => "things" }
|
1150
|
+
}
|
1151
|
+
}
|
1152
|
+
]
|
1153
|
+
}).driver_data_for("sweet", "plat").must_equal({
|
1154
|
+
:name => "suitey",
|
1155
|
+
:color => "purple",
|
1156
|
+
:fruit => ["banana"],
|
1157
|
+
:vehicle => "car",
|
1158
|
+
:deep => {
|
1159
|
+
:common => "junk",
|
1160
|
+
:platform => "stuff",
|
1161
|
+
:suite => "things"
|
1162
|
+
}
|
1163
|
+
})
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
it "platform into common" do
|
1167
|
+
DataMunger.new({
|
1168
|
+
:driver_plugin => "commony",
|
1169
|
+
:driver_config => {
|
1170
|
+
:color => "purple",
|
1171
|
+
:fruit => ["apple", "pear"],
|
1172
|
+
:deep => { :common => "junk" }
|
1173
|
+
},
|
1174
|
+
:platforms => [
|
1175
|
+
{
|
1176
|
+
:name => "plat",
|
1177
|
+
:driver_plugin => "platformy",
|
1178
|
+
:driver_config => {
|
1179
|
+
:fruit => ["banana"],
|
1180
|
+
:deep => { :platform => "stuff" }
|
1181
|
+
}
|
1182
|
+
}
|
1183
|
+
]
|
1184
|
+
}).driver_data_for("sweet", "plat").must_equal({
|
1185
|
+
:name => "platformy",
|
1186
|
+
:color => "purple",
|
1187
|
+
:fruit => ["banana"],
|
1188
|
+
:deep => {
|
1189
|
+
:common => "junk",
|
1190
|
+
:platform => "stuff"
|
1191
|
+
}
|
1192
|
+
})
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
it "suite into common" do
|
1196
|
+
DataMunger.new({
|
1197
|
+
:driver_plugin => "commony",
|
1198
|
+
:driver_config => {
|
1199
|
+
:color => "purple",
|
1200
|
+
:fruit => ["apple", "pear"],
|
1201
|
+
:deep => { :common => "junk" }
|
1202
|
+
},
|
1203
|
+
:suites => [
|
1204
|
+
{
|
1205
|
+
:name => "sweet",
|
1206
|
+
:driver_plugin => "suitey",
|
1207
|
+
:driver_config => {
|
1208
|
+
:vehicle => "car",
|
1209
|
+
:deep => { :suite => "things" }
|
1210
|
+
}
|
1211
|
+
}
|
1212
|
+
]
|
1213
|
+
}).driver_data_for("sweet", "plat").must_equal({
|
1214
|
+
:name => "suitey",
|
1215
|
+
:color => "purple",
|
1216
|
+
:fruit => ["apple", "pear"],
|
1217
|
+
:vehicle => "car",
|
1218
|
+
:deep => {
|
1219
|
+
:common => "junk",
|
1220
|
+
:suite => "things"
|
1221
|
+
}
|
1222
|
+
})
|
1223
|
+
end
|
1224
|
+
|
1225
|
+
it "suite into platform" do
|
1226
|
+
DataMunger.new({
|
1227
|
+
:platforms => [
|
1228
|
+
{
|
1229
|
+
:name => "plat",
|
1230
|
+
:driver_plugin => "platformy",
|
1231
|
+
:driver_config => {
|
1232
|
+
:fruit => ["banana"],
|
1233
|
+
:deep => { :platform => "stuff" }
|
1234
|
+
}
|
1235
|
+
}
|
1236
|
+
],
|
1237
|
+
:suites => [
|
1238
|
+
{
|
1239
|
+
:name => "sweet",
|
1240
|
+
:driver_plugin => "suitey",
|
1241
|
+
:driver_config => {
|
1242
|
+
:vehicle => "car",
|
1243
|
+
:deep => { :suite => "things" }
|
1244
|
+
}
|
1245
|
+
}
|
1246
|
+
]
|
1247
|
+
}).driver_data_for("sweet", "plat").must_equal({
|
1248
|
+
:name => "suitey",
|
1249
|
+
:fruit => ["banana"],
|
1250
|
+
:vehicle => "car",
|
1251
|
+
:deep => {
|
1252
|
+
:platform => "stuff",
|
1253
|
+
:suite => "things"
|
1254
|
+
}
|
1255
|
+
})
|
1256
|
+
end
|
1257
|
+
end
|
1258
|
+
end
|
1259
|
+
|
1260
|
+
describe "legacy chef paths from suite" do
|
1261
|
+
|
1262
|
+
LEGACY_CHEF_PATHS = [:data_path, :data_bags_path, :environments_path,
|
1263
|
+
:nodes_path, :roles_path]
|
1264
|
+
|
1265
|
+
LEGACY_CHEF_PATHS.each do |key|
|
1266
|
+
|
1267
|
+
it "moves #{key} into provisioner" do
|
1268
|
+
DataMunger.new({
|
1269
|
+
:provisioner => "chefy",
|
1270
|
+
:suites => [
|
1271
|
+
{
|
1272
|
+
:name => "sweet",
|
1273
|
+
key => "mypath"
|
1274
|
+
}
|
1275
|
+
]
|
1276
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
1277
|
+
:name => "chefy",
|
1278
|
+
key => "mypath"
|
1279
|
+
})
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
it "merges provisioner into data_path if provisioner exists" do
|
1283
|
+
DataMunger.new({
|
1284
|
+
:suites => [
|
1285
|
+
{
|
1286
|
+
:name => "sweet",
|
1287
|
+
key => "mypath",
|
1288
|
+
:provisioner => "chefy",
|
1289
|
+
}
|
1290
|
+
]
|
1291
|
+
}).provisioner_data_for("sweet", "plat").must_equal({
|
1292
|
+
:name => "chefy",
|
1293
|
+
key => "mypath"
|
1294
|
+
})
|
1295
|
+
end
|
1296
|
+
end
|
1297
|
+
end
|
1298
|
+
|
1299
|
+
describe "legacy require_chef_omnibus from driver" do
|
1300
|
+
|
1301
|
+
describe "from a single source" do
|
1302
|
+
|
1303
|
+
it "common driver value moves into provisioner" do
|
1304
|
+
DataMunger.new({
|
1305
|
+
:provisioner => "chefy",
|
1306
|
+
:driver => {
|
1307
|
+
:name => "starship",
|
1308
|
+
:require_chef_omnibus => "it's probably fine"
|
1309
|
+
}
|
1310
|
+
}).provisioner_data_for("suite", "platform").must_equal({
|
1311
|
+
:name => "chefy",
|
1312
|
+
:require_chef_omnibus => "it's probably fine"
|
1313
|
+
})
|
1314
|
+
end
|
1315
|
+
|
1316
|
+
it "common driver value loses to existing provisioner value" do
|
1317
|
+
DataMunger.new({
|
1318
|
+
:provisioner => {
|
1319
|
+
:name => "chefy",
|
1320
|
+
:require_chef_omnibus => "it's probably fine"
|
1321
|
+
},
|
1322
|
+
:driver => {
|
1323
|
+
:name => "starship",
|
1324
|
+
:require_chef_omnibus => "dragons"
|
1325
|
+
}
|
1326
|
+
}).provisioner_data_for("suite", "platform").must_equal({
|
1327
|
+
:name => "chefy",
|
1328
|
+
:require_chef_omnibus => "it's probably fine"
|
1329
|
+
})
|
1330
|
+
end
|
1331
|
+
|
1332
|
+
it "suite driver value moves into provisioner" do
|
1333
|
+
DataMunger.new({
|
1334
|
+
:suites => [
|
1335
|
+
{
|
1336
|
+
:name => "sweet",
|
1337
|
+
:provisioner => "chefy",
|
1338
|
+
:driver => {
|
1339
|
+
:name => "starship",
|
1340
|
+
:require_chef_omnibus => "it's probably fine"
|
1341
|
+
}
|
1342
|
+
}
|
1343
|
+
],
|
1344
|
+
}).provisioner_data_for("sweet", "platform").must_equal({
|
1345
|
+
:name => "chefy",
|
1346
|
+
:require_chef_omnibus => "it's probably fine"
|
1347
|
+
})
|
1348
|
+
end
|
1349
|
+
|
1350
|
+
it "suite driver value loses to existing provisioner value" do
|
1351
|
+
DataMunger.new({
|
1352
|
+
:suites => [
|
1353
|
+
{
|
1354
|
+
:name => "sweet",
|
1355
|
+
:provisioner => {
|
1356
|
+
:name => "chefy",
|
1357
|
+
:require_chef_omnibus => "it's probably fine"
|
1358
|
+
},
|
1359
|
+
:driver => {
|
1360
|
+
:name => "starship",
|
1361
|
+
:require_chef_omnibus => "dragons"
|
1362
|
+
}
|
1363
|
+
}
|
1364
|
+
]
|
1365
|
+
}).provisioner_data_for("sweet", "platform").must_equal({
|
1366
|
+
:name => "chefy",
|
1367
|
+
:require_chef_omnibus => "it's probably fine"
|
1368
|
+
})
|
1369
|
+
end
|
1370
|
+
|
1371
|
+
it "platform driver value moves into provisioner" do
|
1372
|
+
DataMunger.new({
|
1373
|
+
:platforms => [
|
1374
|
+
{
|
1375
|
+
:name => "plat",
|
1376
|
+
:provisioner => "chefy",
|
1377
|
+
:driver => {
|
1378
|
+
:name => "starship",
|
1379
|
+
:require_chef_omnibus => "it's probably fine"
|
1380
|
+
}
|
1381
|
+
}
|
1382
|
+
],
|
1383
|
+
}).provisioner_data_for("suite", "plat").must_equal({
|
1384
|
+
:name => "chefy",
|
1385
|
+
:require_chef_omnibus => "it's probably fine"
|
1386
|
+
})
|
1387
|
+
end
|
1388
|
+
|
1389
|
+
it "platform driver value loses to existing provisioner value" do
|
1390
|
+
DataMunger.new({
|
1391
|
+
:platforms => [
|
1392
|
+
{
|
1393
|
+
:name => "plat",
|
1394
|
+
:provisioner => {
|
1395
|
+
:name => "chefy",
|
1396
|
+
:require_chef_omnibus => "it's probably fine"
|
1397
|
+
},
|
1398
|
+
:driver => {
|
1399
|
+
:name => "starship",
|
1400
|
+
:require_chef_omnibus => "dragons"
|
1401
|
+
}
|
1402
|
+
}
|
1403
|
+
]
|
1404
|
+
}).provisioner_data_for("suite", "plat").must_equal({
|
1405
|
+
:name => "chefy",
|
1406
|
+
:require_chef_omnibus => "it's probably fine"
|
1407
|
+
})
|
1408
|
+
end
|
1409
|
+
end
|
1410
|
+
end
|
1411
|
+
end
|
1412
|
+
end
|