cuboid 0.0.5 → 0.1.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +13 -13
- data/lib/cuboid/application.rb +10 -10
- data/lib/cuboid/option_groups/{dispatcher.rb → agent.rb} +9 -9
- data/lib/cuboid/option_groups/paths.rb +1 -1
- data/lib/cuboid/options.rb +1 -1
- data/lib/cuboid/processes/{dispatchers.rb → agents.rb} +25 -25
- data/lib/cuboid/processes/executables/agent.rb +5 -0
- data/lib/cuboid/processes/helpers/agents.rb +23 -0
- data/lib/cuboid/processes/helpers/instances.rb +4 -4
- data/lib/cuboid/processes/helpers.rb +1 -1
- data/lib/cuboid/processes/instances.rb +9 -9
- data/lib/cuboid/processes/schedulers.rb +2 -2
- data/lib/cuboid/processes.rb +2 -2
- data/lib/cuboid/rest/server/instance_helpers.rb +13 -13
- data/lib/cuboid/rest/server/routes/dispatcher.rb +11 -11
- data/lib/cuboid/rest/server/routes/grid.rb +8 -8
- data/lib/cuboid/rest/server/routes/instances.rb +1 -1
- data/lib/cuboid/rest/server.rb +5 -5
- data/lib/cuboid/rpc/client/{dispatcher.rb → agent.rb} +4 -4
- data/lib/cuboid/rpc/client/instance.rb +2 -2
- data/lib/cuboid/rpc/client.rb +1 -1
- data/lib/cuboid/rpc/server/agent/node.rb +247 -0
- data/lib/cuboid/rpc/server/{dispatcher → agent}/service.rb +13 -13
- data/lib/cuboid/rpc/server/{dispatcher.rb → agent.rb} +32 -31
- data/lib/cuboid/rpc/server/application_wrapper.rb +1 -1
- data/lib/cuboid/rpc/server/instance.rb +4 -4
- data/lib/cuboid/rpc/server/scheduler.rb +12 -12
- data/lib/version +1 -1
- data/spec/cuboid/option_groups/dispatcher_spec.rb +2 -2
- data/spec/cuboid/rest/server_spec.rb +45 -45
- data/spec/cuboid/rpc/client/dispatcher_spec.rb +2 -2
- data/spec/cuboid/rpc/server/dispatcher/node_spec.rb +65 -65
- data/spec/cuboid/rpc/server/dispatcher/service_spec.rb +16 -16
- data/spec/cuboid/rpc/server/dispatcher_spec.rb +95 -95
- data/spec/cuboid/rpc/server/scheduler_spec.rb +8 -8
- data/spec/support/fixtures/executables/node.rb +3 -3
- data/spec/support/fixtures/mock_app/test_service.rb +8 -8
- data/spec/support/fixtures/mock_app.rb +1 -1
- data/spec/support/fixtures/services/echo.rb +6 -6
- data/spec/support/helpers/resets.rb +1 -1
- data/spec/support/lib/web_server_client.rb +2 -2
- data/spec/support/lib/web_server_dispatcher.rb +1 -1
- metadata +10 -348
- data/lib/cuboid/processes/executables/dispatcher.rb +0 -5
- data/lib/cuboid/processes/helpers/dispatchers.rb +0 -23
- data/lib/cuboid/rpc/server/dispatcher/node.rb +0 -247
- data/spec/support/logs/Dispatcher - 1520492-37227.log +0 -6
- data/spec/support/logs/Dispatcher - 1520680-13689.log +0 -6
- data/spec/support/logs/Dispatcher - 1520682-24167.log +0 -6
- data/spec/support/logs/Dispatcher - 1520688-42731.log +0 -6
- data/spec/support/logs/Dispatcher - 1520690-5750.log +0 -10
- data/spec/support/logs/Dispatcher - 1520692-55183.log +0 -10
- data/spec/support/logs/Dispatcher - 1520695-39752.log +0 -10
- data/spec/support/logs/Dispatcher - 1520697-44327.log +0 -10
- data/spec/support/logs/Dispatcher - 1520699-58785.log +0 -10
- data/spec/support/logs/Dispatcher - 1520701-60952.log +0 -10
- data/spec/support/logs/Dispatcher - 1520796-50420.log +0 -6
- data/spec/support/logs/Dispatcher - 1520894-56883.log +0 -6
- data/spec/support/logs/Dispatcher - 1520896-21419.log +0 -6
- data/spec/support/logs/Dispatcher - 1520898-62584.log +0 -6
- data/spec/support/logs/Dispatcher - 1520900-59721.log +0 -6
- data/spec/support/logs/Dispatcher - 1520910-51632.log +0 -6
- data/spec/support/logs/Dispatcher - 1520920-21801.log +0 -6
- data/spec/support/logs/Dispatcher - 1520930-49223.log +0 -6
- data/spec/support/logs/Dispatcher - 1520933-34241.log +0 -6
- data/spec/support/logs/Dispatcher - 1520935-64571.log +0 -6
- data/spec/support/logs/Dispatcher - 1520937-50734.log +0 -6
- data/spec/support/logs/Dispatcher - 1520939-60841.log +0 -6
- data/spec/support/logs/Dispatcher - 1520944-8124.log +0 -6
- data/spec/support/logs/Dispatcher - 1520946-25192.log +0 -16
- data/spec/support/logs/Dispatcher - 1520948-9752.log +0 -14
- data/spec/support/logs/Dispatcher - 1520952-45543.log +0 -10
- data/spec/support/logs/Dispatcher - 1520958-36653.log +0 -16
- data/spec/support/logs/Dispatcher - 1520960-17456.log +0 -14
- data/spec/support/logs/Dispatcher - 1520964-5774.log +0 -10
- data/spec/support/logs/Dispatcher - 1520976-40848.log +0 -16
- data/spec/support/logs/Dispatcher - 1520978-29867.log +0 -14
- data/spec/support/logs/Dispatcher - 1520982-17715.log +0 -10
- data/spec/support/logs/Dispatcher - 1520987-8925.log +0 -16
- data/spec/support/logs/Dispatcher - 1520989-25480.log +0 -14
- data/spec/support/logs/Dispatcher - 1520993-5124.log +0 -10
- data/spec/support/logs/Dispatcher - 1520999-12901.log +0 -16
- data/spec/support/logs/Dispatcher - 1521004-32265.log +0 -14
- data/spec/support/logs/Dispatcher - 1521008-33455.log +0 -10
- data/spec/support/logs/Dispatcher - 1521014-13779.log +0 -6
- data/spec/support/logs/Dispatcher - 1521017-14755.log +0 -6
- data/spec/support/logs/Dispatcher - 1521022-48687.log +0 -6
- data/spec/support/logs/Dispatcher - 1521024-59097.log +0 -6
- data/spec/support/logs/Dispatcher - 1521034-12604.log +0 -6
- data/spec/support/logs/Dispatcher - 1521038-64272.log +0 -6
- data/spec/support/logs/Dispatcher - 1521043-8680.log +0 -6
- data/spec/support/logs/Dispatcher - 1521047-22949.log +0 -6
- data/spec/support/logs/Dispatcher - 1521051-3355.log +0 -6
- data/spec/support/logs/Dispatcher - 1521074-12332.log +0 -6
- data/spec/support/logs/Dispatcher - 1521118-53130.log +0 -16
- data/spec/support/logs/Dispatcher - 1521128-47137.log +0 -14
- data/spec/support/logs/Dispatcher - 1521136-30328.log +0 -10
- data/spec/support/logs/Dispatcher - 1521161-21329.log +0 -16
- data/spec/support/logs/Dispatcher - 1521172-19183.log +0 -14
- data/spec/support/logs/Dispatcher - 1521179-34902.log +0 -10
- data/spec/support/logs/Dispatcher - 1521190-20155.log +0 -16
- data/spec/support/logs/Dispatcher - 1521204-43843.log +0 -14
- data/spec/support/logs/Dispatcher - 1521211-23972.log +0 -10
- data/spec/support/logs/Dispatcher - 1521237-20879.log +0 -10
- data/spec/support/logs/Dispatcher - 1521239-61999.log +0 -10
- data/spec/support/logs/Dispatcher - 1521242-20975.log +0 -16
- data/spec/support/logs/Dispatcher - 1521246-28409.log +0 -14
- data/spec/support/logs/Dispatcher - 1521250-58505.log +0 -10
- data/spec/support/logs/Dispatcher - 1521262-53292.log +0 -6
- data/spec/support/logs/Dispatcher - 1521266-42758.log +0 -6
- data/spec/support/logs/Dispatcher - 1521277-4215.log +0 -6
- data/spec/support/logs/Dispatcher - 1521292-16086.log +0 -6
- data/spec/support/logs/Dispatcher - 1521301-42112.log +0 -6
- data/spec/support/logs/Dispatcher - 1521312-61196.log +0 -6
- data/spec/support/logs/Dispatcher - 1521316-23353.log +0 -6
- data/spec/support/logs/Dispatcher - 1521321-46361.log +0 -6
- data/spec/support/logs/Dispatcher - 1521438-46016.log +0 -6
- data/spec/support/logs/Dispatcher - 1521454-49862.log +0 -6
- data/spec/support/logs/Dispatcher - 1521470-54737.log +0 -6
- data/spec/support/logs/Instance - 1521353-26273.error.log +0 -105
- data/spec/support/logs/Instance - 1521355-56591.error.log +0 -105
- data/spec/support/logs/Instance - 1521363-26218.error.log +0 -105
- data/spec/support/logs/Scheduler - 1520469-35703.log +0 -3
- data/spec/support/logs/Scheduler - 1520473-60524.log +0 -6
- data/spec/support/logs/Scheduler - 1520509-34951.log +0 -3
- data/spec/support/logs/Scheduler - 1520517-31455.log +0 -6
- data/spec/support/logs/Scheduler - 1520529-43808.log +0 -4
- data/spec/support/logs/Scheduler - 1520536-23387.log +0 -1
- data/spec/support/logs/Scheduler - 1520549-48260.log +0 -3
- data/spec/support/logs/Scheduler - 1520563-45636.log +0 -6
- data/spec/support/logs/Scheduler - 1520599-40643.log +0 -3
- data/spec/support/logs/Scheduler - 1520608-54106.log +0 -6
- data/spec/support/logs/Scheduler - 1520629-24722.log +0 -3
- data/spec/support/logs/Scheduler - 1520637-61755.log +0 -6
- data/spec/support/logs/Scheduler - 1520663-17447.log +0 -4
- data/spec/support/logs/Scheduler - 1520671-38282.log +0 -6
- data/spec/support/logs/Scheduler - 1520703-33082.log +0 -1
- data/spec/support/logs/Scheduler - 1520706-22309.log +0 -1
- data/spec/support/logs/Scheduler - 1520709-1816.log +0 -1
- data/spec/support/logs/Scheduler - 1520711-19998.log +0 -1
- data/spec/support/logs/Scheduler - 1520714-47570.log +0 -1
- data/spec/support/logs/Scheduler - 1520723-18521.log +0 -1
- data/spec/support/logs/Scheduler - 1520725-40913.log +0 -3
- data/spec/support/logs/Scheduler - 1520749-45742.log +0 -6
- data/spec/support/logs/Scheduler - 1520759-44350.log +0 -4
- data/spec/support/logs/Scheduler - 1520770-53219.log +0 -1
- data/spec/support/logs/Scheduler - 1520773-54792.log +0 -1
- data/spec/support/logs/Scheduler - 1520777-19636.log +0 -1
- data/spec/support/logs/Scheduler - 1520780-51801.log +0 -1
- data/spec/support/logs/Scheduler - 1520782-9652.log +0 -3
- data/spec/support/logs/Scheduler - 1520786-59472.log +0 -1
- data/spec/support/logs/Scheduler - 1520789-1603.log +0 -1
- data/spec/support/logs/Scheduler - 1520792-35476.log +0 -1
- data/spec/support/logs/Scheduler - 1521410-47324.log +0 -16
- data/spec/support/logs/Scheduler - 1521422-33737.log +0 -6
- data/spec/support/logs/Scheduler - 1521433-36637.log +0 -6
- data/spec/support/logs/Scheduler - 1521440-15066.log +0 -6
- data/spec/support/logs/Scheduler - 1521456-48637.log +0 -3
- data/spec/support/logs/Scheduler - 1521472-54425.log +0 -5
- data/spec/support/logs/Scheduler - 1521496-12923.log +0 -1
- data/spec/support/logs/Scheduler - 1521518-46819.log +0 -1
- data/spec/support/logs/Scheduler - 1521522-21417.log +0 -1
- data/spec/support/logs/Scheduler - 1521525-35088.log +0 -1
- data/spec/support/logs/Scheduler - 1521528-13676.log +0 -1
- data/spec/support/logs/Scheduler - 1521530-48176.log +0 -1
- data/spec/support/logs/Scheduler - 1521532-13207.log +0 -1
- data/spec/support/logs/Scheduler - 1521535-5799.log +0 -3
- data/spec/support/logs/Scheduler - 1521543-62784.log +0 -3
- data/spec/support/logs/Scheduler - 1521551-10263.log +0 -3
- data/spec/support/logs/Scheduler - 1521556-56026.log +0 -3
- data/spec/support/logs/Scheduler - 1521560-14551.log +0 -4
- data/spec/support/logs/Scheduler - 1521573-47584.log +0 -1
- data/spec/support/logs/Scheduler - 1521578-14443.log +0 -4
- data/spec/support/logs/Scheduler - 1521580-60337.log +0 -1
- data/spec/support/logs/Scheduler - 1521583-52039.log +0 -1
- data/spec/support/logs/Scheduler - 1521586-1500.log +0 -16
- data/spec/support/logs/Scheduler - 1521598-61298.log +0 -4
- data/spec/support/logs/Scheduler - 1521602-61490.log +0 -1
- data/spec/support/logs/Scheduler - 1521604-29209.log +0 -1
- data/spec/support/logs/Scheduler - 1521606-47734.log +0 -1
- data/spec/support/logs/Scheduler - 1521612-63269.log +0 -1
- data/spec/support/logs/Scheduler - 1521614-47018.log +0 -3
- data/spec/support/logs/Scheduler - 1521619-32411.log +0 -1
- data/spec/support/logs/Scheduler - 1521621-42861.log +0 -1
- data/spec/support/logs/Scheduler - 1521623-56258.log +0 -1
- data/spec/support/logs/Scheduler - 1521627-9487.log +0 -1
- data/spec/support/logs/Scheduler - 1521630-3345.log +0 -1
- data/spec/support/logs/Scheduler - 1521632-47325.log +0 -1
- data/spec/support/logs/Scheduler - 1521635-22156.log +0 -2
- data/spec/support/logs/error-1520329.log +0 -797
- data/spec/support/logs/output_spec_1520329.log +0 -390
- data/spec/support/reports/003bed585153336c2548d1c60a026a3e.crf +0 -0
- data/spec/support/reports/30e3c7a8c13e9b40a0a443a5e5a4ff94.crf +0 -0
- data/spec/support/reports/31655751a9f0eee91e588bc796985b1e.crf +0 -0
- data/spec/support/reports/40801b7993c0ed919b73242a9c078dde.crf +0 -0
- data/spec/support/reports/4719b89667e92bb80102f4b0bb4c0c75.crf +0 -0
- data/spec/support/reports/4e765a3d2870d2763ea72167bd3db9d6.crf +0 -0
- data/spec/support/reports/61968f732d8ae715c104175e43679915.crf +0 -0
- data/spec/support/reports/63446a8ec637d9991b8c6a1151ae59a9.crf +0 -0
- data/spec/support/reports/737144b18305c7a115ad7964b9bbe41c.crf +0 -0
- data/spec/support/reports/73fe5f7adf905045c3fe4669bdf60d02.crf +0 -0
- data/spec/support/reports/86cd396db9ef97472876f32e57c44ce7.crf +0 -0
- data/spec/support/reports/8a031ac2b2730dfd07a1d1ca870299f2.crf +0 -0
- data/spec/support/reports/8e16ac74484ee5d8cf7073fe22adf787.crf +0 -0
- data/spec/support/reports/8eff857213ab6ff712a0b0e8582855c9.crf +0 -0
- data/spec/support/reports/9e0e6ed8718973b3d4e63bbb7dd1d1c6.crf +0 -0
- data/spec/support/reports/a9c88f967d09cb9c4e8e1180cfb24828.crf +0 -0
- data/spec/support/reports/ba32970a64686e45ec8caa5032f65c2e.crf +0 -0
- data/spec/support/reports/cceb7596659fd619ab4438953cbda78b.crf +0 -0
- data/spec/support/reports/d2e0f4558b605ffd1215e9226815b951.crf +0 -0
- data/spec/support/snapshots/Cuboid 2022-01-24 14_38_16 +0200 8238609e31cedaf1bcb89205f9d42121.csf +0 -0
- data/spec/support/snapshots/Cuboid 2022-01-24 14_38_30 +0200 68690b002e79c7bc9e3aabfcbc7ac5a7.csf +0 -0
- data/spec/support/snapshots/Cuboid 2022-01-24 14_46_39 +0200 6fd3c9491d3e784e18f9c3c0d9deddec.csf +0 -0
- data/spec/support/snapshots/Cuboid 2022-01-24 14_46_44 +0200 c3a012fba59210bc7c169afb0565d5a8.csf +0 -0
- data/spec/support/snapshots/Cuboid 2022-01-24 14_46_46 +0200 e4c1ce35d8e62e6a16f84eccd36b2283.csf +0 -0
|
@@ -15,7 +15,7 @@ describe Cuboid::Rest::Server do
|
|
|
15
15
|
let(:id) { @id }
|
|
16
16
|
let(:non_existent_id) { 'stuff' }
|
|
17
17
|
|
|
18
|
-
let(:
|
|
18
|
+
let(:agent) { Cuboid::Processes::Agents.spawn }
|
|
19
19
|
let(:scheduler) { Cuboid::Processes::Schedulers.spawn }
|
|
20
20
|
|
|
21
21
|
def create_instance
|
|
@@ -235,17 +235,17 @@ describe Cuboid::Rest::Server do
|
|
|
235
235
|
end
|
|
236
236
|
end
|
|
237
237
|
|
|
238
|
-
context 'when a
|
|
238
|
+
context 'when a Agent has been set' do
|
|
239
239
|
|
|
240
240
|
it 'uses it' do
|
|
241
|
-
put '/
|
|
241
|
+
put '/agent/url', agent.url
|
|
242
242
|
|
|
243
|
-
get "/grid/#{
|
|
243
|
+
get "/grid/#{agent.url}"
|
|
244
244
|
expect(response_data['running_instances']).to be_empty
|
|
245
245
|
|
|
246
246
|
create_instance
|
|
247
247
|
|
|
248
|
-
get "/grid/#{
|
|
248
|
+
get "/grid/#{agent.url}"
|
|
249
249
|
expect(response_data['running_instances'].size).to eq 1
|
|
250
250
|
end
|
|
251
251
|
end
|
|
@@ -623,32 +623,32 @@ describe Cuboid::Rest::Server do
|
|
|
623
623
|
end
|
|
624
624
|
end
|
|
625
625
|
|
|
626
|
-
describe 'GET /
|
|
627
|
-
let(:tpl_url) { '/
|
|
626
|
+
describe 'GET /agent/url' do
|
|
627
|
+
let(:tpl_url) { '/agent/url' }
|
|
628
628
|
|
|
629
|
-
it 'returns the
|
|
630
|
-
put url,
|
|
629
|
+
it 'returns the Agent' do
|
|
630
|
+
put url, agent.url
|
|
631
631
|
expect(response_code).to eq 200
|
|
632
632
|
|
|
633
633
|
get url
|
|
634
634
|
expect(response_code).to eq 200
|
|
635
|
-
expect(response_data).to eq
|
|
635
|
+
expect(response_data).to eq agent.url
|
|
636
636
|
end
|
|
637
637
|
|
|
638
|
-
context 'when no
|
|
638
|
+
context 'when no Agent has been set' do
|
|
639
639
|
it 'returns 501' do
|
|
640
640
|
get url
|
|
641
641
|
expect(response_code).to eq 501
|
|
642
|
-
expect(response_data).to eq 'No
|
|
642
|
+
expect(response_data).to eq 'No Agent has been set.'
|
|
643
643
|
end
|
|
644
644
|
end
|
|
645
645
|
end
|
|
646
646
|
|
|
647
|
-
describe 'PUT /
|
|
648
|
-
let(:tpl_url) { '/
|
|
647
|
+
describe 'PUT /agent/url' do
|
|
648
|
+
let(:tpl_url) { '/agent/url' }
|
|
649
649
|
|
|
650
|
-
it 'sets the
|
|
651
|
-
put url,
|
|
650
|
+
it 'sets the Agent' do
|
|
651
|
+
put url, agent.url
|
|
652
652
|
expect(response_code).to eq 200
|
|
653
653
|
end
|
|
654
654
|
|
|
@@ -663,101 +663,101 @@ describe Cuboid::Rest::Server do
|
|
|
663
663
|
end
|
|
664
664
|
end
|
|
665
665
|
|
|
666
|
-
describe 'DELETE /
|
|
667
|
-
let(:tpl_url) { '/
|
|
666
|
+
describe 'DELETE /agent/url' do
|
|
667
|
+
let(:tpl_url) { '/agent/url' }
|
|
668
668
|
|
|
669
|
-
it 'removes the the
|
|
670
|
-
put url,
|
|
669
|
+
it 'removes the the Agent' do
|
|
670
|
+
put url, agent.url
|
|
671
671
|
expect(response_code).to eq 200
|
|
672
672
|
|
|
673
673
|
delete url
|
|
674
674
|
expect(response_code).to eq 200
|
|
675
675
|
|
|
676
|
-
get url,
|
|
676
|
+
get url, agent.url
|
|
677
677
|
expect(response_code).to eq 501
|
|
678
678
|
end
|
|
679
679
|
|
|
680
|
-
context 'when no
|
|
680
|
+
context 'when no Agent has been set' do
|
|
681
681
|
it 'returns 501' do
|
|
682
682
|
delete url
|
|
683
683
|
expect(response_code).to eq 501
|
|
684
|
-
expect(response_data).to eq 'No
|
|
684
|
+
expect(response_data).to eq 'No Agent has been set.'
|
|
685
685
|
end
|
|
686
686
|
end
|
|
687
687
|
end
|
|
688
688
|
|
|
689
689
|
describe 'GET /grid' do
|
|
690
|
-
let(:
|
|
690
|
+
let(:agent) { Cuboid::Processes::Agents.grid_spawn }
|
|
691
691
|
let(:tpl_url) { '/grid' }
|
|
692
692
|
|
|
693
693
|
it 'returns Grid info' do
|
|
694
|
-
put '/
|
|
694
|
+
put '/agent/url', agent.url
|
|
695
695
|
expect(response_code).to eq 200
|
|
696
696
|
|
|
697
697
|
get url
|
|
698
698
|
expect(response_code).to eq 200
|
|
699
|
-
expect(response_data.sort).to eq ([
|
|
699
|
+
expect(response_data.sort).to eq ([agent.url] + agent.node.peers).sort
|
|
700
700
|
end
|
|
701
701
|
|
|
702
|
-
context 'when no
|
|
702
|
+
context 'when no Agent has been set' do
|
|
703
703
|
it 'returns 501' do
|
|
704
704
|
get url
|
|
705
705
|
expect(response_code).to eq 501
|
|
706
|
-
expect(response_data).to eq 'No
|
|
706
|
+
expect(response_data).to eq 'No Agent has been set.'
|
|
707
707
|
end
|
|
708
708
|
end
|
|
709
709
|
end
|
|
710
710
|
|
|
711
|
-
describe 'GET /grid/:
|
|
712
|
-
let(:
|
|
711
|
+
describe 'GET /grid/:agent' do
|
|
712
|
+
let(:agent) { Cuboid::Processes::Agents.grid_spawn }
|
|
713
713
|
let(:tpl_url) { '/grid/%s' }
|
|
714
714
|
|
|
715
|
-
it 'returns
|
|
716
|
-
put '/
|
|
715
|
+
it 'returns Agent info' do
|
|
716
|
+
put '/agent/url', agent.url
|
|
717
717
|
expect(response_code).to eq 200
|
|
718
718
|
|
|
719
|
-
@id =
|
|
719
|
+
@id = agent.url
|
|
720
720
|
|
|
721
721
|
get url
|
|
722
722
|
expect(response_code).to eq 200
|
|
723
|
-
expect(response_data).to eq
|
|
723
|
+
expect(response_data).to eq agent.statistics
|
|
724
724
|
end
|
|
725
725
|
|
|
726
|
-
context 'when no
|
|
726
|
+
context 'when no Agent has been set' do
|
|
727
727
|
it 'returns 501' do
|
|
728
728
|
@id = 'localhost:2222'
|
|
729
729
|
|
|
730
730
|
get url
|
|
731
731
|
expect(response_code).to eq 501
|
|
732
|
-
expect(response_data).to eq 'No
|
|
732
|
+
expect(response_data).to eq 'No Agent has been set.'
|
|
733
733
|
end
|
|
734
734
|
end
|
|
735
735
|
end
|
|
736
736
|
|
|
737
|
-
describe 'DELETE /grid/:
|
|
738
|
-
let(:
|
|
737
|
+
describe 'DELETE /grid/:agent' do
|
|
738
|
+
let(:agent) { Cuboid::Processes::Agents.grid_spawn }
|
|
739
739
|
let(:tpl_url) { '/grid/%s' }
|
|
740
740
|
|
|
741
|
-
it 'unplugs the
|
|
742
|
-
put '/
|
|
741
|
+
it 'unplugs the Agent from the Grid' do
|
|
742
|
+
put '/agent/url', agent.url
|
|
743
743
|
expect(response_code).to eq 200
|
|
744
744
|
|
|
745
|
-
@id =
|
|
745
|
+
@id = agent.url
|
|
746
746
|
|
|
747
|
-
expect(
|
|
747
|
+
expect(agent.node.grid_member?).to be_truthy
|
|
748
748
|
|
|
749
749
|
delete url
|
|
750
750
|
expect(response_code).to eq 200
|
|
751
|
-
expect(
|
|
751
|
+
expect(agent.node.grid_member?).to be_falsey
|
|
752
752
|
end
|
|
753
753
|
|
|
754
|
-
context 'when no
|
|
754
|
+
context 'when no Agent has been set' do
|
|
755
755
|
it 'returns 501' do
|
|
756
756
|
@id = 'localhost:2222'
|
|
757
757
|
|
|
758
758
|
delete url
|
|
759
759
|
expect(response_code).to eq 501
|
|
760
|
-
expect(response_data).to eq 'No
|
|
760
|
+
expect(response_data).to eq 'No Agent has been set.'
|
|
761
761
|
end
|
|
762
762
|
end
|
|
763
763
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
require 'fileutils'
|
|
3
3
|
|
|
4
|
-
describe Cuboid::RPC::Client::
|
|
5
|
-
subject {
|
|
4
|
+
describe Cuboid::RPC::Client::Agent do
|
|
5
|
+
subject { agent_spawn application: "#{fixtures_path}/mock_app.rb" }
|
|
6
6
|
|
|
7
7
|
describe '#node' do
|
|
8
8
|
it 'provides access to the node data' do
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require "#{Cuboid::Options.paths.lib}/rpc/server/
|
|
2
|
+
require "#{Cuboid::Options.paths.lib}/rpc/server/agent"
|
|
3
3
|
|
|
4
|
-
describe Cuboid::RPC::Server::
|
|
4
|
+
describe Cuboid::RPC::Server::Agent::Node do
|
|
5
5
|
|
|
6
6
|
def get_node( port = available_port )
|
|
7
7
|
Cuboid::Options.rpc.server_port = port
|
|
@@ -25,7 +25,7 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
|
25
25
|
|
|
26
26
|
before( :each ) do
|
|
27
27
|
options.paths.executables = "#{fixtures_path}executables/"
|
|
28
|
-
options.
|
|
28
|
+
options.agent.ping_interval = 0.5
|
|
29
29
|
end
|
|
30
30
|
after( :each ) do
|
|
31
31
|
Cuboid::Processes::Manager.killall
|
|
@@ -35,9 +35,9 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
|
35
35
|
let(:options) { Cuboid::Options }
|
|
36
36
|
|
|
37
37
|
describe '#grid_member?' do
|
|
38
|
-
context 'when the
|
|
38
|
+
context 'when the agent is a grid member' do
|
|
39
39
|
it 'should return true' do
|
|
40
|
-
options.
|
|
40
|
+
options.agent.peer = subject.url
|
|
41
41
|
|
|
42
42
|
c = get_node
|
|
43
43
|
sleep 0.5
|
|
@@ -46,68 +46,68 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
context 'when the
|
|
49
|
+
context 'when the agent is not a grid member' do
|
|
50
50
|
it 'should return false' do
|
|
51
51
|
expect(subject.grid_member?).to be_falsey
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
context 'when a previously unreachable
|
|
57
|
-
it 'gets re-added to the
|
|
56
|
+
context 'when a previously unreachable peer comes back to life' do
|
|
57
|
+
it 'gets re-added to the peers list' do
|
|
58
58
|
port = available_port
|
|
59
|
-
subject.
|
|
59
|
+
subject.add_peer( '127.0.0.1:' + port.to_s )
|
|
60
60
|
|
|
61
61
|
sleep 3
|
|
62
|
-
expect(subject.
|
|
62
|
+
expect(subject.peers).to be_empty
|
|
63
63
|
|
|
64
64
|
c = get_node( port )
|
|
65
65
|
|
|
66
66
|
sleep 0.5
|
|
67
|
-
expect(subject.
|
|
68
|
-
expect(c.
|
|
67
|
+
expect(subject.peers).to eq([c.url])
|
|
68
|
+
expect(c.peers).to eq([subject.url])
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
context 'when a
|
|
72
|
+
context 'when a peer becomes unreachable' do
|
|
73
73
|
it 'is removed' do
|
|
74
74
|
c = get_node
|
|
75
75
|
|
|
76
|
-
subject.
|
|
76
|
+
subject.add_peer( c.url )
|
|
77
77
|
sleep 0.5
|
|
78
78
|
|
|
79
|
-
expect(c.
|
|
80
|
-
expect(subject.
|
|
79
|
+
expect(c.peers).to eq([subject.url])
|
|
80
|
+
expect(subject.peers).to eq([c.url])
|
|
81
81
|
|
|
82
82
|
subject.shutdown rescue break while sleep 0.1
|
|
83
83
|
sleep 0.5
|
|
84
84
|
|
|
85
|
-
expect(c.
|
|
85
|
+
expect(c.peers).to be_empty
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
context 'when initialised with a
|
|
90
|
-
it 'adds that
|
|
91
|
-
options.
|
|
89
|
+
context 'when initialised with a peer' do
|
|
90
|
+
it 'adds that peer and reach convergence' do
|
|
91
|
+
options.agent.peer = subject.url
|
|
92
92
|
|
|
93
93
|
c = get_node
|
|
94
94
|
sleep 0.5
|
|
95
|
-
expect(c.
|
|
96
|
-
expect(subject.
|
|
95
|
+
expect(c.peers).to eq([subject.url])
|
|
96
|
+
expect(subject.peers).to eq([c.url])
|
|
97
97
|
|
|
98
98
|
d = get_node
|
|
99
99
|
sleep 0.5
|
|
100
|
-
expect(d.
|
|
101
|
-
expect(c.
|
|
102
|
-
expect(subject.
|
|
100
|
+
expect(d.peers.sort).to eq([subject.url, c.url].sort)
|
|
101
|
+
expect(c.peers.sort).to eq([subject.url, d.url].sort)
|
|
102
|
+
expect(subject.peers.sort).to eq([c.url, d.url].sort)
|
|
103
103
|
|
|
104
|
-
options.
|
|
104
|
+
options.agent.peer = d.url
|
|
105
105
|
e = get_node
|
|
106
106
|
sleep 0.5
|
|
107
|
-
expect(e.
|
|
108
|
-
expect(d.
|
|
109
|
-
expect(c.
|
|
110
|
-
expect(subject.
|
|
107
|
+
expect(e.peers.sort).to eq([subject.url, c.url, d.url].sort)
|
|
108
|
+
expect(d.peers.sort).to eq([subject.url, c.url, e.url].sort)
|
|
109
|
+
expect(c.peers.sort).to eq([subject.url, d.url, e.url].sort)
|
|
110
|
+
expect(subject.peers.sort).to eq([c.url, d.url, e.url].sort)
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
|
|
@@ -115,75 +115,75 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
|
115
115
|
it 'removes itself from the Grid' do
|
|
116
116
|
c = get_node
|
|
117
117
|
|
|
118
|
-
subject.
|
|
118
|
+
subject.add_peer( c.url )
|
|
119
119
|
sleep 0.5
|
|
120
|
-
expect(c.
|
|
120
|
+
expect(c.peers).to eq([subject.url])
|
|
121
121
|
|
|
122
122
|
c.unplug
|
|
123
123
|
|
|
124
|
-
expect(c.
|
|
124
|
+
expect(c.peers).to be_empty
|
|
125
125
|
expect(c.grid_member?).to be_falsey
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
describe '#
|
|
129
|
+
describe '#add_peer' do
|
|
130
130
|
before(:each) do
|
|
131
|
-
subject.
|
|
131
|
+
subject.add_peer( other.url )
|
|
132
132
|
sleep 0.5
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
let( :other ) { get_node }
|
|
136
136
|
|
|
137
|
-
it 'adds a
|
|
138
|
-
expect(subject.
|
|
139
|
-
expect(other.
|
|
137
|
+
it 'adds a peer' do
|
|
138
|
+
expect(subject.peers).to eq([other.url])
|
|
139
|
+
expect(other.peers).to eq([subject.url])
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
context 'when propagate is set to true' do
|
|
143
|
-
it 'announces the new
|
|
143
|
+
it 'announces the new peer to the existing peers' do
|
|
144
144
|
n = get_node
|
|
145
|
-
subject.
|
|
145
|
+
subject.add_peer( n.url, true )
|
|
146
146
|
sleep 0.5
|
|
147
147
|
|
|
148
|
-
expect(subject.
|
|
149
|
-
expect(other.
|
|
148
|
+
expect(subject.peers.sort).to eq([other.url, n.url].sort)
|
|
149
|
+
expect(other.peers.sort).to eq([subject.url, n.url].sort)
|
|
150
150
|
|
|
151
151
|
c = get_node
|
|
152
|
-
n.
|
|
152
|
+
n.add_peer( c.url, true )
|
|
153
153
|
sleep 0.5
|
|
154
154
|
|
|
155
|
-
expect(subject.
|
|
156
|
-
expect(other.
|
|
157
|
-
expect(c.
|
|
155
|
+
expect(subject.peers.sort).to eq([other.url, n.url, c.url].sort)
|
|
156
|
+
expect(other.peers.sort).to eq([subject.url, n.url, c.url].sort)
|
|
157
|
+
expect(c.peers.sort).to eq([subject.url, n.url, other.url].sort)
|
|
158
158
|
|
|
159
159
|
d = get_node
|
|
160
|
-
d.
|
|
160
|
+
d.add_peer( c.url, true )
|
|
161
161
|
sleep 0.5
|
|
162
162
|
|
|
163
|
-
expect(subject.
|
|
164
|
-
expect(other.
|
|
165
|
-
expect(c.
|
|
166
|
-
expect(d.
|
|
163
|
+
expect(subject.peers.sort).to eq([d.url, other.url, n.url, c.url].sort)
|
|
164
|
+
expect(other.peers.sort).to eq([d.url, subject.url, n.url, c.url].sort)
|
|
165
|
+
expect(c.peers.sort).to eq([d.url, subject.url, n.url, other.url].sort)
|
|
166
|
+
expect(d.peers.sort).to eq([c.url, subject.url, n.url, other.url].sort)
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
describe '#
|
|
172
|
-
it 'returns an array of
|
|
173
|
-
expect(subject.
|
|
171
|
+
describe '#peers' do
|
|
172
|
+
it 'returns an array of peers' do
|
|
173
|
+
expect(subject.peers.is_a?( Array )).to be_truthy
|
|
174
174
|
end
|
|
175
175
|
end
|
|
176
176
|
|
|
177
|
-
describe '#
|
|
178
|
-
it 'returns all
|
|
179
|
-
subject.
|
|
177
|
+
describe '#peers_with_info' do
|
|
178
|
+
it 'returns all peers accompanied by their node info' do
|
|
179
|
+
subject.add_peer( get_node.url )
|
|
180
180
|
sleep 0.5
|
|
181
181
|
|
|
182
|
-
expect(subject.
|
|
183
|
-
expect(subject.
|
|
182
|
+
expect(subject.peers).to be_any
|
|
183
|
+
expect(subject.peers_with_info.size).to eq (subject.peers.size)
|
|
184
184
|
|
|
185
185
|
keys = subject.info.keys.sort
|
|
186
|
-
subject.
|
|
186
|
+
subject.peers_with_info.each do |i|
|
|
187
187
|
expect(i.keys.sort).to eq(keys)
|
|
188
188
|
end
|
|
189
189
|
end
|
|
@@ -191,18 +191,18 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
|
191
191
|
|
|
192
192
|
describe '#info' do
|
|
193
193
|
it 'returns node info' do
|
|
194
|
-
options.
|
|
194
|
+
options.agent.name = 'blah'
|
|
195
195
|
|
|
196
196
|
c = get_node
|
|
197
|
-
subject.
|
|
197
|
+
subject.add_peer( c.url )
|
|
198
198
|
sleep 0.5
|
|
199
199
|
|
|
200
200
|
info = subject.info
|
|
201
201
|
|
|
202
202
|
expect(info['url']).to eq(subject.url)
|
|
203
|
-
expect(info['
|
|
204
|
-
expect(info['
|
|
205
|
-
expect(info['name']).to eq(options.
|
|
203
|
+
expect(info['peers']).to eq(subject.peers)
|
|
204
|
+
expect(info['unreachable_peers']).to be_empty
|
|
205
|
+
expect(info['name']).to eq(options.agent.name)
|
|
206
206
|
end
|
|
207
207
|
|
|
208
208
|
context 'when OptionGroups::RPC#server_external_address has been set' do
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require "#{Cuboid::Options.paths.lib}/rpc/server/
|
|
2
|
+
require "#{Cuboid::Options.paths.lib}/rpc/server/agent"
|
|
3
3
|
|
|
4
|
-
describe Cuboid::RPC::Server::
|
|
4
|
+
describe Cuboid::RPC::Server::Agent::Service do
|
|
5
5
|
before( :each ) do
|
|
6
6
|
Cuboid::Options.paths.services = "#{fixtures_path}services/"
|
|
7
7
|
Cuboid::Options.system.max_slots = 10
|
|
8
8
|
end
|
|
9
9
|
let(:instance_count) { 3 }
|
|
10
|
-
let(:
|
|
11
|
-
let(:subject) {
|
|
10
|
+
let(:agent) { agent_spawn application: "#{fixtures_path}/mock_app.rb" }
|
|
11
|
+
let(:subject) { agent.test_service }
|
|
12
12
|
|
|
13
|
-
describe '#
|
|
14
|
-
it 'provides access to the parent
|
|
15
|
-
expect(subject.
|
|
13
|
+
describe '#agent' do
|
|
14
|
+
it 'provides access to the parent Agent' do
|
|
15
|
+
expect(subject.test_agent).to be_truthy
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
describe '#opts' do
|
|
20
|
-
it 'provides access to the
|
|
20
|
+
it 'provides access to the Agent\'s options' do
|
|
21
21
|
expect(subject.test_opts).to be_truthy
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
describe '#node' do
|
|
26
|
-
it 'provides access to the
|
|
26
|
+
it 'provides access to the Agent\'s node' do
|
|
27
27
|
expect(subject.test_node).to be_truthy
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
describe '#instances' do
|
|
32
32
|
before(:each) do
|
|
33
|
-
instance_count.times {
|
|
33
|
+
instance_count.times { agent.spawn }
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it 'provides access to the running instances' do
|
|
@@ -40,7 +40,7 @@ describe Cuboid::RPC::Server::Dispatcher::Service do
|
|
|
40
40
|
|
|
41
41
|
describe '#map_instances' do
|
|
42
42
|
before(:each) do
|
|
43
|
-
instance_count.times {
|
|
43
|
+
instance_count.times { agent.spawn }
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it 'asynchronously maps all running instances' do
|
|
@@ -52,7 +52,7 @@ describe Cuboid::RPC::Server::Dispatcher::Service do
|
|
|
52
52
|
|
|
53
53
|
describe '#each_instance' do
|
|
54
54
|
before(:each) do
|
|
55
|
-
instance_count.times {
|
|
55
|
+
instance_count.times { agent.spawn }
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it 'asynchronously iterates over all running instances' do
|
|
@@ -92,15 +92,15 @@ describe Cuboid::RPC::Server::Dispatcher::Service do
|
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
describe '#
|
|
96
|
-
it 'connects to the a
|
|
97
|
-
expect(subject.
|
|
95
|
+
describe '#connect_to_agent' do
|
|
96
|
+
it 'connects to the a agent by url' do
|
|
97
|
+
expect(subject.test_connect_to_agent( agent.url )).to be_truthy
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
describe '#connect_to_instance' do
|
|
102
102
|
it 'connects to an instance' do
|
|
103
|
-
|
|
103
|
+
agent.spawn
|
|
104
104
|
instance = subject.instances.first
|
|
105
105
|
|
|
106
106
|
expect(subject.test_connect_to_instance( instance )).to be_falsey
|