boxgrinder-core 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +14 -0
- data/Manifest +4 -1
- data/boxgrinder-core.gemspec +4 -4
- data/lib/boxgrinder-core.rb +0 -2
- data/lib/boxgrinder-core/helpers/appliance-config-helper.rb +13 -16
- data/lib/boxgrinder-core/helpers/appliance-helper.rb +64 -35
- data/lib/boxgrinder-core/helpers/exec-helper.rb +3 -0
- data/lib/boxgrinder-core/helpers/log-helper.rb +2 -3
- data/lib/boxgrinder-core/models/appliance-config.rb +6 -11
- data/lib/boxgrinder-core/models/config.rb +36 -45
- data/lib/boxgrinder-core/validators/appliance-config-validator.rb +0 -1
- data/rubygem-boxgrinder-core.spec +18 -1
- data/spec/helpers/appliance-config-helper-spec.rb +197 -113
- data/spec/helpers/appliance-helper-spec.rb +160 -45
- data/spec/helpers/log-helper-spec.rb +2 -2
- data/spec/models/config-spec.rb +56 -0
- data/spec/rspec/src/appliances/ephemeral-repo.appl +2 -3
- data/spec/rspec/src/appliances/full.appl +2 -3
- data/spec/rspec/src/appliances/invalid_yaml.appl +1 -0
- data/spec/rspec/src/appliances/repo.appl +2 -3
- data/spec/rspec/src/config/empty +0 -0
- data/spec/rspec/src/config/valid +4 -0
- metadata +9 -7
- data/lib/boxgrinder-core/defaults.rb +0 -58
@@ -5,12 +5,13 @@
|
|
5
5
|
|
6
6
|
Summary: Core library for BoxGrinder
|
7
7
|
Name: rubygem-%{gemname}
|
8
|
-
Version: 0.
|
8
|
+
Version: 0.2.0
|
9
9
|
Release: 1%{?dist}
|
10
10
|
Group: Development/Languages
|
11
11
|
License: LGPLv3+
|
12
12
|
URL: http://www.jboss.org/boxgrinder
|
13
13
|
Source0: http://rubygems.org/gems/%{gemname}-%{version}.gem
|
14
|
+
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
14
15
|
|
15
16
|
Requires: ruby(abi) = %{rubyabi}
|
16
17
|
Requires: rubygem(open4)
|
@@ -73,6 +74,22 @@ popd
|
|
73
74
|
%{gemdir}/doc/%{gemname}-%{version}
|
74
75
|
|
75
76
|
%changelog
|
77
|
+
* Tue Jan 04 2011 <mgoldman@redhat.com> - 0.2.0-1
|
78
|
+
- Upstream release: 0.2.0
|
79
|
+
- Added BuildRoot tag to build for EPEL 5
|
80
|
+
- [BGBUILD-79] Allow to use BoxGrinder Build as a library
|
81
|
+
- [BGBUILD-127] Use appliance definition object instead of a file when using BG as a library
|
82
|
+
- [BGBUILD-68] Global .boxgrinder/config or rc style file for config
|
83
|
+
- [BGBUILD-93] Add Red Hat Enterprise Linux 6 support
|
84
|
+
- [BGBUILD-133] Support a consolidated configuration file
|
85
|
+
- [BGBUILD-101] Don't use 'includes' subsection when specifying packages
|
86
|
+
- [BGBUILD-60] Post section merging pattern for appliances depending on the same appliance
|
87
|
+
- [BGBUILD-151] Overriding hardware partitions via inclusion in Appliance Definition File causes build failure
|
88
|
+
|
89
|
+
* Tue Dec 21 2010 <mgoldman@redhat.com> - 0.1.6-1
|
90
|
+
- Updated to upstream version: 0.1.6
|
91
|
+
- [BGBUILD-100] Enable boxgrinder_build to create a Fedora image with encrypted partition(s)
|
92
|
+
|
76
93
|
* Sun Dec 12 2010 <mgoldman@redhat.com> - 0.1.5-1
|
77
94
|
- Updated to upstream version: 0.1.5
|
78
95
|
- [BGBUILD-73] Add support for kickstart files
|
@@ -74,6 +74,38 @@ module BoxGrinder
|
|
74
74
|
config.post['base'].should == ['3_1', '3_2', '2_1', '2_2', '1_1', '1_2']
|
75
75
|
end
|
76
76
|
|
77
|
+
# https://issues.jboss.org/browse/BGBUILD-60
|
78
|
+
it "should merge post sections in right order for appliances depending on same base appliance" do
|
79
|
+
config_a = ApplianceConfig.new
|
80
|
+
config_a.name = 'a'
|
81
|
+
config_a.post['base'] = ["1_1", "1_2"]
|
82
|
+
config_a.appliances << 'b1'
|
83
|
+
config_a.appliances << 'b2'
|
84
|
+
|
85
|
+
config_b1 = ApplianceConfig.new
|
86
|
+
config_b1.name = 'b1'
|
87
|
+
config_b1.post['base'] = ["2_1", "2_2"]
|
88
|
+
config_b1.appliances << 'c'
|
89
|
+
|
90
|
+
config_b2 = ApplianceConfig.new
|
91
|
+
config_b2.name = 'b2'
|
92
|
+
config_b2.post['base'] = ["3_1", "3_2"]
|
93
|
+
config_b2.appliances << 'c'
|
94
|
+
|
95
|
+
config_c = ApplianceConfig.new
|
96
|
+
config_c.name = 'c'
|
97
|
+
config_c.post['base'] = ["4_1", "4_2"]
|
98
|
+
|
99
|
+
prepare_helper([config_a, config_b1, config_c, config_b2, config_c])
|
100
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
101
|
+
|
102
|
+
@helper.merge_post_operations
|
103
|
+
|
104
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
105
|
+
config.post['base'].size.should == 8
|
106
|
+
config.post['base'].should == ['4_1', '4_2', '3_1', '3_2', '2_1', '2_2', '1_1', '1_2']
|
107
|
+
end
|
108
|
+
|
77
109
|
it "should merge post sections in right order with even more and more complicated inheritance" do
|
78
110
|
config_a = ApplianceConfig.new
|
79
111
|
config_a.name = 'a'
|
@@ -137,148 +169,200 @@ module BoxGrinder
|
|
137
169
|
config.post['ec2'].should == ['2_1', '2_2']
|
138
170
|
end
|
139
171
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
172
|
+
describe ".merge_partitions" do
|
173
|
+
it "should merge partitions for default fs_types without options for Fedora 13 (ext4)" do
|
174
|
+
config_a = ApplianceConfig.new
|
175
|
+
config_a.name = 'a'
|
176
|
+
config_a.appliances << 'b'
|
177
|
+
config_a.hardware.partitions = {"/" => {'size' => '2'}}
|
178
|
+
config_a.os.name = 'fedora'
|
179
|
+
config_a.os.version = '13'
|
147
180
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
181
|
+
config_b = ApplianceConfig.new
|
182
|
+
config_b.name = 'b'
|
183
|
+
config_b.hardware.partitions = {"/" => {'size' => '4'}, "/home" => {'size' => '2'}}
|
184
|
+
config_b.os.name = 'fedora'
|
185
|
+
config_b.os.version = '13'
|
153
186
|
|
154
|
-
|
155
|
-
|
187
|
+
prepare_helper([config_a, config_b])
|
188
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
156
189
|
|
157
|
-
|
190
|
+
@helper.merge_partitions
|
158
191
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
192
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
193
|
+
config.hardware.partitions.size.should == 2
|
194
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4'}, "/home" => {'size' => '2', 'type' => 'ext4'}}
|
195
|
+
end
|
163
196
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
197
|
+
it "should merge partitions for default fs_types without options for Fedora 13 (ext4) and specified options" do
|
198
|
+
config_a = ApplianceConfig.new
|
199
|
+
config_a.name = 'a'
|
200
|
+
config_a.appliances << 'b'
|
201
|
+
config_a.hardware.partitions = {"/" => {'size' => '2'}}
|
202
|
+
config_a.os.name = 'fedora'
|
203
|
+
config_a.os.version = '13'
|
171
204
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
205
|
+
config_b = ApplianceConfig.new
|
206
|
+
config_b.name = 'b'
|
207
|
+
config_b.hardware.partitions = {"/" => {'size' => '4', 'options' => 'barrier=0,nodelalloc,nobh,noatime'}, "/home" => {'size' => '2'}}
|
208
|
+
config_b.os.name = 'fedora'
|
209
|
+
config_b.os.version = '13'
|
177
210
|
|
178
|
-
|
179
|
-
|
211
|
+
prepare_helper([config_a, config_b])
|
212
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
180
213
|
|
181
|
-
|
214
|
+
@helper.merge_partitions
|
182
215
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
216
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
217
|
+
config.hardware.partitions.size.should == 2
|
218
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4', "options"=>"barrier=0,nodelalloc,nobh,noatime"}, "/home" => {'size' => '2', 'type' => 'ext4'}}
|
219
|
+
end
|
187
220
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
221
|
+
it "should merge partitions for default fs_types without options for RHEL 5 (ext3)" do
|
222
|
+
config_a = ApplianceConfig.new
|
223
|
+
config_a.name = 'a'
|
224
|
+
config_a.appliances << 'b'
|
225
|
+
config_a.hardware.partitions = {"/" => {'size' => '2'}}
|
226
|
+
config_a.os.name = 'rhel'
|
227
|
+
config_a.os.version = '5'
|
195
228
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
229
|
+
config_b = ApplianceConfig.new
|
230
|
+
config_b.name = 'b'
|
231
|
+
config_b.hardware.partitions = {"/" => {'size' => '4'}, "/home" => {'size' => '2'}}
|
232
|
+
config_b.os.name = 'rhel'
|
233
|
+
config_b.os.version = '5'
|
201
234
|
|
202
|
-
|
203
|
-
|
235
|
+
prepare_helper([config_a, config_b])
|
236
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
204
237
|
|
205
|
-
|
238
|
+
@helper.merge_partitions
|
206
239
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
240
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
241
|
+
config.hardware.partitions.size.should == 2
|
242
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext3'}, "/home" => {'size' => '2', 'type' => 'ext3'}}
|
243
|
+
end
|
211
244
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
245
|
+
it "should merge partitions with different filesystem types" do
|
246
|
+
config_a = ApplianceConfig.new
|
247
|
+
config_a.name = 'a'
|
248
|
+
config_a.appliances << 'b'
|
249
|
+
config_a.hardware.partitions = {"/" => {'size' => '2', 'type' => 'ext4'}}
|
250
|
+
config_a.os.name = 'fedora'
|
251
|
+
config_a.os.version = '13'
|
219
252
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
253
|
+
config_b = ApplianceConfig.new
|
254
|
+
config_b.name = 'b'
|
255
|
+
config_b.hardware.partitions = {"/" => {'size' => '4', 'type' => 'ext3'}, "/home" => {'size' => '2'}}
|
256
|
+
config_b.os.name = 'rhel'
|
257
|
+
config_b.os.version = '5'
|
225
258
|
|
226
|
-
|
227
|
-
|
259
|
+
prepare_helper([config_a, config_b])
|
260
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
228
261
|
|
229
|
-
|
262
|
+
@helper.merge_partitions
|
230
263
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
264
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
265
|
+
config.hardware.partitions.size.should == 2
|
266
|
+
config.os.name.should == 'fedora'
|
267
|
+
config.os.version.should == '13'
|
268
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4'}, "/home" => {'size' => '2', 'type' => 'ext4'}}
|
269
|
+
end
|
235
270
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
271
|
+
it "should merge partitions with different options" do
|
272
|
+
config_a = ApplianceConfig.new
|
273
|
+
config_a.name = 'a'
|
274
|
+
config_a.appliances << 'b'
|
275
|
+
config_a.hardware.partitions = {"/" => {'size' => '2', 'type' => 'ext4', 'options' => 'barrier=0,nodelalloc,nobh,noatime'}}
|
276
|
+
config_a.os.name = 'fedora'
|
277
|
+
config_a.os.version = '13'
|
243
278
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
279
|
+
config_b = ApplianceConfig.new
|
280
|
+
config_b.name = 'b'
|
281
|
+
config_b.hardware.partitions = {"/" => {'size' => '4', 'type' => 'ext3', 'options' => 'shouldnt appear'}, "/home" => {'size' => '2'}}
|
282
|
+
config_b.os.name = 'fedora'
|
283
|
+
config_b.os.version = '13'
|
249
284
|
|
250
|
-
|
251
|
-
|
285
|
+
prepare_helper([config_a, config_b])
|
286
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
252
287
|
|
253
|
-
|
288
|
+
@helper.merge_partitions
|
254
289
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
290
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
291
|
+
config.hardware.partitions.size.should == 2
|
292
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4', 'options' => 'barrier=0,nodelalloc,nobh,noatime'}, "/home" => {'size' => '2', 'type' => 'ext4'}}
|
293
|
+
end
|
259
294
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
295
|
+
it "should merge partitions with different options, another case where type is changing - options should be vanished" do
|
296
|
+
config_a = ApplianceConfig.new
|
297
|
+
config_a.name = 'a'
|
298
|
+
config_a.appliances << 'b'
|
299
|
+
config_a.hardware.partitions = {"/" => {'size' => '2', 'type' => 'ext4'}}
|
300
|
+
config_a.os.name = 'fedora'
|
301
|
+
config_a.os.version = '13'
|
267
302
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
303
|
+
config_b = ApplianceConfig.new
|
304
|
+
config_b.name = 'b'
|
305
|
+
config_b.hardware.partitions = {"/" => {'size' => '4', 'type' => 'ext3', 'options' => 'shouldnt appear'}, "/home" => {'size' => '2'}}
|
306
|
+
config_b.os.name = 'fedora'
|
307
|
+
config_b.os.version = '13'
|
273
308
|
|
274
|
-
|
275
|
-
|
309
|
+
prepare_helper([config_a, config_b])
|
310
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
276
311
|
|
277
|
-
|
312
|
+
@helper.merge_partitions
|
278
313
|
|
279
|
-
|
280
|
-
|
281
|
-
|
314
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
315
|
+
config.hardware.partitions.size.should == 2
|
316
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4'}, "/home" => {'size' => '2', 'type' => 'ext4'}}
|
317
|
+
end
|
318
|
+
|
319
|
+
it "should encrypt the partition while merging the partition" do
|
320
|
+
config_a = ApplianceConfig.new
|
321
|
+
config_a.name = 'a'
|
322
|
+
config_a.appliances << 'b'
|
323
|
+
config_a.hardware.partitions = {"/" => {'size' => '2'}}
|
324
|
+
config_a.os.name = 'fedora'
|
325
|
+
config_a.os.version = '13'
|
326
|
+
|
327
|
+
config_b = ApplianceConfig.new
|
328
|
+
config_b.name = 'b'
|
329
|
+
config_b.hardware.partitions = {"/" => {'size' => '4'}}
|
330
|
+
config_b.os.name = 'fedora'
|
331
|
+
config_b.os.version = '13'
|
332
|
+
|
333
|
+
prepare_helper([config_a, config_b])
|
334
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
335
|
+
|
336
|
+
@helper.merge_partitions
|
337
|
+
|
338
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
339
|
+
config.hardware.partitions.size.should == 1
|
340
|
+
config.hardware.partitions['/']['passphrase'].should == nil
|
341
|
+
end
|
342
|
+
|
343
|
+
it "should use encrypted partitions while merging the partition" do
|
344
|
+
config_a = ApplianceConfig.new
|
345
|
+
config_a.name = 'a'
|
346
|
+
config_a.appliances << 'b'
|
347
|
+
config_a.hardware.partitions = {"/" => {'size' => '2', 'passphrase' => 'marek'}}
|
348
|
+
config_a.os.name = 'fedora'
|
349
|
+
config_a.os.version = '13'
|
350
|
+
|
351
|
+
config_b = ApplianceConfig.new
|
352
|
+
config_b.name = 'b'
|
353
|
+
config_b.hardware.partitions = {"/" => {'size' => '4'}}
|
354
|
+
config_b.os.name = 'fedora'
|
355
|
+
config_b.os.version = '13'
|
356
|
+
|
357
|
+
prepare_helper([config_a, config_b])
|
358
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
359
|
+
|
360
|
+
@helper.merge_partitions
|
361
|
+
|
362
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
363
|
+
config.hardware.partitions.size.should == 1
|
364
|
+
config.hardware.partitions['/']['passphrase'].should == 'marek'
|
365
|
+
end
|
282
366
|
end
|
283
367
|
|
284
368
|
it "should substitute variables in repos" do
|
@@ -25,79 +25,194 @@ module BoxGrinder
|
|
25
25
|
@helper = ApplianceHelper.new(:log => Logger.new('/dev/null'))
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
describe ".read_definitions" do
|
29
|
+
it "should read definition from files with different extensions" do
|
30
|
+
appliance_config = ApplianceConfig.new
|
31
|
+
|
32
|
+
['appl', 'yml', 'yaml'].each do |ext|
|
33
|
+
File.should_receive(:exists?).with("file.#{ext}").and_return(true)
|
34
|
+
@helper.should_receive(:read_yaml_file).with("file.#{ext}").and_return(appliance_config)
|
35
|
+
@helper.read_definitions("file.#{ext}").should == [[appliance_config], appliance_config]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should read YAML definition from files with different content types" do
|
40
|
+
appliance_config = ApplianceConfig.new
|
41
|
+
|
42
|
+
['application/x-yaml', 'text/yaml'].each do |type|
|
43
|
+
File.should_receive(:exists?).with("file").and_return(true)
|
44
|
+
@helper.should_receive(:read_yaml_file).with("file").and_return(appliance_config)
|
45
|
+
@helper.read_definitions("file", type).should == [[appliance_config], appliance_config]
|
46
|
+
end
|
47
|
+
end
|
33
48
|
|
34
|
-
|
35
|
-
|
36
|
-
appliance_a.name = 'a'
|
37
|
-
appliance_a.appliances << "b"
|
49
|
+
it "should read XML definition from files with different content types" do
|
50
|
+
appliance_config = ApplianceConfig.new
|
38
51
|
|
39
|
-
|
40
|
-
|
52
|
+
['application/xml', 'text/xml', 'application/x-xml'].each do |type|
|
53
|
+
File.should_receive(:exists?).with("file").and_return(true)
|
54
|
+
@helper.should_receive(:read_xml_file).with("file").and_return(appliance_config)
|
55
|
+
@helper.read_definitions("file", type).should == [[appliance_config], appliance_config]
|
56
|
+
end
|
57
|
+
end
|
41
58
|
|
42
|
-
|
43
|
-
|
59
|
+
it "should read definition from two files" do
|
60
|
+
appliance_a = ApplianceConfig.new
|
61
|
+
appliance_a.name = 'a'
|
62
|
+
appliance_a.appliances << "b"
|
44
63
|
|
45
|
-
|
46
|
-
|
64
|
+
appliance_b = ApplianceConfig.new
|
65
|
+
appliance_b.name = 'b'
|
66
|
+
|
67
|
+
File.should_receive(:exists?).ordered.with('a.appl').and_return(true)
|
68
|
+
File.should_receive(:exists?).ordered.with('./b.appl').and_return(true)
|
69
|
+
|
70
|
+
@helper.should_receive(:read_yaml_file).ordered.with('a.appl').and_return(appliance_a)
|
71
|
+
@helper.should_receive(:read_yaml_file).ordered.with('./b.appl').and_return(appliance_b)
|
72
|
+
|
73
|
+
@helper.read_definitions("a.appl").should == [[appliance_a, appliance_b], appliance_a]
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should read definitions from a tree file structure" do
|
77
|
+
appliance_a = ApplianceConfig.new
|
78
|
+
appliance_a.name = 'a'
|
79
|
+
appliance_a.appliances << "b1"
|
80
|
+
appliance_a.appliances << "b2"
|
81
|
+
|
82
|
+
appliance_b1 = ApplianceConfig.new
|
83
|
+
appliance_b1.name = 'b1'
|
84
|
+
appliance_b1.appliances << "c1"
|
85
|
+
|
86
|
+
appliance_b2 = ApplianceConfig.new
|
87
|
+
appliance_b2.name = 'b2'
|
88
|
+
appliance_b2.appliances << "c2"
|
89
|
+
|
90
|
+
appliance_c1 = ApplianceConfig.new
|
91
|
+
appliance_c1.name = 'c1'
|
92
|
+
|
93
|
+
appliance_c2 = ApplianceConfig.new
|
94
|
+
appliance_c2.name = 'c2'
|
47
95
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
96
|
+
File.should_receive(:exists?).ordered.with('a.appl').and_return(true)
|
97
|
+
File.should_receive(:exists?).ordered.with('./b2.appl').and_return(true)
|
98
|
+
File.should_receive(:exists?).ordered.with('./c2.appl').and_return(true)
|
99
|
+
File.should_receive(:exists?).ordered.with('./b1.appl').and_return(true)
|
100
|
+
File.should_receive(:exists?).ordered.with('./c1.appl').and_return(true)
|
53
101
|
|
54
|
-
|
55
|
-
|
56
|
-
|
102
|
+
@helper.should_receive(:read_yaml_file).ordered.with('a.appl').and_return(appliance_a)
|
103
|
+
@helper.should_receive(:read_yaml_file).ordered.with('./b2.appl').and_return(appliance_b2)
|
104
|
+
@helper.should_receive(:read_yaml_file).ordered.with('./c2.appl').and_return(appliance_c2)
|
105
|
+
@helper.should_receive(:read_yaml_file).ordered.with('./b1.appl').and_return(appliance_b1)
|
106
|
+
@helper.should_receive(:read_yaml_file).ordered.with('./c1.appl').and_return(appliance_c1)
|
57
107
|
|
58
|
-
|
59
|
-
|
60
|
-
|
108
|
+
@helper.read_definitions("a.appl").should == [[appliance_a, appliance_b2, appliance_c2, appliance_b1, appliance_c1], appliance_a]
|
109
|
+
end
|
110
|
+
|
111
|
+
# https://issues.jboss.org/browse/BGBUILD-60
|
112
|
+
it "should read definitions from a tree file structure based on same appliance" do
|
113
|
+
appliance_a = ApplianceConfig.new
|
114
|
+
appliance_a.name = 'a'
|
115
|
+
appliance_a.appliances << "b1"
|
116
|
+
appliance_a.appliances << "b2"
|
117
|
+
|
118
|
+
appliance_b1 = ApplianceConfig.new
|
119
|
+
appliance_b1.name = 'b1'
|
120
|
+
appliance_b1.appliances << "c"
|
121
|
+
|
122
|
+
appliance_b2 = ApplianceConfig.new
|
123
|
+
appliance_b2.name = 'b2'
|
124
|
+
appliance_b2.appliances << "c"
|
125
|
+
|
126
|
+
appliance_c = ApplianceConfig.new
|
127
|
+
appliance_c.name = 'c'
|
128
|
+
|
129
|
+
File.should_receive(:exists?).ordered.with('a.appl').and_return(true)
|
130
|
+
File.should_receive(:exists?).ordered.with('./b2.appl').and_return(true)
|
131
|
+
File.should_receive(:exists?).ordered.with('./c.appl').and_return(true)
|
132
|
+
File.should_receive(:exists?).ordered.with('./b1.appl').and_return(true)
|
133
|
+
File.should_receive(:exists?).ordered.with('./c.appl').and_return(true)
|
134
|
+
|
135
|
+
@helper.should_receive(:read_yaml_file).ordered.with('a.appl').and_return(appliance_a)
|
136
|
+
@helper.should_receive(:read_yaml_file).ordered.with('./b2.appl').and_return(appliance_b2)
|
137
|
+
@helper.should_receive(:read_yaml_file).ordered.with('./c.appl').and_return(appliance_c)
|
138
|
+
@helper.should_receive(:read_yaml_file).ordered.with('./b1.appl').and_return(appliance_b1)
|
139
|
+
@helper.should_receive(:read_yaml_file).ordered.with('./c.appl').and_return(appliance_c)
|
140
|
+
|
141
|
+
@helper.read_definitions("a.appl").should == [[appliance_a, appliance_b2, appliance_c, appliance_b1, appliance_c], appliance_a]
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should read a YAML content instead of a loading a file" do
|
145
|
+
yaml = "name: abc\nos:\n name: fedora\n version: 13\npackages:\n - @core\nhardware:\n partitions:\n \"/\":\n size: 6"
|
146
|
+
appliance = @helper.read_definitions(yaml).last
|
147
|
+
|
148
|
+
appliance.name.should == 'abc'
|
149
|
+
appliance.os.version.should == '13'
|
150
|
+
appliance.hardware.partitions['/']['size'].should == 6
|
151
|
+
end
|
61
152
|
|
62
|
-
|
63
|
-
|
153
|
+
it "should read invalid YAML content" do
|
154
|
+
lambda { @helper.read_definitions("@$FEWYERTH") }.should raise_error(RuntimeError, 'Provided definition is not a Hash.')
|
155
|
+
end
|
64
156
|
|
65
|
-
|
66
|
-
|
157
|
+
it "should catch exception if YAML parsing raises it" do
|
158
|
+
lambda { @helper.read_definitions("!!") }.should raise_error(RuntimeError, 'Provided definition could not be read.')
|
159
|
+
end
|
67
160
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
@helper.should_receive(:read_yaml).ordered.with('./b1.appl').and_return(appliance_b1)
|
72
|
-
@helper.should_receive(:read_yaml).ordered.with('./c1.appl').and_return(appliance_c1)
|
161
|
+
it "should catch exception if YAML file parsing raises it" do
|
162
|
+
lambda { @helper.read_definitions("#{File.dirname(__FILE__)}/../rspec/src/appliances/invalid_yaml.appl") }.should raise_error(RuntimeError, /File '(.*)' could not be read./)
|
163
|
+
end
|
73
164
|
|
74
|
-
|
165
|
+
it "should raise because xml files aren't supported yet" do
|
166
|
+
File.should_receive(:exists?).with("file.xml").and_return(true)
|
167
|
+
lambda { @helper.read_definitions("file.xml") }.should raise_error(RuntimeError, "Reading XML files is not supported right now. File 'file.xml' could not be read.")
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should raise because of unsupported file format" do
|
171
|
+
File.should_receive(:exists?).with("file.xmdfl").and_return(true)
|
172
|
+
lambda { @helper.read_definitions("file.xmdfl") }.should raise_error(RuntimeError, "Unsupported file format for appliance definition file.")
|
173
|
+
end
|
75
174
|
end
|
76
175
|
|
77
|
-
describe "
|
176
|
+
describe "read_yaml_file" do
|
78
177
|
it "should read default_repos and set to false" do
|
79
178
|
YAML.should_receive(:load_file).with('default_repos_false.appl').and_return({'default_repos'=>false})
|
80
|
-
@helper.
|
179
|
+
@helper.read_yaml_file('default_repos_false.appl').default_repos.should == false
|
81
180
|
end
|
82
181
|
|
83
182
|
it "should read default_repos and set to true" do
|
84
183
|
YAML.should_receive(:load_file).with('default_repos_true.appl').and_return({'default_repos'=>true})
|
85
|
-
@helper.
|
184
|
+
@helper.read_yaml_file('default_repos_true.appl').default_repos.should == true
|
86
185
|
end
|
87
186
|
|
88
187
|
it "should read default_repos but not set it" do
|
89
188
|
YAML.should_receive(:load_file).with('default_repos_empty.appl').and_return({})
|
90
|
-
@helper.
|
189
|
+
@helper.read_yaml_file('default_repos_empty.appl').default_repos.should == nil
|
91
190
|
end
|
92
191
|
|
93
192
|
it "should read default_repos and raise" do
|
94
193
|
YAML.should_receive(:load_file).with('default_repos_bad.appl').and_return({'default_repos'=>'something'})
|
95
194
|
|
96
|
-
|
97
|
-
@helper.
|
98
|
-
|
99
|
-
|
100
|
-
|
195
|
+
lambda {
|
196
|
+
@helper.read_yaml_file("default_repos_bad.appl")
|
197
|
+
}.should raise_error(RuntimeError, 'default_repos should be set to true or false')
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe ".parse_yaml" do
|
202
|
+
context "partitions" do
|
203
|
+
it "should add default partition when no partitions are specified" do
|
204
|
+
appliance_config = @helper.parse_yaml({})
|
205
|
+
|
206
|
+
appliance_config.hardware.partitions.size.should == 1
|
207
|
+
appliance_config.hardware.partitions['/'].should == {'size' => 1}
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should merge partitions with the default one specified in appliance config" do
|
211
|
+
appliance_config = @helper.parse_yaml({'hardware' => {'partitions' => {'/home' => {'size' => 1}}}})
|
212
|
+
|
213
|
+
appliance_config.hardware.partitions.size.should == 2
|
214
|
+
appliance_config.hardware.partitions['/'].should == {'size' => 1}
|
215
|
+
appliance_config.hardware.partitions['/home'].should == {'size' => 1}
|
101
216
|
end
|
102
217
|
end
|
103
218
|
end
|