Browse Source

Hexagon version upgrade to 0.16 (#2909)

* 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
Juanjo Aguililla 8 years ago
parent
commit
b9f2e76840

+ 13 - 4
.travis.yml

@@ -1,6 +1,6 @@
 
 plugins {
-    id 'org.jetbrains.kotlin.jvm' version '1.1.2-2'
+    id 'org.jetbrains.kotlin.jvm' version '1.1.3-2'
 }
 
 apply from: "$gradleScripts/kotlin.gradle"
@@ -12,7 +12,7 @@ defaultTasks 'installDist'
 
 mainClassName = "co.there4.hexagon.BenchmarkKt"
 applicationDefaultJvmArgs = [
-    '-Xms64M', '-Xmx2G', '-XX:+UseNUMA', '-XX:+UseParallelGC', '-XX:+AggressiveOpts'
+    '-Xms2G', '-Xmx2G', '-XX:+UseNUMA', '-XX:+UseParallelGC', '-XX:+AggressiveOpts'
 ]
 
 war {
@@ -21,11 +21,17 @@ war {
 
 installDist.dependsOn 'war'
 
+repositories {
+    jcenter ()
+    mavenCentral ()
+    maven { url  "http://dl.bintray.com/jamming/maven" }
+}
+
 dependencies {
-    compile ("co.there4.hexagon:core:$hexagonVersion")
+    compile ("co.there4.hexagon:server_jetty:$hexagonVersion")
+    compile ("co.there4.hexagon:templates_pebble:$hexagonVersion")
 
     compile ("ch.qos.logback:logback-classic:$logbackVersion")
-    compile ("com.mitchellbosecke:pebble:$pebbleVersion")
     compile ("org.mongodb:mongodb-driver:$mongodbVersion")
     compile ("com.zaxxer:HikariCP:$hikariVersion")
     compile ("org.postgresql:postgresql:$postgresqlVersion")
@@ -34,6 +40,9 @@ dependencies {
     providedCompile ("org.eclipse.jetty:jetty-webapp:$jettyVersion") { exclude module: "slf4j-api" }
 
     testCompile ("org.testng:testng:$testngVersion")
+    testCompile ("org.asynchttpclient:async-http-client:$ahcVersion") {
+        exclude module: 'slf4j-api'
+    }
 }
 
 test {

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

@@ -1,11 +1,11 @@
+ahcVersion=2.0.31
 description=Hexagon web framework's benchmark
-gradleScripts=https\://raw.githubusercontent.com/jaguililla/hexagon/0.14.0/gradle
-hexagonVersion=0.14.0
+gradleScripts=https\://raw.githubusercontent.com/jaguililla/hexagon/0.16.0/gradle
+hexagonVersion=0.16.0
 hikariVersion=2.6.1
-jettyVersion=9.4.4.v20170414
-kotlinVersion=1.1.2-2
-logbackVersion=1.2.2
+jettyVersion=9.4.6.v20170531
+kotlinVersion=1.1.3-2
+logbackVersion=1.2.3
 mongodbVersion=3.4.2
-pebbleVersion=2.3.0
 postgresqlVersion=42.0.0
 testngVersion=6.11

BIN
frameworks/Kotlin/hexagon/gradle/wrapper.jar → frameworks/Kotlin/hexagon/gradle/wrapper/gradle-wrapper.jar


+ 2 - 2
frameworks/Kotlin/hexagon/gradle/wrapper.properties → frameworks/Kotlin/hexagon/gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
-#Fri Dec 09 22:10:54 CET 2016
+#Tue Jun 06 01:23:02 CEST 2017
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip

+ 1 - 1
frameworks/Kotlin/hexagon/gradle/wrapper → frameworks/Kotlin/hexagon/gradlew

@@ -64,7 +64,7 @@ case "`uname`" in
     ;;
 esac
 
-CLASSPATH=$APP_HOME/wrapper.jar
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 
 # Determine the Java command to use to start the JVM.
 if [ -n "$JAVA_HOME" ] ; then

+ 1 - 1
frameworks/Kotlin/hexagon/gradle/wrapper.bat → frameworks/Kotlin/hexagon/gradlew.bat

@@ -63,7 +63,7 @@ set CMD_LINE_ARGS=%*
 :execute
 @rem Setup the command line
 
-set CLASSPATH=%APP_HOME%\wrapper.jar
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
 
 @rem Execute Gradle
 "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

+ 1 - 1
frameworks/Kotlin/hexagon/readme.md

@@ -11,7 +11,7 @@ development platforms. The test utilizes Hexagon routes, serialization and datab
 
 ## Infrastructure Software Versions
 
-* [Hexagon 0.12.x](http://there4.co/hexagon)
+* [Hexagon 0.16.x](http://there4.co/hexagon)
 
 ## Test URLs
 

+ 3 - 6
frameworks/Kotlin/hexagon/setup_jetty_mongodb.sh

@@ -3,9 +3,6 @@
 
 fw_depends java mongodb
 
-gradle/wrapper -x test
-
-nohup build/install/hexagon/bin/hexagon mongodb &
-#rm -rf $RESIN_HOME/webapps/*
-#cp build/libs/ROOT.war $RESIN_HOME/webapps
-#resinctl start
+./gradlew -x test
+export DBSTORE='mongodb'
+nohup build/install/hexagon/bin/hexagon &

+ 3 - 6
frameworks/Kotlin/hexagon/setup_jetty_postgresql.sh

@@ -3,9 +3,6 @@
 
 fw_depends java postgresql
 
-gradle/wrapper -x test
-
-nohup build/install/hexagon/bin/hexagon postgresql &
-#rm -rf $RESIN_HOME/webapps/*
-#cp build/libs/ROOT.war $RESIN_HOME/webapps
-#resinctl start
+./gradlew -x test
+export DBSTORE='postgresql'
+nohup build/install/hexagon/bin/hexagon &

+ 12 - 0
frameworks/Kotlin/hexagon/setup_resin_mongodb.sh

@@ -0,0 +1,12 @@
+
+#!/bin/bash
+
+fw_depends java mongodb
+
+./gradlew -x test
+export DBSTORE='mongodb'
+
+rm -rf $RESIN_HOME/webapps/*
+cp build/libs/ROOT.war $RESIN_HOME/webapps
+resinctl start
+

+ 12 - 0
frameworks/Kotlin/hexagon/setup_resin_postgresql.sh

@@ -0,0 +1,12 @@
+
+#!/bin/bash
+
+fw_depends java postgresql
+
+./gradlew -x test
+export DBSTORE='postgresql'
+
+rm -rf $RESIN_HOME/webapps/*
+cp build/libs/ROOT.war $RESIN_HOME/webapps
+resinctl start
+

+ 21 - 13
frameworks/Kotlin/hexagon/src/main/kotlin/co/there4/hexagon/Benchmark.kt

@@ -2,15 +2,21 @@ package co.there4.hexagon
 
 import co.there4.hexagon.serialization.convertToMap
 import co.there4.hexagon.serialization.serialize
-import co.there4.hexagon.server.*
-import co.there4.hexagon.server.engine.servlet.JettyServletEngine
-import co.there4.hexagon.server.engine.servlet.ServletServer
+import co.there4.hexagon.server.Call
+import co.there4.hexagon.server.Router
+import co.there4.hexagon.server.Server
+import co.there4.hexagon.server.jetty.JettyServletEngine
+import co.there4.hexagon.server.router
+import co.there4.hexagon.server.servlet.ServletServer
 import co.there4.hexagon.settings.SettingsManager.settings
-import java.lang.System.getenv
+import co.there4.hexagon.templates.pebble.PebbleEngine
 
-import java.net.InetAddress.getByName as address
+import java.lang.System.getProperty
+import java.lang.System.getenv
+import java.util.*
 import java.util.concurrent.ThreadLocalRandom
 import javax.servlet.annotation.WebListener
+import java.net.InetAddress.getByName as address
 
 // DATA CLASSES
 internal data class Message(val message: String)
@@ -22,8 +28,6 @@ private const val TEXT_MESSAGE: String = "Hello, World!"
 private const val CONTENT_TYPE_JSON = "application/json"
 private const val QUERIES_PARAM = "queries"
 
-internal var server: Server? = null
-
 // UTILITIES
 internal fun randomWorld() = ThreadLocalRandom.current().nextInt(WORLD_ROWS) + 1
 
@@ -45,8 +49,9 @@ private fun Call.getWorldsCount() = (request[QUERIES_PARAM]?.toIntOrNull() ?: 1)
 // HANDLERS
 private fun Call.listFortunes(store: Store) {
     val fortunes = store.findAllFortunes() + Fortune(0, "Additional fortune added at request time.")
+    val locale = Locale.getDefault()
     response.contentType = "text/html; charset=utf-8"
-    template("fortunes.html", "fortunes" to fortunes.sortedBy { it.message })
+    template(PebbleEngine, "fortunes.html", locale, "fortunes" to fortunes.sortedBy { it.message })
 }
 
 private fun Call.getWorlds(store: Store) {
@@ -57,7 +62,10 @@ private fun Call.updateWorlds(store: Store) {
     returnWorlds(store.replaceWorlds(getWorldsCount()))
 }
 
-private fun router(store: Store): Router = router {
+// CONTROLLER
+private fun router(): Router = router {
+    val store = createStore(getProperty("DBSTORE") ?: getenv("DBSTORE") ?: "mongodb")
+
     before {
         response.addHeader("Server", "Servlet/3.1")
         response.addHeader("Transfer-Encoding", "chunked")
@@ -73,11 +81,11 @@ private fun router(store: Store): Router = router {
 }
 
 @WebListener class Web : ServletServer () {
-    override fun createRouter() = router (createStore(getenv("DBSTORE") ?: "mongodb"))
+    override fun createRouter() = router()
 }
 
+internal var server: Server? = null
+
 fun main(vararg args: String) {
-    val store = createStore(if (args.isEmpty()) getenv("DBSTORE") ?: "mongodb" else args[0])
-    server = Server(JettyServletEngine(), settings, router(store))
-    server?.run()
+    server = Server(JettyServletEngine(), settings, router()).apply { run() }
 }

+ 3 - 3
frameworks/Kotlin/hexagon/src/main/kotlin/co/there4/hexagon/BenchmarkStorage.kt

@@ -87,9 +87,9 @@ private class SqlStore(jdbcUrl: String) : Store {
     init {
         val config = HikariConfig()
         config.jdbcUrl = jdbcUrl
-        config.maximumPoolSize = 32 // TODO Extract to settings
-        config.username = "benchmarkdbuser"
-        config.password = "benchmarkdbpass"
+        config.maximumPoolSize =  settings["maximumPoolSize"] as? Int ?: 32
+        config.username = settings["databaseUsername"] as? String ?: "benchmarkdbuser"
+        config.password = settings["databasePassword"] as? String ?:  "benchmarkdbpass"
         DATA_SOURCE = HikariDataSource(config)
     }
 

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

@@ -10,3 +10,5 @@ fortuneCollection : fortune
 
 databaseUsername : benchmarkdbuser
 databasePassword : benchmarkdbpass
+
+maximumPoolSize : 32

+ 6 - 4
frameworks/Kotlin/hexagon/src/test/kotlin/co/there4/hexagon/BenchmarkTest.kt

@@ -6,20 +6,22 @@ import co.there4.hexagon.server.HttpMethod.GET
 import org.asynchttpclient.Response
 import org.testng.annotations.BeforeClass
 import org.testng.annotations.Test
+import java.lang.System.setProperty
 import kotlin.test.assertFailsWith
 
 internal const val THREADS = 4
 internal const val TIMES = 2
 
-//class BenchmarkMongoDbTest : BenchmarkTest("mongodb")
-//class BenchmarkPostgreSqlTest : BenchmarkTest("postgresql")
+class BenchmarkMongoDbTest : BenchmarkTest("mongodb")
+class BenchmarkPostgreSqlTest : BenchmarkTest("postgresql")
 
-//@Test(threadPoolSize = THREADS, invocationCount = TIMES)
+@Test(threadPoolSize = THREADS, invocationCount = TIMES)
 abstract class BenchmarkTest(val databaseEngine: String) {
     private val client by lazy { Client("http://localhost:${server?.runtimePort}") }
 
     @BeforeClass fun warmup() {
-        main(databaseEngine)
+        setProperty("DBSTORE", databaseEngine)
+        main()
 
         val warmupRounds = if (THREADS > 1) 2 else 0
         (1..warmupRounds).forEach {

+ 1 - 1
frameworks/Kotlin/hexagon/src/test/resources/logback-test.xml

@@ -10,7 +10,7 @@
     </encoder>
   </appender>
 
-  <root level="warn">
+  <root level="off">
     <appender-ref ref="console" />
   </root>
 </configuration>

+ 1 - 0
frameworks/Kotlin/hexagon/src/test/resources/service_test.yaml

@@ -1,2 +1,3 @@
 
 bindPort : 0
+maximumPoolSize : 8