vagrant-subutai 1.0.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.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/Gemfile +7 -0
- data/README.md +52 -0
- data/Rakefile +9 -0
- data/Vagrantfile +7 -0
- data/lib/vagrant-subutai.rb +12 -0
- data/lib/vagrant-subutai/command.rb +142 -0
- data/lib/vagrant-subutai/config.rb +52 -0
- data/lib/vagrant-subutai/models/resource_host.rb +7 -0
- data/lib/vagrant-subutai/packer/subutai_config.rb +380 -0
- data/lib/vagrant-subutai/packer/subutai_hooks.rb +62 -0
- data/lib/vagrant-subutai/packer/subutai_net.rb +125 -0
- data/lib/vagrant-subutai/plugin.rb +20 -0
- data/lib/vagrant-subutai/rest.rb +77 -0
- data/lib/vagrant-subutai/rh_controller.rb +32 -0
- data/lib/vagrant-subutai/subutai_commands.rb +215 -0
- data/lib/vagrant-subutai/version.rb +3 -0
- data/lib/vagrant_init.rb +1 -0
- data/test/.rubocop.yml +14 -0
- data/test/bad_snap_script.sh +1 -0
- data/test/snap_script.sh +3 -0
- data/test/subutai0.yaml +1 -0
- data/test/subutai1.yaml +11 -0
- data/test/subutai2.yaml +10 -0
- data/test/subutai_config_test.rb +445 -0
- data/test/subutai_hooks_test.rb +16 -0
- data/test/subutai_net_test.rb +34 -0
- data/vagrant-subutai.gemspec +22 -0
- data/vagrant-subutai.iml +9 -0
- metadata +110 -0
data/lib/vagrant_init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'vagrant-subutai'
|
data/test/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
echo ./blobs/subutai-dev_6.1.7-1-g344af8d-dev_amd64.snap
|
data/test/snap_script.sh
ADDED
data/test/subutai0.yaml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SUBUTAI_ENV: foo
|
data/test/subutai1.yaml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
SUBUTAI_PEER: false
|
2
|
+
SUBUTAI_ENV: master
|
3
|
+
SUBUTAI_DESKTOP: true
|
4
|
+
DESIRED_CONSOLE_PORT: 9191
|
5
|
+
invalid_value: foo
|
6
|
+
ALLOW_INSECURE: true
|
7
|
+
SUBUTAI_RAM: 2000
|
8
|
+
SUBUTAI_CPU: 6
|
9
|
+
SUBUTAI_SNAP: ./foo/bar/bogus/path/to/shell/script.sh
|
10
|
+
SUBUTAI_MAN_IMPL: ./bar/foo/bogus/path/to/deb/pkg/management.deb
|
11
|
+
APT_PROXY_URL: http://some_server:4444
|
data/test/subutai2.yaml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
SUBUTAI_PEER: false
|
2
|
+
SUBUTAI_ENV: master
|
3
|
+
SUBUTAI_DESKTOP: true
|
4
|
+
DESIRED_CONSOLE_PORT: 9191
|
5
|
+
ALLOW_INSECURE: true
|
6
|
+
SUBUTAI_RAM: 2000
|
7
|
+
SUBUTAI_CPU: 6
|
8
|
+
SUBUTAI_SNAP: ./foo/bar/bogus/path/to/shell/script.sh
|
9
|
+
SUBUTAI_MAN_TMPL: ./bar/foo/bogus/path/to/deb/pkg/management.deb
|
10
|
+
APT_PROXY_URL: http://some_server:4444
|
@@ -0,0 +1,445 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
require_relative '../lib/subutai_cli/packer/subutai_config'
|
6
|
+
|
7
|
+
# Tests the SubutaiConfig module
|
8
|
+
class SubutaiConfigTest < Test::Unit::TestCase
|
9
|
+
# Called before every test method runs. Can be used
|
10
|
+
# to set up fixture information.
|
11
|
+
def setup
|
12
|
+
FileUtils.rm_rf SubutaiConfig::PARENT_DIR
|
13
|
+
assert_path_not_exist(SubutaiConfig::PARENT_DIR)
|
14
|
+
|
15
|
+
File.delete(SubutaiConfig::CONF_FILE) \
|
16
|
+
if File.exist?(SubutaiConfig::CONF_FILE)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Called after every test method runs. Can be used to tear
|
20
|
+
# down fixture information.
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
SubutaiConfig.cleanup!
|
24
|
+
end
|
25
|
+
|
26
|
+
# checks defaults without changing any values
|
27
|
+
def defaults?
|
28
|
+
SubutaiConfig.load_config 'up', :virtualbox
|
29
|
+
assert_equal(SubutaiConfig.config.count, 10)
|
30
|
+
|
31
|
+
assert_true(SubutaiConfig.get(:SUBUTAI_PEER))
|
32
|
+
assert_false(SubutaiConfig.get(:ALLOW_INSECURE))
|
33
|
+
assert_false(SubutaiConfig.get(:SUBUTAI_DESKTOP))
|
34
|
+
|
35
|
+
assert_equal(SubutaiConfig.get(:DESIRED_CONSOLE_PORT), 9999)
|
36
|
+
assert_equal(SubutaiConfig.get(:SUBUTAI_ENV), :prod)
|
37
|
+
assert_equal(SubutaiConfig.get(:SUBUTAI_RAM), 4096)
|
38
|
+
assert_equal(SubutaiConfig.get(:SUBUTAI_CPU), 2)
|
39
|
+
|
40
|
+
assert_nil(SubutaiConfig.get(:SUBUTAI_SNAP))
|
41
|
+
assert_nil(SubutaiConfig.get(:SUBUTAI_MAN_TMPL))
|
42
|
+
assert_nil(SubutaiConfig.get(:APT_PROXY_URL))
|
43
|
+
|
44
|
+
SubutaiConfig::GENERATED_PARAMETERS.each do |p|
|
45
|
+
assert_nil(SubutaiConfig.get(p))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Raise exception without setting valid cmd
|
50
|
+
def test_no_cmd
|
51
|
+
assert_raise do
|
52
|
+
SubutaiConfig.load_config(nil, :virtualbox)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_cleanup!
|
57
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
58
|
+
SubutaiConfig.put('_CONSOLE_PORT', 10_394, true)
|
59
|
+
SubutaiConfig.put('SUBUTAI_PEER', false, true)
|
60
|
+
SubutaiConfig.cleanup!
|
61
|
+
|
62
|
+
assert_path_not_exist(SubutaiConfig::GENERATED_FILE, 'generated.yaml')
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_cleanup
|
66
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
67
|
+
SubutaiConfig.put('SUBUTAI_PEER', true, true)
|
68
|
+
assert_path_exist(SubutaiConfig::GENERATED_FILE, 'generated.yaml')
|
69
|
+
|
70
|
+
SubutaiConfig.cleanup
|
71
|
+
assert_path_exist(SubutaiConfig::GENERATED_FILE, 'generated.yaml')
|
72
|
+
|
73
|
+
SubutaiConfig.put('SUBUTAI_PEER', true, true)
|
74
|
+
assert_path_exist(SubutaiConfig::GENERATED_FILE, 'generated.yaml')
|
75
|
+
|
76
|
+
SubutaiConfig.load_config('destroy', :virtualbox)
|
77
|
+
assert_path_exist(SubutaiConfig::GENERATED_FILE, 'generated.yaml')
|
78
|
+
|
79
|
+
SubutaiConfig.cleanup
|
80
|
+
assert_path_not_exist(SubutaiConfig::GENERATED_FILE, 'generated.yaml')
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_get_put_up
|
84
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
85
|
+
|
86
|
+
#
|
87
|
+
# Bunch of tests for User Parameters
|
88
|
+
#
|
89
|
+
|
90
|
+
# ALLOW_INSECURE
|
91
|
+
assert_false(SubutaiConfig.get(:ALLOW_INSECURE))
|
92
|
+
assert_true(SubutaiConfig.put(:ALLOW_INSECURE, true, true))
|
93
|
+
assert_true(SubutaiConfig.get(:ALLOW_INSECURE))
|
94
|
+
assert_true(SubutaiConfig.get('ALLOW_INSECURE'))
|
95
|
+
|
96
|
+
assert_false(SubutaiConfig.put('ALLOW_INSECURE', false, true))
|
97
|
+
assert_false(SubutaiConfig.get(:ALLOW_INSECURE))
|
98
|
+
assert_false(SubutaiConfig.get('ALLOW_INSECURE'))
|
99
|
+
|
100
|
+
# SUBUTAI_DESKTOP
|
101
|
+
assert_false(SubutaiConfig.get(:SUBUTAI_DESKTOP))
|
102
|
+
assert_true(SubutaiConfig.put(:SUBUTAI_DESKTOP, true, true))
|
103
|
+
assert_true(SubutaiConfig.get(:SUBUTAI_DESKTOP))
|
104
|
+
assert_true(SubutaiConfig.get('SUBUTAI_DESKTOP'))
|
105
|
+
|
106
|
+
assert_false(SubutaiConfig.put('SUBUTAI_DESKTOP', false, true))
|
107
|
+
assert_false(SubutaiConfig.get(:SUBUTAI_DESKTOP))
|
108
|
+
assert_false(SubutaiConfig.get('SUBUTAI_DESKTOP'))
|
109
|
+
|
110
|
+
# SUBUTAI_PEER
|
111
|
+
assert_true(SubutaiConfig.get(:SUBUTAI_PEER))
|
112
|
+
assert_false(SubutaiConfig.put(:SUBUTAI_PEER, false, true))
|
113
|
+
assert_false(SubutaiConfig.get(:SUBUTAI_PEER))
|
114
|
+
assert_false(SubutaiConfig.get('SUBUTAI_PEER'))
|
115
|
+
|
116
|
+
assert_true(SubutaiConfig.put('SUBUTAI_PEER', true, true))
|
117
|
+
assert_true(SubutaiConfig.get(:SUBUTAI_PEER))
|
118
|
+
assert_true(SubutaiConfig.get('SUBUTAI_PEER'))
|
119
|
+
|
120
|
+
# DESIRED_CONSOLE_PORT
|
121
|
+
assert_equal(SubutaiConfig.get(:DESIRED_CONSOLE_PORT), 9999)
|
122
|
+
assert_equal(7777, SubutaiConfig.put(:DESIRED_CONSOLE_PORT, 7777, true))
|
123
|
+
assert_equal(SubutaiConfig.get(:DESIRED_CONSOLE_PORT), 7777)
|
124
|
+
assert_equal(SubutaiConfig.get('DESIRED_CONSOLE_PORT'), 7777)
|
125
|
+
|
126
|
+
assert_equal(SubutaiConfig.put('DESIRED_CONSOLE_PORT', 6666, true), 6666)
|
127
|
+
assert_equal(SubutaiConfig.get(:DESIRED_CONSOLE_PORT), 6666)
|
128
|
+
assert_equal(SubutaiConfig.get('DESIRED_CONSOLE_PORT'), 6666)
|
129
|
+
|
130
|
+
# SUBUTAI_RAM
|
131
|
+
assert_equal(SubutaiConfig.get(:SUBUTAI_RAM), 4096)
|
132
|
+
assert_equal(8192, SubutaiConfig.put(:SUBUTAI_RAM, 8192, true))
|
133
|
+
assert_equal(SubutaiConfig.get(:SUBUTAI_RAM), 8192)
|
134
|
+
assert_equal(SubutaiConfig.get('SUBUTAI_RAM'), 8192)
|
135
|
+
|
136
|
+
assert_equal(SubutaiConfig.put('SUBUTAI_RAM', 2048, true), 2048)
|
137
|
+
assert_equal(SubutaiConfig.get(:SUBUTAI_RAM), 2048)
|
138
|
+
assert_equal(SubutaiConfig.get('SUBUTAI_RAM'), 2048)
|
139
|
+
|
140
|
+
# SUBUTAI_CPU
|
141
|
+
assert_equal(SubutaiConfig.get(:SUBUTAI_CPU), 2)
|
142
|
+
assert_equal(4, SubutaiConfig.put(:SUBUTAI_CPU, 4, true))
|
143
|
+
assert_equal(SubutaiConfig.get(:SUBUTAI_CPU), 4)
|
144
|
+
assert_equal(SubutaiConfig.get('SUBUTAI_CPU'), 4)
|
145
|
+
|
146
|
+
assert_equal(SubutaiConfig.put('SUBUTAI_CPU', 6, true), 6)
|
147
|
+
assert_equal(SubutaiConfig.get(:SUBUTAI_CPU), 6)
|
148
|
+
assert_equal(SubutaiConfig.get('SUBUTAI_CPU'), 6)
|
149
|
+
|
150
|
+
# SUBUTAI_ENV
|
151
|
+
assert_equal(:prod, SubutaiConfig.get(:SUBUTAI_ENV))
|
152
|
+
assert_equal(:dev, SubutaiConfig.put(:SUBUTAI_ENV, :dev, true))
|
153
|
+
assert_equal(:dev, SubutaiConfig.get(:SUBUTAI_ENV))
|
154
|
+
assert_equal(:dev, SubutaiConfig.get('SUBUTAI_ENV'))
|
155
|
+
|
156
|
+
assert_equal(:prod, SubutaiConfig.put('SUBUTAI_ENV', :prod, true))
|
157
|
+
assert_equal(:prod, SubutaiConfig.get(:SUBUTAI_ENV))
|
158
|
+
assert_equal(:prod, SubutaiConfig.get('SUBUTAI_ENV'))
|
159
|
+
|
160
|
+
# SUBUTAI_SNAP
|
161
|
+
assert_nil(SubutaiConfig.get(:SUBUTAI_SNAP))
|
162
|
+
script = './bogus/path/script.sh'
|
163
|
+
assert_equal(script, SubutaiConfig.put(:SUBUTAI_SNAP, script, true))
|
164
|
+
assert_equal(script, SubutaiConfig.get(:SUBUTAI_SNAP))
|
165
|
+
assert_equal(script, SubutaiConfig.get('SUBUTAI_SNAP'))
|
166
|
+
|
167
|
+
# SUBUTAI_MAN_TMPL
|
168
|
+
assert_nil(SubutaiConfig.get(:SUBUTAI_MAN_TMPL))
|
169
|
+
pkg = './bogus/path/management.deb'
|
170
|
+
assert_equal(pkg, SubutaiConfig.put(:SUBUTAI_MAN_TMPL, pkg, true))
|
171
|
+
assert_equal(pkg, SubutaiConfig.get(:SUBUTAI_MAN_TMPL))
|
172
|
+
assert_equal(pkg, SubutaiConfig.get('SUBUTAI_MAN_TMPL'))
|
173
|
+
|
174
|
+
# APT_PROXY_URL
|
175
|
+
assert_equal(SubutaiConfig.get(:APT_PROXY_URL), ENV['APT_PROXY_URL'])
|
176
|
+
url = 'http://localhost:3124'
|
177
|
+
assert_equal(url, SubutaiConfig.put(:APT_PROXY_URL, url, true))
|
178
|
+
assert_equal(url, SubutaiConfig.get(:APT_PROXY_URL))
|
179
|
+
assert_equal(url, SubutaiConfig.get('APT_PROXY_URL'))
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_get_put_generated
|
183
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
184
|
+
|
185
|
+
# _CONSOLE_PORT
|
186
|
+
assert_equal(1234, SubutaiConfig.put(:_CONSOLE_PORT, 1234, true))
|
187
|
+
assert_equal(1234, SubutaiConfig.get(:_CONSOLE_PORT))
|
188
|
+
assert_equal(1234, SubutaiConfig.get('_CONSOLE_PORT'))
|
189
|
+
|
190
|
+
# _ALT_SNAP
|
191
|
+
assert_nil(SubutaiConfig.get(:_ALT_SNAP))
|
192
|
+
snap = './bogus/path.snap'
|
193
|
+
assert_equal(snap, SubutaiConfig.put(:_ALT_SNAP, snap, true))
|
194
|
+
assert_equal(snap, SubutaiConfig.get(:_ALT_SNAP))
|
195
|
+
assert_equal(snap, SubutaiConfig.get('_ALT_SNAP'))
|
196
|
+
|
197
|
+
# _ALT_MANAGEMENT
|
198
|
+
assert_nil(SubutaiConfig.get(:_ALT_MANAGEMENT))
|
199
|
+
pkg = './bogus/path.deb'
|
200
|
+
assert_equal(pkg, SubutaiConfig.put(:_ALT_MANAGEMENT, pkg, true))
|
201
|
+
assert_equal(pkg, SubutaiConfig.get(:_ALT_MANAGEMENT))
|
202
|
+
assert_equal(pkg, SubutaiConfig.get('_ALT_MANAGEMENT'))
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_print
|
206
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
207
|
+
SubutaiConfig.put('_CONSOLE_PORT', '10009', true)
|
208
|
+
SubutaiConfig.print
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_up
|
212
|
+
cmd = 'up'
|
213
|
+
SubutaiConfig.load_config(cmd, :virtualbox)
|
214
|
+
assert_equal(cmd, SubutaiConfig.cmd, 'cmd does not equal ' + cmd)
|
215
|
+
SubutaiConfig.put('SUBUTAI_PEER', true, true)
|
216
|
+
assert_path_exist(SubutaiConfig::GENERATED_FILE)
|
217
|
+
|
218
|
+
SubutaiConfig.put('SUBUTAI_SNAP', './bogus/path', true)
|
219
|
+
assert_equal('./bogus/path', SubutaiConfig.get('SUBUTAI_SNAP'))
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_destroy
|
223
|
+
cmd = 'destroy'
|
224
|
+
SubutaiConfig.load_config(cmd, :virtualbox)
|
225
|
+
assert_equal(cmd, SubutaiConfig.cmd, 'cmd does not equal ' + cmd)
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_seq0
|
229
|
+
cmd = 'up'
|
230
|
+
pkg = './bogus/path/management.deb'
|
231
|
+
snap = './bogus/path.snap'
|
232
|
+
|
233
|
+
SubutaiConfig.load_config(cmd, :virtualbox)
|
234
|
+
assert_equal(cmd, SubutaiConfig.cmd, 'cmd does not equal ' + cmd)
|
235
|
+
assert_equal(snap, SubutaiConfig.put(:SUBUTAI_SNAP, snap, true))
|
236
|
+
assert_equal(pkg, SubutaiConfig.put(:SUBUTAI_MAN_TMPL, pkg, true))
|
237
|
+
assert_equal(1234, SubutaiConfig.put(:_CONSOLE_PORT, 1234, true))
|
238
|
+
assert_equal(snap, SubutaiConfig.put(:_ALT_SNAP, snap, true))
|
239
|
+
assert_equal(pkg, SubutaiConfig.put(:_ALT_MANAGEMENT, pkg, true))
|
240
|
+
assert_true(SubutaiConfig.put(:ALLOW_INSECURE, true, true))
|
241
|
+
assert_true(SubutaiConfig.put(:SUBUTAI_DESKTOP, true, true))
|
242
|
+
assert_false(SubutaiConfig.put(:SUBUTAI_PEER, false, true))
|
243
|
+
assert_equal(7777, SubutaiConfig.put(:DESIRED_CONSOLE_PORT, 7777, true))
|
244
|
+
assert_equal(8192, SubutaiConfig.put(:SUBUTAI_RAM, 8192, true))
|
245
|
+
assert_equal(4, SubutaiConfig.put(:SUBUTAI_CPU, 4, true))
|
246
|
+
assert_equal(:dev, SubutaiConfig.put(:SUBUTAI_ENV, :dev, true))
|
247
|
+
|
248
|
+
SubutaiConfig.reset
|
249
|
+
|
250
|
+
cmd = 'ssh'
|
251
|
+
SubutaiConfig.load_config(cmd, :virtualbox)
|
252
|
+
assert_equal(cmd, SubutaiConfig.cmd, 'cmd does not equal ' + cmd)
|
253
|
+
assert_nil(SubutaiConfig.get(:SUBUTAI_SNAP))
|
254
|
+
assert_nil(SubutaiConfig.get(:SUBUTAI_MAN_TMPL))
|
255
|
+
assert_false(SubutaiConfig.get(:ALLOW_INSECURE))
|
256
|
+
assert_false(SubutaiConfig.get(:SUBUTAI_DESKTOP))
|
257
|
+
assert_true(SubutaiConfig.get(:SUBUTAI_PEER))
|
258
|
+
assert_equal(9999, SubutaiConfig.get(:DESIRED_CONSOLE_PORT))
|
259
|
+
assert_equal(4096, SubutaiConfig.get(:SUBUTAI_RAM))
|
260
|
+
assert_equal(2, SubutaiConfig.get(:SUBUTAI_CPU))
|
261
|
+
assert_equal(:prod, SubutaiConfig.get(:SUBUTAI_ENV))
|
262
|
+
|
263
|
+
# these should not be cleared out by the reset
|
264
|
+
assert_equal(snap, SubutaiConfig.get(:_ALT_SNAP))
|
265
|
+
assert_equal(pkg, SubutaiConfig.get(:_ALT_MANAGEMENT))
|
266
|
+
|
267
|
+
cmd = 'suspend'
|
268
|
+
SubutaiConfig.load_config(cmd, :virtualbox)
|
269
|
+
assert_equal(cmd, SubutaiConfig.cmd, 'cmd does not equal ' + cmd)
|
270
|
+
|
271
|
+
cmd = 'resume'
|
272
|
+
SubutaiConfig.load_config(cmd, :virtualbox)
|
273
|
+
assert_equal(cmd, SubutaiConfig.cmd, 'cmd does not equal ' + cmd)
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_unknown_key
|
277
|
+
assert_raise do
|
278
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
279
|
+
SubutaiConfig.put('foo', 'bar', true)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_bad_env_subutai_yaml_0
|
284
|
+
SubutaiConfig.override_conf_file('./ruby/tests/subutai0.yaml')
|
285
|
+
assert_raise do
|
286
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_bad_key_subutai_yaml_1
|
291
|
+
SubutaiConfig.override_conf_file('./ruby/tests/subutai1.yaml')
|
292
|
+
assert_raise do
|
293
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_subutai_yaml_2
|
298
|
+
SubutaiConfig.override_conf_file('./ruby/tests/subutai2.yaml')
|
299
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
300
|
+
SubutaiConfig.logging!(:debug)
|
301
|
+
SubutaiConfig.print
|
302
|
+
SubutaiConfig.log('up', 'dummy message')
|
303
|
+
SubutaiConfig.log_mode([:debug], ['up'], 'dummy message')
|
304
|
+
assert_equal(:master, SubutaiConfig.get(:SUBUTAI_ENV))
|
305
|
+
assert_equal(9191, SubutaiConfig.get(:DESIRED_CONSOLE_PORT))
|
306
|
+
assert_equal(2000, SubutaiConfig.get(:SUBUTAI_RAM))
|
307
|
+
assert_equal(6, SubutaiConfig.get(:SUBUTAI_CPU))
|
308
|
+
assert_false(SubutaiConfig.get(:SUBUTAI_PEER))
|
309
|
+
assert_true(SubutaiConfig.get(:SUBUTAI_DESKTOP))
|
310
|
+
assert_true(SubutaiConfig.get(:ALLOW_INSECURE))
|
311
|
+
assert_equal('./foo/bar/bogus/path/to/shell/script.sh', SubutaiConfig.get(:SUBUTAI_SNAP))
|
312
|
+
assert_equal('./bar/foo/bogus/path/to/deb/pkg/management.deb', SubutaiConfig.get(:SUBUTAI_MAN_TMPL))
|
313
|
+
|
314
|
+
if ENV['APT_PROXY_URL'].nil?
|
315
|
+
assert_equal('http://some_server:4444', SubutaiConfig.get(:APT_PROXY_URL))
|
316
|
+
else
|
317
|
+
assert_equal(ENV['APT_PROXY_URL'], SubutaiConfig.get(:APT_PROXY_URL))
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_boolean?
|
322
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
323
|
+
assert_true(SubutaiConfig.boolean?(:SUBUTAI_PEER))
|
324
|
+
assert_false(SubutaiConfig.boolean?(:SUBUTAI_DESKTOP))
|
325
|
+
assert_false(SubutaiConfig.boolean?(:SUBUTAI_SNAP))
|
326
|
+
assert_raise do
|
327
|
+
SubutaiConfig.boolean?(:SUBUTAI_CPU)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_raises
|
332
|
+
assert_raise do
|
333
|
+
SubutaiConfig.write?
|
334
|
+
end
|
335
|
+
assert_raise do
|
336
|
+
SubutaiConfig.delete?
|
337
|
+
end
|
338
|
+
assert_raise do
|
339
|
+
SubutaiConfig.read?
|
340
|
+
end
|
341
|
+
|
342
|
+
assert_not_nil(SubutaiConfig.config)
|
343
|
+
|
344
|
+
SubutaiConfig.load_config('ssh', :virtualbox)
|
345
|
+
assert_true(SubutaiConfig.read?)
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_provision_snap?
|
349
|
+
SubutaiConfig.load_config('ssh', :virtualbox)
|
350
|
+
configs = SubutaiConfig.config
|
351
|
+
|
352
|
+
# Make it all negative for provisioning conditions
|
353
|
+
configs.store(:PROVISION, false)
|
354
|
+
configs.store(:_ALT_SNAP, nil)
|
355
|
+
configs.store(:_ALT_SNAP_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
356
|
+
configs.store(:_ALT_SNAP_MD5_LAST, '6fc87ffd922973f8c88fd939fc091885')
|
357
|
+
assert_false(SubutaiConfig.provision_snap?)
|
358
|
+
|
359
|
+
configs.store(:PROVISION, true)
|
360
|
+
configs.store(:_ALT_SNAP, nil)
|
361
|
+
configs.store(:_ALT_SNAP_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
362
|
+
configs.store(:_ALT_SNAP_MD5_LAST, '6fc87ffd922973f8c88fd939fc091885')
|
363
|
+
assert_false(SubutaiConfig.provision_snap?)
|
364
|
+
|
365
|
+
configs.store(:PROVISION, true)
|
366
|
+
configs.store(:_ALT_SNAP, './ruby/tests/snap_script.sh')
|
367
|
+
configs.store(:_ALT_SNAP_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
368
|
+
configs.store(:_ALT_SNAP_MD5_LAST, '6fc87ffd922973f8c88fd939fc091885')
|
369
|
+
assert_false(SubutaiConfig.provision_snap?)
|
370
|
+
|
371
|
+
configs.store(:PROVISION, true)
|
372
|
+
configs.store(:_ALT_SNAP, './ruby/tests/snap_script.sh')
|
373
|
+
configs.store(:_ALT_SNAP_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
374
|
+
configs.store(:_ALT_SNAP_MD5_LAST, nil)
|
375
|
+
assert_false(SubutaiConfig.provision_snap?)
|
376
|
+
|
377
|
+
SubutaiConfig.load_config('provision', :virtualbox)
|
378
|
+
configs.store(:PROVISION, true)
|
379
|
+
configs.store(:_ALT_SNAP, './ruby/tests/snap_script.sh')
|
380
|
+
configs.store(:_ALT_SNAP_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
381
|
+
configs.store(:_ALT_SNAP_MD5_LAST, nil)
|
382
|
+
assert_true(SubutaiConfig.provision_snap?)
|
383
|
+
|
384
|
+
SubutaiConfig.snap_provisioned!
|
385
|
+
end
|
386
|
+
|
387
|
+
def test_provision_management?
|
388
|
+
SubutaiConfig.load_config('ssh', :virtualbox)
|
389
|
+
configs = SubutaiConfig.config
|
390
|
+
|
391
|
+
# Make it all negative for provisioning conditions
|
392
|
+
configs.store(:PROVISION, false)
|
393
|
+
configs.store(:_ALT_MANAGEMENT, nil)
|
394
|
+
configs.store(:_ALT_MANAGEMENT_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
395
|
+
configs.store(:_ALT_MANAGEMENT_MD5_LAST, '6fc87ffd922973f8c88fd939fc091885')
|
396
|
+
assert_false(SubutaiConfig.provision_management?)
|
397
|
+
|
398
|
+
configs.store(:PROVISION, true)
|
399
|
+
configs.store(:_ALT_MANAGEMENT, nil)
|
400
|
+
configs.store(:_ALT_MANAGEMENT_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
401
|
+
configs.store(:_ALT_MANAGEMENT_MD5_LAST, '6fc87ffd922973f8c88fd939fc091885')
|
402
|
+
assert_false(SubutaiConfig.provision_management?)
|
403
|
+
|
404
|
+
configs.store(:PROVISION, true)
|
405
|
+
configs.store(:_ALT_MANAGEMENT, './ruby/tests/snap_script.sh')
|
406
|
+
configs.store(:_ALT_MANAGEMENT_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
407
|
+
configs.store(:_ALT_MANAGEMENT_MD5_LAST, '6fc87ffd922973f8c88fd939fc091885')
|
408
|
+
assert_false(SubutaiConfig.provision_management?)
|
409
|
+
|
410
|
+
configs.store(:PROVISION, true)
|
411
|
+
configs.store(:_ALT_MANAGEMENT, './ruby/tests/snap_script.sh')
|
412
|
+
configs.store(:_ALT_MANAGEMENT_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
413
|
+
configs.store(:_ALT_MANAGEMENT_MD5_LAST, nil)
|
414
|
+
assert_false(SubutaiConfig.provision_management?)
|
415
|
+
|
416
|
+
SubutaiConfig.load_config('ssh', :virtualbox)
|
417
|
+
puts configs
|
418
|
+
configs.store(:PROVISION, true)
|
419
|
+
puts configs
|
420
|
+
|
421
|
+
configs.store(:_ALT_MANAGEMENT, './ruby/tests/snap_script.sh')
|
422
|
+
configs.store(:_ALT_MANAGEMENT_MD5, '6fc87ffd922973f8c88fd939fc091885')
|
423
|
+
configs.store(:_ALT_MANAGEMENT_MD5_LAST, nil)
|
424
|
+
assert_true(SubutaiConfig.provision_management?)
|
425
|
+
|
426
|
+
SubutaiConfig.management_provisioned!
|
427
|
+
end
|
428
|
+
|
429
|
+
def test_do_handlers
|
430
|
+
SubutaiConfig.load_config('ssh', :virtualbox)
|
431
|
+
configs = SubutaiConfig.config
|
432
|
+
assert_false(SubutaiConfig.do_handlers)
|
433
|
+
|
434
|
+
SubutaiConfig.load_config('up', :virtualbox)
|
435
|
+
configs.store(:SUBUTAI_SNAP, './ruby/tests/snap_script.sh')
|
436
|
+
configs.store(:SUBUTAI_MAN_TMPL, './ruby/tests/snap_script.sh')
|
437
|
+
assert_true(SubutaiConfig.do_handlers)
|
438
|
+
|
439
|
+
configs.store(:SUBUTAI_SNAP, './ruby/tests/bad_snap_script.sh')
|
440
|
+
configs.store(:SUBUTAI_MAN_TMPL, './ruby/tests/bad_snap_script.sh')
|
441
|
+
assert_raise do
|
442
|
+
SubutaiConfig.do_handlers
|
443
|
+
end
|
444
|
+
end
|
445
|
+
end
|