Skip to content

Commit

Permalink
fix jmh Microbenchmarks (#8990)
Browse files Browse the repository at this point in the history
# Pull Request Checklist

* [X] Have you read [How to write the perfect pull request](https://github.com/blog/1943-how-to-write-the-perfect-pull-request)?
* [X] Have you read through the [contributor guidelines](https://www.playframework.com/contributing)?
* [X] Have you signed the [Lightbend CLA](https://www.lightbend.com/contribute/cla)?
* [ ] Have you referenced any issues you're fixing using [commit message keywords](https://help.github.com/articles/closing-issues-using-keywords/)?
* [X] Have you added copyright headers to new files?
* [X] Have you checked that both Scala and Java APIs are updated?
* [X] Have you updated the documentation for both Scala and Java sections?
* [X] Have you added tests for any changed functionality?

# Helpful things

## Purpose

Fixes `p.microbenchmark.it.HelloWorldBenchmark` when using akka-http-2 (ak-20-enc) and akka http1.1 encrypted (ak-11-enc)

## Background Context

`ak-20-enc` was failing with a `java.lang.ClassNotFoundException: akka.http.scaladsl.Http2` exception because of missing akka-http2-support jar.
`ak-11-enc` was failing with a `javax.net.ssl.SSLPeerUnverifiedException: Hostname localhost not verified:` which was solved by setting the a dumb `hostnameVerifier` in the OkHttp client


(cherry picked from commit 524aa8b)
  • Loading branch information
jtjeferreira authored and dwijnand committed Mar 12, 2019
1 parent f1dc7a1 commit 985ee6a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ lazy val PlayMicrobenchmarkProject = PlayCrossBuiltProject("Play-Microbenchmark"
PlaySpecs2Project,
PlayFiltersHelpersProject,
PlayJavaProject,
PlayNettyServerProject
PlayNettyServerProject,
PlayAkkaHttpServerProject,
PlayAkkaHttp2SupportProject
)

lazy val PlayCacheProject = PlayCrossBuiltProject("Play-Cache", "cache/play-cache")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import okhttp3.OkHttpClient
import okhttp3.Protocol
import okhttp3.Request
import okhttp3.Response
import javax.net.ssl.SSLSession
import org.openjdk.jmh.annotations._
import play.api.mvc.Results
import play.api.test.ApplicationFactory
Expand Down Expand Up @@ -117,6 +118,7 @@ object HelloWorldBenchmark {
val b2 = bench.serverEndpoint.ssl match {
case Some(ssl) =>
b1.sslSocketFactory(ssl.sslContext.getSocketFactory, ssl.trustManager)
.hostnameVerifier((s: String, sslSession: SSLSession) => true)
case _ => b1
}
b2.build()
Expand Down
3 changes: 2 additions & 1 deletion scripts/validate-microbenchmarks
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ printMessage "VALIDATING MICROBENCHMARKS"
# We are using double-double quotes here so that the command
# is passed to runSbt as a single command and internally be
# passed to sbt as a single command too.
runSbt "Play-Microbenchmark/jmh:run -i 1 -wi 0 -f 1 -t 1"
# foe = FailOnError http://mail.openjdk.java.net/pipermail/jmh-dev/2015-February/001685.html
runSbt "Play-Microbenchmark/jmh:run -i 1 -wi 0 -f 1 -t 1 -foe=true"

printMessage "BENCHMARKS VALIDATED"

0 comments on commit 985ee6a

Please sign in to comment.