diff --git a/docs/actions.md b/docs/actions.md new file mode 100644 index 0000000000000000000000000000000000000000..fefef96d7ed77e9fd0fe6669b03c800e1e45a19b --- /dev/null +++ b/docs/actions.md @@ -0,0 +1,60 @@ +## Infrastructure +The necessary infrastructure for an execution can be defined in the benchmark manifests. The related resources are create *before* an execution is started, and removed *after* an execution is finished. + +### Example + +```yaml + infrastructure: + resources: + - configMap: + name: "example-configmap" + files: + - "uc1-kstreams-deployment.yaml" +``` + +## Action Commands +Theodolite allows to execute commands on running pods (similar to the `kubectl exec -it <pod-name> -- <command>` command). This commands can be run either before (via so called `beforeActions`) or after (via so called `afterActions`) an experiment is executed. + +### Example + +```yaml +# For the system under test + sut: + resources: ... + beforeActions: + - selector: + pod: + matchLabels: + app: busybox1 + exec: + command: ["touch", "test-file-sut"] + timeoutSeconds: 90 + afterActions: + - selector: + pod: + matchLabels: + app: busybox1 + exec: + command: [ "touch", "test-file-sut-after" ] + timeoutSeconds: 90 + +# analog, for the load generator + loadGenerator: + resources: ... + beforeActions: + - selector: + pod: + matchLabels: + app: busybox1 + exec: + command: ["touch", "test-file-loadGen"] + timeoutSeconds: 90 + afterActions: + - selector: + pod: + matchLabels: + app: busybox1 + exec: + command: [ "touch", "test-file-loadGen-after" ] + timeoutSeconds: 90 +``` \ No newline at end of file diff --git a/theodolite/examples/operator/example-benchmark.yaml b/theodolite/examples/operator/example-benchmark.yaml index 84371d86834cda5ea541c05d85f462358187938e..3452fff9c729d680890d6eafa685ce2f13b098d6 100644 --- a/theodolite/examples/operator/example-benchmark.yaml +++ b/theodolite/examples/operator/example-benchmark.yaml @@ -3,26 +3,12 @@ kind: benchmark metadata: name: uc1-kstreams spec: - infrastructure: - resources: - - configMap: - name: "example-configmap" - files: - - "uc1-kstreams-deployment.yaml" sut: resources: - configMap: name: "example-configmap" files: - "uc1-kstreams-deployment.yaml" - beforeActions: - - selector: - pod: - matchLabels: - app: busybox1 - exec: - command: ["touch", "test-folder"] - timeoutSeconds: 90 loadGenerator: resources: - configMap: @@ -30,7 +16,6 @@ spec: files: - uc1-load-generator-service.yaml - uc1-load-generator-deployment.yaml - beforeActions: [] resourceTypes: - typeName: "Instances" patchers: diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt index 21d5cb5bc840c5ec76581a0122d3712ec2c2aed9..c9c75ab32b228e2fa389d0fa22f181733be162e5 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt @@ -47,8 +47,6 @@ class KubernetesBenchmarkDeployment( */ override fun setup() { sutBeforeActions.forEach { it.exec(client = client) } - loadGenBeforeActions.forEach { it.exec(client = client) } - val kafkaTopics = this.topics.filter { !it.removeOnly } .map { NewTopic(it.name, it.numPartitions, it.replicationFactor) } kafkaController.createTopics(kafkaTopics) @@ -56,6 +54,8 @@ class KubernetesBenchmarkDeployment( logger.info { "Wait ${this.loadGenerationDelay} seconds before starting the load generator." } Thread.sleep(Duration.ofSeconds(this.loadGenerationDelay).toMillis()) loadGenResources.forEach { kubernetesManager.deploy(it) } + loadGenBeforeActions.forEach { it.exec(client = client) } + } /**