Add tests to verify Jetty's thread pool defaults match server defaults

Closes gh-21213
pull/21480/head
Madhura Bhave 5 years ago
parent f29bce657e
commit 5583f64b1f

@ -40,6 +40,8 @@ import org.apache.catalina.valves.RemoteIpValve;
import org.apache.coyote.AbstractProtocol; import org.apache.coyote.AbstractProtocol;
import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.thread.ThreadPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat.Accesslog; import org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat.Accesslog;
@ -55,6 +57,7 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.ClientHttpResponse;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.util.unit.DataSize; import org.springframework.util.unit.DataSize;
@ -354,6 +357,20 @@ class ServerPropertiesTests {
assertThat(this.properties.getTomcat().getUseRelativeRedirects()).isFalse(); assertThat(this.properties.getTomcat().getUseRelativeRedirects()).isFalse();
} }
@Test
void jettyThreadPoolPropertyDefaultsShouldMatchServerDefault() {
JettyServletWebServerFactory jettyFactory = new JettyServletWebServerFactory(0);
JettyWebServer jetty = (JettyWebServer) jettyFactory.getWebServer();
Server server = (Server) ReflectionTestUtils.getField(jetty, "server");
ThreadPool threadPool = (ThreadPool) ReflectionTestUtils.getField(server, "_threadPool");
int idleTimeout = (int) ReflectionTestUtils.getField(threadPool, "_idleTimeout");
int maxThreads = (int) ReflectionTestUtils.getField(threadPool, "_maxThreads");
int minThreads = (int) ReflectionTestUtils.getField(threadPool, "_minThreads");
assertThat(this.properties.getJetty().getThreadIdleTimeout().toMillis()).isEqualTo(idleTimeout);
assertThat(this.properties.getJetty().getMaxThreads()).isEqualTo(maxThreads);
assertThat(this.properties.getJetty().getMinThreads()).isEqualTo(minThreads);
}
@Test @Test
void jettyMaxHttpFormPostSizeMatchesDefault() throws Exception { void jettyMaxHttpFormPostSizeMatchesDefault() throws Exception {
JettyServletWebServerFactory jettyFactory = new JettyServletWebServerFactory(0); JettyServletWebServerFactory jettyFactory = new JettyServletWebServerFactory(0);

Loading…
Cancel
Save