scout-gear 6.0.0 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.vimproject +465 -432
- data/VERSION +1 -1
- data/bin/scout +5 -1
- data/lib/rbbt-scout.rb +5 -0
- data/lib/scout/concurrent_stream.rb +6 -2
- data/lib/scout/config.rb +168 -0
- data/lib/scout/exceptions.rb +9 -0
- data/lib/scout/indiferent_hash/options.rb +1 -0
- data/lib/scout/indiferent_hash.rb +4 -2
- data/lib/scout/log/color.rb +31 -2
- data/lib/scout/log/progress/report.rb +1 -0
- data/lib/scout/log/progress/util.rb +3 -1
- data/lib/scout/log/progress.rb +7 -3
- data/lib/scout/log.rb +8 -3
- data/lib/scout/misc/digest.rb +1 -3
- data/lib/scout/misc/monitor.rb +3 -0
- data/lib/scout/misc/system.rb +15 -0
- data/lib/scout/misc.rb +1 -0
- data/lib/scout/named_array.rb +68 -0
- data/lib/scout/open/stream.rb +58 -26
- data/lib/scout/path/find.rb +27 -3
- data/lib/scout/path/util.rb +7 -4
- data/lib/scout/persist/serialize.rb +7 -14
- data/lib/scout/persist.rb +21 -1
- data/lib/scout/resource/produce.rb +7 -94
- data/lib/scout/resource/software.rb +176 -0
- data/lib/scout/tsv/dumper.rb +107 -0
- data/lib/scout/tsv/index.rb +49 -0
- data/lib/scout/tsv/parser.rb +317 -0
- data/lib/scout/tsv/path.rb +13 -0
- data/lib/scout/tsv/persist/adapter.rb +348 -0
- data/lib/scout/tsv/persist/tokyocabinet.rb +113 -0
- data/lib/scout/tsv/persist.rb +15 -0
- data/lib/scout/tsv/traverse.rb +48 -0
- data/lib/scout/tsv/util.rb +24 -0
- data/lib/scout/tsv.rb +27 -0
- data/lib/scout/work_queue/worker.rb +16 -11
- data/lib/scout/work_queue.rb +63 -21
- data/lib/scout/workflow/definition.rb +93 -4
- data/lib/scout/workflow/step/config.rb +18 -0
- data/lib/scout/workflow/step/dependencies.rb +40 -0
- data/lib/scout/workflow/step/file.rb +15 -0
- data/lib/scout/workflow/step/info.rb +33 -6
- data/lib/scout/workflow/step/provenance.rb +148 -0
- data/lib/scout/workflow/step.rb +70 -20
- data/lib/scout/workflow/task.rb +5 -4
- data/lib/scout/workflow/usage.rb +1 -1
- data/lib/scout/workflow.rb +11 -3
- data/lib/scout-gear.rb +1 -0
- data/lib/scout.rb +1 -0
- data/scout-gear.gemspec +38 -3
- data/scout_commands/find +1 -1
- data/scout_commands/workflow/task +16 -10
- data/share/software/install_helpers +523 -0
- data/test/scout/log/test_progress.rb +0 -2
- data/test/scout/misc/test_system.rb +21 -0
- data/test/scout/open/test_stream.rb +160 -1
- data/test/scout/path/test_find.rb +14 -7
- data/test/scout/resource/test_software.rb +24 -0
- data/test/scout/test_config.rb +66 -0
- data/test/scout/test_meta_extension.rb +10 -0
- data/test/scout/test_named_array.rb +19 -0
- data/test/scout/test_persist.rb +35 -0
- data/test/scout/test_semaphore.rb +1 -1
- data/test/scout/test_tmpfile.rb +2 -2
- data/test/scout/test_tsv.rb +74 -0
- data/test/scout/test_work_queue.rb +63 -8
- data/test/scout/tsv/persist/test_adapter.rb +34 -0
- data/test/scout/tsv/persist/test_tokyocabinet.rb +92 -0
- data/test/scout/tsv/test_dumper.rb +44 -0
- data/test/scout/tsv/test_index.rb +64 -0
- data/test/scout/tsv/test_parser.rb +173 -0
- data/test/scout/tsv/test_persist.rb +36 -0
- data/test/scout/tsv/test_traverse.rb +9 -0
- data/test/scout/tsv/test_util.rb +0 -0
- data/test/scout/work_queue/test_worker.rb +49 -1
- data/test/scout/workflow/step/test_dependencies.rb +25 -0
- data/test/scout/workflow/step/test_info.rb +15 -17
- data/test/scout/workflow/step/test_load.rb +16 -18
- data/test/scout/workflow/step/test_provenance.rb +25 -0
- data/test/scout/workflow/test_step.rb +206 -10
- data/test/scout/workflow/test_task.rb +0 -3
- data/test/test_helper.rb +6 -0
- metadata +37 -2
@@ -0,0 +1,92 @@
|
|
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/tsv'
|
5
|
+
|
6
|
+
class TestTSVTokyo < Test::Unit::TestCase
|
7
|
+
def test_tokyo
|
8
|
+
content =<<-'EOF'
|
9
|
+
#: :sep=/\s+/#:type=:double#:merge=:concat
|
10
|
+
#Id ValueA ValueB OtherID
|
11
|
+
row1 a|aa|aaa b Id1|Id2
|
12
|
+
row2 A B Id3
|
13
|
+
row2 a a id3
|
14
|
+
EOF
|
15
|
+
|
16
|
+
tsv = TmpFile.with_file(content) do |filename|
|
17
|
+
Persist.persist(__method__, :HDB) do
|
18
|
+
TSV.open(filename)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
assert_equal %w(a aa aaa), tsv["row1"][0]
|
23
|
+
|
24
|
+
tsv_loaded = assert_nothing_raised do
|
25
|
+
TmpFile.with_file(content) do |filename|
|
26
|
+
Persist.persist(__method__, :HDB) do
|
27
|
+
raise
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_equal %w(a aa aaa), tsv_loaded["row1"][0]
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_custom_load
|
36
|
+
tsv = TSV.setup({}, :type => :double, :key_field => "Key", :fields => %w(Field1 Field2))
|
37
|
+
|
38
|
+
size = 100_000
|
39
|
+
(0..size).each do |i|
|
40
|
+
k = "key-#{i}"
|
41
|
+
values1 = 3.times.collect{|j| "value-#{i}-1-#{j}" }
|
42
|
+
values2 = 5.times.collect{|j| "value-#{i}-2-#{j}" }
|
43
|
+
|
44
|
+
tsv[k] = [values1, values2]
|
45
|
+
end
|
46
|
+
|
47
|
+
tc = Persist.persist(__method__, :HDB) do |file|
|
48
|
+
tsv
|
49
|
+
end
|
50
|
+
|
51
|
+
100.times do
|
52
|
+
i = rand(size).floor
|
53
|
+
assert_equal tc["key-#{i}"], tsv["key-#{i}"]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_speed
|
58
|
+
tsv = TSV.setup({}, :type => :double, :key_field => "Key", :fields => %w(Field1 Field2))
|
59
|
+
|
60
|
+
size = 100_000
|
61
|
+
(0..size).each do |i|
|
62
|
+
k = "key-#{i}"
|
63
|
+
values1 = 3.times.collect{|j| "value-#{i}-1-#{j}" }
|
64
|
+
values2 = 5.times.collect{|j| "value-#{i}-2-#{j}" }
|
65
|
+
|
66
|
+
tsv[k] = [values1, values2]
|
67
|
+
end
|
68
|
+
|
69
|
+
tc = Persist.persist(__method__, :HDB) do |file|
|
70
|
+
data = ScoutCabinet.open(file, true, "HDB")
|
71
|
+
TSV.setup(data, :type => :double, :key_field => "Key", :fields => %w(Field1 Field2))
|
72
|
+
data.extend TSVAdapter
|
73
|
+
Log::ProgressBar.with_bar size do |b|
|
74
|
+
(0..size).each do |i|
|
75
|
+
b.tick
|
76
|
+
k = "key-#{i}"
|
77
|
+
values1 = 3.times.collect{|j| "value-#{i}-1-#{j}" }
|
78
|
+
values2 = 5.times.collect{|j| "value-#{i}-2-#{j}" }
|
79
|
+
|
80
|
+
data[k] = [values1, values2]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
data
|
84
|
+
end
|
85
|
+
|
86
|
+
100.times do
|
87
|
+
i = rand(size).floor
|
88
|
+
assert_equal tc["key-#{i}"], tsv["key-#{i}"]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
@@ -0,0 +1,44 @@
|
|
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/tsv'
|
5
|
+
|
6
|
+
class TestTSVDumper < Test::Unit::TestCase
|
7
|
+
def test_dumper
|
8
|
+
dumper = TSV::Dumper.new :key_field => "Key", :fields => %w(Field1 Field2), :type => :double
|
9
|
+
dumper.init
|
10
|
+
dumper.add "a", [["1", "11"], ["2", "22"]]
|
11
|
+
txt=<<-EOF
|
12
|
+
#: :type=:double
|
13
|
+
#Key\tField1\tField2
|
14
|
+
a\t1|11\t2|22
|
15
|
+
EOF
|
16
|
+
dumper.close
|
17
|
+
assert_equal txt, dumper.stream.read
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_to_s
|
21
|
+
tsv = TSV.setup({}, :key_field => "Key", :fields => %w(Field1 Field2), :type => :double)
|
22
|
+
tsv["a"] = [["1", "11"], ["2", "22"]]
|
23
|
+
txt=<<-EOF
|
24
|
+
#: :type=:double
|
25
|
+
#Key\tField1\tField2
|
26
|
+
a\t1|11\t2|22
|
27
|
+
EOF
|
28
|
+
assert_equal txt, tsv.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_raise
|
32
|
+
dumper = TSV::Dumper.new :key_field => "Key", :fields => %w(Field1 Field2), :type => :double
|
33
|
+
dumper.init
|
34
|
+
t = Thread.new do
|
35
|
+
dumper.add "a", [["1", "11"], ["2", "22"]]
|
36
|
+
dumper.abort ScoutException
|
37
|
+
end
|
38
|
+
|
39
|
+
assert_raise ScoutException do
|
40
|
+
dumper.stream.read
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,64 @@
|
|
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 TestTSVIndex < Test::Unit::TestCase
|
5
|
+
def test_true
|
6
|
+
content =<<-'EOF'
|
7
|
+
#: :sep=/\s+/#:type=:double#:merge=:concat
|
8
|
+
#Id ValueA ValueB OtherID
|
9
|
+
row1 a|aa|aaa b Id1|Id2
|
10
|
+
row2 A B Id3|a
|
11
|
+
row2 a b id3
|
12
|
+
EOF
|
13
|
+
|
14
|
+
TmpFile.with_file(content) do |filename|
|
15
|
+
index = TSV.index(filename, :target => "ValueB")
|
16
|
+
assert_equal 'b', index["row1"]
|
17
|
+
assert_equal 'b', index["a"]
|
18
|
+
assert_equal 'b', index["aaa"]
|
19
|
+
assert_equal 'B', index["A"]
|
20
|
+
end
|
21
|
+
|
22
|
+
TmpFile.with_file(content) do |filename|
|
23
|
+
index = TSV.index(filename, :target => "ValueB", :fields => "OtherID")
|
24
|
+
assert_equal 'B', index["a"]
|
25
|
+
assert_nil index["B"]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_persist
|
30
|
+
content =<<-'EOF'
|
31
|
+
#: :sep=/\s+/#:type=:double#:merge=:concat
|
32
|
+
#Id ValueA ValueB OtherID
|
33
|
+
row1 a|aa|aaa b Id1|Id2
|
34
|
+
row2 A B Id3|a
|
35
|
+
row2 a b id3
|
36
|
+
EOF
|
37
|
+
tsv = TmpFile.with_file(content) do |filename|
|
38
|
+
index = TSV.index(filename, :target => "ValueB", :persist => true)
|
39
|
+
assert_equal 'b', index["row1"]
|
40
|
+
assert_equal 'b', index["a"]
|
41
|
+
assert_equal 'b', index["aaa"]
|
42
|
+
assert_equal 'B', index["A"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def __test_speed
|
47
|
+
content =<<-'EOF'
|
48
|
+
#: :sep=/\s+/#:type=:double#:merge=:concat
|
49
|
+
#Id ValueA ValueB OtherID
|
50
|
+
row1 a|aa|aaa b Id1|Id2
|
51
|
+
row2 A B Id3|a
|
52
|
+
row2 a b id3
|
53
|
+
EOF
|
54
|
+
tsv = TmpFile.with_file(content) do |filename|
|
55
|
+
Misc.benchmark 1000 do
|
56
|
+
TSV.index(filename, :target => "ValueB")
|
57
|
+
end
|
58
|
+
Misc.benchmark 1000 do
|
59
|
+
TSV.index(filename, :target => "ValueB", order: false)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,173 @@
|
|
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/tsv'
|
5
|
+
class TestTSVParser < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_parse_line
|
8
|
+
line = (0..10).to_a * "\t"
|
9
|
+
key, values = TSV.parse_line(line)
|
10
|
+
|
11
|
+
assert_equal "0", key
|
12
|
+
assert_equal (1..10).collect{|v| v.to_s }, values
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_parse_line_key
|
16
|
+
line = (0..10).to_a * "\t"
|
17
|
+
key, values = TSV.parse_line(line, key: 2)
|
18
|
+
|
19
|
+
assert_equal "2", key
|
20
|
+
assert_equal %w(0 1 3 4 5 6 7 8 9 10), values
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def test_parse_double
|
25
|
+
line = (0..10).collect{|v| v == 0 ? v : [v,v] * "|" } * "\t"
|
26
|
+
key, values = TSV.parse_line(line, type: :double, cast: :to_i)
|
27
|
+
|
28
|
+
assert_equal "0", key
|
29
|
+
assert_equal (1..10).collect{|v| [v,v] }, values
|
30
|
+
end
|
31
|
+
|
32
|
+
def __test_benchmark
|
33
|
+
num = 10_000
|
34
|
+
txt = num.times.inject(nil) do |acc,i|
|
35
|
+
(acc.nil? ? "" : acc << "\n") << (0..10).collect{|v| v == 0 ? i : [v,v] * "|" } * "\t"
|
36
|
+
end
|
37
|
+
|
38
|
+
txt = StringIO.new(([txt] * (10))*"\n")
|
39
|
+
Misc.benchmark 1 do
|
40
|
+
#Misc.profile do
|
41
|
+
data = TSV.parse_stream(txt, fix: true, type: :double, bar: true, merge: :concat)
|
42
|
+
assert_equal num, data.size
|
43
|
+
assert_equal 20, data['1'][0].length
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_parse_stream
|
48
|
+
lines =<<-EOF
|
49
|
+
1 2 3 4 5
|
50
|
+
11 12 13 14 15
|
51
|
+
EOF
|
52
|
+
|
53
|
+
lines = StringIO.new lines
|
54
|
+
|
55
|
+
data = TSV.parse_stream lines, sep: " "
|
56
|
+
assert_equal data["1"], %w(2 3 4 5)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_parse_stream_block
|
60
|
+
lines =<<-EOF
|
61
|
+
1 2 3 4 5
|
62
|
+
11 12 13 14 15
|
63
|
+
EOF
|
64
|
+
|
65
|
+
lines = StringIO.new lines
|
66
|
+
|
67
|
+
sum = 0
|
68
|
+
res = TSV.parse_stream(lines, sep: " ") do |k,values|
|
69
|
+
sum += values.inject(0){|acc,i| acc += i.to_i }
|
70
|
+
end
|
71
|
+
assert_equal 68, sum
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_parse_header
|
75
|
+
header =<<-EOF
|
76
|
+
#: :sep=" "
|
77
|
+
#Key ValueA ValueB
|
78
|
+
k A B
|
79
|
+
EOF
|
80
|
+
header = StringIO.new header
|
81
|
+
|
82
|
+
assert_equal "Key", TSV.parse_header(header)[1]
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_parse
|
86
|
+
header =<<-EOF
|
87
|
+
#: :sep=" "#:type=:double
|
88
|
+
#Key ValueA ValueB
|
89
|
+
k a|A b|B
|
90
|
+
EOF
|
91
|
+
header = StringIO.new header
|
92
|
+
|
93
|
+
tsv = TSV.parse(header)
|
94
|
+
assert_equal 'a', tsv['k'][0][0]
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_parse_fields
|
98
|
+
content =<<-EOF
|
99
|
+
#: :sep=" "#:type=:double
|
100
|
+
#Key ValueA ValueB
|
101
|
+
k a|A b|B
|
102
|
+
EOF
|
103
|
+
content = StringIO.new content
|
104
|
+
|
105
|
+
tsv = TSV.parse(content, fields: %w(ValueB))
|
106
|
+
assert_equal [%w(b B)], tsv['k']
|
107
|
+
assert_equal %w(ValueB), tsv.fields
|
108
|
+
|
109
|
+
content.rewind
|
110
|
+
|
111
|
+
tsv = TSV.parse(content, fields: %w(ValueB ValueA))
|
112
|
+
assert_equal [%w(b B), %w(a A)], tsv['k']
|
113
|
+
assert_equal %w(ValueB ValueA), tsv.fields
|
114
|
+
|
115
|
+
content.rewind
|
116
|
+
|
117
|
+
tsv = TSV.parse(content, fields: %w(ValueB Key))
|
118
|
+
assert_equal [%w(b B), %w(k)], tsv['k']
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_parse_key
|
122
|
+
content =<<-EOF
|
123
|
+
#: :sep=" "#:type=:double
|
124
|
+
#Key ValueA ValueB
|
125
|
+
k a|A b|B
|
126
|
+
EOF
|
127
|
+
content = StringIO.new content
|
128
|
+
|
129
|
+
tsv = TSV.parse(content, key_field: "ValueB")
|
130
|
+
assert_equal %w(b B), tsv.keys
|
131
|
+
assert_equal %w(a A), tsv["B"][1]
|
132
|
+
|
133
|
+
content.rewind
|
134
|
+
|
135
|
+
tsv = TSV.parse(content, key_field: "ValueB", one2one: true, type: :double)
|
136
|
+
assert_equal %w(b B), tsv.keys
|
137
|
+
assert_equal %w(A), tsv["B"][1]
|
138
|
+
|
139
|
+
content.rewind
|
140
|
+
|
141
|
+
tsv = TSV.parse(content, key_field: "ValueB", one2one: true, type: :list)
|
142
|
+
assert_equal %w(b B), tsv.keys
|
143
|
+
assert_equal "a", tsv["b"][1]
|
144
|
+
assert_equal "A", tsv["B"][1]
|
145
|
+
assert_equal "k", tsv["b"][0]
|
146
|
+
assert_equal "k", tsv["B"][0]
|
147
|
+
|
148
|
+
content.rewind
|
149
|
+
|
150
|
+
tsv = TSV.parse(content, key_field: "ValueB", one2one: true, type: :list)
|
151
|
+
assert_equal %w(b B), tsv.keys
|
152
|
+
assert_equal "A", tsv["B"][1]
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_parser_class
|
156
|
+
content =<<-EOF
|
157
|
+
Key ValueA ValueB
|
158
|
+
k a|A b|B
|
159
|
+
EOF
|
160
|
+
content = StringIO.new content
|
161
|
+
|
162
|
+
parser = TSV::Parser.new content, sep: " ", header_hash: ''
|
163
|
+
|
164
|
+
assert_equal "Key", parser.key_field
|
165
|
+
|
166
|
+
values = []
|
167
|
+
parser.traverse fields: %w(ValueB), type: :double do |k,v|
|
168
|
+
values << [k,v]
|
169
|
+
end
|
170
|
+
|
171
|
+
assert_equal [["k", [%w(b B)]]], values
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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/tsv'
|
5
|
+
|
6
|
+
class TestTSVPersist < Test::Unit::TestCase
|
7
|
+
def test_persist
|
8
|
+
content =<<-'EOF'
|
9
|
+
#: :sep=/\s+/#:type=:double#:merge=:concat
|
10
|
+
#Id ValueA ValueB OtherID
|
11
|
+
row1 a|aa|aaa b Id1|Id2
|
12
|
+
row2 A B Id3
|
13
|
+
row2 a a id3
|
14
|
+
EOF
|
15
|
+
|
16
|
+
|
17
|
+
tsv = Persist.persist("TEST Persist TSV", :tsv) do
|
18
|
+
TmpFile.with_file(content) do |filename|
|
19
|
+
TSV.open(filename)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
assert_include tsv.keys, 'row1'
|
24
|
+
assert_include tsv.keys, 'row2'
|
25
|
+
|
26
|
+
assert_nothing_raised do
|
27
|
+
tsv = Persist.persist("TEST Persist TSV", :tsv) do
|
28
|
+
raise
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_include tsv.keys, 'row1'
|
33
|
+
assert_include tsv.keys, 'row2'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
File without changes
|
@@ -43,7 +43,7 @@ class TestQueueWorker < Test::Unit::TestCase
|
|
43
43
|
current = nil
|
44
44
|
pid_list.each do |pid|
|
45
45
|
if pid != current
|
46
|
-
raise "Out of order" if seen.include? pid
|
46
|
+
raise "Out of order #{Log.fingerprint seen} #{ pid }" if seen.include? pid
|
47
47
|
end
|
48
48
|
current = pid
|
49
49
|
seen << pid
|
@@ -95,5 +95,53 @@ class TestQueueWorker < Test::Unit::TestCase
|
|
95
95
|
output.clean
|
96
96
|
end
|
97
97
|
|
98
|
+
def test_process_exception
|
99
|
+
input = WorkQueue::Socket.new
|
100
|
+
output = WorkQueue::Socket.new
|
101
|
+
|
102
|
+
workers = 10.times.collect{ WorkQueue::Worker.new }
|
103
|
+
workers.each do |w|
|
104
|
+
w.process(input, output) do |obj|
|
105
|
+
raise ScoutException
|
106
|
+
[Process.pid, obj.inspect] * " "
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
read = Thread.new do
|
111
|
+
Thread.current.report_on_exception = false
|
112
|
+
begin
|
113
|
+
while obj = output.read
|
114
|
+
if DoneProcessing === obj
|
115
|
+
pid = obj.pid
|
116
|
+
@worker_mutex.synchronize{ @workers.delete_if{|w| w.pid = pid } }
|
117
|
+
break if workers.empty?
|
118
|
+
end
|
119
|
+
raise obj if Exception === obj
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
write = Thread.new do
|
125
|
+
Thread.report_on_exception = false
|
126
|
+
100.times do |i|
|
127
|
+
input.write i
|
128
|
+
end
|
129
|
+
10.times do
|
130
|
+
input.write DoneProcessing.new
|
131
|
+
end
|
132
|
+
input.close_write
|
133
|
+
end
|
134
|
+
|
135
|
+
write.join
|
136
|
+
|
137
|
+
assert_raise WorkerException do
|
138
|
+
read.join
|
139
|
+
end
|
140
|
+
|
141
|
+
WorkQueue::Worker.join workers
|
142
|
+
input.clean
|
143
|
+
output.clean
|
144
|
+
end
|
145
|
+
|
98
146
|
end
|
99
147
|
|
@@ -0,0 +1,25 @@
|
|
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/named_array'
|
5
|
+
class TestStepDependencies < Test::Unit::TestCase
|
6
|
+
def test_recursive_inputs
|
7
|
+
tmpfile = tmpdir.test_step
|
8
|
+
step1 = Step.new tmpfile.step1, NamedArray.setup(["12"], %w(input1)) do |s|
|
9
|
+
s.length
|
10
|
+
end
|
11
|
+
|
12
|
+
step2 = Step.new tmpfile.step2, NamedArray.setup([2], %w(input2)) do |times|
|
13
|
+
step1 = dependencies.first
|
14
|
+
(step1.inputs.first + " has " + step1.load.to_s + " characters") * times
|
15
|
+
end
|
16
|
+
|
17
|
+
step2.dependencies = [step1]
|
18
|
+
|
19
|
+
assert_equal 2, step2.inputs["input2"]
|
20
|
+
assert_equal "12", step2.recursive_inputs["input1"]
|
21
|
+
assert_equal 2, step2.inputs[:input2]
|
22
|
+
assert_equal "12", step2.recursive_inputs[:input1]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -4,27 +4,25 @@ require 'scout/workflow'
|
|
4
4
|
|
5
5
|
class TestStepInfo < Test::Unit::TestCase
|
6
6
|
def test_dependency
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
7
|
+
TmpFile.with_file do |tmpdir|
|
8
|
+
Path.setup(tmpdir)
|
9
|
+
tmpfile = tmpdir.test_step
|
10
|
+
step1 = Step.new tmpfile.step1, ["12"] do |s|
|
11
|
+
s.length
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
assert_equal 2, step1.exec
|
15
|
+
assert_equal 2, step1.run
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
step2 = Step.new tmpfile.step2 do
|
18
|
+
step1 = dependencies.first
|
19
|
+
step1.inputs.first + " has " + step1.load.to_s + " characters"
|
20
|
+
end
|
22
21
|
|
23
|
-
|
22
|
+
step2.dependencies = [step1]
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
end
|
24
|
+
assert_equal "12 has 2 characters", step2.run
|
25
|
+
assert_equal "12 has 2 characters", step2.run
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -5,29 +5,27 @@ require 'scout/workflow/step'
|
|
5
5
|
|
6
6
|
class TestStepLoad < Test::Unit::TestCase
|
7
7
|
def test_dependency
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
8
|
+
tmpfile = tmpdir.test_step
|
9
|
+
step1 = Step.new tmpfile.step1, ["12"] do |s|
|
10
|
+
s.length
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
step2 = Step.new tmpfile.step2 do
|
14
|
+
step1 = dependencies.first
|
15
|
+
step1.inputs.first + " has " + step1.load.to_s + " characters"
|
16
|
+
end
|
18
17
|
|
19
|
-
|
18
|
+
step2.dependencies = [step1]
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
step2.recursive_clean
|
21
|
+
step2.run
|
23
22
|
|
24
|
-
|
23
|
+
new_step2 = Step.load(step2.path)
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
25
|
+
assert_equal "12 has 2 characters", new_step2.load
|
26
|
+
assert_equal "12 has 2 characters", new_step2.run
|
27
|
+
assert_equal 2, new_step2.dependencies.first.run
|
28
|
+
assert_equal "12", new_step2.dependencies.first.inputs.first
|
31
29
|
end
|
32
30
|
|
33
31
|
def test_relocate
|
@@ -0,0 +1,25 @@
|
|
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/workflow'
|
5
|
+
class TestStepProvenance < Test::Unit::TestCase
|
6
|
+
def test_true
|
7
|
+
tmpfile = tmpdir.test_step
|
8
|
+
step1 = Step.new tmpfile.step1, ["12"] do |s|
|
9
|
+
s.length
|
10
|
+
end
|
11
|
+
|
12
|
+
step2 = Step.new tmpfile.step2 do
|
13
|
+
step1 = dependencies.first
|
14
|
+
step1.inputs.first + " has " + step1.load.to_s + " characters"
|
15
|
+
end
|
16
|
+
|
17
|
+
step2.dependencies = [step1]
|
18
|
+
|
19
|
+
step2.run
|
20
|
+
|
21
|
+
assert_include Step.prov_report(step2), 'step1'
|
22
|
+
assert_include Step.prov_report(step2), 'step2'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|