Skip to content

Commit 6cf4e2b

Browse files
committed
Fixed failing tests due to mcast route change
1 parent 47acc7e commit 6cf4e2b

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

tests/junit-functional/org/jgroups/tests/NioServerTest2.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.jgroups.protocols.pbcast.GMS;
99
import org.jgroups.protocols.pbcast.NAKACK2;
1010
import org.jgroups.protocols.pbcast.STABLE;
11+
import org.jgroups.util.ResourceManager;
1112
import org.jgroups.util.Util;
1213
import org.testng.annotations.AfterMethod;
1314
import org.testng.annotations.BeforeMethod;
@@ -30,9 +31,10 @@ public class NioServerTest2 {
3031
protected MyReceiver ra, rb;
3132

3233
@BeforeMethod protected void init() throws Exception {
33-
a=create("A");
34+
String mcast_addr=ResourceManager.getNextMulticastAddress();
35+
a=create("A", mcast_addr);
3436
a.setReceiver(ra=new MyReceiver());
35-
b=create("B");
37+
b=create("B", mcast_addr);
3638
b.setReceiver(rb=new MyReceiver());
3739
a.connect("NioServerTest2");
3840
b.connect("NioServerTest2");
@@ -76,10 +78,10 @@ protected static void check(MyReceiver r, String name) {
7678
}
7779

7880

79-
protected static JChannel create(String name) throws Exception {
81+
protected static JChannel create(String name, String mcast_addr) throws Exception {
8082
return new JChannel(
8183
new TCP_NIO2().setRecvBufSize(recv_buf_size).setSendBufSize(send_buf_size).setBindAddress(Util.getLoopback()),
82-
new MPING(),
84+
new MPING().setMulticastAddress(mcast_addr),
8385
new NAKACK2().useMcastXmit(false),
8486
new UNICAST3(),
8587
new STABLE(),

tests/junit/org/jgroups/tests/ConcurrentStartupTest.java

+17-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
import org.jgroups.protocols.pbcast.NAKACK2;
99
import org.jgroups.protocols.pbcast.STABLE;
1010
import org.jgroups.stack.Protocol;
11+
import org.jgroups.util.ResourceManager;
1112
import org.jgroups.util.Util;
1213
import org.testng.annotations.AfterMethod;
1314
import org.testng.annotations.Test;
1415

16+
import java.net.InetAddress;
1517
import java.util.concurrent.CountDownLatch;
1618
import java.util.concurrent.TimeUnit;
1719
import java.util.concurrent.TimeoutException;
@@ -40,21 +42,29 @@ public class ConcurrentStartupTest {
4042
}
4143

4244
@Test(enabled=false)
43-
protected void setup(Class<? extends TP> tp_cl, Class<? extends Discovery> discovery_cl) throws Exception {
44-
for(int i=0; i < channels.length; i++)
45-
channels[i]=create(tp_cl, discovery_cl, String.valueOf(i+1));
45+
protected void setup(Class<? extends TP> tp_cl, Class<? extends Discovery> discovery_cl,
46+
String mcast_addr) throws Exception {
47+
for(int i=0; i < channels.length; i++) {
48+
channels[i]=create(tp_cl,discovery_cl,String.valueOf(i + 1));
49+
if(mcast_addr != null) {
50+
TP tp=channels[i].getProtocolStack().getTransport();
51+
if(tp instanceof UDP)
52+
((UDP)tp).setMulticastAddress(InetAddress.getByName(mcast_addr));
53+
}
54+
}
4655
}
4756

4857

4958
// @Test(invocationCount=5)
5059
public void testConcurrentJoinWithSHARED_LOOPBACK() throws Exception {
51-
setup(SHARED_LOOPBACK.class, SHARED_LOOPBACK_PING.class);
60+
setup(SHARED_LOOPBACK.class, SHARED_LOOPBACK_PING.class, null);
5261
startThreads(CLUSTER_SHARED);
5362
}
5463

5564
@Test(invocationCount=10)
5665
public void testConcurrentJoinWithLOCAL_PING() throws Exception {
57-
setup(UDP.class, LOCAL_PING.class);
66+
String mcast_addr=ResourceManager.getNextMulticastAddress();
67+
setup(UDP.class, LOCAL_PING.class, mcast_addr);
5868
for(int i=0; i < channels.length; i++) {
5969
final int index=i;
6070
channels[i].setUpHandler(new UpHandler() {
@@ -82,7 +92,8 @@ public Object up(Event evt) {
8292

8393
// @Test(invocationCount=10)
8494
public void testConcurrentJoinWithPING() throws Exception {
85-
setup(UDP.class, PING.class);
95+
String mcast_addr=ResourceManager.getNextMulticastAddress();
96+
setup(UDP.class, PING.class, mcast_addr);
8697
startThreads("withUDPandPING");
8798
}
8899

tests/junit/org/jgroups/tests/SequencerOrderTest.java

+23-12
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44

55

66
import org.jgroups.*;
7+
import org.jgroups.protocols.MPING;
78
import org.jgroups.protocols.SHUFFLE;
9+
import org.jgroups.protocols.TP;
10+
import org.jgroups.protocols.UDP;
811
import org.jgroups.protocols.pbcast.NAKACK2;
912
import org.jgroups.stack.ProtocolStack;
13+
import org.jgroups.util.ResourceManager;
1014
import org.jgroups.util.Util;
1115
import org.testng.annotations.AfterMethod;
1216
import org.testng.annotations.BeforeMethod;
1317
import org.testng.annotations.Test;
1418

19+
import java.net.InetAddress;
1520
import java.util.LinkedList;
1621
import java.util.List;
1722
import java.util.concurrent.atomic.AtomicInteger;
@@ -38,20 +43,15 @@ public class SequencerOrderTest {
3843

3944
@BeforeMethod
4045
void setUp() throws Exception {
41-
a=new JChannel(props).name("A");
42-
a.connect(GROUP);
43-
r1=new MyReceiver("A");
44-
a.setReceiver(r1);
46+
String mcast_addr=ResourceManager.getNextMulticastAddress();
47+
a=create(props, "A", mcast_addr).connect(GROUP);
48+
a.setReceiver(r1=new MyReceiver("A"));
4549

46-
b=new JChannel(props).name("B");
47-
b.connect(GROUP);
48-
r2=new MyReceiver("B");
49-
b.setReceiver(r2);
50+
b=create(props, "B", mcast_addr).connect(GROUP);
51+
b.setReceiver(r2=new MyReceiver("B"));
5052

51-
c=new JChannel(props).name("C");
52-
c.connect(GROUP);
53-
r3=new MyReceiver("C");
54-
c.setReceiver(r3);
53+
c=create(props, "C", mcast_addr).connect(GROUP);
54+
c.setReceiver(r3=new MyReceiver("C"));
5555

5656
Util.waitUntilAllChannelsHaveSameView(10000, 1000, a, b, c);
5757

@@ -93,6 +93,17 @@ public void testBroadcastSequence() throws Exception {
9393
verifySameOrder(EXPECTED_MSGS, l1, l2, l3);
9494
}
9595

96+
protected JChannel create(String props, String name, String mcast_addr) throws Exception {
97+
JChannel ch=new JChannel(props).name(name);
98+
TP tp=ch.getProtocolStack().getTransport();
99+
if(tp instanceof UDP)
100+
((UDP)tp).setMulticastAddress(InetAddress.getByName(mcast_addr));
101+
MPING mping=ch.getProtocolStack().findProtocol(MPING.class);
102+
if(mping != null)
103+
mping.setMulticastAddress(mcast_addr);
104+
return ch;
105+
}
106+
96107
protected static void insertShuffle(JChannel... channels) throws Exception {
97108
for(JChannel ch: channels) {
98109
SHUFFLE shuffle=new SHUFFLE();

0 commit comments

Comments
 (0)