-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathwaiter_launch_spec.rb
156 lines (123 loc) · 3.33 KB
/
waiter_launch_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#
# specifying flor
#
# Tue Jan 24 07:42:13 JST 2017
#
require 'spec_helper'
describe Flor::Waiter do
context 'and Unit#launch(wait:)' do
before :each do
@unit = Flor::Unit.new('envs/test/etc/conf.json')
@unit.conf['unit'] = 'waitertest'
#@unit.hook('journal', Flor::Journal)
@unit.storage.delete_tables
@unit.storage.migrate
@unit.start
class << @unit
attr_reader :wlist
end
class << @unit.wlist
attr_reader :waiters
end
sleep 0.350
end
after :each do
@unit.shutdown
end
it 'lets wait until the scheduler gets idle' do
r = @unit.launch(%{ sleep 10 }, wait: %w[ idle ] * 4)
expect(r['point']).to eq('idle')
expect(r['exid']).to eq(nil)
expect(r.keys).to eq(%w[
point idle_count consumed ])
expect(r['idle_count']).to eq(4)
end
it 'lets wait until the executor run ends' do
r = @unit.launch(%{ sleep 10 }, wait: 'end')
expect(r['point']).to eq('end')
expect(r['exid']).not_to eq(nil)
expect(r.keys).to eq(%w[
point exid start duration consumed counters
nodes execution_size er pr ])
end
it 'lets wait until a tag is entered' do
r = @unit.launch(
%q{
sequence tag: 'stage-a'
push f.l 0
sequence tag: 'stage-b'
push f.l 1
stall _
sequence tag: 'stage-c'
push f.l 2
},
payload: { l: [] },
wait: 'entered')
expect(r['point']).to eq('entered')
expect(r['tags']).to eq(%w[ stage-a ])
expect(r['nid']).to eq('0_0')
end
it 'lets wait until a given tag is entered' do
r = @unit.launch(
%q{
sequence tag: 'stage-a'
push f.l 0
sequence tag: 'stage-b'
push f.l 1
stall _
sequence tag: 'stage-c'
push f.l 2
},
payload: { l: [] },
wait: 'entered:stage-b')
expect(r['point']).to eq('entered')
expect(r['tags']).to eq(%w[ stage-b ])
expect(r['nid']).to eq('0_1')
expect(r['payload']['l']).to eq([ 0 ])
end
it 'lets wait until a given tag is left' do
r = @unit.launch(
%q{
sequence tag: 'stage-a'
push f.l 0
sequence tag: 'stage-b'
push f.l 1
sequence tag: 'stage-c'
stall _
push f.l 2
},
payload: { l: [] },
wait: 'left:stage-b')
expect(r['point']).to eq('left')
expect(r['tags']).to eq(%w[ stage-b ])
expect(r['nid']).to eq('0_1')
expect(r['payload']['l']).to eq([ 0, 1 ])
end
# it 'understands timeout:' do
#
# Thread.new do
# @unit.launch(%{ sleep 10 }, wait: 'end', timeout: 7)
# end
# waiter = wait_until { @unit.wlist.waiters.first }
#
# class << waiter; attr_reader :timeout; end
#
# expect(waiter.timeout).to eq(7)
# end
#
# it 'understands on_timeout:' do
#
# Thread.new do
# @unit.launch(%{ sleep 10 }, wait: 'end', on_timeout: 'shutup')
# end
# waiter = wait_until { @unit.wlist.waiters.first }
#
# class << waiter; attr_reader :on_timeout; end
#
# expect(waiter.on_timeout).to eq('shutup')
# end
end
context 'and Unit#wait(exid, sthing)' do
it 'works'
end
end