carioca 1.1 → 2.0.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.
- checksums.yaml +5 -5
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +42 -34
- data/README.md +12 -220
- data/Rakefile +5 -59
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/carioca.gemspec +41 -25
- data/config/locales/en.yml +15 -0
- data/config/locales/fr.yml +19 -0
- data/lib/carioca/configuration.rb +47 -0
- data/lib/carioca/constants.rb +45 -0
- data/lib/carioca/container.rb +16 -0
- data/lib/carioca/dependencies.rb +19 -0
- data/lib/carioca/helpers.rb +44 -31
- data/lib/carioca/mixin.rb +32 -0
- data/lib/carioca/{tasks/rake.rb → rake/manage.rb} +4 -6
- data/lib/carioca/rake/tasks/registry.tasks +57 -0
- data/lib/carioca/registry.rb +93 -0
- data/lib/carioca/registry_file.rb +62 -0
- data/lib/carioca/services/config.rb +140 -0
- data/lib/carioca/services/i18n.rb +20 -0
- data/lib/carioca/services/init.rb +2 -0
- data/lib/carioca/validator.rb +49 -0
- data/lib/carioca.rb +2 -319
- data/samples/Rakefile +2 -0
- data/samples/config/carioca.registry +22 -0
- data/samples/config/locales/en.yml +2 -0
- data/samples/config/locales/es.yml +2 -0
- data/samples/config/locales/fr.yml +2 -0
- data/samples/config/settings.yml +24 -0
- data/samples/test.rb +71 -0
- metadata +59 -152
- data/AUTHORS +0 -8
- data/COPYRIGHT +0 -24
- data/ChangeLog +0 -7
- data/INSTALL +0 -7
- data/doc/manual.rdoc +0 -225
- data/lib/carioca/exceptions.rb +0 -9
- data/lib/carioca/private.rb +0 -170
- data/lib/carioca/services/configuration.rb +0 -187
- data/lib/carioca/services/debug.rb +0 -73
- data/lib/carioca/services/logger.rb +0 -58
- data/lib/carioca/services.rb +0 -143
- data/lib/carioca/tasks/registry_init.rake +0 -11
- data/spec/carioca_spec.rb +0 -459
- data/spec/config/services.registry +0 -55
- data/spec/init_spec.rb +0 -1
- data/spec/samples/dummy.rb +0 -10
- data/spec/samples/otherdummy.rb +0 -10
- data/spec/samples/requireddummy.rb +0 -10
- data/spec/spec_helper.rb +0 -11
- data/test.rb +0 -12
- data/ultragreen_roodi_coding_convention.yml +0 -25
data/spec/carioca_spec.rb
DELETED
@@ -1,459 +0,0 @@
|
|
1
|
-
require'rubygems'
|
2
|
-
require'rspec'
|
3
|
-
require 'carioca'
|
4
|
-
|
5
|
-
$debug = true
|
6
|
-
|
7
|
-
describe Carioca do
|
8
|
-
|
9
|
-
before :all do
|
10
|
-
FileUtils.rm_rf("/tmp/log.file")
|
11
|
-
File::unlink('/tmp/dorsal/ringserver.pid') if File::exist?('/tmp/dorsal/ringserver.pid')
|
12
|
-
File::unlink('/tmp/dorsal/service-distdummy.pid') if File::exist?('/tmp/dorsal/service-distdummy.pid')
|
13
|
-
pid = `ps aux|grep ruby|grep -v grep |grep 'Ultragreen Ring Server'|awk '{ print $2}'`
|
14
|
-
unless pid.empty? then
|
15
|
-
res = `kill -TERM #{pid.chomp}`
|
16
|
-
end
|
17
|
-
pid = `ps aux|grep ruby|grep -v grep |grep 'a dummy test service'|awk '{ print $2}'`
|
18
|
-
unless pid.empty? then
|
19
|
-
res = `kill -TERM #{pid.chomp}`
|
20
|
-
end
|
21
|
-
$carioca = Carioca::Services::Registry.init :file => 'spec/config/services.registry', :debug => $debug
|
22
|
-
end
|
23
|
-
|
24
|
-
subject { Carioca }
|
25
|
-
it { should be_an_instance_of Module}
|
26
|
-
context "Carioca::Services" do
|
27
|
-
subject { Carioca::Services }
|
28
|
-
it { should be_an_instance_of Module }
|
29
|
-
end
|
30
|
-
|
31
|
-
context "Carioca::Services::Registry" do
|
32
|
-
subject { $carioca }
|
33
|
-
context "#init" do
|
34
|
-
it "should be a Singleton" do
|
35
|
-
carioca1 = Carioca::Services::Registry.init
|
36
|
-
carioca2 = Carioca::Services::Registry.init
|
37
|
-
test = (carioca1.inspect == carioca2.inspect)
|
38
|
-
test.should be_true
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
it { should be_an_instance_of Carioca::Services::Registry }
|
43
|
-
it { $carioca.list.keys.should include "logger" }
|
44
|
-
it "should log Registry starting and logger init if debug mode", :if => $debug do
|
45
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Registry started, service logger preloaded/).size.should eq 1
|
46
|
-
end
|
47
|
-
it "should not log Registry starting and logger init if not debug mode", :unless => $debug do
|
48
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Registry started, service logger preloaded/).size.should eq 0
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
it "should be possible to log with this primary service" do
|
53
|
-
$logger = subject.get_service :name => 'logger'
|
54
|
-
$logger.info("test").should eq true
|
55
|
-
open('/tmp/log.file').grep(/INFO -- : test/).size.should eq 1
|
56
|
-
$logger.warn("test").should eq true
|
57
|
-
open('/tmp/log.file').grep(/WARN -- : test/).size.should eq 1
|
58
|
-
$logger.error("test").should eq true
|
59
|
-
open('/tmp/log.file').grep(/ERROR -- : test/).size.should eq 1
|
60
|
-
$logger.fatal("test").should eq true
|
61
|
-
open('/tmp/log.file').grep(/FATAL -- : test/).size.should eq 1
|
62
|
-
$logger.info("Program") { "running" }
|
63
|
-
open('/tmp/log.file').grep(/INFO -- Program: running/).size.should eq 1
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "attributs" do
|
68
|
-
context "#debug (RW)" do
|
69
|
-
it { should respond_to :debug }
|
70
|
-
it { should respond_to :debug= }
|
71
|
-
it "should be true if debug mode", :if => $debug do
|
72
|
-
subject.debug.should eq true
|
73
|
-
end
|
74
|
-
it "should be false if not debug mode", :unless => $debug do
|
75
|
-
subject.debug.should eq false
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "#name (RW)" do
|
80
|
-
it { should respond_to :name }
|
81
|
-
it { should respond_to :name= }
|
82
|
-
it { $carioca.name.should be_an_instance_of String }
|
83
|
-
it { $carioca.name.should eq 'Carioca'}
|
84
|
-
end
|
85
|
-
|
86
|
-
context "#list (RO)" do
|
87
|
-
it { should respond_to :list }
|
88
|
-
it { should_not respond_to :list= }
|
89
|
-
it { subject.list.should be_an_instance_of Hash }
|
90
|
-
it { $carioca.list.keys.sort.should eq ["configuration", "debug", "distdummy","dorsal", "dummy", "logger", "uuid", "uuidbygemfile"] }
|
91
|
-
end
|
92
|
-
|
93
|
-
context "#loaded_services (RO)" do
|
94
|
-
it { should respond_to :loaded_services }
|
95
|
-
it { should_not respond_to :loaded_services= }
|
96
|
-
it { subject.loaded_services.should be_an_instance_of Hash }
|
97
|
-
it { $carioca.loaded_services.keys.should eq ["logger"] }
|
98
|
-
end
|
99
|
-
|
100
|
-
context "#registry_filename" do
|
101
|
-
it { should respond_to :registry_filename }
|
102
|
-
it { should respond_to :registry_filename= }
|
103
|
-
it { subject.registry_filename.should be_an_instance_of String }
|
104
|
-
it { $carioca.registry_filename.should eq "spec/config/services.registry" }
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
context "#start_service" do
|
110
|
-
it { should respond_to :start_service }
|
111
|
-
it { should respond_to :get_service }
|
112
|
-
|
113
|
-
context "Builtin services" do
|
114
|
-
context "Logger service" do
|
115
|
-
it "should be possible to get the builtin logger service" do
|
116
|
-
$logger = subject.get_service :name => 'logger'
|
117
|
-
end
|
118
|
-
it "should log if debug mode", :if => $debug do
|
119
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: getting service logger/).size.should >= 1
|
120
|
-
end
|
121
|
-
it "should not log if debug mode", :unless => $debug do
|
122
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: getting service logger/).size.should eq 0
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
context "Debug Proxy Service" do
|
128
|
-
it "should start the builtin service debug" do
|
129
|
-
myservice = subject.start_service :name => 'debug' , :params => {:service => 'dummy'}
|
130
|
-
myservice.test 'titi'
|
131
|
-
end
|
132
|
-
it { subject.list.keys.should include "debug" }
|
133
|
-
it "should log a proxy service log sequence", :if => $debug do
|
134
|
-
open('/tmp/log.file').grep(/DEBUG -- ProxyDebug: BEGIN CALL for mapped service dummy/).size.should eq 1
|
135
|
-
open('/tmp/log.file').grep(/DEBUG -- ProxyDebug: called: test/).size.should eq 1
|
136
|
-
open('/tmp/log.file').grep(/DEBUG -- ProxyDebug: args : titi/).size.should eq 1
|
137
|
-
open('/tmp/log.file').grep(/DEBUG -- ProxyDebug: => returned: OK/).size.should eq 1
|
138
|
-
open('/tmp/log.file').grep(/DEBUG -- ProxyDebug: END CALL/).size.should eq 1
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
context "Configuration Service" do
|
143
|
-
it "should start the builtin configuration service" do
|
144
|
-
$conf = subject.start_service :name => 'configuration'
|
145
|
-
end
|
146
|
-
it "should access flat settings" do
|
147
|
-
$conf.settings.context1.key0.should eq 'value'
|
148
|
-
$conf.settings.context1.node.key1 eq 'value1'
|
149
|
-
$conf.settings.context1.node.key2 eq 'value2'
|
150
|
-
$conf.settings.context2.key0.should eq 'value'
|
151
|
-
$conf.settings.context2.node.key1 eq 'value3'
|
152
|
-
$conf.settings.context2.node.key2 eq 'value4'
|
153
|
-
end
|
154
|
-
it "should access contextualized settings" do
|
155
|
-
$conf = subject.restart_service :name => 'configuration', :params => { :context => 'context2' }
|
156
|
-
$conf.settings.key0.should eq 'value'
|
157
|
-
$conf.settings.node.key1 eq 'value3'
|
158
|
-
$conf.settings.node.key2 eq 'value4'
|
159
|
-
end
|
160
|
-
it "should access inherited settings from YAML" do
|
161
|
-
$conf = subject.restart_service :name => 'configuration', :params => { :context => 'context3' }
|
162
|
-
$conf.settings.key0.should eq 'value'
|
163
|
-
$conf.settings.node.key1 eq 'value3'
|
164
|
-
$conf.settings.node.key2 eq 'value4'
|
165
|
-
end
|
166
|
-
it "should be possible to override a config value" do
|
167
|
-
$conf.settings.node.key2 = 'value8'
|
168
|
-
$conf.settings.node.key2.should eq 'value8'
|
169
|
-
$conf.settings[:node][:key2] = 'value6'
|
170
|
-
$conf.settings[:node][:key2].should eq 'value6'
|
171
|
-
end
|
172
|
-
it { $conf.should respond_to :config_file }
|
173
|
-
it { $conf.should respond_to :config_file= }
|
174
|
-
it { $conf.should respond_to :save! }
|
175
|
-
|
176
|
-
it "should be saved in other file" do
|
177
|
-
$conf.config_file = '/tmp/.config'
|
178
|
-
$conf.save!.should be_true
|
179
|
-
|
180
|
-
end
|
181
|
-
it "should stop the configuration service" do
|
182
|
-
subject.stop_service({:name => 'configuration'}).should eq true
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
|
188
|
-
context "External services" do
|
189
|
-
|
190
|
-
it "should start a dummy service precised in registry YAML configuration" do
|
191
|
-
|
192
|
-
$dummy = subject.start_service :name => 'dummy'
|
193
|
-
$dummy.should be_an_instance_of ExternalServices::Dummy
|
194
|
-
end
|
195
|
-
it { subject.list.keys.should include "dummy" }
|
196
|
-
it "should be possible to use test method of the dummy service, and return 'OK'" do
|
197
|
-
$dummy.test.should eq 'OK'
|
198
|
-
end
|
199
|
-
it "should start a gem service precised in registry YAML configuration" do
|
200
|
-
$uuid = subject.start_service :name => 'uuid'
|
201
|
-
$uuid.should be_an_instance_of UUID
|
202
|
-
end
|
203
|
-
it { subject.list.keys.should include "uuid" }
|
204
|
-
it "should be possible to execute a method with the gem service" do
|
205
|
-
$uuid.generate.should be_a_kind_of String
|
206
|
-
end
|
207
|
-
it "should start a file in gem service precised by gem_file in registry YAML configuration" do
|
208
|
-
$uuidgemfile = subject.start_service :name => 'uuidbygemfile'
|
209
|
-
$uuidgemfile.should be_an_instance_of UUID
|
210
|
-
end
|
211
|
-
it { subject.list.keys.should include "uuidbygemfile" }
|
212
|
-
it { subject.loaded_services.keys.should include "uuidbygemfile" }
|
213
|
-
it "should be possible to execute a method with the gem_file service" do
|
214
|
-
$uuidgemfile.generate.should be_a_kind_of String
|
215
|
-
subject.stop_service :name => "uuidbygemfile"
|
216
|
-
end
|
217
|
-
|
218
|
-
|
219
|
-
context "Distributed service" do
|
220
|
-
it "should be possible to execute a distributed service" do
|
221
|
-
$dummy_dist = subject.start_service :name => 'distdummy'
|
222
|
-
end
|
223
|
-
it "should exist a processus Ring server" do
|
224
|
-
File::exist?('/tmp/dorsal/ringserver.pid').should be_true
|
225
|
-
pid = `ps aux|grep ruby|grep -v grep |grep 'Ultragreen Ring Server'|awk '{ print $2}'`
|
226
|
-
pid.should_not be_empty
|
227
|
-
end
|
228
|
-
it "should log if debug mode", :if => $debug do
|
229
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Starting new Ring Server/).size.should >= 1
|
230
|
-
end
|
231
|
-
it "should not log if debug mode", :unless => $debug do
|
232
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Starting new Ring Server/).size.should eq 0
|
233
|
-
end
|
234
|
-
it "should include 'distdummy' in @loaded_services.keys" do
|
235
|
-
subject.loaded_services.should include "distdummy"
|
236
|
-
end
|
237
|
-
it "should distdummy be a DRbObject" do
|
238
|
-
$dummy_dist.should be_a_kind_of DRb::DRbObject
|
239
|
-
end
|
240
|
-
it "should be possible to use test method of the distributed dummy service, and return 'OK'" do
|
241
|
-
$dummy_dist.test.should eq 'OK'
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
|
249
|
-
context "#stop_service" do
|
250
|
-
it { should respond_to :stop_service }
|
251
|
-
it "should raise ArgumentError if the option hash argument passed not include :name" do
|
252
|
-
lambda { subject.stop_service }.should raise_error ArgumentError
|
253
|
-
lambda { subject.stop_service(:notname => 'debug') }.should raise_error ArgumentError
|
254
|
-
end
|
255
|
-
it "should return true if service really stop" do
|
256
|
-
subject.stop_service({:name => 'dummy'}).should eq true
|
257
|
-
end
|
258
|
-
it "should log if debug mode", :if => $debug do
|
259
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Service dummy stopped/).size.should >= 1
|
260
|
-
end
|
261
|
-
it "should not log if debug mode", :unless => $debug do
|
262
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Service dummy stopped/).size.should eq 0
|
263
|
-
end
|
264
|
-
it "should return false if service not already running" do
|
265
|
-
subject.stop_service({:name => 'dum'}).should eq false
|
266
|
-
end
|
267
|
-
it "should log if debug mode and service not loaded", :if => $debug do
|
268
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Service dum not loaded/).size.should >= 1
|
269
|
-
end
|
270
|
-
it "should not log if debug mode and service not loaded", :unless => $debug do
|
271
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Service dum not loaded/).size.should eq 0
|
272
|
-
end
|
273
|
-
it "should return false if service :name is logger" do
|
274
|
-
subject.stop_service({:name => 'logger'}).should eq false
|
275
|
-
end
|
276
|
-
it "should log if debug mode and service :name is logger", :if => $debug do
|
277
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Service logger can't be unloaded/).size.should >= 1
|
278
|
-
end
|
279
|
-
it "should not log if debug mode and service :name is logger", :unless => $debug do
|
280
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Service logger can't be unloaded/).size.should eq 0
|
281
|
-
end
|
282
|
-
|
283
|
-
context "Distributed Service" do
|
284
|
-
it "should be possible to stop a distributed service" do
|
285
|
-
$dummy_dist = subject.start_service :name => 'distdummy'
|
286
|
-
subject.stop_service({:name => 'distdummy'}).should be_true
|
287
|
-
end
|
288
|
-
it "should not exist forked daemon instance for this stopped service" do
|
289
|
-
pid = `ps aux|grep ruby|grep -v grep |grep 'a dummy test service'|awk '{ print $2}'`
|
290
|
-
pid.should be_empty
|
291
|
-
end
|
292
|
-
it "should not exist the pid file of this stopped services" do
|
293
|
-
File::exist?('/tmp/dorsal/service-distdummy.pid').should be_false
|
294
|
-
$dummy_dist = subject.start_service :name => 'distdummy'
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
end
|
299
|
-
|
300
|
-
context "#restart_service" do
|
301
|
-
it { should respond_to :start_service }
|
302
|
-
it "should start an instance of a service like dummy_one" do
|
303
|
-
$dummy = subject.restart_service :name => 'dummy_one'
|
304
|
-
$dummy = subject.restart_service :name => 'dummy'
|
305
|
-
$dummy.should be_an_instance_of ExternalServices::Dummy
|
306
|
-
$carioca.loaded_services.keys.should include 'dummy'
|
307
|
-
$carioca.loaded_services.keys.should include 'dummy_one'
|
308
|
-
end
|
309
|
-
it "should restart a service already loaded and log it" do
|
310
|
-
$dummy = subject.restart_service :name => 'dummy'
|
311
|
-
end
|
312
|
-
|
313
|
-
context "Distributed service" do
|
314
|
-
it "should ne possible to restart a distributed service" do
|
315
|
-
$dummy_dist = subject.restart_service :name => 'distdummy'
|
316
|
-
end
|
317
|
-
it "should log it if debug mode", :if => $debug do
|
318
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Restarting distributed service distdummy/).size.should eq 1
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
it "should log it if debug mode", :if => $debug do
|
323
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Restarting service dummy/).size.should eq 1
|
324
|
-
end
|
325
|
-
it "should not log it if not debug mode", :if => $debug do
|
326
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Restarting service dummy/).size.should eq 1
|
327
|
-
end
|
328
|
-
|
329
|
-
end
|
330
|
-
|
331
|
-
|
332
|
-
context "#unregister_service" do
|
333
|
-
it { should respond_to :unregister_service }
|
334
|
-
it "should be possible te unregistered the configuration service" do
|
335
|
-
subject.list.keys.should include "configuration"
|
336
|
-
subject.unregister_service :name => "configuration"
|
337
|
-
subject.list.keys.should_not include "configuration"
|
338
|
-
end
|
339
|
-
it "should raise RegistryError if trying to unregister logger" do
|
340
|
-
lambda { subject.unregister_service :name => "logger"}.should raise_error RegistryError
|
341
|
-
end
|
342
|
-
it "should raise RegistryError if trying to unregister a loaded service" do
|
343
|
-
lambda { subject.unregister_service :name => "dummy"}.should raise_error RegistryError
|
344
|
-
end
|
345
|
-
|
346
|
-
end
|
347
|
-
|
348
|
-
context "#discover_builtins" do
|
349
|
-
it { should respond_to :discover_builtins }
|
350
|
-
it "should rebuild builtin service in @list" do
|
351
|
-
subject.discover_builtins
|
352
|
-
subject.list.keys.should include "configuration"
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
context "#register_service" do
|
357
|
-
it { should respond_to :register_service }
|
358
|
-
it "should add a new service" do
|
359
|
-
subject.register_service :name => 'otherdummy',
|
360
|
-
:type => :file,
|
361
|
-
:resource => './spec/samples/otherdummy.rb',
|
362
|
-
:service =>'ExternalServices::OtherDummy',
|
363
|
-
:description => 'An other Dummy Service',
|
364
|
-
:requires => ['requireddummy']
|
365
|
-
end
|
366
|
-
it "should raised RegistryError if started without a registered required service" do
|
367
|
-
lambda { subject.start_service :name => 'otherdummy' }.should raise_error RegistryError
|
368
|
-
end
|
369
|
-
it "should follow requires when started" do
|
370
|
-
subject.register_service :name => 'requireddummy',
|
371
|
-
:type => :file,
|
372
|
-
:resource => './spec/samples/requireddummy.rb',
|
373
|
-
:service =>'ExternalServices::RequiredDummy',
|
374
|
-
:description => 'An other Dummy Service'
|
375
|
-
subject.start_service :name => 'otherdummy'
|
376
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Registry dependancy found and not loaded : requireddummy/).size.should eq 1 if $debug
|
377
|
-
subject.loaded_services.keys.should include 'requireddummy'
|
378
|
-
subject.loaded_services.keys.should include 'otherdummy'
|
379
|
-
end
|
380
|
-
it "should raise Argument error if :type is not :gem, :file, :gem_file or :builtin" do
|
381
|
-
lambda { subject.register_service :name => 'otherdummy',
|
382
|
-
:type => :error,
|
383
|
-
:resource => 'spec/samples/otherdummy.rb',
|
384
|
-
:service =>'ExternalServices::OtherDummy',
|
385
|
-
:description => 'An other Dummy Service'}.should raise_error ArgumentError
|
386
|
-
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
context "#save!" do
|
395
|
-
it { should respond_to :save! }
|
396
|
-
it "should save the config to an other file @registry_filename" do
|
397
|
-
File::unlink('/tmp/test.reg') if File::exist?('/tmp/test.reg')
|
398
|
-
prev = subject.registry_filename
|
399
|
-
subject.registry_filename = '/tmp/test.reg'
|
400
|
-
subject.save!
|
401
|
-
File::exist?('/tmp/test.reg').should be_true
|
402
|
-
subject.registry_filename = prev
|
403
|
-
subject.registry_filename.should eq "spec/config/services.registry"
|
404
|
-
end
|
405
|
-
|
406
|
-
end
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
context "#close" do
|
411
|
-
context "Closing the Carioca registry" do
|
412
|
-
it { should respond_to :close }
|
413
|
-
it "should close" do
|
414
|
-
subject.close.should eq true
|
415
|
-
end
|
416
|
-
it "should log a registry closing notification if debug mode", :if => $debug do
|
417
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: closing Registry .../).size.should eq 1
|
418
|
-
end
|
419
|
-
it "should not log a registry closing notification if not debug mode", :unless => $debug do
|
420
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: closing Registry .../).size.should eq 0
|
421
|
-
end
|
422
|
-
it "should log a distributed service killing notification if debug mode", :if => $debug do
|
423
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Killing distributed Service distdummy./).size.should >= 1
|
424
|
-
end
|
425
|
-
it "should not log a distributed service killing notification if not debug mode", :unless => $debug do
|
426
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Killing distributed Service distdummy./).size.should eq 0
|
427
|
-
end
|
428
|
-
it "should log a stopping notification for each services if debug mode", :if => $debug do
|
429
|
-
['debug','uuid','dorsal','dummy','dummy_one','requireddummy','otherdummy'].each do |service|
|
430
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Service #{service} stopped/).size.should >= 1
|
431
|
-
end
|
432
|
-
end
|
433
|
-
it "should not log a stopping notification for each services if not debug mode", :unless => $debug do
|
434
|
-
['debug','uuid','dorsal','dummy','dummy_one','requireddummy','otherdummy'].each do |service|
|
435
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Service #{service} stopped/).size.should eq 0
|
436
|
-
end
|
437
|
-
end
|
438
|
-
it "should log a registry closing confirmation if debug mode", :if => $debug do
|
439
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Registry services closed, logger will be closed asynchronously/).size.should eq 1
|
440
|
-
end
|
441
|
-
it "should not log a registry closing confirmation if not debug mode", :unless => $debug do
|
442
|
-
open('/tmp/log.file').grep(/DEBUG -- Carioca: Registry services closed, logger will be closed asynchronously/).size.should eq 0
|
443
|
-
end
|
444
|
-
it "should loaded services empty" do
|
445
|
-
subject.loaded_services.empty?.should eq true
|
446
|
-
end
|
447
|
-
context "Distributed service" do
|
448
|
-
end
|
449
|
-
end
|
450
|
-
end
|
451
|
-
end
|
452
|
-
end
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
@@ -1,55 +0,0 @@
|
|
1
|
-
---
|
2
|
-
uuid:
|
3
|
-
:type: :gem
|
4
|
-
:resource: uuid
|
5
|
-
:description: a Rubygems called uuid to build UUID ids.
|
6
|
-
:service: UUID
|
7
|
-
logger:
|
8
|
-
# :distributed: true
|
9
|
-
:type: :builtin
|
10
|
-
:resource: logger
|
11
|
-
:init_options:
|
12
|
-
:target: /tmp/log.file
|
13
|
-
:description: The standard ruby Logger internal wrapper Service
|
14
|
-
:service: Carioca::Services::InternalLogger
|
15
|
-
configuration:
|
16
|
-
# :distributed: true
|
17
|
-
:type: :builtin
|
18
|
-
:resource: configuration
|
19
|
-
:description: The configuration service of Carioca
|
20
|
-
:service: Carioca::Services::Configuration
|
21
|
-
:init_options:
|
22
|
-
:config_file: ./spec/config/.config
|
23
|
-
dorsal:
|
24
|
-
:type: :gem
|
25
|
-
:resource: dorsal
|
26
|
-
:description: The Dorsal Distributed Services architecture
|
27
|
-
:service: Dorsal::Controller
|
28
|
-
:init_options:
|
29
|
-
:host: localhost
|
30
|
-
:port: 8686
|
31
|
-
:dir: /tmp/dorsal
|
32
|
-
:description: Ultragreen Ring Server
|
33
|
-
dummy:
|
34
|
-
:type: :file
|
35
|
-
:resource: ./spec/samples/dummy.rb
|
36
|
-
:description: a dummy test service
|
37
|
-
:service: ExternalServices::Dummy
|
38
|
-
distdummy:
|
39
|
-
:type: :file
|
40
|
-
:resource: ./spec/samples/dummy.rb
|
41
|
-
:description: a dummy test service
|
42
|
-
:service: ExternalServices::Dummy
|
43
|
-
:distributed: true
|
44
|
-
uuidbygemfile:
|
45
|
-
:type: :gem_file
|
46
|
-
:resource: uuid:lib/uuid.rb
|
47
|
-
:description: uuid file in gem
|
48
|
-
:service: UUID
|
49
|
-
debug:
|
50
|
-
:type: :builtin
|
51
|
-
:resource: debug
|
52
|
-
:init_options:
|
53
|
-
:service: dummy
|
54
|
-
:description: Class Proxy debug logger Service
|
55
|
-
:service: Carioca::Services::ProxyDebug
|
data/spec/init_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
data/spec/samples/dummy.rb
DELETED
data/spec/samples/otherdummy.rb
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
-
RSpec.configure do |config|
|
8
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
-
config.run_all_when_everything_filtered = true
|
10
|
-
# config.filter_run :focus
|
11
|
-
end
|
data/test.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
AssignmentInConditionalCheck:
|
2
|
-
CaseMissingElseCheck:
|
3
|
-
ClassLineCountCheck:
|
4
|
-
line_count: 300
|
5
|
-
ClassNameCheck:
|
6
|
-
pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
|
7
|
-
#ClassVariableCheck:
|
8
|
-
CyclomaticComplexityBlockCheck:
|
9
|
-
complexity: 5
|
10
|
-
CyclomaticComplexityMethodCheck:
|
11
|
-
complexity: 10
|
12
|
-
EmptyRescueBodyCheck:
|
13
|
-
ForLoopCheck:
|
14
|
-
MethodLineCountCheck:
|
15
|
-
line_count: 30
|
16
|
-
MethodNameCheck:
|
17
|
-
pattern: !ruby/regexp /^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
|
18
|
-
# MissingForeignKeyIndexCheck:
|
19
|
-
ModuleLineCountCheck:
|
20
|
-
line_count: 500
|
21
|
-
ModuleNameCheck:
|
22
|
-
pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
|
23
|
-
ParameterNumberCheck:
|
24
|
-
parameter_count: 5
|
25
|
-
|