# Test/rinda/test\_rinda.rb fails occasionally

**URL:** <https://www.ruby-forum.com/t/test-rinda-test-rinda-rb-fails-occasionally/153554>\
**Category:** Development\
**Created:** [November 18, 2008, 6:22pm UTC](https://www.ruby-forum.com/t/test-rinda-test-rinda-rb-fails-occasionally/153554 "2008-11-18T18:22:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shinichiro.h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@shinichiro.h](https://www.ruby-forum.com/u/shinichiro.h)\
**Post date:** [November 18, 2008, 6:22pm UTC](https://www.ruby-forum.com/t/test-rinda-test-rinda-rb-fails-occasionally/153554/1 "2008-11-18T18:22:11Z")

</div>

e$BIMCO$G$9!#e(B

e$B$J$s$+BN46$Ge(B 1/5 e$B$/$i$$$N3NN($Ge(B test\_rinda.rb e$B$,e(B

1. Failure:  
test\_core\_03\_notify(Rinda::TupleSpaceTest)  
[/home/i/src/ruby\_orig/test/rinda/test\_rinda.rb:396]:  
\<[0, 3]\> expected but was  
\<[0, 1]\>.

e$B$J$I$H8@$C$F%3%1$k$N$G!"\>/$7D/$a$F$\_$^$7$?!#e(B  
e$B$h$/$o$+$C$F$^$;$s$,e(B MockClock e$B$,e(B mock e$B$7$-$l$F$J$/$Fe(B  
e$B$A$g$C$H$:$l$F$k$s$8$c$J$$$+$H;W$$$^$9!#e(B  
expire e$B$9$ke(B timeout e$B$r$A$g$C$H$f$H$j$r2C$($F$d$k$He(B  
100e$B2s$d$C$Fe(B100e$B2sDL$C$?$N$G$^$!%^%7$K$J$C$F$O$$$k$N$G$J$$$+$H!#e(B

e$B$5$i$K%l%"$Je(B

1. Failure:  
test\_core\_03\_notify(Rinda::TupleSpaceTest)  
[/home/i/src/ruby/test/rinda/test\_rin  
da.rb:408]:  
\<[“delete”, {“message”=\>“second”, “name”=\>“1”}]\> expected but was  
\<[“close”]\>.

e$B$NJ}$G$9$,e(B(e$B?t==2s$Ke(B1e$B2s=P$kDxEYe(B?)e$B!"$3$l$be(B notify3  
e$B$Ne(B  
timeout e$B$K$f$H$j$r;}$?$;$?$i=P$J$/$J$C$?$h$&$K;W$$$^$9!#e(B

e$B$D$$$G$Ke(B sleep e$B$N0U?^$,$h$/$o$+$i$J$+$C$?$N$Ge(B  
e$B%3%a%s%H$rB-$7$F$_$$$?$N$H!"e(B listener1 e$B$He(B listener2 e$B$Ge(B  
e$B%9%?%$%k$,0c$&$3$H$K0UL#$r8+=P$;$J$+$C$?$N$G$$$8$C$F$_$-$^$7$?!#e(B

e$B%^%8%a$K=$@5$9$k$J$i$\*$=$i$/e(B MockClock e$B$re(B  
deterministic e$B$J7A$K=q$-D\>$9$Y$-$J$N$+$J!“e(B  
e$B$H;W$$$^$9$,3N?.$O$”$j$^$;$s!#e(B

# Index: test/rinda/test\_rinda.rb

— test/rinda/test\_rinda.rb (revision 20267)  
+++ test/rinda/test\_rinda.rb (working copy)  
@@ -317,8 +317,8 @@

def test\_core\_03\_notify  
notify1 = @ts.notify(nil, [:req, Integer])

- notify2 = @ts.notify(nil, [:ans, Integer], 5)
- notify3 = @ts.notify(nil, {“message”=\>String, “name”=\>String}, 5)

- notify2 = @ts.notify(nil, [:ans, Integer], 8)

- notify3 = @ts.notify(nil, {“message”=\>String, “name”=\>String}, 8)

- 

```
 notify2.each do |ev|

```

- 

```
 notify2.each do |ev, tuple|

```

n += 1

- if ev[0] == ‘write’

- if ev == ‘write’  
lv = lv + 1

- elsif ev[0] == ‘take’

- elsif ev == ‘take’  
lv = lv - 1

- elsif ev[0] == ‘close’

- elsif ev == ‘close’  
result = [lv, n]  
break  
end  
assert(lv \>= 0)

- assert\_equal([:ans, 10], ev[1])

- assert\_equal([:ans, 10], tuple)  
end  
result  
end  
@@ -385,13 +385,15 @@

- 
# notify2 must not expire until this @ts.take.
- 
# sleep(4) might be short enough for the timeout of notify2 (8

## secs) tuple = @ts.take([:ans, nil]) assert\_equal(10, tuple[1]) assert\_equal([], @ts.read\_all([nil, nil]))

- notify1.cancel

- sleep(3) # notify2 expired
- 

- sleep(7) # notify2 expired (sleep(4)+sleep(7) \> 8)
- assert\_equal([0, 11], thread\_join(listener1))  
assert\_equal([0, 3], thread\_join(listener2))

---

<div class="post-metadata">

**Author:** ![shinichiro.h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@shinichiro.h](https://www.ruby-forum.com/u/shinichiro.h)\
**Post date:** [November 18, 2008, 7:11pm UTC](https://www.ruby-forum.com/t/test-rinda-test-rinda-rb-fails-occasionally/153554/2 "2008-11-18T19:11:31Z")

</div>

e$B31$H$$$$$^$9!#e(B

On 2008/11/19, at 2:15, shinichiro.h wrote:

> e$B$NJ}$G$9$,e(B(e$B?t==2s$Ke(B1e$B2s=P$kDxEYe(B?)e$B!"$3$l$be(B  
> notify3 e$B$Ne(B  
> timeout e$B$K$f$H$j$r;}$?$;$?$i=P$J$/$J$C$?$h$&$K;W$$$^$9!#e(B
> 
> e$B$D$$$G$Ke(B sleep e$B$N0U?^$,$h$/$o$+$i$J$+$C$?$N$Ge(B  
> e$B%3%a%s%H$rB-$7$F$_$$$?$N$H!"e(B listener1 e$B$He(B  
> listener2 e$B$Ge(B  
> e$B%9%?%$%k$,0c$&$3$H$K0UL#$r8+=P$;$J$+$C$?$N$G$$$8$C$F$_$-$^$7$?!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#e(B  
e$B@h$[$Ie(Bcie$B$7$^$7$?!#e(B

e$B5-21$,$"$d$7$$$s$G$9$,!"e(B  
timeoute$B$K$f$H$j$,$J$$$N$Oe(BMockClocke$B$8$c$J$+$C$?$H$-$Ne(B  
e$BL\>;D$j$+$b$7$l$^$;$s!#e(B

> e$B%^%8%a$K=$@5$9$k$J$i$\*$=$i$/e(B MockClock e$B$re(B  
> deterministic e$B$J7A$K=q$-D\>$9$Y$-$J$N$+$J!“e(B  
> e$B$H;W$$$^$9$,3N?.$O$”$j$^$;$s!#e(B

e$B$=$&;W$$$^$9!#e(B  
e$B$G$b6qBNE\*$K$I$&$7$?$i$h$$$+;W$$$D$+$J$$$s$G$9$h$M!#e(B
