Skip to content

Commit 2c0e76d

Browse files
committed
fixes integration test
Signed-off-by: Oleh Dokuka <[email protected]>
1 parent 78a747a commit 2c0e76d

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

rsocket-core/src/test/java/io/rsocket/core/SetupRejectionTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.rsocket.transport.ServerTransport;
2020
import io.rsocket.util.DefaultPayload;
2121
import java.time.Duration;
22-
import org.junit.jupiter.api.Disabled;
2322
import org.junit.jupiter.api.Test;
2423
import reactor.core.publisher.Mono;
2524
import reactor.core.publisher.UnicastProcessor;
@@ -47,7 +46,6 @@ void responderRejectSetup() {
4746
}
4847

4948
@Test
50-
@Disabled("FIXME: needs to be revised")
5149
void requesterStreamsTerminatedOnZeroErrorFrame() {
5250
LeaksTrackingByteBufAllocator allocator =
5351
LeaksTrackingByteBufAllocator.instrument(ByteBufAllocator.DEFAULT);

rsocket-test/src/main/java/io/rsocket/test/LeaksTrackingByteBufAllocator.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public LeaksTrackingByteBufAllocator assertHasNoLeaks() {
6060

6161
final Duration awaitZeroRefCntDuration = this.awaitZeroRefCntDuration;
6262
if (!unreleased.isEmpty() && !awaitZeroRefCntDuration.isZero()) {
63-
long endTimeInMillis = System.currentTimeMillis() + awaitZeroRefCntDuration.toMillis();
63+
final long startTime = System.currentTimeMillis();
64+
final long endTimeInMillis = startTime + awaitZeroRefCntDuration.toMillis();
6465
boolean hasUnreleased;
6566
while (System.currentTimeMillis() <= endTimeInMillis) {
6667
hasUnreleased = false;
@@ -72,14 +73,21 @@ public LeaksTrackingByteBufAllocator assertHasNoLeaks() {
7273
}
7374

7475
if (!hasUnreleased) {
75-
break;
76+
System.out.println("all the buffers are released...");
77+
return this;
7678
}
7779

78-
parkNanos(100);
80+
System.out.println("await buffers to be released");
81+
for (int i = 0; i < 100; i++) {
82+
System.gc();
83+
parkNanos(1000);
84+
System.gc();
85+
}
7986
}
8087
}
8188

8289
Assertions.assertThat(unreleased).allMatch(bb -> bb.refCnt() == 0);
90+
System.out.println("all the buffers are released...");
8391
} finally {
8492
tracker.clear();
8593
}

rsocket-test/src/main/java/io/rsocket/test/TransportTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ default void setUp() {
101101
default void close() {
102102
getTransportPair().responder.awaitAllInteractionTermination(getTimeout());
103103
getTransportPair().dispose();
104+
getTransportPair().awaitClosed();
104105
getTransportPair().byteBufAllocator.assertHasNoLeaks();
105106
Hooks.resetOnOperatorDebug();
106107
}
@@ -611,6 +612,10 @@ public String expectedPayloadMetadata() {
611612
return metadata;
612613
}
613614

615+
public void awaitClosed() {
616+
server.onClose().and(client.onClose()).block(Duration.ofMinutes(1));
617+
}
618+
614619
private static class AsyncDuplexConnection implements DuplexConnection {
615620

616621
private final DuplexConnection duplexConnection;

0 commit comments

Comments
 (0)