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

Bump reactor-netty to 2022.0.7 #437

Merged
merged 5 commits into from
May 23, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 29 additions & 13 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,43 @@
name: Java CI - Code tests
on: [pull_request]
env:
MAVEN_OPTS: -Dmaven.artifact.threads=4 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3
MAVEN_OPTS: >-
-Dmaven.artifact.threads=4
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
-Dmaven.wagon.httpconnectionManager.ttlSeconds=25
-Dmaven.wagon.http.retryHandler.count=3
MAVEN_CLI_OPTS: >-
--batch-mode
-Pproduction
-Dmaven.test.redirectTestOutputToFile=true
-Dsurefire.rerunFailingTestsCount=3
--update-snapshots
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: 'Set up JDK 17'
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: '17.0.3'
java-version: '17'
distribution: 'temurin'
- name: 'Cache Maven packages'
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2
key: 'cache'
restore-keys: 'cache'
- name: 'Build with Maven'
run: mvn verify -Pproduction -Dmaven.test.redirectTestOutputToFile=true -Dsurefire.rerunFailingTestsCount=3
- name: 'Remove Snapshots Before Caching'
run: find ~/.m2 -name '*SNAPSHOT' | xargs rm -Rf
- name: 'Build and test with Maven'
run: mvn verify
- name: 'Report test results'
uses: dorny/test-reporter@v1
if: always()
with:
name: Maven Tests
path: carapace-*/target/surefire-reports/*.xml
reporter: java-junit
fail-on-error: true
20 changes: 14 additions & 6 deletions carapace-server/src/test/java/org/carapaceproxy/RawClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,13 @@ public void testServerRequestContinue() throws Exception {
failed.set(true);
return;
}
resp = consumeHttpResponseInput(socket.getInputStream()).getBodyString();
System.out.println("### RESP client1: " + resp);
if (!resp.contains("resp=client1")) {
int count = 0;
do {
Thread.sleep(5_000);
resp = consumeHttpResponseInput(socket.getInputStream()).getBodyString();
System.out.println("### RESP client1: " + resp);
} while (!resp.contains("resp=client1") && count++ < 10);
if (count >= 10) {
failed.set(true);
}
} catch (Exception e) {
Expand Down Expand Up @@ -661,9 +665,13 @@ public void testMaxConnectionsAndBorrowTimeout() throws Exception {
failed.set(true);
return;
}
resp = consumeHttpResponseInput(socket.getInputStream()).getBodyString();
System.out.println("### RESP client1: " + resp);
if (!resp.contains("resp=client1")) {
int count = 0;
do {
Thread.sleep(5_000);
resp = consumeHttpResponseInput(socket.getInputStream()).getBodyString();
System.out.println("### RESP client1: " + resp);
} while (!resp.contains("resp=client1") && count++ < 10);
if (count >= 10) {
failed.set(true);
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
Expand Down Expand Up @@ -70,8 +72,6 @@ public class ConnectionPoolTest extends UseAdminServer {
@Rule
public WireMockRule wireMockRule = new WireMockRule(0);

private Properties config;

private void configureAndStartServer() throws Exception {

HttpTestUtils.overrideJvmWideHttpsVerifier();
Expand All @@ -80,10 +80,10 @@ private void configureAndStartServer() throws Exception {
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/html")
.withHeader("Content-Length", "it <b>works</b> !!".length() + "")
.withHeader("Content-Length", String.valueOf("it <b>works</b> !!".length()))
.withBody("it <b>works</b> !!")));

config = new Properties(HTTP_ADMIN_SERVER_CONFIG);
final Properties config = new Properties(HTTP_ADMIN_SERVER_CONFIG);
config.put("config.type", "database");
config.put("db.jdbc.url", "jdbc:herddb:localhost");
config.put("db.server.base.dir", tmpDir.newFolder().getAbsolutePath());
Expand All @@ -107,12 +107,12 @@ private void configureAndStartServer() throws Exception {
config.put("backend.1.id", "localhost");
config.put("backend.1.enabled", "true");
config.put("backend.1.host", "localhost");
config.put("backend.1.port", wireMockRule.port() + "");
config.put("backend.1.port", String.valueOf(wireMockRule.port()));

config.put("backend.2.id", "localhost2");
config.put("backend.2.enabled", "true");
config.put("backend.2.host", "localhost2");
config.put("backend.2.port", wireMockRule.port() + "");
config.put("backend.2.port", String.valueOf(wireMockRule.port()));

// Default director
config.put("director.1.id", "*");
Expand Down Expand Up @@ -172,55 +172,55 @@ public void hostHeaderTest() throws Exception {

//No Http header host
String response = sendRequest(false, hostname, port, path, null);
assertTrue(response.contains("Bad request"));
assertThat(response, containsString("Bad request"));

//Add Http header host
String response2 = sendRequest(true, hostname, port, path, "localhost");
assertTrue(response2.contains("it <b>works</b> !!"));
assertThat(response2, containsString("it <b>works</b> !!"));

//Empty header host
String response3 = sendRequest(true, hostname, port, path, "");
assertTrue(response3.contains("Bad request"));
assertThat(response3, containsString("Bad request"));

//Empty header host
String response4 = sendRequest(true, hostname, port, path, " ");
assertTrue(response4.contains("Bad request"));
assertThat(response4, containsString("Bad request"));

//Header host with special character
String response5 = sendRequest(true, hostname, port, path, "local%&&host");
assertTrue(response5.contains("Bad request"));
assertThat(response5, containsString("Bad request"));

//Header host with multiple domain
String response6 = sendRequest(true, hostname, port, path, "localhost1,localhost2");
assertTrue(response6.contains("Bad request"));
assertThat(response6, containsString("Bad request"));

//Ip address as host header
String response7 = sendRequest(true, hostname, port, path, "127.0.0.1");
assertTrue(response7.contains("it <b>works</b> !!"));
assertThat(response7, containsString("it <b>works</b> !!"));

//Invalid ip address
String response8 = sendRequest(true, hostname, port, path, "256.0.0.0");
assertTrue(response8.contains("Bad request"));
assertThat(response8, containsString("Bad request"));

//Ip address as host header with port
String response9 = sendRequest(true, hostname, port, path, "127.0.0.1:8080");
assertTrue(response9.contains("it <b>works</b> !!"));
assertThat(response9, containsString("it <b>works</b> !!"));

//Hostname as host header with port
String response10 = sendRequest(true, hostname, port, path, "localhost:8080");
assertTrue(response10.contains("it <b>works</b> !!"));
assertThat(response10, containsString("it <b>works</b> !!"));

//Hostname as host header with port
String response11 = sendRequest(true, hostname, port, path, "localhost:8080&");
assertTrue(response11.contains("Bad request"));
assertThat(response11, containsString("Bad Request"));

//Invalid hostname
String response12 = sendRequest(true, hostname, port, path, "::::8080::9999");
assertTrue(response12.contains("Bad request"));
assertThat(response12, containsString("Bad Request"));

//Add Http header host
String response13 = sendRequest(true, hostname, port, path, "localhost3");
assertTrue(response13.contains("it <b>works</b> !!"));
assertThat(response13, containsString("it <b>works</b> !!"));
}

public String sendRequest(boolean addHeaderHost, String hostname, int port, String path, String headerHost) throws IOException {
Expand Down Expand Up @@ -271,8 +271,9 @@ public void test() throws Exception {
ConnectionProvider provider = connectionPools.get(defaultPool);
assertThat(provider, not(nullValue()));
Map<SocketAddress, Integer> maxConnectionsPerHost = provider.maxConnectionsPerHost();
assertThat(maxConnectionsPerHost, is(notNullValue(Map.class)));
assertThat(maxConnectionsPerHost.size(), is(2));
maxConnectionsPerHost.values().stream().allMatch(e -> e == 10);
assertTrue(maxConnectionsPerHost.values().stream().allMatch(e -> e == 10));
}

// pool with defaults
Expand All @@ -283,8 +284,9 @@ public void test() throws Exception {
ConnectionProvider provider = connectionPools.get(poolWithDefaults);
assertThat(provider, not(nullValue()));
Map<SocketAddress, Integer> maxConnectionsPerHost = provider.maxConnectionsPerHost();
assertThat(maxConnectionsPerHost, is(notNullValue(Map.class)));
assertThat(maxConnectionsPerHost.size(), is(2));
maxConnectionsPerHost.values().stream().allMatch(e -> e == 10);
assertTrue(maxConnectionsPerHost.values().stream().allMatch(e -> e == 10));
}

// custom pool
Expand All @@ -295,8 +297,9 @@ public void test() throws Exception {
ConnectionProvider provider = connectionPools.get(customPool);
assertThat(provider, not(nullValue()));
Map<SocketAddress, Integer> maxConnectionsPerHost = provider.maxConnectionsPerHost();
assertThat(maxConnectionsPerHost, is(notNullValue(Map.class)));
assertThat(maxConnectionsPerHost.size(), is(2));
maxConnectionsPerHost.values().stream().allMatch(e -> e == 20);
assertTrue(maxConnectionsPerHost.values().stream().allMatch(e -> e == 20));
}

// connection pool selection
Expand All @@ -313,8 +316,9 @@ public void test() throws Exception {
assertThat(res.getKey(), is(defaultPool));
ConnectionProvider provider = res.getValue();
Map<SocketAddress, Integer> maxConnectionsPerHost = provider.maxConnectionsPerHost();
assertThat(maxConnectionsPerHost, is(notNullValue(Map.class)));
assertThat(maxConnectionsPerHost.size(), is(2));
maxConnectionsPerHost.values().stream().allMatch(e -> e == 10);
assertTrue(maxConnectionsPerHost.values().stream().allMatch(e -> e == 10));

try (RawHttpClient client = new RawHttpClient("localhost", port)) {
RawHttpClient.HttpResponse resp = client.executeRequest("GET /index.html HTTP/1.1\r\n" + HttpHeaderNames.HOST + ": localhostx" + "\r\n\r\n");
Expand All @@ -337,8 +341,9 @@ public void test() throws Exception {
assertThat(res.getKey(), is(poolWithDefaults));
ConnectionProvider provider = res.getValue();
Map<SocketAddress, Integer> maxConnectionsPerHost = provider.maxConnectionsPerHost();
assertThat(maxConnectionsPerHost, is(notNullValue(Map.class)));
assertThat(maxConnectionsPerHost.size(), is(2));
maxConnectionsPerHost.values().stream().allMatch(e -> e == 10);
assertTrue(maxConnectionsPerHost.values().stream().allMatch(e -> e == 10));

try (RawHttpClient client = new RawHttpClient("localhost", port)) {
RawHttpClient.HttpResponse resp = client.executeRequest("GET /index.html HTTP/1.1\r\n" + HttpHeaderNames.HOST + ": localhost" + "\r\n\r\n");
Expand All @@ -361,8 +366,9 @@ public void test() throws Exception {
assertThat(res.getKey(), is(customPool));
ConnectionProvider provider = res.getValue();
Map<SocketAddress, Integer> maxConnectionsPerHost = provider.maxConnectionsPerHost();
assertThat(maxConnectionsPerHost, is(notNullValue(Map.class)));
assertThat(maxConnectionsPerHost.size(), is(2));
maxConnectionsPerHost.values().stream().allMatch(e -> e == 20);
assertTrue(maxConnectionsPerHost.values().stream().allMatch(e -> e == 20));

try (RawHttpClient client = new RawHttpClient("localhost", port)) {
RawHttpClient.HttpResponse resp = client.executeRequest("GET /index.html HTTP/1.1\r\n" + HttpHeaderNames.HOST + ": localhost3" + "\r\n\r\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ public void test() throws Exception {

HttpResponse<String> response2 = httpClient2.send(request, HttpResponse.BodyHandlers.ofString());

assertEquals(413, response2.statusCode());
assertEquals(431, response2.statusCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@
public TemporaryFolder tmpDir = new TemporaryFolder();

@Test
public void testWithContentLenghtHeader() throws Exception {
public void testWithContentLengthHeader() throws Exception {

String body = "01234567890123456789";

stubFor(get(urlEqualTo("/index.html"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/html")
.withHeader("Content-Length", body.length() + "")
.withHeader("Content-Length", String.valueOf(body.length()))
.withBody(body)));

testFileSizeCache(body, false);
}

@Test
public void testWithoutContentLenghtHeader() throws Exception {
public void testWithoutContentLengthHeader() throws Exception {

String body = "01234567890123456789";

Expand All @@ -86,7 +86,7 @@

// No size checking
{
try (HttpProxyServer server = HttpProxyServer.buildForTests("localhost", 0, mapper, tmpDir.newFolder());) {
try (HttpProxyServer server = HttpProxyServer.buildForTests("localhost", 0, mapper, tmpDir.newFolder())) {
server.getCurrentConfiguration().setCacheMaxFileSize(0);
server.getCurrentConfiguration().setRequestCompressionEnabled(false);
server.getCache().reloadConfiguration(server.getCurrentConfiguration());
Expand All @@ -102,7 +102,7 @@

// Max size set to current content size
{
try (HttpProxyServer server = HttpProxyServer.buildForTests("localhost", 0, mapper, tmpDir.newFolder());) {
try (HttpProxyServer server = HttpProxyServer.buildForTests("localhost", 0, mapper, tmpDir.newFolder())) {
server.getCurrentConfiguration().setCacheMaxFileSize(body.length());
server.getCurrentConfiguration().setRequestCompressionEnabled(false);
server.getCache().reloadConfiguration(server.getCurrentConfiguration());
Expand All @@ -118,7 +118,7 @@

// Max size set to drop current content
{
try (HttpProxyServer server = HttpProxyServer.buildForTests("localhost", 0, mapper, tmpDir.newFolder());) {
try (HttpProxyServer server = HttpProxyServer.buildForTests("localhost", 0, mapper, tmpDir.newFolder())) {
server.getCurrentConfiguration().setCacheMaxFileSize(body.length() - 1);
server.getCurrentConfiguration().setRequestCompressionEnabled(false);
server.getCache().reloadConfiguration(server.getCurrentConfiguration());
Expand Down Expand Up @@ -153,7 +153,7 @@

EndpointStats stats = server.getProxyRequestsManager().getEndpointStats(key);
assertNotNull(stats);
assertThat(server.getCache().getCacheSize(), is(cacheSize));

Check failure on line 156 in carapace-server/src/test/java/org/carapaceproxy/server/cache/CacheContentLengthLimitTest.java

View workflow job for this annotation

GitHub Actions / Maven Tests

org.carapaceproxy.server.cache.CacheContentLengthLimitTest ► testWithContentLengthHeader

Failed test found in: carapace-server/target/surefire-reports/TEST-org.carapaceproxy.server.cache.CacheContentLengthLimitTest.xml Error: java.lang.AssertionError:
Raw output
java.lang.AssertionError: 

Expected: is <1>
     but: was <0>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
	at org.carapaceproxy.server.cache.CacheContentLengthLimitTest.requestAndTestCached(CacheContentLengthLimitTest.java:156)
	at org.carapaceproxy.server.cache.CacheContentLengthLimitTest.testFileSizeCache(CacheContentLengthLimitTest.java:96)
	at org.carapaceproxy.server.cache.CacheContentLengthLimitTest.testWithContentLengthHeader(CacheContentLengthLimitTest.java:65)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:54)
	at com.github.tomakehurst.wiremock.junit.WireMockRule$1.evaluate(WireMockRule.java:67)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
}
}

Expand Down