Skip to content

Commit

Permalink
UNICAST3_Test now fails if CONN_CLOSE_TIMEOUT is small (e.g. 1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Feb 20, 2017
1 parent 6b249df commit 5dead63
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/junit-functional/org/jgroups/protocols/UNICAST3_Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class UNICAST3_Test {
protected UNICAST3 uni_a, uni_b;
protected DropUnicastAck drop_ack=new DropUnicastAck((short)499);
protected static final short UNICAST3_ID=ClassConfigurator.getProtocolId(UNICAST3.class);
protected static final int CONN_CLOSE_TIMEOUT=60_000; // change to a low value (e.g. 1000) to make this test fail

@BeforeMethod protected void setup() throws Exception {
a=create("A").connect(getClass().getSimpleName());
Expand All @@ -36,6 +37,21 @@ public class UNICAST3_Test {
@AfterMethod protected void destroy() {Util.close(b, a);}


/**
- A and B exchanging unicast messages
- Seqno 499 is sent from A to B
- B adds it to its table for A, and sends the ACK, then delivers the message
- The ack for 499 from B to A is dropped
- B excludes A (but A doesn't exclude B) and removes A's table
* This happens only if conn_close_timeout is small (default: 10s)
* If conn_close_timeout == 0, connections will not be removed
- A retransmits 499 to B
- B receives A:499, but asks for the first seqno
- A has its highest seqno acked at 498, so resends 499 with first==true
- B creates a receiver window for A at 499, receives 499 and delivers it (again)
The issue is fixed by setting CONN_CLOSE_TIMEOUT to a highher value, or to 0
*/
public void testDuplicateMessageDelivery() throws Exception {
b.setReceiver(receiver);

Expand All @@ -52,20 +68,21 @@ public void testDuplicateMessageDelivery() throws Exception {

// remove A's receive window in B:
System.out.printf("-- closing the receive-window for %s:\n", a_addr);
// e.g. caused by an asymmetric network split: B excludes A, but not vice versa
uni_b.closeReceiveConnection(a_addr);

uni_a.setLevel("trace");
uni_b.setLevel("trace");

uni_b.setValue("conn_close_timeout", 1000);
uni_b.setValue("conn_close_timeout", CONN_CLOSE_TIMEOUT);
// wait until B closes the receive window for A:
for(int i=0; i < 10; i++) {
if(uni_b.getNumReceiveConnections() == 0)
break;
Util.sleep(500);
}

assert uni_b.getNumReceiveConnections() == 0;
// assert uni_b.getNumReceiveConnections() > 0;

// remove the DropUnicastAck protocol:
System.out.printf("-- removing the %s protocol\n", DropUnicastAck.class.getSimpleName());
Expand All @@ -77,7 +94,7 @@ public void testDuplicateMessageDelivery() throws Exception {
Util.sleep(100);
}
System.out.printf("B: received %d messages from A\n", receiver.count);
assert receiver.count == 500;
assert receiver.count == 499 : String.format("received %d messages, but should only have received 499", receiver.count);
}


Expand Down

0 comments on commit 5dead63

Please sign in to comment.