From b37a85a8a11b9d7b1e71215ae14417a47019a5b8 Mon Sep 17 00:00:00 2001
From: Simon Ehrenstein <simon.ehrenstein@gmail.com>
Date: Mon, 22 Mar 2021 16:11:45 +0100
Subject: [PATCH] Add @RegisterForReflection annotation for compatibility with
 native images

---
 theodolite-quarkus/.dockerignore                         | 3 ++-
 .../resources/yaml => config}/BenchmarkExecution.yaml    | 0
 .../main/resources/yaml => config}/BenchmarkType.yaml    | 0
 .../resources/yaml => config}/aggregation-service.yaml   | 0
 .../main/resources/yaml => config}/jmx-configmap.yaml    | 0
 .../main/resources/yaml => config}/service-monitor.yaml  | 0
 .../yaml => config}/uc1-kstreams-deployment.yaml         | 0
 .../yaml => config}/uc1-load-generator-deployment.yaml   | 0
 .../yaml => config}/uc1-load-generator-service.yaml      | 0
 theodolite-quarkus/src/main/docker/Dockerfile.native     | 1 +
 .../src/main/kotlin/theodolite/benchmark/Benchmark.kt    | 2 ++
 .../kotlin/theodolite/benchmark/BenchmarkExecution.kt    | 6 ++++++
 .../kotlin/theodolite/benchmark/KubernetesBenchmark.kt   | 2 ++
 .../theodolite/execution/TheodoliteYamlExecutor.kt       | 9 +++++++--
 .../src/main/kotlin/theodolite/patcher/Patcher.kt        | 3 +++
 .../main/kotlin/theodolite/util/ConfigurationOverride.kt | 3 +++
 .../src/main/kotlin/theodolite/util/KafkaConfig.kt       | 2 ++
 .../src/main/kotlin/theodolite/util/PatcherDefinition.kt | 3 +++
 .../src/main/kotlin/theodolite/util/TypeName.kt          | 3 +++
 19 files changed, 34 insertions(+), 3 deletions(-)
 rename theodolite-quarkus/{src/main/resources/yaml => config}/BenchmarkExecution.yaml (100%)
 rename theodolite-quarkus/{src/main/resources/yaml => config}/BenchmarkType.yaml (100%)
 rename theodolite-quarkus/{src/main/resources/yaml => config}/aggregation-service.yaml (100%)
 rename theodolite-quarkus/{src/main/resources/yaml => config}/jmx-configmap.yaml (100%)
 rename theodolite-quarkus/{src/main/resources/yaml => config}/service-monitor.yaml (100%)
 rename theodolite-quarkus/{src/main/resources/yaml => config}/uc1-kstreams-deployment.yaml (100%)
 rename theodolite-quarkus/{src/main/resources/yaml => config}/uc1-load-generator-deployment.yaml (100%)
 rename theodolite-quarkus/{src/main/resources/yaml => config}/uc1-load-generator-service.yaml (100%)

diff --git a/theodolite-quarkus/.dockerignore b/theodolite-quarkus/.dockerignore
index 4361d2fb3..d95caadc4 100644
--- a/theodolite-quarkus/.dockerignore
+++ b/theodolite-quarkus/.dockerignore
@@ -2,4 +2,5 @@
 !build/*-runner
 !build/*-runner.jar
 !build/lib/*
-!build/quarkus-app/*
\ No newline at end of file
+!build/quarkus-app/*
+!config/*
\ No newline at end of file
diff --git a/theodolite-quarkus/src/main/resources/yaml/BenchmarkExecution.yaml b/theodolite-quarkus/config/BenchmarkExecution.yaml
similarity index 100%
rename from theodolite-quarkus/src/main/resources/yaml/BenchmarkExecution.yaml
rename to theodolite-quarkus/config/BenchmarkExecution.yaml
diff --git a/theodolite-quarkus/src/main/resources/yaml/BenchmarkType.yaml b/theodolite-quarkus/config/BenchmarkType.yaml
similarity index 100%
rename from theodolite-quarkus/src/main/resources/yaml/BenchmarkType.yaml
rename to theodolite-quarkus/config/BenchmarkType.yaml
diff --git a/theodolite-quarkus/src/main/resources/yaml/aggregation-service.yaml b/theodolite-quarkus/config/aggregation-service.yaml
similarity index 100%
rename from theodolite-quarkus/src/main/resources/yaml/aggregation-service.yaml
rename to theodolite-quarkus/config/aggregation-service.yaml
diff --git a/theodolite-quarkus/src/main/resources/yaml/jmx-configmap.yaml b/theodolite-quarkus/config/jmx-configmap.yaml
similarity index 100%
rename from theodolite-quarkus/src/main/resources/yaml/jmx-configmap.yaml
rename to theodolite-quarkus/config/jmx-configmap.yaml
diff --git a/theodolite-quarkus/src/main/resources/yaml/service-monitor.yaml b/theodolite-quarkus/config/service-monitor.yaml
similarity index 100%
rename from theodolite-quarkus/src/main/resources/yaml/service-monitor.yaml
rename to theodolite-quarkus/config/service-monitor.yaml
diff --git a/theodolite-quarkus/src/main/resources/yaml/uc1-kstreams-deployment.yaml b/theodolite-quarkus/config/uc1-kstreams-deployment.yaml
similarity index 100%
rename from theodolite-quarkus/src/main/resources/yaml/uc1-kstreams-deployment.yaml
rename to theodolite-quarkus/config/uc1-kstreams-deployment.yaml
diff --git a/theodolite-quarkus/src/main/resources/yaml/uc1-load-generator-deployment.yaml b/theodolite-quarkus/config/uc1-load-generator-deployment.yaml
similarity index 100%
rename from theodolite-quarkus/src/main/resources/yaml/uc1-load-generator-deployment.yaml
rename to theodolite-quarkus/config/uc1-load-generator-deployment.yaml
diff --git a/theodolite-quarkus/src/main/resources/yaml/uc1-load-generator-service.yaml b/theodolite-quarkus/config/uc1-load-generator-service.yaml
similarity index 100%
rename from theodolite-quarkus/src/main/resources/yaml/uc1-load-generator-service.yaml
rename to theodolite-quarkus/config/uc1-load-generator-service.yaml
diff --git a/theodolite-quarkus/src/main/docker/Dockerfile.native b/theodolite-quarkus/src/main/docker/Dockerfile.native
index 4a6d4147c..37a5a4bd8 100644
--- a/theodolite-quarkus/src/main/docker/Dockerfile.native
+++ b/theodolite-quarkus/src/main/docker/Dockerfile.native
@@ -20,6 +20,7 @@ RUN chown 1001 /work \
     && chmod "g+rwX" /work \
     && chown 1001:root /work
 COPY --chown=1001:root build/*-runner /work/application
+COPY config/ /work/config/
 
 EXPOSE 8080
 USER 1001
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt
index 8c15fa1dc..8a52987c4 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt
@@ -1,9 +1,11 @@
 package theodolite.benchmark
 
+import io.quarkus.runtime.annotations.RegisterForReflection
 import theodolite.util.ConfigurationOverride
 import theodolite.util.LoadDimension
 import theodolite.util.Resource
 
+@RegisterForReflection
 interface Benchmark {
     fun buildDeployment(
         load: LoadDimension,
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt
index 25535e1a6..14bb9e49a 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt
@@ -1,8 +1,10 @@
 package theodolite.benchmark
 
+import io.quarkus.runtime.annotations.RegisterForReflection
 import theodolite.util.ConfigurationOverride
 import kotlin.properties.Delegates
 
+@RegisterForReflection
 class BenchmarkExecution {
     lateinit var name: String
     lateinit var benchmark: String
@@ -12,6 +14,7 @@ class BenchmarkExecution {
     lateinit var execution: Execution
     lateinit var configOverrides: List<ConfigurationOverride>
 
+    @RegisterForReflection
     class Execution {
         lateinit var strategy: String
         var duration by Delegates.notNull<Long>()
@@ -19,6 +22,7 @@ class BenchmarkExecution {
         lateinit var restrictions: List<String>
     }
 
+    @RegisterForReflection
     class Slo {
         lateinit var sloType: String
         var threshold by Delegates.notNull<Int>()
@@ -28,11 +32,13 @@ class BenchmarkExecution {
         var warmup by Delegates.notNull<Int>()
     }
 
+    @RegisterForReflection
     class LoadDefinition {
         lateinit var loadType: String
         lateinit var loadValues: List<Int>
     }
 
+    @RegisterForReflection
     class ResourceDefinition {
         lateinit var resourceType: String
         lateinit var resourceValues: List<Int>
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
index 1e2d9a2e6..62b7ba8eb 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
@@ -2,6 +2,7 @@ package theodolite.benchmark
 
 import io.fabric8.kubernetes.api.model.KubernetesResource
 import io.fabric8.kubernetes.client.DefaultKubernetesClient
+import io.quarkus.runtime.annotations.RegisterForReflection
 import mu.KotlinLogging
 import theodolite.k8s.K8sResourceLoader
 import theodolite.patcher.PatcherManager
@@ -11,6 +12,7 @@ private val logger = KotlinLogging.logger {}
 
 private var DEFAULT_NAMESPACE = "default"
 
+@RegisterForReflection
 class KubernetesBenchmark : Benchmark {
     lateinit var name: String
     lateinit var appResource: List<String>
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteYamlExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteYamlExecutor.kt
index f6c109dac..d6505431c 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteYamlExecutor.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteYamlExecutor.kt
@@ -5,6 +5,7 @@ import mu.KotlinLogging
 import theodolite.benchmark.BenchmarkExecution
 import theodolite.benchmark.KubernetesBenchmark
 import theodolite.util.YamlParser
+import java.nio.file.Paths
 import kotlin.system.exitProcess
 
 private val logger = KotlinLogging.logger {}
@@ -14,13 +15,17 @@ object TheodoliteYamlExecutor {
     @JvmStatic
     fun main(args: Array<String>) {
         logger.info { "Theodolite started" }
+        val path = Paths.get("").toAbsolutePath().toString()
+        logger.info{ path }
 
         // load the BenchmarkExecution and the BenchmarkType
         val parser = YamlParser()
         val benchmarkExecution =
-            parser.parse("./../../../resources/main/yaml/BenchmarkExecution.yaml", BenchmarkExecution::class.java)!!
+            parser.parse("./config/BenchmarkExecution.yaml", BenchmarkExecution::class.java)!!
         val benchmark =
-            parser.parse("./../../../resources/main/yaml/BenchmarkType.yaml", KubernetesBenchmark::class.java)!!
+            parser.parse("./config/BenchmarkType.yaml", KubernetesBenchmark::class.java)!!
+
+        logger.info { benchmark.name.toString() }
 
         val executor = TheodoliteExecutor(benchmarkExecution, benchmark)
         executor.run()
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/Patcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/Patcher.kt
index 82c562572..55cde39f5 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/Patcher.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/Patcher.kt
@@ -1,5 +1,8 @@
 package theodolite.patcher
 
+import io.quarkus.runtime.annotations.RegisterForReflection
+
+@RegisterForReflection
 interface Patcher {
     fun <T> patch(value: T)
 }
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt
index fcf8244e8..bf517595a 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt
@@ -1,5 +1,8 @@
 package theodolite.util
 
+import io.quarkus.runtime.annotations.RegisterForReflection
+
+@RegisterForReflection
 class ConfigurationOverride {
     lateinit var patcher: PatcherDefinition
     lateinit var value: String
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt
index 8c529e3d8..d21e8c77f 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt
@@ -1,8 +1,10 @@
 package theodolite.util
 
+import io.quarkus.runtime.annotations.RegisterForReflection
 import org.apache.kafka.clients.admin.NewTopic
 import kotlin.properties.Delegates
 
+@RegisterForReflection
 class KafkaConfig {
     lateinit var bootstrapServer: String
     lateinit var topics: List<TopicWrapper>
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt
index 13b1e721c..9ebe82a66 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt
@@ -1,5 +1,8 @@
 package theodolite.util
 
+import io.quarkus.runtime.annotations.RegisterForReflection
+
+@RegisterForReflection
 class PatcherDefinition {
     lateinit var type: String
     lateinit var resource: String
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/TypeName.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/TypeName.kt
index 3568a355e..2a83eef70 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/util/TypeName.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/TypeName.kt
@@ -1,5 +1,8 @@
 package theodolite.util
 
+import io.quarkus.runtime.annotations.RegisterForReflection
+
+@RegisterForReflection
 class TypeName {
     lateinit var typeName: String
     lateinit var patchers: List<PatcherDefinition>
-- 
GitLab