boxgrinder-core 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/Manifest +32 -0
- data/Rakefile +49 -0
- data/boxgrinder-core.gemspec +3 -3
- data/lib/boxgrinder-core/helpers/appliance-config-helper.rb +29 -4
- data/lib/boxgrinder-core/helpers/appliance-helper.rb +9 -3
- data/rubygem-boxgrinder-core.spec +33 -7
- data/spec/helpers/appliance-config-helper-spec.rb +74 -13
- data/spec/helpers/appliance-helper-spec.rb +39 -14
- metadata +5 -6
- data/spec/Rakefile +0 -28
data/CHANGELOG
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
|
2
|
+
v0.1.2
|
3
|
+
|
4
|
+
* [BGBUILD-87] Set default filesystem to ext4 for Fedora 13+
|
5
|
+
* [BGBUILD-65] Allow to specify own repos overriding default repos provided for selected OS
|
6
|
+
|
2
7
|
v0.1.1
|
3
8
|
|
4
9
|
* [BGBUILD-65] Allow to specify own repos overriding default repos provided for selected OS
|
data/Manifest
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
LICENSE
|
3
|
+
Manifest
|
4
|
+
README
|
5
|
+
Rakefile
|
6
|
+
boxgrinder-core.gemspec
|
7
|
+
lib/boxgrinder-core.rb
|
8
|
+
lib/boxgrinder-core/defaults.rb
|
9
|
+
lib/boxgrinder-core/helpers/appliance-config-helper.rb
|
10
|
+
lib/boxgrinder-core/helpers/appliance-helper.rb
|
11
|
+
lib/boxgrinder-core/helpers/exec-helper.rb
|
12
|
+
lib/boxgrinder-core/helpers/log-helper.rb
|
13
|
+
lib/boxgrinder-core/helpers/queue-helper.rb
|
14
|
+
lib/boxgrinder-core/models/appliance-config.rb
|
15
|
+
lib/boxgrinder-core/models/config.rb
|
16
|
+
lib/boxgrinder-core/models/task.rb
|
17
|
+
lib/boxgrinder-core/validators/appliance-config-validator.rb
|
18
|
+
lib/boxgrinder-core/validators/errors.rb
|
19
|
+
lib/openhash/openhash.rb
|
20
|
+
rubygem-boxgrinder-core.spec
|
21
|
+
spec/helpers/appliance-config-helper-spec.rb
|
22
|
+
spec/helpers/appliance-helper-spec.rb
|
23
|
+
spec/helpers/exec-helper-spec.rb
|
24
|
+
spec/helpers/log-helper-spec.rb
|
25
|
+
spec/helpers/queue-helper-spec.rb
|
26
|
+
spec/rspec/ls/one
|
27
|
+
spec/rspec/ls/two
|
28
|
+
spec/rspec/rspec-config-helper.rb
|
29
|
+
spec/rspec/src/appliances/ephemeral-repo.appl
|
30
|
+
spec/rspec/src/appliances/full.appl
|
31
|
+
spec/rspec/src/appliances/repo.appl
|
32
|
+
spec/validators/appliance-config-validator-spec.rb
|
data/Rakefile
CHANGED
@@ -16,6 +16,8 @@
|
|
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'
|
20
|
+
require 'spec/rake/spectask'
|
19
21
|
require 'echoe'
|
20
22
|
|
21
23
|
Echoe.new("boxgrinder-core") do |p|
|
@@ -26,3 +28,50 @@ Echoe.new("boxgrinder-core") do |p|
|
|
26
28
|
p.email = "info@boxgrinder.org"
|
27
29
|
p.runtime_dependencies = ['open4 >=1.0.0']
|
28
30
|
end
|
31
|
+
|
32
|
+
desc "Run all tests"
|
33
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
34
|
+
t.rcov = false
|
35
|
+
t.spec_files = FileList["spec/**/*-spec.rb"]
|
36
|
+
t.spec_opts = ['--colour', '--format', 'specdoc', '-b']
|
37
|
+
t.verbose = true
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Run all tests and generate code coverage report"
|
41
|
+
Spec::Rake::SpecTask.new('spec:coverage') do |t|
|
42
|
+
t.spec_files = FileList["spec/**/*-spec.rb"]
|
43
|
+
t.spec_opts = ['--colour', '--format', 'html:pkg/rspec_report.html', '-b']
|
44
|
+
t.rcov = true
|
45
|
+
t.rcov_opts = ['--exclude', 'spec,teamcity/*,/usr/lib/ruby/,.gem/ruby,/boxgrinder-build/,/gems/']
|
46
|
+
t.verbose = true
|
47
|
+
end
|
48
|
+
|
49
|
+
topdir = "#{Dir.pwd}/pkg/rpmbuild"
|
50
|
+
directory "#{topdir}/SOURCES"
|
51
|
+
|
52
|
+
task 'gem:copy' => [:clean, :manifest, :gem, 'rpm:topdir'] do
|
53
|
+
Dir["**/pkg/*.gem"].each { |gem| FileUtils.cp(gem, "#{topdir}/SOURCES", :verbose => true) }
|
54
|
+
end
|
55
|
+
|
56
|
+
task 'rpm:topdir' do
|
57
|
+
FileUtils.mkdir_p(["#{topdir}/SOURCES", "#{topdir}/RPMS", "#{topdir}/BUILD", "#{topdir}/SPECS", "#{topdir}/SRPMS"], :verbose => true)
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Create RPM"
|
61
|
+
task 'rpm' => ['gem:copy'] do
|
62
|
+
Dir["**/rubygem-*.spec"].each do |spec|
|
63
|
+
`rpmbuild --define '_topdir #{topdir}' -ba #{spec}`
|
64
|
+
exit 1 unless $? == 0
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Install RPM"
|
69
|
+
task 'rpm:install' => ['rpm'] do
|
70
|
+
puts "sudo yum -y remove rubygem-boxgrinder-core"
|
71
|
+
system "sudo yum -y remove rubygem-boxgrinder-core"
|
72
|
+
exit 1 unless $? == 0
|
73
|
+
|
74
|
+
puts "sudo yum -y --nogpgcheck localinstall #{topdir}/RPMS/noarch/*.rpm"
|
75
|
+
system "sudo yum -y --nogpgcheck localinstall #{topdir}/RPMS/noarch/*.rpm"
|
76
|
+
exit 1 unless $? == 0
|
77
|
+
end
|
data/boxgrinder-core.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{boxgrinder-core}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Marek Goldmann"]
|
9
|
-
s.date = %q{2010-11-
|
9
|
+
s.date = %q{2010-11-11}
|
10
10
|
s.description = %q{Core library for BoxGrinder}
|
11
11
|
s.email = %q{info@boxgrinder.org}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/helpers/queue-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb", "lib/openhash/openhash.rb"]
|
13
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/helpers/queue-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb", "lib/openhash/openhash.rb", "rubygem-boxgrinder-core.spec", "spec/
|
13
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "boxgrinder-core.gemspec", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/helpers/queue-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb", "lib/openhash/openhash.rb", "rubygem-boxgrinder-core.spec", "spec/helpers/appliance-config-helper-spec.rb", "spec/helpers/appliance-helper-spec.rb", "spec/helpers/exec-helper-spec.rb", "spec/helpers/log-helper-spec.rb", "spec/helpers/queue-helper-spec.rb", "spec/rspec/ls/one", "spec/rspec/ls/two", "spec/rspec/rspec-config-helper.rb", "spec/rspec/src/appliances/ephemeral-repo.appl", "spec/rspec/src/appliances/full.appl", "spec/rspec/src/appliances/repo.appl", "spec/validators/appliance-config-validator-spec.rb"]
|
14
14
|
s.homepage = %q{http://www.jboss.org/boxgrinder}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-core", "--main", "README"]
|
16
16
|
s.require_paths = ["lib"]
|
@@ -76,8 +76,8 @@ module BoxGrinder
|
|
76
76
|
var = resolve_stack.last
|
77
77
|
refs = @appliance_config.variables.keys.delete_if { |k|
|
78
78
|
@appliance_config.variables[k].nil? ||
|
79
|
-
|
80
|
-
|
79
|
+
@appliance_config.variables[k].index("##{k}#").nil? ||
|
80
|
+
resolve_stack.index(k).nil?
|
81
81
|
}
|
82
82
|
refs.each do |ref|
|
83
83
|
resolve(Arrays.new(resolve_stack).push(ref), resolved_set) unless resolved_set.include?(ref)
|
@@ -111,17 +111,42 @@ module BoxGrinder
|
|
111
111
|
unless partition['type'].nil?
|
112
112
|
partitions[root].delete('options') if partitions[root]['type'] != partition['type']
|
113
113
|
partitions[root]['type'] = partition['type']
|
114
|
+
else
|
115
|
+
partitions[root]['type'] = default_filesystem_type
|
114
116
|
end
|
115
|
-
partitions[root]['options'] = partition['options'] unless partition['options'].nil? and partitions[root]['type'] == partition['type']
|
116
117
|
else
|
117
|
-
partitions[root] =
|
118
|
+
partitions[root] = {}
|
119
|
+
partitions[root]['size'] = partition['size']
|
120
|
+
|
121
|
+
unless partition['type'].nil?
|
122
|
+
partitions[root]['type'] = partition['type']
|
123
|
+
else
|
124
|
+
partitions[root]['type'] = default_filesystem_type
|
125
|
+
end
|
118
126
|
end
|
127
|
+
|
128
|
+
partitions[root]['options'] = partition['options'] unless partition['options'].nil?
|
119
129
|
end
|
120
130
|
end
|
121
131
|
|
122
132
|
@appliance_config.hardware.partitions = partitions
|
123
133
|
end
|
124
134
|
|
135
|
+
def default_filesystem_type
|
136
|
+
fs = 'ext3'
|
137
|
+
|
138
|
+
case @appliance_config.os.name
|
139
|
+
when 'fedora'
|
140
|
+
|
141
|
+
case @appliance_config.os.version
|
142
|
+
when '13', '14'
|
143
|
+
fs = 'ext4'
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
fs
|
148
|
+
end
|
149
|
+
|
125
150
|
def merge_memory
|
126
151
|
merge_field('hardware.memory') { |memory| @appliance_config.hardware.memory = memory if memory > @appliance_config.hardware.memory }
|
127
152
|
end
|
@@ -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 'boxgrinder-core/models/appliance-config'
|
19
20
|
require 'yaml'
|
20
21
|
|
21
22
|
module BoxGrinder
|
@@ -61,7 +62,7 @@ module BoxGrinder
|
|
61
62
|
def read_yaml(file)
|
62
63
|
begin
|
63
64
|
definition = YAML.load_file(file)
|
64
|
-
raise if definition.nil?
|
65
|
+
raise if definition.nil? or definition == false
|
65
66
|
rescue
|
66
67
|
raise "File '#{file}' could not be read."
|
67
68
|
end
|
@@ -78,8 +79,13 @@ module BoxGrinder
|
|
78
79
|
appliance_config.appliances = definition['appliances'] unless definition['appliances'].nil?
|
79
80
|
appliance_config.repos = definition['repos'] unless definition['repos'].nil?
|
80
81
|
|
81
|
-
appliance_config.version
|
82
|
-
appliance_config.release
|
82
|
+
appliance_config.version = definition['version'].to_s unless definition['version'].nil?
|
83
|
+
appliance_config.release = definition['release'].to_s unless definition['release'].nil?
|
84
|
+
|
85
|
+
unless definition['default_repos'].nil?
|
86
|
+
appliance_config.default_repos = definition['default_repos']
|
87
|
+
raise "#{File.basename(file)}: default_repos should be set to true or false" unless appliance_config.default_repos.is_a?(TrueClass) or appliance_config.default_repos.is_a?(FalseClass)
|
88
|
+
end
|
83
89
|
|
84
90
|
unless definition['packages'].nil?
|
85
91
|
appliance_config.packages.includes = definition['packages']['includes'] unless definition['packages']['includes'].nil?
|
@@ -5,12 +5,13 @@
|
|
5
5
|
|
6
6
|
Summary: Core library for BoxGrinder
|
7
7
|
Name: rubygem-%{gemname}
|
8
|
-
Version: 0.1.
|
8
|
+
Version: 0.1.2
|
9
9
|
Release: 1%{?dist}
|
10
10
|
Group: Development/Languages
|
11
|
-
License:
|
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: rubygems >= 1.2
|
@@ -25,6 +26,14 @@ Provides: rubygem(%{gemname}) = %{version}
|
|
25
26
|
%description
|
26
27
|
Core library containing files required by BoxGrinder family of projects
|
27
28
|
|
29
|
+
%package doc
|
30
|
+
Summary: Documentation for %{name}
|
31
|
+
Group: Documentation
|
32
|
+
Requires:%{name} = %{version}-%{release}
|
33
|
+
|
34
|
+
%description doc
|
35
|
+
Documentation for %{name}
|
36
|
+
|
28
37
|
%prep
|
29
38
|
|
30
39
|
%build
|
@@ -35,6 +44,12 @@ mkdir -p %{buildroot}%{gemdir}
|
|
35
44
|
gem install --local --install-dir %{buildroot}%{gemdir} \
|
36
45
|
--force --rdoc %{SOURCE0}
|
37
46
|
|
47
|
+
%check
|
48
|
+
pushd %{buildroot}/%{geminstdir}
|
49
|
+
rake spec
|
50
|
+
rm -rf log
|
51
|
+
popd
|
52
|
+
|
38
53
|
%clean
|
39
54
|
rm -rf %{buildroot}
|
40
55
|
|
@@ -42,18 +57,29 @@ rm -rf %{buildroot}
|
|
42
57
|
%defattr(-, root, root, -)
|
43
58
|
%dir %{geminstdir}
|
44
59
|
%{geminstdir}/lib
|
45
|
-
%doc %{gemdir}/doc/%{gemname}-%{version}
|
46
|
-
%doc %{geminstdir}/%{gemname}.gemspec
|
47
|
-
%doc %{geminstdir}/rubygem-%{gemname}.spec
|
48
60
|
%doc %{geminstdir}/CHANGELOG
|
49
61
|
%doc %{geminstdir}/LICENSE
|
50
62
|
%doc %{geminstdir}/README
|
51
63
|
%doc %{geminstdir}/Manifest
|
52
|
-
%doc %{geminstdir}/Rakefile
|
53
|
-
%doc %{geminstdir}/spec
|
54
64
|
%{gemdir}/cache/%{gemname}-%{version}.gem
|
55
65
|
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
|
56
66
|
|
67
|
+
%files doc
|
68
|
+
%defattr(-, root, root, -)
|
69
|
+
%{geminstdir}/spec
|
70
|
+
%{geminstdir}/Rakefile
|
71
|
+
%{geminstdir}/rubygem-%{gemname}.spec
|
72
|
+
%{geminstdir}/%{gemname}.gemspec
|
73
|
+
%{gemdir}/doc/%{gemname}-%{version}
|
74
|
+
|
57
75
|
%changelog
|
76
|
+
* Tue Nov 09 2010 <mgoldman@redhat.com> - 0.1.2-1
|
77
|
+
- [BGBUILD-87] Set default filesystem to ext4 for Fedora 13+
|
78
|
+
- [BGBUILD-65] Allow to specify own repos overriding default repos provided for selected OS
|
79
|
+
|
80
|
+
* Tue Nov 09 2010 <mgoldman@redhat.com> - 0.1.1-2
|
81
|
+
- [BGBUILD-85] Adjust BoxGrinder spec files for review
|
82
|
+
- Added 'check' section that executes tests
|
83
|
+
|
58
84
|
* Mon Oct 18 2010 <mgoldman@redhat.com> - 0.1.1-1
|
59
85
|
- Initial package
|
@@ -17,12 +17,9 @@
|
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
19
|
require 'boxgrinder-core/helpers/appliance-config-helper'
|
20
|
-
require 'rspec/rspec-config-helper'
|
21
20
|
|
22
21
|
module BoxGrinder
|
23
22
|
describe ApplianceConfigHelper do
|
24
|
-
include RSpecConfigHelper
|
25
|
-
|
26
23
|
before(:all) do
|
27
24
|
@arch = `uname -m`.chomp.strip
|
28
25
|
@base_arch = @arch.eql?("x86_64") ? "x86_64" : "i386"
|
@@ -103,11 +100,11 @@ module BoxGrinder
|
|
103
100
|
config_c2.post['base'] = ["5_1", "5_2"]
|
104
101
|
|
105
102
|
prepare_helper([
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
103
|
+
config_a,
|
104
|
+
config_b1,
|
105
|
+
config_c1,
|
106
|
+
config_b2,
|
107
|
+
config_c2
|
111
108
|
])
|
112
109
|
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
113
110
|
|
@@ -140,15 +137,43 @@ module BoxGrinder
|
|
140
137
|
config.post['ec2'].should == ['2_1', '2_2']
|
141
138
|
end
|
142
139
|
|
143
|
-
it "should merge partitions" do
|
140
|
+
it "should merge partitions for default fs_types without options for Fedora 13 (ext4)" do
|
144
141
|
config_a = ApplianceConfig.new
|
145
142
|
config_a.name = 'a'
|
146
143
|
config_a.appliances << 'b'
|
147
144
|
config_a.hardware.partitions = {"/" => {'size' => '2'}}
|
145
|
+
config_a.os.name = 'fedora'
|
146
|
+
config_a.os.version = '13'
|
148
147
|
|
149
148
|
config_b = ApplianceConfig.new
|
150
149
|
config_b.name = 'b'
|
151
150
|
config_b.hardware.partitions = {"/" => {'size' => '4'}, "/home" => {'size' => '2'}}
|
151
|
+
config_b.os.name = 'fedora'
|
152
|
+
config_b.os.version = '13'
|
153
|
+
|
154
|
+
prepare_helper([config_a, config_b])
|
155
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
156
|
+
|
157
|
+
@helper.merge_partitions
|
158
|
+
|
159
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
160
|
+
config.hardware.partitions.size.should == 2
|
161
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4'}, "/home" => {'size' => '2', 'type' => 'ext4'}}
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should merge partitions for default fs_types without options for Fedora 13 (ext4) and specified options" do
|
165
|
+
config_a = ApplianceConfig.new
|
166
|
+
config_a.name = 'a'
|
167
|
+
config_a.appliances << 'b'
|
168
|
+
config_a.hardware.partitions = {"/" => {'size' => '2'}}
|
169
|
+
config_a.os.name = 'fedora'
|
170
|
+
config_a.os.version = '13'
|
171
|
+
|
172
|
+
config_b = ApplianceConfig.new
|
173
|
+
config_b.name = 'b'
|
174
|
+
config_b.hardware.partitions = {"/" => {'size' => '4', 'options' => 'barrier=0,nodelalloc,nobh,noatime'}, "/home" => {'size' => '2'}}
|
175
|
+
config_b.os.name = 'fedora'
|
176
|
+
config_b.os.version = '13'
|
152
177
|
|
153
178
|
prepare_helper([config_a, config_b])
|
154
179
|
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
@@ -157,7 +182,31 @@ module BoxGrinder
|
|
157
182
|
|
158
183
|
config = @helper.instance_variable_get(:@appliance_config)
|
159
184
|
config.hardware.partitions.size.should == 2
|
160
|
-
config.hardware.partitions.should == {"/" => {'size' => '4'}, "/home" => {'size' => '2'}}
|
185
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4', "options"=>"barrier=0,nodelalloc,nobh,noatime"}, "/home" => {'size' => '2', 'type' => 'ext4'}}
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should merge partitions for default fs_types without options for Fedora 11 (ext3)" do
|
189
|
+
config_a = ApplianceConfig.new
|
190
|
+
config_a.name = 'a'
|
191
|
+
config_a.appliances << 'b'
|
192
|
+
config_a.hardware.partitions = {"/" => {'size' => '2'}}
|
193
|
+
config_a.os.name = 'fedora'
|
194
|
+
config_a.os.version = '11'
|
195
|
+
|
196
|
+
config_b = ApplianceConfig.new
|
197
|
+
config_b.name = 'b'
|
198
|
+
config_b.hardware.partitions = {"/" => {'size' => '4'}, "/home" => {'size' => '2'}}
|
199
|
+
config_b.os.name = 'fedora'
|
200
|
+
config_b.os.version = '11'
|
201
|
+
|
202
|
+
prepare_helper([config_a, config_b])
|
203
|
+
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
204
|
+
|
205
|
+
@helper.merge_partitions
|
206
|
+
|
207
|
+
config = @helper.instance_variable_get(:@appliance_config)
|
208
|
+
config.hardware.partitions.size.should == 2
|
209
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext3'}, "/home" => {'size' => '2', 'type' => 'ext3'}}
|
161
210
|
end
|
162
211
|
|
163
212
|
it "should merge partitions with different filesystem types" do
|
@@ -165,10 +214,14 @@ module BoxGrinder
|
|
165
214
|
config_a.name = 'a'
|
166
215
|
config_a.appliances << 'b'
|
167
216
|
config_a.hardware.partitions = {"/" => {'size' => '2', 'type' => 'ext4'}}
|
217
|
+
config_a.os.name = 'fedora'
|
218
|
+
config_a.os.version = '12'
|
168
219
|
|
169
220
|
config_b = ApplianceConfig.new
|
170
221
|
config_b.name = 'b'
|
171
222
|
config_b.hardware.partitions = {"/" => {'size' => '4', 'type' => 'ext3'}, "/home" => {'size' => '2'}}
|
223
|
+
config_b.os.name = 'fedora'
|
224
|
+
config_b.os.version = '11'
|
172
225
|
|
173
226
|
prepare_helper([config_a, config_b])
|
174
227
|
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
@@ -177,7 +230,7 @@ module BoxGrinder
|
|
177
230
|
|
178
231
|
config = @helper.instance_variable_get(:@appliance_config)
|
179
232
|
config.hardware.partitions.size.should == 2
|
180
|
-
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4'}, "/home" => {'size' => '2'}}
|
233
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4'}, "/home" => {'size' => '2', 'type' => 'ext3'}}
|
181
234
|
end
|
182
235
|
|
183
236
|
it "should merge partitions with different options" do
|
@@ -185,10 +238,14 @@ module BoxGrinder
|
|
185
238
|
config_a.name = 'a'
|
186
239
|
config_a.appliances << 'b'
|
187
240
|
config_a.hardware.partitions = {"/" => {'size' => '2', 'type' => 'ext4', 'options' => 'barrier=0,nodelalloc,nobh,noatime'}}
|
241
|
+
config_a.os.name = 'fedora'
|
242
|
+
config_a.os.version = '13'
|
188
243
|
|
189
244
|
config_b = ApplianceConfig.new
|
190
245
|
config_b.name = 'b'
|
191
246
|
config_b.hardware.partitions = {"/" => {'size' => '4', 'type' => 'ext3', 'options' => 'shouldnt appear'}, "/home" => {'size' => '2'}}
|
247
|
+
config_b.os.name = 'fedora'
|
248
|
+
config_b.os.version = '13'
|
192
249
|
|
193
250
|
prepare_helper([config_a, config_b])
|
194
251
|
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
@@ -197,7 +254,7 @@ module BoxGrinder
|
|
197
254
|
|
198
255
|
config = @helper.instance_variable_get(:@appliance_config)
|
199
256
|
config.hardware.partitions.size.should == 2
|
200
|
-
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4', 'options' => 'barrier=0,nodelalloc,nobh,noatime'}, "/home" => {'size' => '2'}}
|
257
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4', 'options' => 'barrier=0,nodelalloc,nobh,noatime'}, "/home" => {'size' => '2', 'type' => 'ext4'}}
|
201
258
|
end
|
202
259
|
|
203
260
|
it "should merge partitions with different options, another case where type is changing - options should be vanished" do
|
@@ -205,10 +262,14 @@ module BoxGrinder
|
|
205
262
|
config_a.name = 'a'
|
206
263
|
config_a.appliances << 'b'
|
207
264
|
config_a.hardware.partitions = {"/" => {'size' => '2', 'type' => 'ext4'}}
|
265
|
+
config_a.os.name = 'fedora'
|
266
|
+
config_a.os.version = '13'
|
208
267
|
|
209
268
|
config_b = ApplianceConfig.new
|
210
269
|
config_b.name = 'b'
|
211
270
|
config_b.hardware.partitions = {"/" => {'size' => '4', 'type' => 'ext3', 'options' => 'shouldnt appear'}, "/home" => {'size' => '2'}}
|
271
|
+
config_b.os.name = 'fedora'
|
272
|
+
config_b.os.version = '13'
|
212
273
|
|
213
274
|
prepare_helper([config_a, config_b])
|
214
275
|
@helper.instance_variable_set(:@appliance_config, config_a.clone)
|
@@ -217,7 +278,7 @@ module BoxGrinder
|
|
217
278
|
|
218
279
|
config = @helper.instance_variable_get(:@appliance_config)
|
219
280
|
config.hardware.partitions.size.should == 2
|
220
|
-
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4'}, "/home" => {'size' => '2'}}
|
281
|
+
config.hardware.partitions.should == {"/" => {'size' => '4', 'type' => 'ext4'}, "/home" => {'size' => '2', 'type' => 'ext4'}}
|
221
282
|
end
|
222
283
|
|
223
284
|
it "should substitute variables in repos" do
|
@@ -17,20 +17,18 @@
|
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
19
|
require 'boxgrinder-core/helpers/appliance-helper'
|
20
|
-
require 'rspec/rspec-config-helper'
|
21
20
|
|
22
21
|
module BoxGrinder
|
23
22
|
describe ApplianceHelper do
|
24
|
-
include RSpecConfigHelper
|
25
23
|
|
26
24
|
before(:each) do
|
27
|
-
@helper = ApplianceHelper.new(
|
25
|
+
@helper = ApplianceHelper.new(:log => Logger.new('/dev/null'))
|
28
26
|
end
|
29
27
|
|
30
28
|
it "should read definition from one file" do
|
31
29
|
appliance_config = ApplianceConfig.new
|
32
|
-
@helper.should_receive(:read_yaml).with('file.appl').and_return(
|
33
|
-
@helper.read_definitions(
|
30
|
+
@helper.should_receive(:read_yaml).with('file.appl').and_return(appliance_config)
|
31
|
+
@helper.read_definitions("file.appl").should == [[appliance_config], appliance_config]
|
34
32
|
end
|
35
33
|
|
36
34
|
it "should read definition from two files" do
|
@@ -41,10 +39,10 @@ module BoxGrinder
|
|
41
39
|
appliance_b = ApplianceConfig.new
|
42
40
|
appliance_b.name = 'b'
|
43
41
|
|
44
|
-
@helper.should_receive(:read_yaml).ordered.with('a.appl').and_return(
|
45
|
-
@helper.should_receive(:read_yaml).ordered.with('./b.appl').and_return(
|
42
|
+
@helper.should_receive(:read_yaml).ordered.with('a.appl').and_return(appliance_a)
|
43
|
+
@helper.should_receive(:read_yaml).ordered.with('./b.appl').and_return(appliance_b)
|
46
44
|
|
47
|
-
@helper.read_definitions(
|
45
|
+
@helper.read_definitions("a.appl").should == [[appliance_a, appliance_b], appliance_a]
|
48
46
|
end
|
49
47
|
|
50
48
|
it "should read definitions from a tree file structure" do
|
@@ -67,14 +65,41 @@ module BoxGrinder
|
|
67
65
|
appliance_c2 = ApplianceConfig.new
|
68
66
|
appliance_c2.name = 'c2'
|
69
67
|
|
70
|
-
@helper.should_receive(:read_yaml).ordered.with('a.appl').and_return(
|
71
|
-
@helper.should_receive(:read_yaml).ordered.with('./b2.appl').and_return(
|
72
|
-
@helper.should_receive(:read_yaml).ordered.with('./c2.appl').and_return(
|
73
|
-
@helper.should_receive(:read_yaml).ordered.with('./b1.appl').and_return(
|
74
|
-
@helper.should_receive(:read_yaml).ordered.with('./c1.appl').and_return(
|
68
|
+
@helper.should_receive(:read_yaml).ordered.with('a.appl').and_return(appliance_a)
|
69
|
+
@helper.should_receive(:read_yaml).ordered.with('./b2.appl').and_return(appliance_b2)
|
70
|
+
@helper.should_receive(:read_yaml).ordered.with('./c2.appl').and_return(appliance_c2)
|
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)
|
75
73
|
|
76
|
-
@helper.read_definitions(
|
74
|
+
@helper.read_definitions("a.appl").should == [[appliance_a, appliance_b2, appliance_c2, appliance_b1, appliance_c1], appliance_a]
|
77
75
|
end
|
78
76
|
|
77
|
+
describe "read_yaml" do
|
78
|
+
it "should read default_repos and set to false" do
|
79
|
+
YAML.should_receive(:load_file).with('default_repos_false.appl').and_return({'default_repos'=>false})
|
80
|
+
@helper.read_yaml('default_repos_false.appl').default_repos.should == false
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should read default_repos and set to true" do
|
84
|
+
YAML.should_receive(:load_file).with('default_repos_true.appl').and_return({'default_repos'=>true})
|
85
|
+
@helper.read_yaml('default_repos_true.appl').default_repos.should == true
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should read default_repos but not set it" do
|
89
|
+
YAML.should_receive(:load_file).with('default_repos_empty.appl').and_return({})
|
90
|
+
@helper.read_yaml('default_repos_empty.appl').default_repos.should == nil
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should read default_repos and raise" do
|
94
|
+
YAML.should_receive(:load_file).with('default_repos_bad.appl').and_return({'default_repos'=>'something'})
|
95
|
+
|
96
|
+
begin
|
97
|
+
@helper.read_yaml("default_repos_bad.appl")
|
98
|
+
raise 'Should raise'
|
99
|
+
rescue => e
|
100
|
+
e.message.should == 'default_repos_bad.appl: default_repos should be set to true or false'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
79
104
|
end
|
80
105
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxgrinder-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek Goldmann
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-11 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- Manifest
|
64
64
|
- README
|
65
65
|
- Rakefile
|
66
|
+
- boxgrinder-core.gemspec
|
66
67
|
- lib/boxgrinder-core.rb
|
67
68
|
- lib/boxgrinder-core/defaults.rb
|
68
69
|
- lib/boxgrinder-core/helpers/appliance-config-helper.rb
|
@@ -77,7 +78,6 @@ files:
|
|
77
78
|
- lib/boxgrinder-core/validators/errors.rb
|
78
79
|
- lib/openhash/openhash.rb
|
79
80
|
- rubygem-boxgrinder-core.spec
|
80
|
-
- spec/Rakefile
|
81
81
|
- spec/helpers/appliance-config-helper-spec.rb
|
82
82
|
- spec/helpers/appliance-helper-spec.rb
|
83
83
|
- spec/helpers/exec-helper-spec.rb
|
@@ -90,7 +90,6 @@ files:
|
|
90
90
|
- spec/rspec/src/appliances/full.appl
|
91
91
|
- spec/rspec/src/appliances/repo.appl
|
92
92
|
- spec/validators/appliance-config-validator-spec.rb
|
93
|
-
- boxgrinder-core.gemspec
|
94
93
|
has_rdoc: true
|
95
94
|
homepage: http://www.jboss.org/boxgrinder
|
96
95
|
licenses: []
|
data/spec/Rakefile
DELETED
@@ -1,28 +0,0 @@
|
|
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 'rake'
|
20
|
-
require 'spec/rake/spectask'
|
21
|
-
|
22
|
-
desc "Run all examples"
|
23
|
-
Spec::Rake::SpecTask.new(:default) do |t|
|
24
|
-
t.spec_files = FileList['**/*-spec.rb']
|
25
|
-
t.rcov = true
|
26
|
-
t.spec_opts = ['--colour', '--format', 'nested']
|
27
|
-
t.rcov_opts = ['--exclude', 'spec']
|
28
|
-
end
|