boxgrinder-core 0.3.0 → 0.3.1
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 +10 -0
- data/Rakefile +13 -9
- data/boxgrinder-core.gemspec +11 -8
- data/lib/boxgrinder-core/appliance-parser.rb +84 -0
- data/{spec/validators/appliance-config-validator-spec.rb → lib/boxgrinder-core/appliance-validator.rb} +15 -2
- data/lib/boxgrinder-core/{validators/errors.rb → errors.rb} +16 -0
- data/lib/boxgrinder-core/helpers/appliance-config-helper.rb +10 -18
- data/lib/boxgrinder-core/helpers/appliance-definition-helper.rb +19 -59
- data/lib/boxgrinder-core/helpers/appliance-transformation-helper.rb +58 -0
- data/lib/boxgrinder-core/helpers/exec-helper.rb +48 -21
- data/lib/boxgrinder-core/models/appliance-config.rb +39 -23
- data/lib/boxgrinder-core/models/config.rb +4 -2
- data/lib/boxgrinder-core/schemas/appliance_schema_0.8.0.yaml +95 -0
- data/lib/boxgrinder-core/schemas/appliance_schema_0.9.0.yaml +92 -0
- data/rubygem-boxgrinder-core.spec +13 -1
- data/spec/appliance-parser-spec.rb +68 -0
- data/spec/appliance-validator-spec.rb +71 -0
- data/spec/helpers/appliance-config-helper-spec.rb +136 -1
- data/spec/helpers/appliance-definition-helper-spec.rb +51 -79
- data/spec/helpers/appliance-transformation-helper-spec.rb +51 -0
- data/spec/helpers/exec-helper-spec.rb +40 -12
- data/spec/helpers/log-helper-spec.rb +1 -0
- data/spec/models/config-spec.rb +2 -1
- data/spec/rspec/src/appliances/0.8.x.appl +38 -0
- data/spec/rspec/src/appliances/0.9.x-invalid.appl +40 -0
- data/spec/rspec/src/appliances/0.9.x.appl +36 -0
- metadata +48 -19
- data/lib/boxgrinder-core/validators/appliance-config-validator.rb +0 -65
@@ -16,54 +16,47 @@
|
|
16
16
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
|
+
require 'rubygems'
|
19
20
|
require 'boxgrinder-core/helpers/appliance-definition-helper'
|
21
|
+
require 'boxgrinder-core/appliance-parser'
|
20
22
|
|
21
23
|
module BoxGrinder
|
22
24
|
describe ApplianceDefinitionHelper do
|
23
25
|
|
24
|
-
|
26
|
+
def prepare_helper
|
25
27
|
@helper = ApplianceDefinitionHelper.new(:log => LogHelper.new(:level => :trace, :type => :stdout))
|
26
28
|
end
|
27
29
|
|
30
|
+
before(:each) do
|
31
|
+
prepare_helper
|
32
|
+
end
|
33
|
+
|
28
34
|
describe ".read_definitions" do
|
29
35
|
it "should read definition from files with different extensions" do
|
30
36
|
appliance_config = ApplianceConfig.new
|
31
|
-
|
32
37
|
['appl', 'yml', 'yaml'].each do |ext|
|
33
|
-
|
38
|
+
prepare_helper
|
39
|
+
@helper.appliance_parser.should_receive(:load_schemas)
|
34
40
|
File.should_receive(:exists?).with("file.#{ext}").and_return(true)
|
35
|
-
@helper.should_receive(:
|
41
|
+
@helper.appliance_parser.should_receive(:parse_definition).with("file.#{ext}").and_return(appliance_config)
|
36
42
|
@helper.read_definitions("file.#{ext}")
|
37
|
-
|
38
43
|
configs = @helper.appliance_configs
|
39
|
-
configs.should == [appliance_config]
|
40
|
-
end
|
41
|
-
end
|
42
44
|
|
43
|
-
|
44
|
-
appliance_config = ApplianceConfig.new
|
45
|
+
puts configs.size
|
45
46
|
|
46
|
-
['application/x-yaml', 'text/yaml'].each do |type|
|
47
|
-
@helper = ApplianceDefinitionHelper.new(:log => Logger.new('/dev/null'))
|
48
|
-
File.should_receive(:exists?).with("file").and_return(true)
|
49
|
-
@helper.should_receive(:read_yaml_file).with("file").and_return(appliance_config)
|
50
|
-
@helper.read_definitions("file", type)
|
51
|
-
|
52
|
-
configs = @helper.appliance_configs
|
53
47
|
configs.should == [appliance_config]
|
54
|
-
configs.first.should == appliance_config
|
55
48
|
end
|
56
49
|
end
|
57
50
|
|
58
|
-
it "should read
|
51
|
+
it "should read YAML definition from files with different content types" do
|
59
52
|
appliance_config = ApplianceConfig.new
|
60
53
|
|
61
|
-
['application/
|
62
|
-
|
54
|
+
['application/x-yaml', 'text/yaml'].each do |type|
|
55
|
+
prepare_helper
|
56
|
+
@helper.appliance_parser.should_receive(:load_schemas)
|
63
57
|
File.should_receive(:exists?).with("file").and_return(true)
|
64
|
-
@helper.should_receive(:
|
58
|
+
@helper.appliance_parser.should_receive(:parse_definition).with("file").and_return(appliance_config)
|
65
59
|
@helper.read_definitions("file", type)
|
66
|
-
|
67
60
|
configs = @helper.appliance_configs
|
68
61
|
configs.should == [appliance_config]
|
69
62
|
configs.first.should == appliance_config
|
@@ -71,6 +64,8 @@ module BoxGrinder
|
|
71
64
|
end
|
72
65
|
|
73
66
|
it "should read definition from two files" do
|
67
|
+
@helper.appliance_parser.should_receive(:load_schemas).twice
|
68
|
+
|
74
69
|
appliance_a = ApplianceConfig.new
|
75
70
|
appliance_a.name = 'a'
|
76
71
|
appliance_a.appliances << "b"
|
@@ -81,8 +76,8 @@ module BoxGrinder
|
|
81
76
|
File.should_receive(:exists?).ordered.with('a.appl').and_return(true)
|
82
77
|
File.should_receive(:exists?).ordered.with('./b.appl').and_return(true)
|
83
78
|
|
84
|
-
@helper.should_receive(:
|
85
|
-
@helper.should_receive(:
|
79
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('a.appl').and_return(appliance_a)
|
80
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('./b.appl').and_return(appliance_b)
|
86
81
|
|
87
82
|
@helper.read_definitions("a.appl")
|
88
83
|
|
@@ -92,6 +87,8 @@ module BoxGrinder
|
|
92
87
|
end
|
93
88
|
|
94
89
|
it "should read definitions from a tree file structure" do
|
90
|
+
@helper.appliance_parser.should_receive(:load_schemas).exactly(5).times
|
91
|
+
|
95
92
|
appliance_a = ApplianceConfig.new
|
96
93
|
appliance_a.name = 'a'
|
97
94
|
appliance_a.appliances << "b1"
|
@@ -117,11 +114,11 @@ module BoxGrinder
|
|
117
114
|
File.should_receive(:exists?).ordered.with('./b1.appl').and_return(true)
|
118
115
|
File.should_receive(:exists?).ordered.with('./c1.appl').and_return(true)
|
119
116
|
|
120
|
-
@helper.should_receive(:
|
121
|
-
@helper.should_receive(:
|
122
|
-
@helper.should_receive(:
|
123
|
-
@helper.should_receive(:
|
124
|
-
@helper.should_receive(:
|
117
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('a.appl').and_return(appliance_a)
|
118
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('./b2.appl').and_return(appliance_b2)
|
119
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('./c2.appl').and_return(appliance_c2)
|
120
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('./b1.appl').and_return(appliance_b1)
|
121
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('./c1.appl').and_return(appliance_c1)
|
125
122
|
|
126
123
|
@helper.read_definitions("a.appl")
|
127
124
|
|
@@ -132,6 +129,8 @@ module BoxGrinder
|
|
132
129
|
|
133
130
|
# https://issues.jboss.org/browse/BGBUILD-60
|
134
131
|
it "should read definitions from a tree file structure based on same appliance" do
|
132
|
+
@helper.appliance_parser.should_receive(:load_schemas).exactly(4).times
|
133
|
+
|
135
134
|
appliance_a = ApplianceConfig.new
|
136
135
|
appliance_a.name = 'a'
|
137
136
|
appliance_a.appliances << "b1"
|
@@ -153,11 +152,11 @@ module BoxGrinder
|
|
153
152
|
File.should_receive(:exists?).ordered.with('./c.appl').and_return(true)
|
154
153
|
File.should_receive(:exists?).ordered.with('./b1.appl').and_return(true)
|
155
154
|
|
156
|
-
@helper.should_receive(:
|
157
|
-
@helper.should_receive(:
|
158
|
-
@helper.should_receive(:
|
159
|
-
@helper.should_receive(:
|
160
|
-
@helper.should_not_receive(:
|
155
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('a.appl').and_return(appliance_a)
|
156
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('./b2.appl').and_return(appliance_b2)
|
157
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('./c.appl').and_return(appliance_c)
|
158
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('./b1.appl').and_return(appliance_b1)
|
159
|
+
@helper.appliance_parser.should_not_receive(:parse_definition).ordered.with('./c.appl')
|
161
160
|
|
162
161
|
@helper.read_definitions("a.appl")
|
163
162
|
|
@@ -167,7 +166,7 @@ module BoxGrinder
|
|
167
166
|
end
|
168
167
|
|
169
168
|
it "should read YAML content instead of loading a file" do
|
170
|
-
yaml = "name: abc\nos:\n name: fedora\n version: 13\npackages:\n - @core\nhardware:\n partitions:\n \"/\":\n size: 6"
|
169
|
+
yaml = "name: abc\nos:\n name: fedora\n version: '13'\npackages:\n - @core\nhardware:\n partitions:\n \"/\":\n size: 6"
|
171
170
|
appliance = @helper.read_definitions(yaml).last
|
172
171
|
|
173
172
|
appliance.name.should == 'abc'
|
@@ -175,21 +174,16 @@ module BoxGrinder
|
|
175
174
|
appliance.hardware.partitions['/']['size'].should == 6
|
176
175
|
end
|
177
176
|
|
178
|
-
it "should read invalid YAML content" do
|
179
|
-
lambda { @helper.read_definitions("@$FEWYERTH") }.should raise_error(
|
177
|
+
it "should read invalid YAML content" do #ApplianceValidationError: :
|
178
|
+
lambda { @helper.read_definitions("@$FEWYERTH") }.should raise_error(ApplianceValidationError, "The appliance definition was invalid according to schema 0.9.0. See log for details.")
|
180
179
|
end
|
181
180
|
|
182
181
|
it "should catch exception if YAML parsing raises it" do
|
183
|
-
lambda { @helper.read_definitions("!!") }.should raise_error(
|
182
|
+
lambda { @helper.read_definitions("!!") }.should raise_error(ApplianceValidationError, "The appliance definition was invalid according to schema 0.9.0. See log for details.")
|
184
183
|
end
|
185
184
|
|
186
185
|
it "should catch exception if YAML file parsing raises it" do
|
187
|
-
lambda { @helper.read_definitions("#{File.dirname(__FILE__)}/../rspec/src/appliances/invalid-yaml.appl") }.should raise_error(
|
188
|
-
end
|
189
|
-
|
190
|
-
it "should raise because xml files aren't supported yet" do
|
191
|
-
File.should_receive(:exists?).with("file.xml").and_return(true)
|
192
|
-
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.")
|
186
|
+
lambda { @helper.read_definitions("#{File.dirname(__FILE__)}/../rspec/src/appliances/invalid-yaml.appl") }.should raise_error(ApplianceValidationError, "The appliance definition was invalid according to schema 0.9.0. See log for details.")
|
193
187
|
end
|
194
188
|
|
195
189
|
it "should raise because of unsupported file format" do
|
@@ -197,9 +191,18 @@ module BoxGrinder
|
|
197
191
|
lambda { @helper.read_definitions("file.xmdfl") }.should raise_error(RuntimeError, "Unsupported file format for appliance definition file.")
|
198
192
|
end
|
199
193
|
|
194
|
+
#Do more extensive tests in the parser/validator itself
|
195
|
+
it "should allow legacy package inclusion styles" do #@helper.appliance_validator.should_receive(:load_specification_files).
|
196
|
+
#@helper = ApplianceDefinitionHelper.new(:log => LogHelper.new(:level => :trace, :type => :stdout))
|
197
|
+
@helper.read_definitions("#{File.dirname(__FILE__)}/../rspec/src/appliances/legacy.appl")
|
198
|
+
@helper.appliance_configs.last.packages.should == ['squid', 'boxgrinder-rest']
|
199
|
+
end
|
200
|
+
|
200
201
|
# https://issues.jboss.org/browse/BGBUILD-150
|
201
202
|
context "cyclical dependency" do
|
202
203
|
it "should stop reading appliances when appliance was already read" do
|
204
|
+
@helper.appliance_parser.should_receive(:load_schemas).twice
|
205
|
+
|
203
206
|
appliance_a = ApplianceConfig.new
|
204
207
|
appliance_a.name = 'a'
|
205
208
|
appliance_a.appliances << "b"
|
@@ -213,45 +216,19 @@ module BoxGrinder
|
|
213
216
|
File.should_receive(:exists?).with('./b.appl').and_return(true)
|
214
217
|
File.should_not_receive(:exists?).ordered.with('./a.appl')
|
215
218
|
|
216
|
-
@helper.should_receive(:
|
217
|
-
@helper.should_receive(:
|
218
|
-
@helper.should_not_receive(:
|
219
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('a.appl').and_return(appliance_a)
|
220
|
+
@helper.appliance_parser.should_receive(:parse_definition).ordered.with('./b.appl').and_return(appliance_b)
|
221
|
+
@helper.appliance_parser.should_not_receive(:parse_definition).ordered.with('./a.appl')
|
219
222
|
|
220
223
|
@helper.read_definitions("a.appl")
|
221
224
|
end
|
222
225
|
end
|
223
226
|
end
|
224
227
|
|
225
|
-
describe "read_yaml_file" do
|
226
|
-
it "should read default_repos and set to false" do
|
227
|
-
YAML.should_receive(:load_file).with('default_repos_false.appl').and_return({'default_repos'=>false})
|
228
|
-
@helper.read_yaml_file('default_repos_false.appl').default_repos.should == false
|
229
|
-
end
|
230
|
-
|
231
|
-
it "should read default_repos and set to true" do
|
232
|
-
YAML.should_receive(:load_file).with('default_repos_true.appl').and_return({'default_repos'=>true})
|
233
|
-
@helper.read_yaml_file('default_repos_true.appl').default_repos.should == true
|
234
|
-
end
|
235
|
-
|
236
|
-
it "should read default_repos but not set it" do
|
237
|
-
YAML.should_receive(:load_file).with('default_repos_empty.appl').and_return({})
|
238
|
-
@helper.read_yaml_file('default_repos_empty.appl').default_repos.should == nil
|
239
|
-
end
|
240
|
-
|
241
|
-
it "should read default_repos and raise" do
|
242
|
-
YAML.should_receive(:load_file).with('default_repos_bad.appl').and_return({'default_repos'=>'something'})
|
243
|
-
|
244
|
-
lambda {
|
245
|
-
@helper.read_yaml_file("default_repos_bad.appl")
|
246
|
-
}.should raise_error(RuntimeError, 'default_repos should be set to true or false')
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
228
|
describe ".parse_yaml" do
|
251
229
|
context "partitions" do
|
252
230
|
it "should add default partition when no partitions are specified" do
|
253
231
|
appliance_config = @helper.parse_yaml({})
|
254
|
-
|
255
232
|
appliance_config.hardware.partitions.size.should == 1
|
256
233
|
appliance_config.hardware.partitions['/'].should == {'size' => 1}
|
257
234
|
end
|
@@ -264,11 +241,6 @@ module BoxGrinder
|
|
264
241
|
appliance_config.hardware.partitions['/home'].should == {'size' => 1}
|
265
242
|
end
|
266
243
|
|
267
|
-
it "should allow legacy package inclusion style" do
|
268
|
-
appliance = @helper.read_yaml_file("#{File.dirname(__FILE__)}/../rspec/src/appliances/legacy.appl")
|
269
|
-
appliance.packages.should == ['squid','boxgrinder-rest']
|
270
|
-
end
|
271
|
-
|
272
244
|
end
|
273
245
|
end
|
274
246
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2010 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This is free software; you can redistribute it and/or modify it
|
5
|
+
# under the terms of the GNU Lesser General Public License as
|
6
|
+
# published by the Free Software Foundation; either version 3 of
|
7
|
+
# the License, or (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This software is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
# Lesser General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
15
|
+
# License along with this software; if not, write to the Free
|
16
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
17
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
|
+
|
19
|
+
require 'rubygems'
|
20
|
+
require 'boxgrinder-core/helpers/appliance-transformation-helper'
|
21
|
+
|
22
|
+
module BoxGrinder
|
23
|
+
describe ApplianceTransformationHelper do
|
24
|
+
before(:each) do
|
25
|
+
|
26
|
+
@log = LogHelper.new(:level => :trace, :type => :stdout)
|
27
|
+
@helper = ApplianceTransformationHelper.new('0.9.0', :log => @log)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".transform" do
|
31
|
+
it "should not transform to the same version" do
|
32
|
+
@log.should_not_receive(:debug) # hacky, but does the trick
|
33
|
+
@helper.transform('definition', '0.9.0').should == 'definition'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should transform with one pass" do
|
37
|
+
@helper.should_receive(:to_0_9_0).with('definition').and_return('new-def')
|
38
|
+
@helper.transform('definition', '0.8.0').should == 'new-def'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ".to_0_9_0" do
|
43
|
+
it "should remove excludes section" do
|
44
|
+
appl = "name: test-appl\nos:\n name: fedora\n version: 15\npackages:\n includes:\n - @base\n - emacs\n excludes:\n - this-does-nothing"
|
45
|
+
out = @helper.to_0_9_0(YAML.load(appl))
|
46
|
+
out['packages'].should == ["@base", "emacs"]
|
47
|
+
out['excludes'].should == nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -16,36 +16,59 @@
|
|
16
16
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
|
+
require 'rubygems'
|
19
20
|
require 'boxgrinder-core/helpers/exec-helper'
|
20
21
|
|
21
22
|
module BoxGrinder
|
22
23
|
describe ExecHelper do
|
23
24
|
before(:each) do
|
24
25
|
@helper = ExecHelper.new(:log => Logger.new('/dev/null'))
|
26
|
+
@o4 = (RUBY_PLATFORM =~ /java/ ? IO : Open4)
|
27
|
+
|
28
|
+
@pid = 1234
|
29
|
+
@stdin = mock('STDIN')
|
30
|
+
@stdout = mock('STDOUT')
|
31
|
+
@stderr = mock('STDERR')
|
25
32
|
end
|
26
33
|
|
27
34
|
it "should fail when command doesn't exists" do
|
28
|
-
|
29
|
-
|
35
|
+
@o4.should_receive(:send).with(:popen4, 'thisdoesntexists').and_raise('abc')
|
30
36
|
proc { @helper.execute("thisdoesntexists") }.should raise_error("An error occurred while executing command: 'thisdoesntexists', abc")
|
31
37
|
end
|
32
38
|
|
33
|
-
|
34
|
-
|
35
|
-
|
39
|
+
if RUBY_PLATFORM =~ /java/
|
40
|
+
it "should fail when command exit status != 0 and is on MRI" do
|
41
|
+
@stdout.should_receive(:each)
|
42
|
+
@stderr.should_receive(:each)
|
43
|
+
Process.should_receive(:getpgid)
|
44
|
+
Process.should_receive(:waitpid2).with(1234).and_return([1234, OpenCascade.new(:exitstatus => 1)])
|
45
|
+
|
46
|
+
@o4.should_receive(:send).with(:popen4, 'exitstatus').and_return([@pid, @stdin, @stdout, @stderr])
|
36
47
|
|
37
|
-
|
48
|
+
lambda { @helper.execute("exitstatus") }.should_not raise_error("An error occurred while executing command: 'exitstatus', process exited with wrong exit status: 1")
|
49
|
+
end
|
50
|
+
else
|
51
|
+
it "should fail when command exit status != 0 and is on MRI" do
|
52
|
+
@stdout.should_receive(:each)
|
53
|
+
@stderr.should_receive(:each)
|
54
|
+
Process.should_receive(:getpgid)
|
55
|
+
Process.should_receive(:waitpid2).with(1234).and_return([1234, OpenCascade.new(:exitstatus => 1)])
|
38
56
|
|
39
|
-
|
57
|
+
@o4.should_receive(:send).with(:popen4, 'exitstatus').and_return([@pid, @stdin, @stdout, @stderr])
|
58
|
+
|
59
|
+
lambda { @helper.execute("exitstatus") }.should raise_error("An error occurred while executing command: 'exitstatus', process exited with wrong exit status: 1")
|
60
|
+
end
|
40
61
|
end
|
41
62
|
|
42
63
|
it "should execute the command" do
|
43
|
-
|
44
|
-
|
64
|
+
@stdout.should_receive(:each)
|
65
|
+
@stderr.should_receive(:each)
|
66
|
+
Process.should_receive(:getpgid)
|
67
|
+
Process.should_receive(:waitpid2).with(1234).and_return([1234, OpenCascade.new(:exitstatus => 0)])
|
45
68
|
|
46
|
-
|
69
|
+
@o4.should_receive(:send).with(:popen4, 'abc').and_return([@pid, @stdin, @stdout, @stderr])
|
47
70
|
|
48
|
-
|
71
|
+
lambda { @helper.execute("abc") }.should_not raise_error
|
49
72
|
end
|
50
73
|
|
51
74
|
it "should execute the command and return output" do
|
@@ -60,8 +83,13 @@ module BoxGrinder
|
|
60
83
|
log = mock('Logger')
|
61
84
|
log.should_receive(:debug).with("Executing command: 'ala ma <REDACTED> i jest fajnie'")
|
62
85
|
|
86
|
+
@stdout.should_receive(:each)
|
87
|
+
@stderr.should_receive(:each)
|
88
|
+
Process.should_receive(:getpgid)
|
89
|
+
Process.should_receive(:waitpid2).with(1234).and_return([1234, OpenCascade.new(:exitstatus => 0)])
|
90
|
+
|
63
91
|
@helper = ExecHelper.new(:log => log)
|
64
|
-
|
92
|
+
@o4.should_receive(:send).with(:popen4, "ala ma kota i jest fajnie").and_return([@pid, @stdin, @stdout, @stderr])
|
65
93
|
|
66
94
|
@helper.execute("ala ma kota i jest fajnie", :redacted => ['kota'])
|
67
95
|
end
|
data/spec/models/config-spec.rb
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
|
+
require 'rubygems'
|
19
20
|
require 'boxgrinder-core/models/config'
|
20
21
|
|
21
22
|
module BoxGrinder
|
@@ -53,4 +54,4 @@ module BoxGrinder
|
|
53
54
|
config.platform.should == :ec2
|
54
55
|
end
|
55
56
|
end
|
56
|
-
end
|
57
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
name: 0.8.x test appliance
|
2
|
+
summary: appliance to test 0.8.x schema
|
3
|
+
version: 0
|
4
|
+
release: 0
|
5
|
+
os:
|
6
|
+
name: fedora
|
7
|
+
version: 15
|
8
|
+
password: boxgrinder-ftw
|
9
|
+
hardware:
|
10
|
+
cpus: 4
|
11
|
+
memory: 2048
|
12
|
+
partitions:
|
13
|
+
"/":
|
14
|
+
size: 4
|
15
|
+
type: ext4
|
16
|
+
appliances:
|
17
|
+
- _include
|
18
|
+
packages:
|
19
|
+
includes:
|
20
|
+
- @base
|
21
|
+
- emacs
|
22
|
+
- mc
|
23
|
+
excludes:
|
24
|
+
- this-does-nothing
|
25
|
+
repos:
|
26
|
+
- name: boxgrinder-ci-repo
|
27
|
+
baseurl: http://repo.ci.boxgrinder.org/fedora/15/RPMS/
|
28
|
+
ephemeral: true
|
29
|
+
- name: test
|
30
|
+
baseurl: "http://example.com/repo/#BASE_ARCH#/"
|
31
|
+
variables:
|
32
|
+
my_var: "bg rocks!"
|
33
|
+
something: "other"
|
34
|
+
post:
|
35
|
+
base:
|
36
|
+
- "/bin/echo 'Hello, World!' > hello-world"
|
37
|
+
vmware:
|
38
|
+
- "/bin/echo 'Hello, World!' > hello-world-vmware"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
name: ""
|
2
|
+
summary: ""
|
3
|
+
version: -1
|
4
|
+
release: -2
|
5
|
+
hardware:
|
6
|
+
cpus: 0
|
7
|
+
memory: 0
|
8
|
+
partitions:
|
9
|
+
"/":
|
10
|
+
size: 0
|
11
|
+
"/home":
|
12
|
+
size: -1
|
13
|
+
type: ABC123 #no such type
|
14
|
+
appliances:
|
15
|
+
- /cannot/do/this
|
16
|
+
- #wrong
|
17
|
+
- "" #wrong
|
18
|
+
- " "#technically ok
|
19
|
+
- this$is%fine£though
|
20
|
+
packages:
|
21
|
+
- this-is-fine
|
22
|
+
- good/bad/u g l y
|
23
|
+
- $%^&*dontlet$$£this%£"$work
|
24
|
+
- #blank is bad
|
25
|
+
- "" #empty string is invalid too
|
26
|
+
- " "#no spaces allowed
|
27
|
+
repos:
|
28
|
+
- name: "" # wrong and missing baseurl/mirrorlist
|
29
|
+
- name: " "# no spaces and missing baseurl/mirrorlist
|
30
|
+
- name: "blah" # repo has baseurl AND mirrorlist which is wrong
|
31
|
+
baseurl: sftp://example.com #no sftp support
|
32
|
+
mirrorlist: http:// this is not ok .\/\/ #invalid uri
|
33
|
+
post:
|
34
|
+
base:
|
35
|
+
- #wrong
|
36
|
+
- "" #wrong
|
37
|
+
- " " #wrong
|
38
|
+
- "this>is<fine >> << $() || && == ++ --"
|
39
|
+
fred: #ok
|
40
|
+
- "shred" #ok
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: 0.9.x test appliance
|
2
|
+
summary: appliance to test 0.9.x schema
|
3
|
+
version: 0
|
4
|
+
release: 0
|
5
|
+
os:
|
6
|
+
name: fedora
|
7
|
+
version: 15
|
8
|
+
password: boxgrinder-ftw
|
9
|
+
hardware:
|
10
|
+
cpus: 4
|
11
|
+
memory: 2048
|
12
|
+
partitions:
|
13
|
+
"/":
|
14
|
+
size: 4
|
15
|
+
type: ext4
|
16
|
+
appliances:
|
17
|
+
- _include
|
18
|
+
packages:
|
19
|
+
- squid
|
20
|
+
- rubygem-boxgrinder-build
|
21
|
+
repos:
|
22
|
+
- name: boxgrinder-ci-repo
|
23
|
+
baseurl: http://repo.ci.boxgrinder.org/fedora/15/RPMS/
|
24
|
+
ephemeral: true
|
25
|
+
- name: test
|
26
|
+
baseurl: "http://example.com/repo/#BASE_ARCH#/"
|
27
|
+
- name: mirrorlist
|
28
|
+
mirrorlist: "http://example.com/"
|
29
|
+
variables:
|
30
|
+
my_var: "bg rocks!"
|
31
|
+
something: "other"
|
32
|
+
post:
|
33
|
+
base:
|
34
|
+
- "/bin/echo 'Hello, World!' > hello-world"
|
35
|
+
vmware:
|
36
|
+
- "/bin/echo 'Hello, World!' > hello-world-vmware"
|