Skip to content

Commit

Permalink
Fixes #90 - Start SslContextFactory.Client eagerly.
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Jun 14, 2021
1 parent 037994f commit 3f7dee2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public static Builder builder() {
addBean(config);
addBean(config.getExecutor());
addBean(config.getScheduler());
addBean(config.getSslContextFactory());
}

private CompletableFuture<Void> spawn() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.SocketAddressResolver;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -104,6 +107,34 @@ public void testDefaultConfiguration() throws Exception {
loadGenerator.begin().get(5, TimeUnit.SECONDS);
}

@Test
public void testComponentsAreStarted() throws Exception {
startServer(new TestHandler());

QueuedThreadPool threadPool = new QueuedThreadPool();
ScheduledExecutorScheduler scheduler = new ScheduledExecutorScheduler();
SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
LoadGenerator loadGenerator = new LoadGenerator.Builder()
.port(connector.getLocalPort())
.httpClientTransportBuilder(clientTransportBuilder)
.executor(threadPool)
.scheduler(scheduler)
.sslContextFactory(sslContextFactory)
.build();

loadGenerator.start();
try {
Assert.assertTrue(threadPool.isStarted());
Assert.assertTrue(scheduler.isStarted());
Assert.assertTrue(sslContextFactory.isStarted());
} finally {
loadGenerator.stop();
Assert.assertTrue(threadPool.isStopped());
Assert.assertTrue(scheduler.isStopped());
Assert.assertTrue(sslContextFactory.isStopped());
}
}

@Test
public void testSlowServer() throws Exception {
int iterations = 1;
Expand Down Expand Up @@ -207,9 +238,7 @@ public void handle(String target, org.eclipse.jetty.server.Request jettyRequest,
.port(connector.getLocalPort())
.httpClientTransportBuilder(clientTransportBuilder)
.iterationsPerThread(0)
.resourceListener((Resource.NodeListener)info -> {
info.getLoadGenerator().interrupt();
});
.resourceListener((Resource.NodeListener)info -> info.getLoadGenerator().interrupt());
LoadGenerator loadGenerator = new LoadGenerator(config) {
@Override
boolean isInterrupted() {
Expand Down

0 comments on commit 3f7dee2

Please sign in to comment.