turbo_test 0.1.0 → 0.1.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 +4 -4
- data/lib/turbo_test/command/run.rb +1 -6
- data/lib/turbo_test/server.rb +37 -12
- data/lib/turbo_test/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f598fcd0bc09d2a885b3d0440eabbfa54c2718fae7f39d9f8b853fa37503474
|
4
|
+
data.tar.gz: 348390cf74c0b7ba9c05d806eb2e84dd9571b3851cac2ae6dfd98898d2531a35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2afcc1b037df3aa41ba017861939fbfff7fe7ff9e861026f56aa3771504344e6b2de58b4eecccfa963e1bca9688e789d931c7a51c2949353526a99e6847017ad
|
7
|
+
data.tar.gz: 4b1270405702e4f9ccdd736c6bdbcfd75e61fa02bcc0080b1317cc1c21d42f2152cc8fc1cd8cee3e3013538f54dbf2f369f281239739788e7ee3bac88fac74ec
|
data/lib/turbo_test/server.rb
CHANGED
@@ -24,6 +24,9 @@ require 'async'
|
|
24
24
|
require 'async/container'
|
25
25
|
require 'async/io/unix_endpoint'
|
26
26
|
require 'async/io/shared_endpoint'
|
27
|
+
|
28
|
+
require 'async/io/threads'
|
29
|
+
|
27
30
|
require 'msgpack'
|
28
31
|
|
29
32
|
module TurboTest
|
@@ -49,14 +52,10 @@ module TurboTest
|
|
49
52
|
class Server
|
50
53
|
def initialize(configuration, endpoint = nil)
|
51
54
|
@configuration = configuration
|
52
|
-
@endpoint = endpoint || Async::IO::Endpoint.unix(
|
55
|
+
@endpoint = endpoint || Async::IO::Endpoint.unix("turbo_test-#{Process.pid}.ipc")
|
53
56
|
@wrapper = Wrapper.new
|
54
57
|
|
55
58
|
@container = Async::Container.new
|
56
|
-
|
57
|
-
@bound_endpoint = Sync do
|
58
|
-
Async::IO::SharedEndpoint.bound(@endpoint)
|
59
|
-
end
|
60
59
|
end
|
61
60
|
|
62
61
|
def host(queue)
|
@@ -73,9 +72,13 @@ module TurboTest
|
|
73
72
|
}
|
74
73
|
|
75
74
|
Async do |task|
|
75
|
+
bound_endpoint = Sync do
|
76
|
+
Async::IO::SharedEndpoint.bound(@endpoint)
|
77
|
+
end
|
78
|
+
|
76
79
|
instance.ready!
|
77
80
|
|
78
|
-
|
81
|
+
bound_endpoint.accept do |peer|
|
79
82
|
# Console.logger.info(self) {"Incoming connection from #{peer}..."}
|
80
83
|
|
81
84
|
packer = @wrapper.packer(peer)
|
@@ -123,8 +126,9 @@ module TurboTest
|
|
123
126
|
end
|
124
127
|
end
|
125
128
|
end
|
129
|
+
|
130
|
+
bound_endpoint.close
|
126
131
|
end
|
127
|
-
|
128
132
|
ensure
|
129
133
|
Console.logger.info("Writing results")
|
130
134
|
@wrapper.packer(output).write(statistics).flush
|
@@ -159,8 +163,9 @@ module TurboTest
|
|
159
163
|
def workers
|
160
164
|
@container.run(name: "#{self.class} Worker") do |instance|
|
161
165
|
Async do |task|
|
166
|
+
sleep(rand)
|
162
167
|
@endpoint.connect do |peer|
|
163
|
-
|
168
|
+
threads = Async::IO::Threads.new
|
164
169
|
|
165
170
|
packer = @wrapper.packer(peer)
|
166
171
|
unpacker = @wrapper.unpacker(peer)
|
@@ -168,6 +173,8 @@ module TurboTest
|
|
168
173
|
packer.write([:ready])
|
169
174
|
packer.flush
|
170
175
|
|
176
|
+
instance.ready!
|
177
|
+
|
171
178
|
unpacker.each do |message|
|
172
179
|
command, tail = message
|
173
180
|
|
@@ -178,10 +185,14 @@ module TurboTest
|
|
178
185
|
klass, *arguments = *tail
|
179
186
|
|
180
187
|
begin
|
181
|
-
|
188
|
+
# We run this in a separate thread to keep it isolated from the worker loop:
|
189
|
+
result = threads.async do
|
190
|
+
klass.new(*arguments).call(packer: packer)
|
191
|
+
end.wait
|
192
|
+
|
182
193
|
packer.write([:result, result])
|
183
194
|
rescue Exception => exception
|
184
|
-
packer.write([:error, exception, exception.backtrace])
|
195
|
+
packer.write([:error, exception.class, exception.backtrace])
|
185
196
|
end
|
186
197
|
|
187
198
|
packer.write([:ready])
|
@@ -191,13 +202,27 @@ module TurboTest
|
|
191
202
|
end
|
192
203
|
end
|
193
204
|
end
|
205
|
+
rescue Errno::ECONNREFUSED
|
206
|
+
# Host is finished already.
|
194
207
|
end
|
195
208
|
end
|
196
209
|
end
|
197
210
|
|
198
|
-
def
|
211
|
+
def run(queue)
|
212
|
+
# Start the host:
|
213
|
+
results = self.host(queue)
|
214
|
+
|
215
|
+
# Wait until the host is ready:
|
216
|
+
@container.wait_until_ready
|
217
|
+
|
218
|
+
# Start the workers:
|
219
|
+
self.workers
|
220
|
+
|
221
|
+
# Wait for the container to finish:
|
199
222
|
@container.wait
|
200
|
-
|
223
|
+
|
224
|
+
# Read the results from the host:
|
225
|
+
return results.read
|
201
226
|
end
|
202
227
|
end
|
203
228
|
end
|
data/lib/turbo_test/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-container
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
120
|
+
rubygems_version: 3.2.3
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Press the turbo button... for your tests.
|