Bläddra i källkod

Update Hexagon version (#5305)

* Update Hexagon benchmark

* Update Hexagon benchmark

* Remove features not used in tests

* Remove MySql storage

* Enable Resin test

* Upgrade Hexagon to v0.11

* Disable Resin

* Fix dependencies

* Improve template rendering

* Test in travis

* Fix build script

* Restore Travis script

* Restore Travis script

* MySQL store support and MongoDB fix

* Fix MySQL test

* Fix MySQL test

* Fix MySQL test

* Travis testing

* Fix MySQL test

* Restore Travis

* Take MySQL URL from other test

* Add PostgreSQL support

* Update version and tests

* Update version and tests

* Only test Hexagon in fork

* Fix config

* Fix config

* Update version and tests

* Remove Resin tests

* Restore Travis

* Restore Travis

* Upgrade framework version

* Reduce local tests temporarily

* Disable Resin tests

* Fix Gradle Wrapper issues

* Restore Resin tests

* Add Bintray repository

* Disable Resin backend

* Restore master's

* Upgrade framework version

* Test only Hexagon changes (temporary)

* Test Hexagon in Travis CI

* Add Undertow support

* Test only Undertow

* Restore Travis jobs

* Enable all Hexagon's variants

* Optimize benchmark

* Fix documentation

* Fix documentation

* Add Gradle Wrapper

* Move code to conform with Kotlin's coding standards

* Trace more information (only in tests)

* Add mini performance tests (to be sure everything would be fine in TFB)

* Support different template engines

* Add configuration properties

* Drop Undertow engine

* Update versions and dependencies

* Update documentation

* Ignore Gradle directories

* Update configuration

* Update benchmark

* Improve benchmark

* Improve benchmark dockerfiles

* Next Hexagon release

* Delete Gatlin simulation

* Fix url for testing

* Remove Gatling test

* Update Hexagon benchmark

* Improve data update test

* Merge Hexagon config

* Remove batch for updates benchmark

* Fix compilation problem

* Update Kotlin version

* Update dependencies and tools

* Move source files to their package directories

* Update Gradle version

* Update

* Update Hexagon version

* Update Hexagon version

* Update Hexagon version

* Disable logging

* Update versions

* Update versions

* Update Hexagon version

* Fix dockerfiles

* Fix link
Juanjo Aguililla 5 år sedan
förälder
incheckning
f050af8636

+ 5 - 0
frameworks/Kotlin/hexagon/.gitignore

@@ -0,0 +1,5 @@
+
+gradle/
+gradlew*
+
+src/test/scala/

+ 8 - 8
frameworks/Kotlin/hexagon/README.md

@@ -1,13 +1,13 @@
 
 # Hexagon Benchmarking Test
 
-This is the Hexagon portion of a [benchmarking test suite](../) comparing a variety of web
-development platforms. The test utilizes Hexagon routes, serialization and database access.
+This is the Hexagon portion of a [benchmarking test suite](../../../README.md) comparing a variety
+of web development platforms. The test utilizes Hexagon routes, serialization and database access.
 
 ## Tests
 
-* [Hexagon Web](/src/main/kotlin/com/hexagonkt/Benchmark.kt)
-* [Hexagon Storage](/src/main/kotlin/com/hexagonkt/BenchmarkStorage.kt)
+* [Hexagon Web](src/main/kotlin/com/hexagonkt/Benchmark.kt)
+* [Hexagon Storage](src/main/kotlin/com/hexagonkt/BenchmarkStorage.kt)
 
 ## Infrastructure Software Versions
 
@@ -25,8 +25,8 @@ and `${TEMPLATE_ENGINE}` with: `pebble`
 ### Jetty
 
 * JSON Encoding Test: http://localhost:9090/json
-* Plain Text Test: http://localhost:9090/plaintext 
-* Data-Store/Database Mapping Test: http://localhost:9090/${DB_ENGINE}/db?queries=5 
+* Plain Text Test: http://localhost:9090/plaintext
+* Data-Store/Database Mapping Test: http://localhost:9090/${DB_ENGINE}/db?queries=5
 * Fortunes: http://localhost:9090/${DB_ENGINE}/${TEMPLATE_ENGINE}/fortunes
 * Database updates: http://localhost:9090/${DB_ENGINE}/update
 * Database queries: http://localhost:9090/${DB_ENGINE}/query
@@ -34,8 +34,8 @@ and `${TEMPLATE_ENGINE}` with: `pebble`
 ### Resin
 
 * JSON Encoding Test: http://localhost:8080/json
-* Plain Text Test: http://localhost:8080/plaintext 
-* Data-Store/Database Mapping Test: http://localhost:8080/${DB_ENGINE}/db?queries=5 
+* Plain Text Test: http://localhost:8080/plaintext
+* Data-Store/Database Mapping Test: http://localhost:8080/${DB_ENGINE}/db?queries=5
 * Fortunes: http://localhost:8080/${DB_ENGINE}/${TEMPLATE_ENGINE}/fortunes
 * Database updates: http://localhost:8080/${DB_ENGINE}/update
 * Database queries: http://localhost:8080/${DB_ENGINE}/query

+ 3 - 3
frameworks/Kotlin/hexagon/build.gradle

@@ -1,6 +1,6 @@
 
 plugins {
-    id "org.jetbrains.kotlin.jvm" version "1.3.31"
+    id "org.jetbrains.kotlin.jvm" version "1.3.61"
 }
 
 apply(from: "$gradleScripts/kotlin.gradle")
@@ -12,10 +12,10 @@ apply(plugin: "war")
 defaultTasks("installDist")
 
 mainClassName = "com.hexagonkt.BenchmarkKt"
-applicationDefaultJvmArgs = [ "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts" ]
+applicationDefaultJvmArgs = [ "-XX:+UseNUMA", "-XX:+UseParallelGC" ]
 
 war {
-    archiveName = "ROOT.war"
+    archiveFileName = "ROOT.war"
 }
 
 installDist.dependsOn("war")

+ 7 - 7
frameworks/Kotlin/hexagon/gradle.properties

@@ -1,11 +1,11 @@
 description=Hexagon web framework's benchmark
-gradleScripts=https\://raw.githubusercontent.com/hexagonkt/hexagon/1.0.0/gradle
-hexagonVersion=1.0.0
-hikariVersion=3.3.1
-jettyVersion=9.4.18.v20190429
-kotlinCoroutinesVersion=1.2.1
-kotlinVersion=1.3.31
+gradleScripts=https\://raw.githubusercontent.com/hexagonkt/hexagon/1.1.3/gradle
+hexagonVersion=1.1.3
+hikariVersion=3.4.1
+jettyVersion=9.4.24.v20191120
+kotlinCoroutinesVersion=1.3.3
+kotlinVersion=1.3.61
 logbackVersion=1.2.3
 name=hexagon
-postgresqlVersion=42.2.5.jre7
+postgresqlVersion=42.2.8
 testngVersion=6.14.3

+ 2 - 2
frameworks/Kotlin/hexagon/hexagon-jetty-postgresql.dockerfile

@@ -2,7 +2,7 @@
 #
 # BUILD
 #
-FROM gradle:5.4.1-jdk11 AS gradle_build
+FROM gradle:5.5.1-jdk11 AS gradle_build
 USER root
 WORKDIR /hexagon
 
@@ -14,7 +14,7 @@ RUN gradle --quiet --exclude-task test
 #
 # RUNTIME
 #
-FROM openjdk:11.0.3-jdk-stretch
+FROM openjdk:11.0.3-jre-stretch
 ENV DBSTORE postgresql
 ENV POSTGRESQL_DB_HOST tfb-database
 ENV WEBENGINE jetty

+ 4 - 3
frameworks/Kotlin/hexagon/hexagon-resin-mongodb.dockerfile

@@ -2,7 +2,7 @@
 #
 # BUILD
 #
-FROM gradle:5.4.1-jdk11 AS gradle_build
+FROM gradle:5.5.1-jdk11 AS gradle_build
 USER root
 WORKDIR /hexagon
 
@@ -14,12 +14,13 @@ RUN gradle --quiet --exclude-task test
 #
 # RUNTIME
 #
-FROM openjdk:11.0.3-jdk-stretch
+FROM openjdk:11.0.3-jre-stretch
 ENV DBSTORE mongodb
 ENV MONGODB_DB_HOST tfb-database
+ENV RESIN http://caucho.com/download/resin-4.0.61.tar.gz
 
 WORKDIR /resin
-RUN curl -sL http://caucho.com/download/resin-4.0.61.tar.gz | tar xz --strip-components=1
+RUN curl -sL $RESIN | tar xz --strip-components=1
 RUN rm -rf webapps/*
 COPY --from=gradle_build /hexagon/build/libs/ROOT.war webapps/ROOT.war
 COPY resin.xml conf/resin.xml

+ 4 - 3
frameworks/Kotlin/hexagon/hexagon-resin-postgresql.dockerfile

@@ -2,7 +2,7 @@
 #
 # BUILD
 #
-FROM gradle:5.4.1-jdk11 AS gradle_build
+FROM gradle:5.5.1-jdk11 AS gradle_build
 USER root
 WORKDIR /hexagon
 
@@ -14,12 +14,13 @@ RUN gradle --quiet --exclude-task test
 #
 # RUNTIME
 #
-FROM openjdk:11.0.3-jdk-stretch
+FROM openjdk:11.0.3-jre-stretch
 ENV DBSTORE postgresql
 ENV POSTGRESQL_DB_HOST tfb-database
+ENV RESIN http://caucho.com/download/resin-4.0.61.tar.gz
 
 WORKDIR /resin
-RUN curl -sL http://caucho.com/download/resin-4.0.61.tar.gz | tar xz --strip-components=1
+RUN curl -sL $RESIN | tar xz --strip-components=1
 RUN rm -rf webapps/*
 COPY --from=gradle_build /hexagon/build/libs/ROOT.war webapps/ROOT.war
 COPY resin.xml conf/resin.xml

+ 2 - 2
frameworks/Kotlin/hexagon/hexagon.dockerfile

@@ -2,7 +2,7 @@
 #
 # BUILD
 #
-FROM gradle:5.4.1-jdk11 AS gradle_build
+FROM gradle:5.5.1-jdk11 AS gradle_build
 USER root
 WORKDIR /hexagon
 
@@ -14,7 +14,7 @@ RUN gradle --quiet --exclude-task test
 #
 # RUNTIME
 #
-FROM openjdk:11.0.3-jdk-stretch
+FROM openjdk:11.0.3-jre-stretch
 ENV DBSTORE mongodb
 ENV MONGODB_DB_HOST tfb-database
 ENV WEBENGINE jetty

+ 13 - 15
frameworks/Kotlin/hexagon/resin.xml

@@ -1,18 +1,16 @@
-<resin xmlns="http://caucho.com/ns/resin"
-       xmlns:resin="http://caucho.com/ns/resin/core">
+<resin xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core">
 
-    <cluster id="">
-        <resin:import path="/resin/conf/app-default.xml" />
-        
-        <log name="" level="config" path="stdout:" timestamp="[%H:%M:%S.%s] " />
+  <cluster id="">
+    <resin:import path="/resin/conf/app-default.xml"/>
 
-        <server id="">
-            <http port="8080" />
-        </server>
+    <log name="" level="config" path="stdout:" timestamp="[%H:%M:%S.%s] "/>
 
-        <host>
-            <web-app-deploy path="/resin/webapps"
-                            expand-preserve-fileset="WEB-INF/work/**"/>
-        </host>
-    </cluster>
-</resin>
+    <server id="">
+      <http port="8080"/>
+    </server>
+
+    <host>
+      <web-app-deploy path="/resin/webapps" expand-preserve-fileset="WEB-INF/work/**"/>
+    </host>
+  </cluster>
+</resin>

+ 8 - 8
frameworks/Kotlin/hexagon/src/main/kotlin/com/hexagonkt/Benchmark.kt

@@ -35,14 +35,9 @@ internal val benchmarkTemplateEngines: Map<String, TemplatePort> by lazy {
     mapOf("pebble" to PebbleAdapter)
 }
 
-private val defaultLocale = Locale.getDefault()
+internal val engine by lazy { createEngine() }
 
-private val engine by lazy {
-    when (systemSetting("WEBENGINE", "jetty")) {
-        "jetty" -> JettyServletAdapter()
-        else -> error("Unsupported server engine")
-    }
-}
+private val defaultLocale = Locale.getDefault()
 
 private val router: Router by lazy {
     Router {
@@ -54,7 +49,7 @@ private val router: Router by lazy {
         get("/plaintext") { ok(TEXT_MESSAGE, "text/plain") }
         get("/json") { ok(Message(TEXT_MESSAGE), Json) }
 
-        benchmarkStores.forEach { storeEngine, store ->
+        benchmarkStores.forEach { (storeEngine, store) ->
             benchmarkTemplateEngines.forEach { templateKind ->
                 val path = "/$storeEngine/${templateKind.key}/fortunes"
 
@@ -71,6 +66,11 @@ private val router: Router by lazy {
 internal val benchmarkServer: Server by lazy { Server(engine, router, SettingsManager.settings) }
 
 // UTILITIES
+internal fun createEngine(): ServerPort = when (systemSetting("WEBENGINE", "jetty")) {
+    "jetty" -> JettyServletAdapter()
+    else -> error("Unsupported server engine")
+}
+
 private fun returnWorlds(worldsList: List<World>): List<Map<Any?, Any?>> =
     worldsList.map { it.convertToMap() - "_id" }
 

+ 3 - 3
frameworks/Kotlin/hexagon/src/main/kotlin/com/hexagonkt/BenchmarkStorage.kt

@@ -77,7 +77,7 @@ internal class BenchmarkSqlStore(engine: String) : BenchmarkStore {
     }
 
     override fun findAllFortunes(): List<Fortune> {
-        var fortunes = listOf<Fortune>()
+        val fortunes = mutableListOf<Fortune>()
 
         dataSource.connection.use { con: Connection ->
             val rs = con.prepareStatement(SELECT_ALL_FORTUNES).executeQuery()
@@ -89,7 +89,7 @@ internal class BenchmarkSqlStore(engine: String) : BenchmarkStore {
     }
 
     override fun findWorlds(count: Int): List<World> {
-        var worlds: List<World> = listOf()
+        val worlds: MutableList<World> = mutableListOf()
 
         dataSource.connection.use { con: Connection ->
             val stmtSelect = con.prepareStatement(SELECT_WORLD)
@@ -107,7 +107,7 @@ internal class BenchmarkSqlStore(engine: String) : BenchmarkStore {
     }
 
     override fun replaceWorlds(count: Int): List<World> {
-        var worlds: List<World> = listOf()
+        val worlds: MutableList<World> = mutableListOf()
 
         dataSource.connection.use { con: Connection ->
             val stmtSelect = con.prepareStatement(SELECT_WORLD)

+ 9 - 9
frameworks/Kotlin/hexagon/src/main/resources/service.yaml

@@ -1,14 +1,14 @@
 
-serviceName : Hexagon Benchmark
+serviceName: Hexagon Benchmark
 
-bindPort : 9090
-bindAddress : 0.0.0.0
+bindPort: 9090
+bindAddress: 0.0.0.0
 
-database : hello_world
-worldCollection : world
-fortuneCollection : fortune
+database: hello_world
+worldCollection: world
+fortuneCollection: fortune
 
-databaseUsername : benchmarkdbuser
-databasePassword : benchmarkdbpass
+databaseUsername: benchmarkdbuser
+databasePassword: benchmarkdbpass
 
-maximumPoolSize : 96
+maximumPoolSize: 96

+ 17 - 3
frameworks/Kotlin/hexagon/src/test/kotlin/com/hexagonkt/BenchmarkTest.kt

@@ -3,12 +3,14 @@ package com.hexagonkt
 import com.hexagonkt.serialization.parse
 import com.hexagonkt.http.client.Client
 import com.hexagonkt.serialization.Json
-import com.hexagonkt.serialization.parseList
+import com.hexagonkt.serialization.parseObjects
 import com.hexagonkt.http.Method.GET
+import com.hexagonkt.http.server.jetty.JettyServletAdapter
 import org.asynchttpclient.Response
 import org.testng.annotations.AfterClass
 import org.testng.annotations.BeforeClass
 import org.testng.annotations.Test
+import java.lang.IllegalStateException
 import java.lang.System.setProperty
 
 @Test class BenchmarkJettyMongoDbTest : BenchmarkTestBase("jetty", "mongodb")
@@ -32,6 +34,18 @@ import java.lang.System.setProperty
         benchmarkServer.stop()
     }
 
+    @Test fun `Empty server code creates a Jetty Servlet Adapter`() {
+        System.clearProperty("WEBENGINE")
+        createEngine()
+        assert(engine is JettyServletAdapter)
+    }
+
+    @Test(expectedExceptions = [ IllegalStateException::class ])
+    fun `Invalid server code throws an exception`() {
+        setProperty("WEBENGINE", "invalid")
+        createEngine()
+    }
+
     @Test fun web() {
         val web = Web()
 
@@ -55,7 +69,7 @@ import java.lang.System.setProperty
         val content = response.responseBody
 
         checkResponse(response, Json.contentType)
-        assert("Hello, World!" == content.parse(Message::class).message)
+        assert("Hello, World!" == content.parse<Message>().message)
     }
 
     @Test fun plaintext() {
@@ -91,7 +105,7 @@ import java.lang.System.setProperty
         val body = response.responseBody
 
         checkResponse(response, Json.contentType)
-        val bodyMap = body.parseList(Map::class).first()
+        val bodyMap = body.parseObjects(Map::class).first()
         assert(bodyMap.containsKey(World::id.name))
         assert(bodyMap.containsKey(World::randomNumber.name))
     }