-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- STABLE.down(): send STABILITY message when flag DONT_LOOPBACK is se…
…t and max_bytes is exceeded - Added STABLE_Test to test https://issues.redhat.com/browse/JGRP-2605
- Loading branch information
Showing
2 changed files
with
125 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
tests/junit-functional/org/jgroups/protocols/STABLE_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.jgroups.protocols; | ||
|
||
import org.jgroups.Global; | ||
import org.jgroups.JChannel; | ||
import org.jgroups.Message; | ||
import org.jgroups.protocols.pbcast.NAKACK2; | ||
import org.jgroups.protocols.pbcast.STABLE; | ||
import org.jgroups.util.MyReceiver; | ||
import org.jgroups.util.Table; | ||
import org.jgroups.util.Util; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* Tests sending of STABLE messages when DONT_LOOPBACK is set (https://issues.redhat.com/browse/JGRP-2605) | ||
* @author Bela Ban | ||
* @since 5.2.1, 4.2.20 | ||
*/ | ||
@Test(groups=Global.FUNCTIONAL) | ||
public class STABLE_Test { | ||
protected JChannel a,b,c; | ||
protected MyReceiver<byte[]> r1, r2, r3; | ||
protected final String GRP=STABLE_Test.class.getSimpleName(); | ||
|
||
@BeforeMethod protected void setup() throws Exception { | ||
a=create("A").connect(GRP); | ||
b=create("B").connect(GRP); | ||
c=create("C").connect(GRP); | ||
Util.waitUntilAllChannelsHaveSameView(10000, 500, a,b,c); | ||
r1=new MyReceiver<byte[]>().rawMsgs(true); | ||
r2=new MyReceiver<byte[]>().rawMsgs(true); | ||
r3=new MyReceiver<byte[]>().rawMsgs(true); | ||
a.setReceiver(r1); | ||
b.setReceiver(r2); | ||
c.setReceiver(r3); | ||
} | ||
|
||
@AfterMethod protected void destroy() {Util.closeReverse(a,b,c);} | ||
|
||
public void testStableWithDontLoopback() throws Exception { | ||
byte[] payload=new byte[5000]; | ||
for(int i=0; i < 10; i++) { | ||
Message msg=new Message(null, payload).setTransientFlag(Message.TransientFlag.DONT_LOOPBACK); | ||
b.send(msg); | ||
Util.sleep(200); // prevents batches, which trigger STABLE msgs in non-10000 increments | ||
} | ||
Util.waitUntil(5000, 500, () -> Stream.of(r1,r3).allMatch(r -> r.size() == 10)); | ||
assert r2.size() == 0; | ||
|
||
Util.waitUntilTrue(5000, 500, () -> Stream.of(a, b, c) | ||
.map(c -> ((NAKACK2)c.getProtocolStack().findProtocol(NAKACK2.class)).getWindow(b.getAddress())) | ||
.allMatch(t -> t.getHighestReceived() == 10 && t.getHighestDelivered() == 10 && t.getLow() == 10)); | ||
|
||
for(JChannel ch: Arrays.asList(a, b, c)) { | ||
NAKACK2 n=ch.getProtocolStack().findProtocol(NAKACK2.class); | ||
Table<Message> t=n.getWindow(b.getAddress()); | ||
assert t.getHighestReceived() == 10 && t.getHighestDelivered() == 10 && t.getLow() == 10 | ||
: String.format("table for %s is %s (low is probably 0)", ch.getName(), t); | ||
} | ||
} | ||
|
||
protected static JChannel create(String name) throws Exception { | ||
JChannel ch=new JChannel(Util.getTestStack()).name(name); | ||
STABLE stable=ch.getProtocolStack().findProtocol(STABLE.class); | ||
stable.setDesiredAverageGossip(0); // disabled periodical stable | ||
stable.setMaxBytes(10000); | ||
return ch; | ||
} | ||
} |