Skip to content

Commit 5cb33b9

Browse files
loop flaky test in case of regression
1 parent 4b88f56 commit 5cb33b9

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

test/distributed_exec.jl

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -208,29 +208,34 @@ put!(f, :OK)
208208
@test remotecall_fetch(k->haskey(Distributed.PGRP.refs, k), wid1, fid) == false
209209
@test fetch(f) === :OK
210210

211-
# RemoteException should be thrown on a put! when another process has set the value
212-
f = Future(wid1)
213-
fid = remoteref_id(f)
211+
# Test this multiple times as races have been seen where `@spawn` was used over
212+
# `@async`. Issue #124
213+
max_attempts = 100
214+
for i in 1:max_attempts
215+
let f = Future(wid1), fid = remoteref_id(f), fstore = RemoteChannel(wid2)
216+
# RemoteException should be thrown on a put! when another process has set the value
214217

215-
fstore = RemoteChannel(wid2)
216-
put!(fstore, f) # send f to wid2
217-
put!(f, :OK) # set value from master
218+
put!(fstore, f) # send f to wid2
219+
put!(f, :OK) # set value from master
218220

219-
@test remotecall_fetch(k->haskey(Distributed.PGRP.refs, k), wid1, fid) == true
221+
@test remotecall_fetch(k->haskey(Distributed.PGRP.refs, k), wid1, fid) == true
220222

221-
testval = remotecall_fetch(wid2, fstore) do x
222-
try
223-
put!(fetch(x), :OK)
224-
return 0
225-
catch e
226-
if isa(e, RemoteException)
227-
return 1
228-
else
229-
return 2
223+
testval = remotecall_fetch(wid2, fstore) do x
224+
try
225+
put!(fetch(x), :OK)
226+
return 0
227+
catch e
228+
if isa(e, RemoteException)
229+
return 1
230+
else
231+
rethrow()
232+
end
233+
end
230234
end
235+
testval == 1 || @info "test failed on attempt $i (max $max_attempts)"
236+
@test testval == 1
231237
end
232238
end
233-
@test testval == 1
234239

235240
# Issue number #25847
236241
@everywhere function f25847(ref)

0 commit comments

Comments
 (0)