Skip to content
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

Minor corrections for tests #3093

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
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 @@ -23,6 +23,7 @@
import io.servicetalk.concurrent.api.Executors;
import io.servicetalk.concurrent.api.Publisher;
import io.servicetalk.concurrent.api.Single;
import io.servicetalk.concurrent.internal.TestTimeoutConstants;
import io.servicetalk.http.api.FilterableStreamingHttpConnection;
import io.servicetalk.http.api.HttpLifecycleObserver;
import io.servicetalk.http.api.HttpProtocolConfig;
Expand Down Expand Up @@ -83,7 +84,6 @@
import static io.servicetalk.transport.netty.internal.AddressUtils.localAddress;
import static io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort;
import static io.servicetalk.utils.internal.ThrowableUtils.throwException;
import static java.lang.Boolean.parseBoolean;
import static java.lang.Thread.NORM_PRIORITY;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -235,7 +235,7 @@ Single<HttpServerContext> listen(HttpServerBuilder builder) {
}

void ignoreTestWhen(ExecutorSupplier clientExecutorSupplier, ExecutorSupplier serverExecutorSupplier) {
assumeFalse(parseBoolean(System.getenv("CI")) &&
assumeFalse(TestTimeoutConstants.CI &&
this.clientExecutorSupplier == clientExecutorSupplier &&
this.serverExecutorSupplier == serverExecutorSupplier,
"Ignored flaky test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import static io.servicetalk.concurrent.api.AsyncCloseables.emptyAsyncCloseable;
import static io.servicetalk.concurrent.api.Single.succeeded;
import static io.servicetalk.http.api.HttpSerializers.textSerializerUtf8;
import static io.servicetalk.transport.netty.internal.AddressUtils.localAddress;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -71,7 +72,7 @@ void testFactoryOffloading(boolean offload, HttpExecutionStrategy httpStrategy)

Thread appThread = Thread.currentThread();

try (ServerContext server = HttpServers.forPort(0)
try (ServerContext server = HttpServers.forAddress(localAddress(0))
.listenAndAwait(ConnectionFactoryOffloadingTest::helloWorld)) {
SocketAddress serverAddress = server.listenAddress();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,16 @@
import static io.servicetalk.capacity.limiter.api.CapacityLimiters.fixedCapacity;
import static io.servicetalk.concurrent.api.Single.succeeded;
import static io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION;
import static io.servicetalk.concurrent.internal.TestTimeoutConstants.CI;
import static io.servicetalk.http.api.HttpProtocolVersion.HTTP_1_1;
import static io.servicetalk.http.netty.AsyncContextHttpFilterVerifier.verifyServerFilterAsyncContextVisibility;
import static io.servicetalk.http.netty.HttpProtocolConfigs.h1Default;
import static io.servicetalk.http.netty.HttpProtocolConfigs.h2Default;
import static io.servicetalk.http.netty.HttpServers.forAddress;
import static io.servicetalk.traffic.resilience.http.NoOpTrafficResiliencyObserver.NO_OP_TICKET_OBSERVER;
import static io.servicetalk.transport.api.ServiceTalkSocketOptions.CONNECT_TIMEOUT;
import static io.servicetalk.transport.api.ServiceTalkSocketOptions.SO_BACKLOG;
import static io.servicetalk.transport.netty.internal.AddressUtils.localAddress;
import static io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort;
import static java.lang.Boolean.parseBoolean;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -85,8 +84,6 @@ class TrafficResilienceHttpServiceFilterTest {

private static final boolean IS_LINUX = "linux".equals(normalizedOs());

private static final boolean CI = parseBoolean(System.getenv("CI"));

// There is an off-by-one behavior difference between macOS & Linux.
// Linux has a greater-than check
// (see. https://github.com/torvalds/linux/blob/5bfc75d92efd494db37f5c4c173d3639d4772966/include/net/sock.h#L941)
Expand All @@ -104,8 +101,8 @@ void verifyPeerRejectionCallbacks() throws Exception {
final AtomicInteger consumption = new AtomicInteger();
// Expect two state changes
final CountDownLatch latch = new CountDownLatch(2);
try (ServerContext serverContext = HttpServers.forPort(0).listenAndAwait((ctx, request, responseFactory) ->
succeeded(responseFactory.serviceUnavailable()))) {
try (ServerContext serverContext = HttpServers.forAddress(localAddress(0))
.listenBlockingAndAwait((ctx, request, responseFactory) -> responseFactory.serviceUnavailable())) {
final TrafficResilienceHttpClientFilter trafficResilienceHttpClientFilter =
new TrafficResilienceHttpClientFilter.Builder(() -> CapacityLimiters.fixedCapacity(1)
.stateObserver((capacity, consumed) -> {
Expand Down Expand Up @@ -226,7 +223,7 @@ void testStopAcceptingConnections(final boolean dryRun, final String protocol) t
.dryRun(dryRun)
.build();

final HttpServerContext serverContext = forAddress(localAddress(0))
final HttpServerContext serverContext = HttpServers.forAddress(localAddress(0))
.protocols(protocolConfig)
.listenSocketOption(SO_BACKLOG, TCP_BACKLOG)
.appendNonOffloadingServiceFilter(filter)
Expand Down
Loading