Reconnect test fails easier now

This commit is contained in:
nathan 2019-01-25 16:14:00 +01:00
parent 8c9140b3f6
commit e6cc3fd851

View File

@ -141,51 +141,60 @@ class ReconnectTest extends BaseTest {
if (useTCP && useUDP) { if (useTCP && useUDP) {
initialCount += 2; initialCount += 2;
} }
for (int i = 1; i < count + 1; i++) { try {
System.out.println("....."); for (int i = 1; i < count + 1; i++) {
try { System.out.println(".....");
client.connect(5000); try {
} catch (IOException e) { client.connect(5000);
e.printStackTrace(); } catch (IOException e) {
} e.printStackTrace();
}
int waitingRetryCount = 20;
int target = i * initialCount;
boolean failed = false;
int waitingRetryCount = 20; synchronized (receivedCount) {
int target = i * initialCount; while (this.receivedCount.get() != target) {
if (waitingRetryCount-- < 0) {
System.err.println("Aborting unit test... wrong count!");
if (useUDP) {
// If TCP and UDP both fill the pipe, THERE WILL BE FRAGMENTATION and dropped UDP packets!
// it results in severe UDP packet loss and contention.
//
// http://www.isoc.org/INET97/proceedings/F3/F3_1.HTM
// also, a google search on just "INET97/proceedings/F3/F3_1.HTM" turns up interesting problems.
// Usually it's with ISPs.
synchronized (receivedCount) { System.err.println("NOTE: UDP can fail, even on loopback! See: http://www.isoc.org/INET97/proceedings/F3/F3_1.HTM");
while (this.receivedCount.get() != target) { }
if (waitingRetryCount-- < 0) { if (target != this.receivedCount.get()) {
System.err.println("Aborting unit test... wrong count!"); failed = true;
if (useUDP) { break;
// If TCP and UDP both fill the pipe, THERE WILL BE FRAGMENTATION and dropped UDP packets! }
// it results in severe UDP packet loss and contention. }
// try {
// http://www.isoc.org/INET97/proceedings/F3/F3_1.HTM receivedCount.wait(1000);
// also, a google search on just "INET97/proceedings/F3/F3_1.HTM" turns up interesting problems. } catch (InterruptedException e) {
// Usually it's with ISPs. e.printStackTrace();
System.err.println("NOTE: UDP can fail, even on loopback! See: http://www.isoc.org/INET97/proceedings/F3/F3_1.HTM");
} }
stopEndPoints();
assertEquals(target, this.receivedCount.get());
}
try {
receivedCount.wait(1000);
} catch (InterruptedException e) {
e.printStackTrace();
} }
} }
client.close();
System.out.println(".....");
if (failed) {
break;
}
} }
client.close(); assertEquals(count * initialCount, this.receivedCount.get());
System.out.println("....."); } finally {
stopEndPoints();
waitForThreads(10);
} }
assertEquals(count * initialCount, this.receivedCount.get());
stopEndPoints();
waitForThreads(10);
} }
@Test @Test