Skip to content

Fixing Flaky ReactorNetty4StreamingStressIT test case (another attempt) #18193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.opensearch.client.Response;
import org.opensearch.client.StreamingRequest;
import org.opensearch.client.StreamingResponse;
import org.opensearch.common.settings.Settings;
import org.opensearch.test.rest.OpenSearchRestTestCase;
import org.junit.After;

Expand All @@ -22,6 +23,7 @@
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;

Expand All @@ -44,7 +46,11 @@ public void tearDown() throws Exception {
super.tearDown();
}

@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/15840")
@Override
protected Settings restClientSettings() {
return Settings.builder().put(super.restClientSettings()).put(CLIENT_SOCKET_TIMEOUT, "5s").build();
}

public void testCloseClientStreamingRequest() throws Exception {
final VirtualTimeScheduler scheduler = VirtualTimeScheduler.create(true);

Expand All @@ -67,17 +73,19 @@ public void testCloseClientStreamingRequest() throws Exception {
final StreamingResponse<ByteBuffer> streamingResponse = client().streamRequest(streamingRequest);
scheduler.advanceTimeBy(delay); /* emit first element */

StepVerifier.create(Flux.from(streamingResponse.getBody()).map(b -> new String(b.array(), StandardCharsets.UTF_8)))
.expectNextMatches(s -> s.contains("\"result\":\"created\"") && s.contains("\"_id\":\"1\""))
.then(() -> {
try {
client().close();
} catch (final IOException ex) {
throw new UncheckedIOException(ex);
}
})
StepVerifier.create(
Flux.from(streamingResponse.getBody()).timeout(Duration.ofSeconds(5)).map(b -> new String(b.array(), StandardCharsets.UTF_8))
).expectNextMatches(s -> s.contains("\"result\":\"created\"") && s.contains("\"_id\":\"1\"")).then(() -> {
try {
client().close();
} catch (final IOException ex) {
throw new UncheckedIOException(ex);
}
})
.then(() -> scheduler.advanceTimeBy(delay))
.expectErrorMatches(t -> t instanceof InterruptedIOException || t instanceof ConnectionClosedException)
.expectErrorMatches(
t -> t instanceof InterruptedIOException || t instanceof ConnectionClosedException || t instanceof TimeoutException
)
.verify(Duration.ofSeconds(10));
}
}
Loading