-
Notifications
You must be signed in to change notification settings - Fork 33
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
add SdkAsyncHttpClientH1TestSuite #829
add SdkAsyncHttpClientH1TestSuite #829
Conversation
There is a task associated with this. #655 I'd prefer to cover the integration test CI in a different PR. The Scala 3 build is failing for this PR. Some classloading issue for junit. |
This is a bit different, as these are not integration tests and do not require an AWS account
Agree
I will have a look |
I managed to reproduce locally, but only in java 8. I will keep digging... |
The error was
where the important part is I tried to upgrade scala to 3.3.4, upgrade |
@jtjeferreira I merged #827 - can you rebase this and get it ready for merging? |
exceptions in toPekkoRequest should be wrapped in a future failed
SdkAsyncHttpClientH1TestSuite uses netty to simulate a server...
…ala 3 Error was: org.junit.platform.commons.JUnitException: ClassSelector [className = 'org.apache.pekko.stream.connectors.awsspi.RequestRunnerSpec$$anon$1', classLoader = java.net.URLClassLoader@79baaf07] resolution failed : ClassSelector [className = 'org.apache.pekko.stream.connectors.awsspi.RequestRunnerSpec$$anon$1', classLoader = java.net.URLClassLoader@79baaf07] resolution failed
5ce5778
to
e593362
Compare
done |
@@ -53,9 +60,11 @@ class PekkoHttpClient(shutdownHandle: () => Unit, private[awsspi] val connection | |||
lazy val runner = new RequestRunner() | |||
|
|||
override def execute(request: AsyncExecuteRequest): CompletableFuture[Void] = { | |||
val pekkoHttpRequest = toPekkoRequest(request.request(), request.requestContentPublisher()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving pekkoHttpRequest
inside runner.run
and changes below in RequestRunner.scala
were needed to make test naughtyHeaderCharactersDoNotGetToServer
pass.
The test is defined as:
@Test
public void naughtyHeaderCharactersDoNotGetToServer() {
String naughtyHeader = "foo\r\nbar";
assertThatThrownBy(() -> HttpTestUtils.sendRequest(client,
SdkHttpFullRequest.builder()
.uri(URI.create("https://localhost:" + server.port()))
.method(SdkHttpMethod.POST)
.appendHeader("h", naughtyHeader)
.build())
.join())
.hasCauseInstanceOf(Exception.class);
}
and it was failing because toPekkoRequest
is throwing an exception, but that exception should be inside a Future.failed.
See a734b17
@@ -185,14 +194,20 @@ object PekkoHttpClient { | |||
connectionPoolSettings.getOrElse(ConnectionPoolSettings(as)), | |||
resolvedOptions | |||
) | |||
|
|||
val connectionContext = | |||
if (resolvedOptions.get(SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES).booleanValue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add support for TRUST_ALL_CERTIFICATES
option so the test suite can connect to an insecure server. Unfortunately, skipping cert validation is not so easy (see for example akka/akka-http#4042)
// Future.unit.flatMap(expr) is a scala 2.12 equivalent of Future.delegate(expr) | ||
val result = Future.unit.flatMap(_ => runRequest()).flatMap { response => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open for suggestions
@@ -44,7 +43,7 @@ | |||
|
|||
import static org.junit.Assert.assertEquals; | |||
|
|||
public class S3Test extends JUnitSuite { | |||
public class S3Test { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, using JUnitSuite
from scalatest+junit is not needed, and we can remove dependency on "org.scalatestplus" %% "junit-4-13"
@@ -15,7 +15,7 @@ | |||
<appender-ref ref="STDOUT" /> | |||
</root> | |||
|
|||
<logger name="io.netty" level="trace" additivity="false"> | |||
<logger name="io.netty" level="info" additivity="false"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SdkAsyncHttpClientH1TestSuite
uses netty, and netty bootstrapping is very verbose, so I increased the log level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this comment why these changes were needed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @jtjeferreira - I will merge this now
depends on #827
There is a junit test suite in AWS SDK that might be useful to test the PekkoHttpClient