scout-gear 5.2.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.vimproject +14 -8
- data/VERSION +1 -1
- data/lib/scout/exceptions.rb +14 -2
- data/lib/scout/log/color.rb +34 -10
- data/lib/scout/log/progress/report.rb +5 -4
- data/lib/scout/misc/monitor.rb +18 -0
- data/lib/scout/open/stream.rb +30 -0
- data/lib/scout/semaphore.rb +148 -0
- data/lib/scout/work_queue/socket.rb +119 -0
- data/lib/scout/work_queue/worker.rb +54 -0
- data/lib/scout/work_queue.rb +86 -0
- data/lib/scout/workflow/step/info.rb +2 -2
- data/scout-gear.gemspec +14 -3
- data/share/color/color_names +507 -0
- data/share/color/diverging_colors.hex +12 -0
- data/test/scout/log/test_color.rb +0 -0
- data/test/scout/test_semaphore.rb +17 -0
- data/test/scout/test_work_queue.rb +93 -0
- data/test/scout/work_queue/test_socket.rb +46 -0
- data/test/scout/work_queue/test_worker.rb +99 -0
- metadata +13 -2
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
class TestSocket < Test::Unit::TestCase
|
5
|
+
def test_simple
|
6
|
+
socket = WorkQueue::Socket.new
|
7
|
+
|
8
|
+
socket.write 1
|
9
|
+
socket.write 2
|
10
|
+
socket.write "STRING"
|
11
|
+
socket.write :string
|
12
|
+
|
13
|
+
assert_equal 1, socket.read
|
14
|
+
assert_equal 2, socket.read
|
15
|
+
assert_equal "STRING", socket.read
|
16
|
+
assert_equal :string, socket.read
|
17
|
+
|
18
|
+
socket.close_write
|
19
|
+
assert_raise ClosedStream do
|
20
|
+
socket.read
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def __test_speed
|
25
|
+
sss 0
|
26
|
+
socket = WorkQueue::Socket.new
|
27
|
+
|
28
|
+
num = 10_000
|
29
|
+
|
30
|
+
Thread.new do
|
31
|
+
num.times do |i|
|
32
|
+
socket.write nil
|
33
|
+
end
|
34
|
+
socket.write DoneProcessing.new
|
35
|
+
end
|
36
|
+
|
37
|
+
bar = Log::ProgressBar.new num
|
38
|
+
while true
|
39
|
+
i = socket.read
|
40
|
+
bar.tick
|
41
|
+
break if DoneProcessing === i
|
42
|
+
end
|
43
|
+
bar.done
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
require 'scout/semaphore'
|
5
|
+
require 'scout/work_queue/socket'
|
6
|
+
class TestQueueWorker < Test::Unit::TestCase
|
7
|
+
def test_simple
|
8
|
+
worker = WorkQueue::Worker.new
|
9
|
+
TmpFile.with_file do |file|
|
10
|
+
worker.run do
|
11
|
+
Open.write file, "TEST"
|
12
|
+
end
|
13
|
+
worker.join
|
14
|
+
|
15
|
+
assert_equal "TEST", Open.read(file)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_semaphore
|
20
|
+
ScoutSemaphore.with_semaphore 1 do |sem|
|
21
|
+
|
22
|
+
TmpFile.with_file do |outfile|
|
23
|
+
2.times do
|
24
|
+
sout = Open.open_pipe do |sin|
|
25
|
+
workers = 100.times.collect{ WorkQueue::Worker.new }
|
26
|
+
workers.each do |w|
|
27
|
+
w.run do
|
28
|
+
ScoutSemaphore.synchronize(sem) do
|
29
|
+
10.times do
|
30
|
+
sin.puts Process.pid
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
WorkQueue::Worker.join(workers)
|
37
|
+
end
|
38
|
+
Open.consume_stream(sout, false, outfile)
|
39
|
+
pid_list = Open.read(outfile).split("\n")
|
40
|
+
|
41
|
+
assert_nothing_raised do
|
42
|
+
seen = []
|
43
|
+
current = nil
|
44
|
+
pid_list.each do |pid|
|
45
|
+
if pid != current
|
46
|
+
raise "Out of order" if seen.include? pid
|
47
|
+
end
|
48
|
+
current = pid
|
49
|
+
seen << pid
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_process
|
58
|
+
input = WorkQueue::Socket.new
|
59
|
+
output = WorkQueue::Socket.new
|
60
|
+
|
61
|
+
workers = 10.times.collect{ WorkQueue::Worker.new }
|
62
|
+
workers.each do |w|
|
63
|
+
w.process(input, output) do |obj|
|
64
|
+
[Process.pid, obj.inspect] * " "
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
read = Thread.new do
|
69
|
+
begin
|
70
|
+
while obj = output.read
|
71
|
+
if DoneProcessing === obj
|
72
|
+
pid = obj.pid
|
73
|
+
workers.delete_if{|w| w.pid = pid }
|
74
|
+
break if workers.empty?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
write = Thread.new do
|
81
|
+
100.times do |i|
|
82
|
+
input.write i
|
83
|
+
end
|
84
|
+
10.times do
|
85
|
+
input.write DoneProcessing.new
|
86
|
+
end
|
87
|
+
input.close_write
|
88
|
+
end
|
89
|
+
|
90
|
+
write.join
|
91
|
+
read.join
|
92
|
+
|
93
|
+
WorkQueue::Worker.join workers
|
94
|
+
input.clean
|
95
|
+
output.clean
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout-gear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/scout/resource/produce/rake.rb
|
139
139
|
- lib/scout/resource/scout.rb
|
140
140
|
- lib/scout/resource/util.rb
|
141
|
+
- lib/scout/semaphore.rb
|
141
142
|
- lib/scout/simple_opt.rb
|
142
143
|
- lib/scout/simple_opt/accessor.rb
|
143
144
|
- lib/scout/simple_opt/doc.rb
|
@@ -145,6 +146,9 @@ files:
|
|
145
146
|
- lib/scout/simple_opt/parse.rb
|
146
147
|
- lib/scout/simple_opt/setup.rb
|
147
148
|
- lib/scout/tmpfile.rb
|
149
|
+
- lib/scout/work_queue.rb
|
150
|
+
- lib/scout/work_queue/socket.rb
|
151
|
+
- lib/scout/work_queue/worker.rb
|
148
152
|
- lib/scout/workflow.rb
|
149
153
|
- lib/scout/workflow/definition.rb
|
150
154
|
- lib/scout/workflow/documentation.rb
|
@@ -165,8 +169,11 @@ files:
|
|
165
169
|
- scout_commands/workflow/list
|
166
170
|
- scout_commands/workflow/task
|
167
171
|
- scout_commands/workflow/task_old
|
172
|
+
- share/color/color_names
|
173
|
+
- share/color/diverging_colors.hex
|
168
174
|
- test/scout/indiferent_hash/test_case_insensitive.rb
|
169
175
|
- test/scout/indiferent_hash/test_options.rb
|
176
|
+
- test/scout/log/test_color.rb
|
170
177
|
- test/scout/log/test_progress.rb
|
171
178
|
- test/scout/misc/test_digest.rb
|
172
179
|
- test/scout/misc/test_filesystem.rb
|
@@ -197,8 +204,12 @@ files:
|
|
197
204
|
- test/scout/test_path.rb
|
198
205
|
- test/scout/test_persist.rb
|
199
206
|
- test/scout/test_resource.rb
|
207
|
+
- test/scout/test_semaphore.rb
|
200
208
|
- test/scout/test_tmpfile.rb
|
209
|
+
- test/scout/test_work_queue.rb
|
201
210
|
- test/scout/test_workflow.rb
|
211
|
+
- test/scout/work_queue/test_socket.rb
|
212
|
+
- test/scout/work_queue/test_worker.rb
|
202
213
|
- test/scout/workflow/step/test_info.rb
|
203
214
|
- test/scout/workflow/step/test_load.rb
|
204
215
|
- test/scout/workflow/task/test_inputs.rb
|