From 73e7fe5dfad0ff1d1772977539ed650a3ec33fdd Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Wed, 27 Mar 2024 15:29:57 +0100 Subject: [PATCH] Fix load test ; set target jdk ; fix some dependencies --- api-webapp/pom.xml | 1 + api-webapp/src/test/kotlin/LoadTest.kt | 24 +++++++++++++++++++++--- api-webapp/src/test/kotlin/TestUtils.kt | 5 ++++- pairgoth-common/pom.xml | 6 ------ pom.xml | 5 ++++- view-webapp/pom.xml | 6 ------ 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/api-webapp/pom.xml b/api-webapp/pom.xml index 1dcf37f..3893950 100644 --- a/api-webapp/pom.xml +++ b/api-webapp/pom.xml @@ -289,6 +289,7 @@ org.mockito.kotlin mockito-kotlin + 4.1.0 test diff --git a/api-webapp/src/test/kotlin/LoadTest.kt b/api-webapp/src/test/kotlin/LoadTest.kt index 10385f6..fbd69ae 100644 --- a/api-webapp/src/test/kotlin/LoadTest.kt +++ b/api-webapp/src/test/kotlin/LoadTest.kt @@ -5,6 +5,7 @@ import org.ajbrown.namemachine.NameGenerator import org.ajbrown.namemachine.NameGeneratorOptions import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test +import java.io.IOException import kotlin.random.Random class LoadTest: TestBase() { @@ -13,7 +14,18 @@ class LoadTest: TestBase() { val PLAYERS = 1500 val ROUNDS = 10 val SKIP_RATIO = 0.1 // 10% - + + @JvmStatic + fun main(args: Array) { + System.out.println("Press Enter to continue...") + try { + System.`in`.read() + } catch (e: IOException) { + e.printStackTrace() + } + LoadTest().testVeryBigTournament() + } + private val nameGenerator = NameGenerator( NameGeneratorOptions().apply { randomSeed = 123456L @@ -72,6 +84,9 @@ class LoadTest: TestBase() { repeat(PLAYERS) { TestAPI.post("/api/tour/$tour/part", generatePlayer()) } + getOutputFile("verybig-nopairing.json").printWriter().use { + it.println(TestAPI.getJson("/api/tour/$tour")) + } repeat(ROUNDS) { val round = it + 1 val resp = TestAPI.post("/api/tour/$tour/pair/$round", Json.Array("all")) @@ -86,8 +101,11 @@ class LoadTest: TestBase() { )) } } - val standings = TestAPI.get("/api/tour/$tour/standings/$ROUNDS") - logger.info(standings.toString()) + // val standings = TestAPI.get("/api/tour/$tour/standings/$ROUNDS") + // logger.info(standings.toString()) + getOutputFile("verybig.json").printWriter().use { + it.println(TestAPI.getJson("/api/tour/$tour")) + } } finally { val after = System.currentTimeMillis() logger.info("testVeryBigTournament ran in ${(after - before) / 1000} seconds") diff --git a/api-webapp/src/test/kotlin/TestUtils.kt b/api-webapp/src/test/kotlin/TestUtils.kt index 7ff309f..12a6e5c 100644 --- a/api-webapp/src/test/kotlin/TestUtils.kt +++ b/api-webapp/src/test/kotlin/TestUtils.kt @@ -82,6 +82,9 @@ object TestAPI { fun get(uri: String): Json = Json.parse(testRequest("GET", uri)) ?: throw Error("no payload") fun getXml(uri: String): String = testRequest("GET", uri, "application/xml") + fun getJson(uri: String): String = testRequest("GET", uri, "application/json") + fun getCSV(uri: String): String = testRequest("GET", uri, "text/csv") + fun getFFG(uri: String): String = testRequest("GET", uri, "application/ffg") fun post(uri: String, payload: T) = Json.parse(testRequest("POST", uri, payload = payload)) ?: throw Error("no payload") fun put(uri: String, payload: T) = Json.parse(testRequest("PUT", uri, payload = payload)) ?: throw Error("no payload") fun delete(uri: String, payload: T) = Json.parse(testRequest("DELETE", uri, payload = payload)) ?: throw Error("no payload") @@ -117,4 +120,4 @@ class DelegatingServletInputStream(val sourceStream: InputStream) : ServletInput super.close() sourceStream.close() } -} \ No newline at end of file +} diff --git a/pairgoth-common/pom.xml b/pairgoth-common/pom.xml index 9cbffa9..9023b02 100644 --- a/pairgoth-common/pom.xml +++ b/pairgoth-common/pom.xml @@ -145,11 +145,5 @@ ${junit.jupiter.version} test - - org.mockito.kotlin - mockito-kotlin - 4.1.0 - test - diff --git a/pom.xml b/pom.xml index 551b363..85adb1b 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,7 @@ 1.9.22 official - 10 + 11 true @@ -188,6 +188,9 @@ org.jetbrains.kotlin kotlin-maven-plugin ${kotlin.version} + + 11 + properties-maven-plugin diff --git a/view-webapp/pom.xml b/view-webapp/pom.xml index bbd86e6..668428d 100644 --- a/view-webapp/pom.xml +++ b/view-webapp/pom.xml @@ -303,12 +303,6 @@ ${junit.jupiter.version} test - - org.mockito.kotlin - mockito-kotlin - 4.1.0 - test - com.icegreen