-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexercise_verification.rb
47 lines (39 loc) · 1.48 KB
/
exercise_verification.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
# Don't mess with this stuff please :-)
def verify_ex_4!
start_time = Time.now.to_f
sleep 1
easy_stuff_started = Redis.current.get('ex_4:the_easy_stuff:started')
hard_stuff_started = Redis.current.get('ex_4:the_hard_stuff:started')
return unless easy_stuff_started || hard_stuff_started
until Redis.current.get('ex_4:the_hard_stuff:finished')
sleep 0.2
break if Time.now.to_f - start_time > 8.0
end
easy_stuff_started = Redis.current.get('ex_4:the_easy_stuff:started')
easy_stuff_finished = Redis.current.get('ex_4:the_easy_stuff:finished')
hard_stuff_started = Redis.current.get('ex_4:the_hard_stuff:started')
hard_stuff_finished = Redis.current.get('ex_4:the_hard_stuff:finished')
if easy_stuff_started < hard_stuff_started
puts 'Make sure you start the hard request first.'
elsif hard_stuff_finished < easy_stuff_finished
puts 'Make sure you\'re doing this work asynchronously.'
else
puts 'Exercise 4 complete!'
end
end
def verify_ex_5!
sleep 1
return unless Redis.current.get('ex_5:status') == 'started'
start_time = Time.now.to_f
until Redis.current.get('ex_5:status') == 'complete'
sleep 0.2
break if Time.now.to_f - start_time > 30.0
end
if Redis.current.get('ex_5:requests_submitted').to_i != 3
puts 'Looks like you aren\'t retrying properly. Or perhaps that sidekiq is being *very* slow.'
elsif Redis.current.get('ex_5:status') == 'complete'
puts 'Exercise 5 complete!'
else
puts 'Ex 5 did not go well.'
end
end