Skip to content
Snippets Groups Projects
Commit e944be2e authored by Sören Henning's avatar Sören Henning
Browse files

Merge branch 'master' into pubsub-load-generator

parents bd9af6e8 47ec6dbc
No related branches found
No related tags found
1 merge request!225Add option to generate load via Google PubSub
Showing with 52 additions and 57 deletions
...@@ -18,34 +18,20 @@ ...@@ -18,34 +18,20 @@
# #
# Then run the container using : # Then run the container using :
# #
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/theodolite-legacy-jar # docker run -i --rm -p 8080:8080 quarkus/theodolite-legacy-jar
# #
### ###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 FROM registry.access.redhat.com/ubi8/openjdk-11-runtime:1.10
ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
COPY build/lib/* /deployments/lib/ COPY build/lib/* /deployments/lib/
COPY build/*-runner.jar /deployments/app.jar COPY build/*-runner.jar /deployments/quarkus-run.jar
EXPOSE 8080 EXPOSE 8080
USER 1001 USER 185
ENTRYPOINT [ "/deployments/run-java.sh" ] ENTRYPOINT [ "java", "-jar", "/deployments/quarkus-run.jar" ]
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
# docker run -i --rm -p 8080:8080 quarkus/theodolite # docker run -i --rm -p 8080:8080 quarkus/theodolite
# #
### ###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 FROM quay.io/quarkus/quarkus-micro-image:1.0
WORKDIR /deployments/ WORKDIR /work/
RUN chown 1001 /deployments \ RUN chown 1001 /work \
&& chmod "g+rwX" /deployments \ && chmod "g+rwX" /work \
&& chown 1001:root /deployments && chown 1001:root /work
COPY --chown=1001:root build/*-runner /deployments/application COPY --chown=1001:root build/*-runner /work/application
EXPOSE 8080 EXPOSE 8080
USER 1001 USER 1001
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
# #
### ###
FROM quay.io/quarkus/quarkus-distroless-image:1.0 FROM quay.io/quarkus/quarkus-distroless-image:1.0
WORKDIR /deployments/ COPY build/*-runner /application
COPY build/*-runner /deployments/application
EXPOSE 8080 EXPOSE 8080
USER nonroot USER nonroot
......
...@@ -12,7 +12,7 @@ import java.lang.IllegalArgumentException ...@@ -12,7 +12,7 @@ import java.lang.IllegalArgumentException
@RegisterForReflection @RegisterForReflection
@JsonDeserialize @JsonDeserialize
class ConfigMapResourceSet: ResourceSet, KubernetesResource { class ConfigMapResourceSet : ResourceSet, KubernetesResource {
lateinit var name: String lateinit var name: String
lateinit var files: List<String> // load all files, iff files is not set lateinit var files: List<String> // load all files, iff files is not set
...@@ -26,30 +26,35 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource { ...@@ -26,30 +26,35 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource {
.withName(name) .withName(name)
.get() ?: throw DeploymentFailedException("Cannot find ConfigMap with name '$name'.")) .get() ?: throw DeploymentFailedException("Cannot find ConfigMap with name '$name'."))
.data .data
.filter { it.key.endsWith(".yaml") } .filter { it.key.endsWith(".yaml") || it.key.endsWith(".yml")}
} catch (e: KubernetesClientException) { } catch (e: KubernetesClientException) {
throw DeploymentFailedException("Cannot find or read ConfigMap with name '$name'.", e) throw DeploymentFailedException("Cannot find or read ConfigMap with name '$name'.", e)
} }
if (::files.isInitialized){ if (::files.isInitialized) {
resources = resources.filter { files.contains(it.key) } val filteredResources = resources.filter { files.contains(it.key) }
if (filteredResources.size != files.size) {
if (resources.size != files.size) {
throw DeploymentFailedException("Could not find all specified Kubernetes manifests files") throw DeploymentFailedException("Could not find all specified Kubernetes manifests files")
} }
resources = filteredResources
} }
return try { return try {
resources resources
.map { Pair( .map {
getKind(resource = it.value), Pair(
it) } getKind(resource = it.value),
it
)
}
.map { .map {
Pair( Pair(
it.second.key, it.second.key,
loader.loadK8sResource(it.first, it.second.value)) } loader.loadK8sResource(it.first, it.second.value)
)
}
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
throw DeploymentFailedException("Can not create resource set from specified configmap", e) throw DeploymentFailedException("Cannot create resource set from specified ConfigMap", e)
} }
} }
...@@ -58,10 +63,7 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource { ...@@ -58,10 +63,7 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource {
val parser = YamlParserFromString() val parser = YamlParserFromString()
val resourceAsMap = parser.parse(resource, HashMap<String, String>()::class.java) val resourceAsMap = parser.parse(resource, HashMap<String, String>()::class.java)
return try { return resourceAsMap?.get("kind")
resourceAsMap?.get("kind") !! ?: throw DeploymentFailedException("Could not find field kind of Kubernetes resource: ${resourceAsMap?.get("name")}")
} catch (e: NullPointerException) {
throw DeploymentFailedException( "Could not find field kind of Kubernetes resource: ${resourceAsMap?.get("name")}", e)
}
} }
} }
\ No newline at end of file
...@@ -28,7 +28,7 @@ class FileSystemResourceSet: ResourceSet, KubernetesResource { ...@@ -28,7 +28,7 @@ class FileSystemResourceSet: ResourceSet, KubernetesResource {
return try { return try {
File(path) File(path)
.list() !! .list() !!
.filter { it.endsWith(".yaml") } // consider only yaml files, e.g. ignore readme files .filter { it.endsWith(".yaml") || it.endsWith(".yml") }
.map { .map {
loadSingleResource(resourceURL = it, client = client) loadSingleResource(resourceURL = it, client = client)
} }
......
...@@ -39,7 +39,7 @@ class KubernetesBenchmark : KubernetesResource, Benchmark { ...@@ -39,7 +39,7 @@ class KubernetesBenchmark : KubernetesResource, Benchmark {
lateinit var name: String lateinit var name: String
lateinit var resourceTypes: List<TypeName> lateinit var resourceTypes: List<TypeName>
lateinit var loadTypes: List<TypeName> lateinit var loadTypes: List<TypeName>
lateinit var kafkaConfig: KafkaConfig var kafkaConfig: KafkaConfig? = null
lateinit var infrastructure: Resources lateinit var infrastructure: Resources
lateinit var sut: Resources lateinit var sut: Resources
lateinit var loadGenerator: Resources lateinit var loadGenerator: Resources
...@@ -110,6 +110,9 @@ class KubernetesBenchmark : KubernetesResource, Benchmark { ...@@ -110,6 +110,9 @@ class KubernetesBenchmark : KubernetesResource, Benchmark {
patcherFactory.createPatcher(it.patcher, appResources + loadGenResources).patch(override.value) patcherFactory.createPatcher(it.patcher, appResources + loadGenResources).patch(override.value)
} }
} }
val kafkaConfig = this.kafkaConfig
return KubernetesBenchmarkDeployment( return KubernetesBenchmarkDeployment(
sutBeforeActions = sut.beforeActions, sutBeforeActions = sut.beforeActions,
sutAfterActions = sut.afterActions, sutAfterActions = sut.afterActions,
...@@ -119,8 +122,8 @@ class KubernetesBenchmark : KubernetesResource, Benchmark { ...@@ -119,8 +122,8 @@ class KubernetesBenchmark : KubernetesResource, Benchmark {
loadGenResources = loadGenResources.map { it.second }, loadGenResources = loadGenResources.map { it.second },
loadGenerationDelay = loadGenerationDelay, loadGenerationDelay = loadGenerationDelay,
afterTeardownDelay = afterTeardownDelay, afterTeardownDelay = afterTeardownDelay,
kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer), kafkaConfig = if (kafkaConfig != null) hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer) else mapOf(),
topics = kafkaConfig.topics, topics = kafkaConfig?.topics ?: listOf(),
client = this.client client = this.client
) )
} }
......
...@@ -31,7 +31,7 @@ class KubernetesBenchmarkDeployment( ...@@ -31,7 +31,7 @@ class KubernetesBenchmarkDeployment(
val loadGenResources: List<KubernetesResource>, val loadGenResources: List<KubernetesResource>,
private val loadGenerationDelay: Long, private val loadGenerationDelay: Long,
private val afterTeardownDelay: Long, private val afterTeardownDelay: Long,
private val kafkaConfig: HashMap<String, Any>, private val kafkaConfig: Map<String, Any>,
private val topics: List<KafkaConfig.TopicWrapper>, private val topics: List<KafkaConfig.TopicWrapper>,
private val client: NamespacedKubernetesClient private val client: NamespacedKubernetesClient
) : BenchmarkDeployment { ) : BenchmarkDeployment {
...@@ -46,9 +46,12 @@ class KubernetesBenchmarkDeployment( ...@@ -46,9 +46,12 @@ class KubernetesBenchmarkDeployment(
* - Deploy the needed resources. * - Deploy the needed resources.
*/ */
override fun setup() { override fun setup() {
val kafkaTopics = this.topics.filter { !it.removeOnly } if (this.topics.isNotEmpty()) {
.map { NewTopic(it.name, it.numPartitions, it.replicationFactor) } val kafkaTopics = this.topics
kafkaController.createTopics(kafkaTopics) .filter { !it.removeOnly }
.map { NewTopic(it.name, it.numPartitions, it.replicationFactor) }
kafkaController.createTopics(kafkaTopics)
}
sutBeforeActions.forEach { it.exec(client = client) } sutBeforeActions.forEach { it.exec(client = client) }
appResources.forEach { kubernetesManager.deploy(it) } appResources.forEach { kubernetesManager.deploy(it) }
logger.info { "Wait ${this.loadGenerationDelay} seconds before starting the load generator." } logger.info { "Wait ${this.loadGenerationDelay} seconds before starting the load generator." }
...@@ -69,7 +72,9 @@ class KubernetesBenchmarkDeployment( ...@@ -69,7 +72,9 @@ class KubernetesBenchmarkDeployment(
loadGenAfterActions.forEach { it.exec(client = client) } loadGenAfterActions.forEach { it.exec(client = client) }
appResources.forEach { kubernetesManager.remove(it) } appResources.forEach { kubernetesManager.remove(it) }
sutAfterActions.forEach { it.exec(client = client) } sutAfterActions.forEach { it.exec(client = client) }
kafkaController.removeTopics(this.topics.map { topic -> topic.name }) if (this.topics.isNotEmpty()) {
kafkaController.removeTopics(this.topics.map { topic -> topic.name })
}
ResourceByLabelHandler(client).removePods( ResourceByLabelHandler(client).removePods(
labelName = LAG_EXPORTER_POD_LABEL_NAME, labelName = LAG_EXPORTER_POD_LABEL_NAME,
labelValue = LAG_EXPORTER_POD_LABEL_VALUE labelValue = LAG_EXPORTER_POD_LABEL_VALUE
......
...@@ -24,7 +24,7 @@ class BenchmarkStateChecker( ...@@ -24,7 +24,7 @@ class BenchmarkStateChecker(
Thread { Thread {
while (running) { while (running) {
updateBenchmarkStatus() updateBenchmarkStatus()
Thread.sleep(100 * 1) Thread.sleep(1000)
} }
}.start() }.start()
} }
......
...@@ -37,9 +37,9 @@ class TheodoliteController( ...@@ -37,9 +37,9 @@ class TheodoliteController(
*/ */
fun run() { fun run() {
sleep(5000) // wait until all states are correctly set sleep(5000) // wait until all states are correctly set
benchmarkStateChecker.start(true)
while (true) { while (true) {
reconcile() reconcile()
benchmarkStateChecker.start(true)
sleep(2000) sleep(2000)
} }
} }
...@@ -98,11 +98,11 @@ class TheodoliteController( ...@@ -98,11 +98,11 @@ class TheodoliteController(
} }
else -> { else -> {
executionStateHandler.setExecutionState(execution.name, ExecutionState.FAILURE) executionStateHandler.setExecutionState(execution.name, ExecutionState.FAILURE)
logger.warn { "Unexpected execution state, set state to ${ExecutionState.FAILURE.value}" } logger.warn { "Unexpected execution state, set state to ${ExecutionState.FAILURE.value}." }
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
EventCreator().createEvent( EventCreator().createEvent(
executionName = execution.name, executionName = execution.name,
type = "WARNING", type = "WARNING",
reason = "Execution failed", reason = "Execution failed",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment