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.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +13 -13
  4. data/lib/cuboid/application.rb +10 -10
  5. data/lib/cuboid/option_groups/{dispatcher.rb → agent.rb} +9 -9
  6. data/lib/cuboid/option_groups/paths.rb +1 -1
  7. data/lib/cuboid/options.rb +1 -1
  8. data/lib/cuboid/processes/{dispatchers.rb → agents.rb} +25 -25
  9. data/lib/cuboid/processes/executables/agent.rb +5 -0
  10. data/lib/cuboid/processes/helpers/agents.rb +23 -0
  11. data/lib/cuboid/processes/helpers/instances.rb +4 -4
  12. data/lib/cuboid/processes/helpers.rb +1 -1
  13. data/lib/cuboid/processes/instances.rb +9 -9
  14. data/lib/cuboid/processes/schedulers.rb +2 -2
  15. data/lib/cuboid/processes.rb +2 -2
  16. data/lib/cuboid/rest/server/instance_helpers.rb +13 -13
  17. data/lib/cuboid/rest/server/routes/dispatcher.rb +11 -11
  18. data/lib/cuboid/rest/server/routes/grid.rb +8 -8
  19. data/lib/cuboid/rest/server/routes/instances.rb +1 -1
  20. data/lib/cuboid/rest/server.rb +5 -5
  21. data/lib/cuboid/rpc/client/{dispatcher.rb → agent.rb} +4 -4
  22. data/lib/cuboid/rpc/client/instance.rb +2 -2
  23. data/lib/cuboid/rpc/client.rb +1 -1
  24. data/lib/cuboid/rpc/server/agent/node.rb +247 -0
  25. data/lib/cuboid/rpc/server/{dispatcher → agent}/service.rb +13 -13
  26. data/lib/cuboid/rpc/server/{dispatcher.rb → agent.rb} +32 -31
  27. data/lib/cuboid/rpc/server/application_wrapper.rb +1 -1
  28. data/lib/cuboid/rpc/server/instance.rb +4 -4
  29. data/lib/cuboid/rpc/server/scheduler.rb +12 -12
  30. data/lib/version +1 -1
  31. data/spec/cuboid/option_groups/dispatcher_spec.rb +2 -2
  32. data/spec/cuboid/rest/server_spec.rb +45 -45
  33. data/spec/cuboid/rpc/client/dispatcher_spec.rb +2 -2
  34. data/spec/cuboid/rpc/server/dispatcher/node_spec.rb +65 -65
  35. data/spec/cuboid/rpc/server/dispatcher/service_spec.rb +16 -16
  36. data/spec/cuboid/rpc/server/dispatcher_spec.rb +95 -95
  37. data/spec/cuboid/rpc/server/scheduler_spec.rb +8 -8
  38. data/spec/support/fixtures/executables/node.rb +3 -3
  39. data/spec/support/fixtures/mock_app/test_service.rb +8 -8
  40. data/spec/support/fixtures/mock_app.rb +1 -1
  41. data/spec/support/fixtures/services/echo.rb +6 -6
  42. data/spec/support/helpers/resets.rb +1 -1
  43. data/spec/support/lib/web_server_client.rb +2 -2
  44. data/spec/support/lib/web_server_dispatcher.rb +1 -1
  45. metadata +10 -348
  46. data/lib/cuboid/processes/executables/dispatcher.rb +0 -5
  47. data/lib/cuboid/processes/helpers/dispatchers.rb +0 -23
  48. data/lib/cuboid/rpc/server/dispatcher/node.rb +0 -247
  49. data/spec/support/logs/Dispatcher - 1520492-37227.log +0 -6
  50. data/spec/support/logs/Dispatcher - 1520680-13689.log +0 -6
  51. data/spec/support/logs/Dispatcher - 1520682-24167.log +0 -6
  52. data/spec/support/logs/Dispatcher - 1520688-42731.log +0 -6
  53. data/spec/support/logs/Dispatcher - 1520690-5750.log +0 -10
  54. data/spec/support/logs/Dispatcher - 1520692-55183.log +0 -10
  55. data/spec/support/logs/Dispatcher - 1520695-39752.log +0 -10
  56. data/spec/support/logs/Dispatcher - 1520697-44327.log +0 -10
  57. data/spec/support/logs/Dispatcher - 1520699-58785.log +0 -10
  58. data/spec/support/logs/Dispatcher - 1520701-60952.log +0 -10
  59. data/spec/support/logs/Dispatcher - 1520796-50420.log +0 -6
  60. data/spec/support/logs/Dispatcher - 1520894-56883.log +0 -6
  61. data/spec/support/logs/Dispatcher - 1520896-21419.log +0 -6
  62. data/spec/support/logs/Dispatcher - 1520898-62584.log +0 -6
  63. data/spec/support/logs/Dispatcher - 1520900-59721.log +0 -6
  64. data/spec/support/logs/Dispatcher - 1520910-51632.log +0 -6
  65. data/spec/support/logs/Dispatcher - 1520920-21801.log +0 -6
  66. data/spec/support/logs/Dispatcher - 1520930-49223.log +0 -6
  67. data/spec/support/logs/Dispatcher - 1520933-34241.log +0 -6
  68. data/spec/support/logs/Dispatcher - 1520935-64571.log +0 -6
  69. data/spec/support/logs/Dispatcher - 1520937-50734.log +0 -6
  70. data/spec/support/logs/Dispatcher - 1520939-60841.log +0 -6
  71. data/spec/support/logs/Dispatcher - 1520944-8124.log +0 -6
  72. data/spec/support/logs/Dispatcher - 1520946-25192.log +0 -16
  73. data/spec/support/logs/Dispatcher - 1520948-9752.log +0 -14
  74. data/spec/support/logs/Dispatcher - 1520952-45543.log +0 -10
  75. data/spec/support/logs/Dispatcher - 1520958-36653.log +0 -16
  76. data/spec/support/logs/Dispatcher - 1520960-17456.log +0 -14
  77. data/spec/support/logs/Dispatcher - 1520964-5774.log +0 -10
  78. data/spec/support/logs/Dispatcher - 1520976-40848.log +0 -16
  79. data/spec/support/logs/Dispatcher - 1520978-29867.log +0 -14
  80. data/spec/support/logs/Dispatcher - 1520982-17715.log +0 -10
  81. data/spec/support/logs/Dispatcher - 1520987-8925.log +0 -16
  82. data/spec/support/logs/Dispatcher - 1520989-25480.log +0 -14
  83. data/spec/support/logs/Dispatcher - 1520993-5124.log +0 -10
  84. data/spec/support/logs/Dispatcher - 1520999-12901.log +0 -16
  85. data/spec/support/logs/Dispatcher - 1521004-32265.log +0 -14
  86. data/spec/support/logs/Dispatcher - 1521008-33455.log +0 -10
  87. data/spec/support/logs/Dispatcher - 1521014-13779.log +0 -6
  88. data/spec/support/logs/Dispatcher - 1521017-14755.log +0 -6
  89. data/spec/support/logs/Dispatcher - 1521022-48687.log +0 -6
  90. data/spec/support/logs/Dispatcher - 1521024-59097.log +0 -6
  91. data/spec/support/logs/Dispatcher - 1521034-12604.log +0 -6
  92. data/spec/support/logs/Dispatcher - 1521038-64272.log +0 -6
  93. data/spec/support/logs/Dispatcher - 1521043-8680.log +0 -6
  94. data/spec/support/logs/Dispatcher - 1521047-22949.log +0 -6
  95. data/spec/support/logs/Dispatcher - 1521051-3355.log +0 -6
  96. data/spec/support/logs/Dispatcher - 1521074-12332.log +0 -6
  97. data/spec/support/logs/Dispatcher - 1521118-53130.log +0 -16
  98. data/spec/support/logs/Dispatcher - 1521128-47137.log +0 -14
  99. data/spec/support/logs/Dispatcher - 1521136-30328.log +0 -10
  100. data/spec/support/logs/Dispatcher - 1521161-21329.log +0 -16
  101. data/spec/support/logs/Dispatcher - 1521172-19183.log +0 -14
  102. data/spec/support/logs/Dispatcher - 1521179-34902.log +0 -10
  103. data/spec/support/logs/Dispatcher - 1521190-20155.log +0 -16
  104. data/spec/support/logs/Dispatcher - 1521204-43843.log +0 -14
  105. data/spec/support/logs/Dispatcher - 1521211-23972.log +0 -10
  106. data/spec/support/logs/Dispatcher - 1521237-20879.log +0 -10
  107. data/spec/support/logs/Dispatcher - 1521239-61999.log +0 -10
  108. data/spec/support/logs/Dispatcher - 1521242-20975.log +0 -16
  109. data/spec/support/logs/Dispatcher - 1521246-28409.log +0 -14
  110. data/spec/support/logs/Dispatcher - 1521250-58505.log +0 -10
  111. data/spec/support/logs/Dispatcher - 1521262-53292.log +0 -6
  112. data/spec/support/logs/Dispatcher - 1521266-42758.log +0 -6
  113. data/spec/support/logs/Dispatcher - 1521277-4215.log +0 -6
  114. data/spec/support/logs/Dispatcher - 1521292-16086.log +0 -6
  115. data/spec/support/logs/Dispatcher - 1521301-42112.log +0 -6
  116. data/spec/support/logs/Dispatcher - 1521312-61196.log +0 -6
  117. data/spec/support/logs/Dispatcher - 1521316-23353.log +0 -6
  118. data/spec/support/logs/Dispatcher - 1521321-46361.log +0 -6
  119. data/spec/support/logs/Dispatcher - 1521438-46016.log +0 -6
  120. data/spec/support/logs/Dispatcher - 1521454-49862.log +0 -6
  121. data/spec/support/logs/Dispatcher - 1521470-54737.log +0 -6
  122. data/spec/support/logs/Instance - 1521353-26273.error.log +0 -105
  123. data/spec/support/logs/Instance - 1521355-56591.error.log +0 -105
  124. data/spec/support/logs/Instance - 1521363-26218.error.log +0 -105
  125. data/spec/support/logs/Scheduler - 1520469-35703.log +0 -3
  126. data/spec/support/logs/Scheduler - 1520473-60524.log +0 -6
  127. data/spec/support/logs/Scheduler - 1520509-34951.log +0 -3
  128. data/spec/support/logs/Scheduler - 1520517-31455.log +0 -6
  129. data/spec/support/logs/Scheduler - 1520529-43808.log +0 -4
  130. data/spec/support/logs/Scheduler - 1520536-23387.log +0 -1
  131. data/spec/support/logs/Scheduler - 1520549-48260.log +0 -3
  132. data/spec/support/logs/Scheduler - 1520563-45636.log +0 -6
  133. data/spec/support/logs/Scheduler - 1520599-40643.log +0 -3
  134. data/spec/support/logs/Scheduler - 1520608-54106.log +0 -6
  135. data/spec/support/logs/Scheduler - 1520629-24722.log +0 -3
  136. data/spec/support/logs/Scheduler - 1520637-61755.log +0 -6
  137. data/spec/support/logs/Scheduler - 1520663-17447.log +0 -4
  138. data/spec/support/logs/Scheduler - 1520671-38282.log +0 -6
  139. data/spec/support/logs/Scheduler - 1520703-33082.log +0 -1
  140. data/spec/support/logs/Scheduler - 1520706-22309.log +0 -1
  141. data/spec/support/logs/Scheduler - 1520709-1816.log +0 -1
  142. data/spec/support/logs/Scheduler - 1520711-19998.log +0 -1
  143. data/spec/support/logs/Scheduler - 1520714-47570.log +0 -1
  144. data/spec/support/logs/Scheduler - 1520723-18521.log +0 -1
  145. data/spec/support/logs/Scheduler - 1520725-40913.log +0 -3
  146. data/spec/support/logs/Scheduler - 1520749-45742.log +0 -6
  147. data/spec/support/logs/Scheduler - 1520759-44350.log +0 -4
  148. data/spec/support/logs/Scheduler - 1520770-53219.log +0 -1
  149. data/spec/support/logs/Scheduler - 1520773-54792.log +0 -1
  150. data/spec/support/logs/Scheduler - 1520777-19636.log +0 -1
  151. data/spec/support/logs/Scheduler - 1520780-51801.log +0 -1
  152. data/spec/support/logs/Scheduler - 1520782-9652.log +0 -3
  153. data/spec/support/logs/Scheduler - 1520786-59472.log +0 -1
  154. data/spec/support/logs/Scheduler - 1520789-1603.log +0 -1
  155. data/spec/support/logs/Scheduler - 1520792-35476.log +0 -1
  156. data/spec/support/logs/Scheduler - 1521410-47324.log +0 -16
  157. data/spec/support/logs/Scheduler - 1521422-33737.log +0 -6
  158. data/spec/support/logs/Scheduler - 1521433-36637.log +0 -6
  159. data/spec/support/logs/Scheduler - 1521440-15066.log +0 -6
  160. data/spec/support/logs/Scheduler - 1521456-48637.log +0 -3
  161. data/spec/support/logs/Scheduler - 1521472-54425.log +0 -5
  162. data/spec/support/logs/Scheduler - 1521496-12923.log +0 -1
  163. data/spec/support/logs/Scheduler - 1521518-46819.log +0 -1
  164. data/spec/support/logs/Scheduler - 1521522-21417.log +0 -1
  165. data/spec/support/logs/Scheduler - 1521525-35088.log +0 -1
  166. data/spec/support/logs/Scheduler - 1521528-13676.log +0 -1
  167. data/spec/support/logs/Scheduler - 1521530-48176.log +0 -1
  168. data/spec/support/logs/Scheduler - 1521532-13207.log +0 -1
  169. data/spec/support/logs/Scheduler - 1521535-5799.log +0 -3
  170. data/spec/support/logs/Scheduler - 1521543-62784.log +0 -3
  171. data/spec/support/logs/Scheduler - 1521551-10263.log +0 -3
  172. data/spec/support/logs/Scheduler - 1521556-56026.log +0 -3
  173. data/spec/support/logs/Scheduler - 1521560-14551.log +0 -4
  174. data/spec/support/logs/Scheduler - 1521573-47584.log +0 -1
  175. data/spec/support/logs/Scheduler - 1521578-14443.log +0 -4
  176. data/spec/support/logs/Scheduler - 1521580-60337.log +0 -1
  177. data/spec/support/logs/Scheduler - 1521583-52039.log +0 -1
  178. data/spec/support/logs/Scheduler - 1521586-1500.log +0 -16
  179. data/spec/support/logs/Scheduler - 1521598-61298.log +0 -4
  180. data/spec/support/logs/Scheduler - 1521602-61490.log +0 -1
  181. data/spec/support/logs/Scheduler - 1521604-29209.log +0 -1
  182. data/spec/support/logs/Scheduler - 1521606-47734.log +0 -1
  183. data/spec/support/logs/Scheduler - 1521612-63269.log +0 -1
  184. data/spec/support/logs/Scheduler - 1521614-47018.log +0 -3
  185. data/spec/support/logs/Scheduler - 1521619-32411.log +0 -1
  186. data/spec/support/logs/Scheduler - 1521621-42861.log +0 -1
  187. data/spec/support/logs/Scheduler - 1521623-56258.log +0 -1
  188. data/spec/support/logs/Scheduler - 1521627-9487.log +0 -1
  189. data/spec/support/logs/Scheduler - 1521630-3345.log +0 -1
  190. data/spec/support/logs/Scheduler - 1521632-47325.log +0 -1
  191. data/spec/support/logs/Scheduler - 1521635-22156.log +0 -2
  192. data/spec/support/logs/error-1520329.log +0 -797
  193. data/spec/support/logs/output_spec_1520329.log +0 -390
  194. data/spec/support/reports/003bed585153336c2548d1c60a026a3e.crf +0 -0
  195. data/spec/support/reports/30e3c7a8c13e9b40a0a443a5e5a4ff94.crf +0 -0
  196. data/spec/support/reports/31655751a9f0eee91e588bc796985b1e.crf +0 -0
  197. data/spec/support/reports/40801b7993c0ed919b73242a9c078dde.crf +0 -0
  198. data/spec/support/reports/4719b89667e92bb80102f4b0bb4c0c75.crf +0 -0
  199. data/spec/support/reports/4e765a3d2870d2763ea72167bd3db9d6.crf +0 -0
  200. data/spec/support/reports/61968f732d8ae715c104175e43679915.crf +0 -0
  201. data/spec/support/reports/63446a8ec637d9991b8c6a1151ae59a9.crf +0 -0
  202. data/spec/support/reports/737144b18305c7a115ad7964b9bbe41c.crf +0 -0
  203. data/spec/support/reports/73fe5f7adf905045c3fe4669bdf60d02.crf +0 -0
  204. data/spec/support/reports/86cd396db9ef97472876f32e57c44ce7.crf +0 -0
  205. data/spec/support/reports/8a031ac2b2730dfd07a1d1ca870299f2.crf +0 -0
  206. data/spec/support/reports/8e16ac74484ee5d8cf7073fe22adf787.crf +0 -0
  207. data/spec/support/reports/8eff857213ab6ff712a0b0e8582855c9.crf +0 -0
  208. data/spec/support/reports/9e0e6ed8718973b3d4e63bbb7dd1d1c6.crf +0 -0
  209. data/spec/support/reports/a9c88f967d09cb9c4e8e1180cfb24828.crf +0 -0
  210. data/spec/support/reports/ba32970a64686e45ec8caa5032f65c2e.crf +0 -0
  211. data/spec/support/reports/cceb7596659fd619ab4438953cbda78b.crf +0 -0
  212. data/spec/support/reports/d2e0f4558b605ffd1215e9226815b951.crf +0 -0
  213. data/spec/support/snapshots/Cuboid 2022-01-24 14_38_16 +0200 8238609e31cedaf1bcb89205f9d42121.csf +0 -0
  214. data/spec/support/snapshots/Cuboid 2022-01-24 14_38_30 +0200 68690b002e79c7bc9e3aabfcbc7ac5a7.csf +0 -0
  215. data/spec/support/snapshots/Cuboid 2022-01-24 14_46_39 +0200 6fd3c9491d3e784e18f9c3c0d9deddec.csf +0 -0
  216. data/spec/support/snapshots/Cuboid 2022-01-24 14_46_44 +0200 c3a012fba59210bc7c169afb0565d5a8.csf +0 -0
  217. data/spec/support/snapshots/Cuboid 2022-01-24 14_46_46 +0200 e4c1ce35d8e62e6a16f84eccd36b2283.csf +0 -0
@@ -1,16 +1,16 @@
1
1
  require 'spec_helper'
2
2
  require 'fileutils'
3
3
 
4
- require "#{Cuboid::Options.paths.lib}/rpc/server/dispatcher"
4
+ require "#{Cuboid::Options.paths.lib}/rpc/server/agent"
5
5
 
6
- describe Cuboid::RPC::Server::Dispatcher do
6
+ describe Cuboid::RPC::Server::Agent do
7
7
  before( :each ) do
8
8
  Cuboid::Options.system.max_slots = slots
9
9
  end
10
10
 
11
11
  let(:instance_info_keys) { %w(token application pid url owner birthdate helpers now age) }
12
12
  let(:slots) { 3 }
13
- let(:subject) { dispatcher_spawn( application: "#{fixtures_path}/mock_app.rb" ) }
13
+ let(:subject) { agent_spawn( application: "#{fixtures_path}/mock_app.rb" ) }
14
14
 
15
15
  describe '#alive?' do
16
16
  it 'returns true' do
@@ -19,32 +19,32 @@ describe Cuboid::RPC::Server::Dispatcher do
19
19
  end
20
20
 
21
21
  describe '#preferred' do
22
- context 'when the dispatcher is a grid member' do
22
+ context 'when the agent is a grid member' do
23
23
  context 'and strategy is' do
24
24
  context :horizontal do
25
- it 'returns the URL of least burdened Dispatcher' do
26
- dispatcher_spawn( neighbour: subject.url ).dispatch( load_balance: false )
27
- dispatcher_spawn( neighbour: subject.url ).dispatch( load_balance: false )
25
+ it 'returns the URL of least burdened Agent' do
26
+ agent_spawn( peer: subject.url ).spawn( load_balance: false )
27
+ agent_spawn( peer: subject.url ).spawn( load_balance: false )
28
28
 
29
29
  expect(subject.preferred( :horizontal )).to eq(subject.url)
30
30
  end
31
31
  end
32
32
 
33
33
  context :vertical do
34
- it 'returns the URL of most burdened Dispatcher' do
35
- dispatcher_spawn( neighbour: subject.url ).dispatch( load_balance: false )
36
- d = dispatcher_spawn( neighbour: subject.url )
37
- d.dispatch( load_balance: false )
38
- d.dispatch( load_balance: false )
34
+ it 'returns the URL of most burdened Agent' do
35
+ agent_spawn( peer: subject.url ).spawn( load_balance: false )
36
+ d = agent_spawn( peer: subject.url )
37
+ d.spawn( load_balance: false )
38
+ d.spawn( load_balance: false )
39
39
 
40
40
  expect(subject.preferred( :vertical )).to eq(d.url)
41
41
  end
42
42
  end
43
43
 
44
44
  context 'default' do
45
- it 'returns the URL of least burdened Dispatcher' do
46
- dispatcher_spawn( neighbour: subject.url ).dispatch( load_balance: false )
47
- dispatcher_spawn( neighbour: subject.url ).dispatch( load_balance: false )
45
+ it 'returns the URL of least burdened Agent' do
46
+ agent_spawn( peer: subject.url ).spawn( load_balance: false )
47
+ agent_spawn( peer: subject.url ).spawn( load_balance: false )
48
48
 
49
49
  expect(subject.preferred).to eq(subject.url)
50
50
  end
@@ -52,38 +52,38 @@ describe Cuboid::RPC::Server::Dispatcher do
52
52
 
53
53
  context 'other' do
54
54
  it 'returns :error_unknown_strategy' do
55
- dispatcher_spawn( neighbour: subject.url ).dispatch( load_balance: false )
56
- dispatcher_spawn( neighbour: subject.url ).dispatch( load_balance: false )
55
+ agent_spawn( peer: subject.url ).spawn( load_balance: false )
56
+ agent_spawn( peer: subject.url ).spawn( load_balance: false )
57
57
 
58
58
  expect(subject.preferred( :blah )).to eq('error_unknown_strategy')
59
59
  end
60
60
  end
61
61
  end
62
62
 
63
- context 'and all Dispatchers are at max utilization' do
63
+ context 'and all Agents are at max utilization' do
64
64
  before :each do
65
- subject.dispatch( load_balance: false )
65
+ subject.spawn( load_balance: false )
66
66
  end
67
67
 
68
68
  let(:slots) { 1 }
69
69
 
70
70
  it 'returns nil' do
71
- dispatcher_spawn( neighbour: subject.url ).dispatch( load_balance: false )
72
- dispatcher_spawn( neighbour: subject.url ).dispatch( load_balance: false )
71
+ agent_spawn( peer: subject.url ).spawn( load_balance: false )
72
+ agent_spawn( peer: subject.url ).spawn( load_balance: false )
73
73
 
74
74
  expect(subject.preferred).to be_nil
75
75
  end
76
76
  end
77
77
  end
78
78
 
79
- context 'when the dispatcher is not a grid member' do
80
- it 'returns the URL of the Dispatcher' do
79
+ context 'when the agent is not a grid member' do
80
+ it 'returns the URL of the Agent' do
81
81
  expect(subject.preferred).to eq(subject.url)
82
82
  end
83
83
 
84
84
  context 'and it is at max utilization' do
85
85
  before :each do
86
- subject.dispatch( load_balance: false )
86
+ subject.spawn( load_balance: false )
87
87
  end
88
88
 
89
89
  let(:slots) { 1 }
@@ -101,20 +101,20 @@ describe Cuboid::RPC::Server::Dispatcher do
101
101
  end
102
102
  end
103
103
 
104
- describe '#dispatch' do
104
+ describe '#spawn' do
105
105
  it 'does not leak Instances' do
106
106
  slots.times do
107
- subject.dispatch
107
+ subject.spawn
108
108
  end
109
109
 
110
110
  expect(subject.instances.size).to eq(slots)
111
111
  end
112
112
 
113
- it 'sets OptionGroups::Dispatcher#url' do
114
- info = subject.dispatch
113
+ it 'sets OptionGroups::Agent#url' do
114
+ info = subject.spawn
115
115
  instance = instance_connect( info['url'], info['token'] )
116
116
 
117
- expect(instance.dispatcher_url).to eq subject.url
117
+ expect(instance.agent_url).to eq subject.url
118
118
  end
119
119
 
120
120
  context "when #{Cuboid::OptionGroups::RPC}#server_external_address has been set" do
@@ -125,13 +125,13 @@ describe Cuboid::RPC::Server::Dispatcher do
125
125
  let(:address) { '127.0.0.2' }
126
126
 
127
127
  it 'advertises that address' do
128
- expect(subject.dispatch['url']).to start_with "#{address}:"
128
+ expect(subject.spawn['url']).to start_with "#{address}:"
129
129
  end
130
130
  end
131
131
 
132
132
  context 'when not a Grid member' do
133
133
  it 'returns Instance info' do
134
- info = subject.dispatch( owner: 'rspec' )
134
+ info = subject.spawn( owner: 'rspec' )
135
135
 
136
136
  %w(token application pid url owner birthdate helpers).each do |k|
137
137
  expect(info[k]).to be_truthy
@@ -143,19 +143,19 @@ describe Cuboid::RPC::Server::Dispatcher do
143
143
 
144
144
  it 'assigns an optional owner' do
145
145
  owner = 'blah'
146
- expect(subject.dispatch( owner: owner )['owner']).to eq(owner)
146
+ expect(subject.spawn( owner: owner )['owner']).to eq(owner)
147
147
  end
148
148
 
149
149
  context 'when the there are no available slots' do
150
150
  let(:slots) { 5 }
151
151
  before :each do
152
152
  slots.times do
153
- subject.dispatch
153
+ subject.spawn
154
154
  end
155
155
  end
156
156
 
157
157
  it 'returns nil' do
158
- expect(subject.dispatch).to be nil
158
+ expect(subject.spawn).to be nil
159
159
  end
160
160
 
161
161
  context 'and slots are freed' do
@@ -173,12 +173,12 @@ describe Cuboid::RPC::Server::Dispatcher do
173
173
 
174
174
  instances = []
175
175
  free.times do
176
- instances << subject.dispatch
176
+ instances << subject.spawn
177
177
  end
178
178
  instances.compact!
179
179
 
180
180
  expect(instances.size).to eq free
181
- expect(subject.dispatch).to be nil
181
+ expect(subject.spawn).to be nil
182
182
  end
183
183
  end
184
184
  end
@@ -189,148 +189,148 @@ describe Cuboid::RPC::Server::Dispatcher do
189
189
 
190
190
  context 'and strategy is' do
191
191
  context :horizontal do
192
- it 'provides Instances from the least burdened Dispatcher' do
193
- d1 = dispatcher_spawn(
192
+ it 'provides Instances from the least burdened Agent' do
193
+ d1 = agent_spawn(
194
194
  address: '127.0.0.1',
195
195
  application: "#{fixtures_path}/mock_app.rb"
196
196
  )
197
197
 
198
198
  3.times do
199
- d1.dispatch( load_balance: false )
199
+ d1.spawn( load_balance: false )
200
200
  end
201
201
 
202
- d2 = dispatcher_spawn(
202
+ d2 = agent_spawn(
203
203
  address: '127.0.0.2',
204
- neighbour: d1.url,
204
+ peer: d1.url,
205
205
  application: "#{fixtures_path}/mock_app.rb"
206
206
  )
207
207
 
208
208
  2.times do
209
- d2.dispatch( load_balance: false )
209
+ d2.spawn( load_balance: false )
210
210
  end
211
211
 
212
- d3 = dispatcher_spawn(
212
+ d3 = agent_spawn(
213
213
  address: '127.0.0.3',
214
- neighbour: d1.url,
214
+ peer: d1.url,
215
215
  application: "#{fixtures_path}/mock_app.rb"
216
216
  )
217
- d3.dispatch( load_balance: false )
217
+ d3.spawn( load_balance: false )
218
218
  preferred = d3.url.split( ':' ).first
219
219
 
220
- expect(d3.dispatch(strategy: :horizontal )['url'].split( ':' ).first).to eq(preferred)
221
- expect(%W{127.0.0.3 127.0.0.2}).to include d1.dispatch['url'].split( ':' ).first
222
- expect(d2.dispatch(strategy: :horizontal )['url'].split( ':' ).first).to eq(preferred)
223
- expect(%W{127.0.0.1 127.0.0.3}).to include d3.dispatch(strategy: :horizontal )['url'].split( ':' ).first
224
- expect(%W{127.0.0.2 127.0.0.3}).to include d3.dispatch(strategy: :horizontal )['url'].split( ':' ).first
225
- expect(%W{127.0.0.2 127.0.0.3}).to include d1.dispatch(strategy: :horizontal )['url'].split( ':' ).first
220
+ expect(d3.spawn(strategy: :horizontal )['url'].split( ':' ).first).to eq(preferred)
221
+ expect(%W{127.0.0.3 127.0.0.2}).to include d1.spawn['url'].split( ':' ).first
222
+ expect(d2.spawn(strategy: :horizontal )['url'].split( ':' ).first).to eq(preferred)
223
+ expect(%W{127.0.0.1 127.0.0.3}).to include d3.spawn(strategy: :horizontal )['url'].split( ':' ).first
224
+ expect(%W{127.0.0.2 127.0.0.3}).to include d3.spawn(strategy: :horizontal )['url'].split( ':' ).first
225
+ expect(%W{127.0.0.2 127.0.0.3}).to include d1.spawn(strategy: :horizontal )['url'].split( ':' ).first
226
226
  end
227
227
  end
228
228
 
229
229
  context :vertical do
230
- it 'provides Instances from the most burdened Dispatcher' do
231
- d1 = dispatcher_spawn(
230
+ it 'provides Instances from the most burdened Agent' do
231
+ d1 = agent_spawn(
232
232
  address: '127.0.0.1',
233
233
  application: "#{fixtures_path}/mock_app.rb"
234
234
  )
235
235
 
236
236
  3.times do
237
- d1.dispatch( load_balance: false )
237
+ d1.spawn( load_balance: false )
238
238
  end
239
239
 
240
- d2 = dispatcher_spawn(
240
+ d2 = agent_spawn(
241
241
  address: '127.0.0.2',
242
- neighbour: d1.url,
242
+ peer: d1.url,
243
243
  application: "#{fixtures_path}/mock_app.rb"
244
244
  )
245
245
 
246
246
  2.times do
247
- d2.dispatch( load_balance: false )
247
+ d2.spawn( load_balance: false )
248
248
  end
249
249
 
250
- d3 = dispatcher_spawn(
250
+ d3 = agent_spawn(
251
251
  address: '127.0.0.3',
252
- neighbour: d1.url,
252
+ peer: d1.url,
253
253
  application: "#{fixtures_path}/mock_app.rb"
254
254
  )
255
- d3.dispatch( load_balance: false )
255
+ d3.spawn( load_balance: false )
256
256
 
257
257
  preferred = d1.url.split( ':' ).first
258
- expect(d3.dispatch( strategy: :vertical )['url'].split( ':' ).first).to eq(preferred)
258
+ expect(d3.spawn( strategy: :vertical )['url'].split( ':' ).first).to eq(preferred)
259
259
  end
260
260
  end
261
261
 
262
262
  context 'default' do
263
- it 'provides Instances from the least burdened Dispatcher' do
264
- d1 = dispatcher_spawn(
263
+ it 'provides Instances from the least burdened Agent' do
264
+ d1 = agent_spawn(
265
265
  address: '127.0.0.1',
266
266
  application: "#{fixtures_path}/mock_app.rb"
267
267
  )
268
268
 
269
269
  3.times do
270
- d1.dispatch( load_balance: false )
270
+ d1.spawn( load_balance: false )
271
271
  end
272
272
 
273
- d2 = dispatcher_spawn(
273
+ d2 = agent_spawn(
274
274
  address: '127.0.0.2',
275
- neighbour: d1.url,
275
+ peer: d1.url,
276
276
  application: "#{fixtures_path}/mock_app.rb"
277
277
  )
278
278
 
279
279
  2.times do
280
- d2.dispatch( load_balance: false )
280
+ d2.spawn( load_balance: false )
281
281
  end
282
282
 
283
- d3 = dispatcher_spawn(
283
+ d3 = agent_spawn(
284
284
  address: '127.0.0.3',
285
- neighbour: d1.url,
285
+ peer: d1.url,
286
286
  application: "#{fixtures_path}/mock_app.rb"
287
287
  )
288
- d3.dispatch( load_balance: false )
288
+ d3.spawn( load_balance: false )
289
289
  preferred = d3.url.split( ':' ).first
290
290
 
291
- expect(d3.dispatch['url'].split( ':' ).first).to eq(preferred)
292
- expect(%W{127.0.0.3 127.0.0.2}).to include d1.dispatch['url'].split( ':' ).first
293
- expect(d2.dispatch['url'].split( ':' ).first).to eq(preferred)
294
- expect(%W{127.0.0.1 127.0.0.3}).to include d3.dispatch['url'].split( ':' ).first
295
- expect(%W{127.0.0.2 127.0.0.3}).to include d3.dispatch['url'].split( ':' ).first
296
- expect(%W{127.0.0.2 127.0.0.3}).to include d1.dispatch['url'].split( ':' ).first
291
+ expect(d3.spawn['url'].split( ':' ).first).to eq(preferred)
292
+ expect(%W{127.0.0.3 127.0.0.2}).to include d1.spawn['url'].split( ':' ).first
293
+ expect(d2.spawn['url'].split( ':' ).first).to eq(preferred)
294
+ expect(%W{127.0.0.1 127.0.0.3}).to include d3.spawn['url'].split( ':' ).first
295
+ expect(%W{127.0.0.2 127.0.0.3}).to include d3.spawn['url'].split( ':' ).first
296
+ expect(%W{127.0.0.2 127.0.0.3}).to include d1.spawn['url'].split( ':' ).first
297
297
  end
298
298
  end
299
299
 
300
300
  context 'other' do
301
301
  it 'returns :error_unknown_strategy' do
302
- expect(dispatcher_spawn( neighbour: subject.url ).
303
- dispatch( strategy: 'blah' )).to eq('error_unknown_strategy')
302
+ expect(agent_spawn( peer: subject.url ).
303
+ spawn( strategy: 'blah' )).to eq('error_unknown_strategy')
304
304
  end
305
305
  end
306
306
  end
307
307
 
308
308
  context 'when the load-balance option is set to false' do
309
- it 'returns an Instance from the requested Dispatcher' do
310
- d1 = dispatcher_spawn(
309
+ it 'returns an Instance from the requested Agent' do
310
+ d1 = agent_spawn(
311
311
  address: '127.0.0.1',
312
312
  application: "#{fixtures_path}/mock_app.rb"
313
313
  )
314
314
 
315
- d1.dispatch( load_balance: false )
315
+ d1.spawn( load_balance: false )
316
316
 
317
- d2 = dispatcher_spawn(
317
+ d2 = agent_spawn(
318
318
  address: '127.0.0.2',
319
- neighbour: d1.url,
319
+ peer: d1.url,
320
320
  application: "#{fixtures_path}/mock_app.rb"
321
321
  )
322
- d2.dispatch( load_balance: false )
322
+ d2.spawn( load_balance: false )
323
323
 
324
- d3 = dispatcher_spawn(
324
+ d3 = agent_spawn(
325
325
  address: '127.0.0.3',
326
- neighbour: d1.url,
326
+ peer: d1.url,
327
327
  application: "#{fixtures_path}/mock_app.rb"
328
328
  )
329
329
  2.times do
330
- d3.dispatch( load_balance: false )
330
+ d3.spawn( load_balance: false )
331
331
  end
332
332
 
333
- expect(d3.dispatch( load_balance: false )['url'].
333
+ expect(d3.spawn( load_balance: false )['url'].
334
334
  split( ':' ).first).to eq('127.0.0.3')
335
335
  end
336
336
  end
@@ -339,7 +339,7 @@ describe Cuboid::RPC::Server::Dispatcher do
339
339
 
340
340
  describe '#instance' do
341
341
  it 'returns proc info by PID' do
342
- instance = subject.dispatch( owner: 'rspec' )
342
+ instance = subject.spawn( owner: 'rspec' )
343
343
  info = subject.instance( instance['pid'] )
344
344
  instance_info_keys.each do |k|
345
345
  expect(info[k]).to be_truthy
@@ -349,7 +349,7 @@ describe Cuboid::RPC::Server::Dispatcher do
349
349
 
350
350
  describe '#instances' do
351
351
  it 'returns proc info by PID for all instances' do
352
- slots.times { subject.dispatch( owner: 'rspec' ) }
352
+ slots.times { subject.spawn( owner: 'rspec' ) }
353
353
 
354
354
  subject.instances.each do |instance|
355
355
  instance_info_keys.each do |k|
@@ -361,7 +361,7 @@ describe Cuboid::RPC::Server::Dispatcher do
361
361
 
362
362
  describe '#running_instances' do
363
363
  it 'returns proc info for running instances' do
364
- slots.times { subject.dispatch }
364
+ slots.times { subject.spawn }
365
365
 
366
366
  expect(subject.running_instances.size).to eq(slots)
367
367
  end
@@ -369,7 +369,7 @@ describe Cuboid::RPC::Server::Dispatcher do
369
369
 
370
370
  describe '#finished_instances' do
371
371
  it 'returns proc info for finished instances' do
372
- 3.times { Cuboid::Processes::Manager.kill subject.dispatch['pid'] }
372
+ 3.times { Cuboid::Processes::Manager.kill subject.spawn['pid'] }
373
373
 
374
374
  expect(subject.finished_instances.size).to eq(3)
375
375
  end
@@ -378,7 +378,7 @@ describe Cuboid::RPC::Server::Dispatcher do
378
378
  describe '#utilization' do
379
379
  it 'returns a float signifying the amount of workload' do
380
380
  3.times do
381
- subject.dispatch
381
+ subject.spawn
382
382
  end
383
383
 
384
384
  expect(subject.utilization).to eq(3 / Float(slots))
@@ -387,7 +387,7 @@ describe Cuboid::RPC::Server::Dispatcher do
387
387
 
388
388
  describe '#statistics' do
389
389
  it 'returns general statistics' do
390
- subject.dispatch
390
+ subject.spawn
391
391
  instances = subject.instances
392
392
  Cuboid::Processes::Manager.kill( instances.first['pid'] )
393
393
 
@@ -406,7 +406,7 @@ describe Cuboid::RPC::Server::Dispatcher do
406
406
 
407
407
  context 'when there are snapshots' do
408
408
  it 'lists them' do
409
- info = subject.dispatch
409
+ info = subject.spawn
410
410
 
411
411
  instance = Cuboid::RPC::Client::Instance.new(
412
412
  info['url'], info['token']
@@ -52,20 +52,20 @@ describe Cuboid::RPC::Server::Scheduler do
52
52
  end
53
53
  end
54
54
 
55
- context 'when a Dispatcher has been set' do
56
- subject { Cuboid::Processes::Schedulers.spawn dispatcher: dispatcher.url }
57
- let(:dispatcher) do
58
- Cuboid::Processes::Dispatchers.spawn( application: "#{fixtures_path}/mock_app.rb" )
55
+ context 'when a Agent has been set' do
56
+ subject { Cuboid::Processes::Schedulers.spawn agent: agent.url }
57
+ let(:agent) do
58
+ Cuboid::Processes::Agents.spawn( application: "#{fixtures_path}/mock_app.rb" )
59
59
  end
60
60
 
61
61
  it 'gets Instances from it' do
62
- expect(dispatcher.finished_instances).to be_empty
62
+ expect(agent.finished_instances).to be_empty
63
63
 
64
64
  subject.push( options )
65
65
  sleep 0.1 while subject.completed.empty?
66
66
  sleep 2
67
67
 
68
- expect(dispatcher.finished_instances).to be_any
68
+ expect(agent.finished_instances).to be_any
69
69
  end
70
70
 
71
71
  it 'sets OptionGroups::Scheduler#url' do
@@ -80,7 +80,7 @@ describe Cuboid::RPC::Server::Scheduler do
80
80
  it 'does not consume the queue' do
81
81
  subject
82
82
 
83
- Cuboid::Processes::Dispatchers.killall
83
+ Cuboid::Processes::Agents.killall
84
84
  sleep 3
85
85
 
86
86
  expect(subject.size).to be 0
@@ -89,7 +89,7 @@ describe Cuboid::RPC::Server::Scheduler do
89
89
  sleep 5
90
90
 
91
91
  expect(subject.size).to be 1
92
- expect(subject.errors.join("\n")).to include "Failed to contact Dispatcher at: #{dispatcher.url}"
92
+ expect(subject.errors.join("\n")).to include "Failed to contact Agent at: #{agent.url}"
93
93
  end
94
94
  end
95
95
  end
@@ -1,14 +1,14 @@
1
1
  require Options.paths.lib + 'ui/output'
2
- require Options.paths.lib + 'rpc/server/dispatcher'
2
+ require Options.paths.lib + 'rpc/server/agent'
3
3
  require Options.paths.lib + 'processes/manager'
4
4
 
5
- class Node < Cuboid::RPC::Server::Dispatcher::Node
5
+ class Node < Cuboid::RPC::Server::Agent::Node
6
6
 
7
7
  def initialize
8
8
  @options = Options.instance
9
9
 
10
10
  methods.each do |m|
11
- next if method( m ).owner != Cuboid::RPC::Server::Dispatcher::Node
11
+ next if method( m ).owner != Cuboid::RPC::Server::Agent::Node
12
12
  self.class.send :private, m
13
13
  self.class.send :public, m
14
14
  end
@@ -1,20 +1,20 @@
1
- require 'cuboid/rpc/server/dispatcher'
1
+ require 'cuboid/rpc/server/agent'
2
2
 
3
- class TestService < Cuboid::RPC::Server::Dispatcher::Service
3
+ class TestService < Cuboid::RPC::Server::Agent::Service
4
4
 
5
5
  private :instances
6
6
  public :instances
7
7
 
8
- def test_dispatcher
9
- dispatcher.class == Cuboid::RPC::Server::Dispatcher
8
+ def test_agent
9
+ agent.class == Cuboid::RPC::Server::Agent
10
10
  end
11
11
 
12
12
  def test_opts
13
- dispatcher.instance_eval{ @options } == options
13
+ agent.instance_eval{ @options } == options
14
14
  end
15
15
 
16
16
  def test_node
17
- node.class == Cuboid::RPC::Server::Dispatcher::Node
17
+ node.class == Cuboid::RPC::Server::Agent::Node
18
18
  end
19
19
 
20
20
  def test_map_instances( &block )
@@ -39,8 +39,8 @@ class TestService < Cuboid::RPC::Server::Dispatcher::Service
39
39
  iterator_for( instances ).class == Arachni::Reactor::Iterator
40
40
  end
41
41
 
42
- def test_connect_to_dispatcher( url, &block )
43
- connect_to_dispatcher( url ).alive? { |b| block.call b }
42
+ def test_connect_to_agent( url, &block )
43
+ connect_to_agent( url ).alive? { |b| block.call b }
44
44
  end
45
45
 
46
46
  def test_connect_to_instance( *args, &block )
@@ -21,7 +21,7 @@ class MockApp < Cuboid::Application
21
21
  # RPC, report and snapshot file.
22
22
  serialize_with Marshal
23
23
 
24
- dispatcher_service_for :test_service, TestService
24
+ agent_service_for :test_service, TestService
25
25
 
26
26
  # Execution entry point.
27
27
  def run
@@ -1,15 +1,15 @@
1
- class Cuboid::RPC::Server::Dispatcher
1
+ class Cuboid::RPC::Server::Agent
2
2
  class Service::Echo < Service
3
3
 
4
4
  private :instances
5
5
  public :instances
6
6
 
7
- def test_dispatcher
8
- dispatcher.class == Cuboid::RPC::Server::Dispatcher
7
+ def test_agent
8
+ agent.class == Cuboid::RPC::Server::Agent
9
9
  end
10
10
 
11
11
  def test_opts
12
- dispatcher.instance_eval{ @options } == options
12
+ agent.instance_eval{ @options } == options
13
13
  end
14
14
 
15
15
  def test_node
@@ -38,8 +38,8 @@ class Service::Echo < Service
38
38
  iterator_for( instances ).class == Arachni::Reactor::Iterator
39
39
  end
40
40
 
41
- def test_connect_to_dispatcher( url, &block )
42
- connect_to_dispatcher( url ).alive? { |b| block.call b }
41
+ def test_connect_to_agent( url, &block )
42
+ connect_to_agent( url ).alive? { |b| block.call b }
43
43
  end
44
44
 
45
45
  def test_connect_to_instance( *args, &block )
@@ -40,7 +40,7 @@ end
40
40
 
41
41
  def processes_killall
42
42
  instance_killall
43
- dispatcher_killall
43
+ agent_killall
44
44
  scheduler_killall
45
45
  process_killall
46
46
  process_kill_reactor
@@ -2,9 +2,9 @@ require 'arachni/rpc'
2
2
 
3
3
  # @note Needs `ENV['WEB_SERVER_DISPATCHER']` in the format of `host:port`.
4
4
  #
5
- # {WebServerManager}-API-compatible client for the {WebServerDispatcher}.
5
+ # {WebServerManager}-API-compatible client for the {WebServerAgent}.
6
6
  #
7
- # Delegates test webserver creation to the machine running {WebServerDispatcher},
7
+ # Delegates test webserver creation to the machine running {WebServerAgent},
8
8
  # for hosts that lack support for fast servers (like Windows, which can't run
9
9
  # Thin, Puma etc.).
10
10
  #
@@ -9,7 +9,7 @@ require 'arachni/rpc'
9
9
  # Exposes the {WebServerManager} over RPC.
10
10
  #
11
11
  # @author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
12
- class WebServerDispatcher
12
+ class WebServerAgent
13
13
 
14
14
  def initialize( options = {} )
15
15
  host, port = ENV['WEB_SERVER_DISPATCHER'].split( ':' )