Skip to content
Snippets Groups Projects
Commit 538b7486 authored by Björn Vonheiden's avatar Björn Vonheiden Committed by Sören Henning
Browse files

Add a Patcher to handle ospbench data volume settings

This handler takes the total defined load and compute the
needed load generator instances and set the volume that each generator
should generate
parent c3821898
No related branches found
No related tags found
1 merge request!174Add a Patcher to handle ospbench data volume settings
package theodolite.patcher
import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.api.model.apps.Deployment
/**
* The DataVolumeLoadGeneratorReplicaPatcher allows to modify the value of an environment variable
*
* @property k8sResource Kubernetes resource to be patched.
* @property container Container to be patched.
* @property variableName Name of the environment variable to be patched.
*/
class DataVolumeLoadGeneratorReplicaPatcher(
private val k8sResource: KubernetesResource,
private val maxVolume: String,
container: String,
variableName: String
) : EnvVarPatcher(k8sResource, container, variableName) {
override fun <String> patch(value: String) {
if (k8sResource is Deployment) {
if (value is kotlin.String) {
val load = value.toInt()
val loadGenInstances = (load + maxVolume.toInt() - 1) / maxVolume.toInt()
this.k8sResource.spec.replicas = loadGenInstances
val loadPerInstance = load / loadGenInstances
super.patch(loadPerInstance.toString())
}
}
}
}
......@@ -12,7 +12,7 @@ import io.fabric8.kubernetes.api.model.apps.Deployment
* @property container Container to be patched.
* @property variableName Name of the environment variable to be patched.
*/
class EnvVarPatcher(
open class EnvVarPatcher(
private val k8sResource: KubernetesResource,
private val container: String,
private val variableName: String
......
......@@ -48,6 +48,12 @@ class PatcherFactory {
k8sResource = resource,
loadGenMaxRecords = patcherDefinition.properties["loadGenMaxRecords"]!!
)
"DataVolumeLoadGeneratorReplicaPatcher" -> DataVolumeLoadGeneratorReplicaPatcher(
k8sResource = resource,
maxVolume = patcherDefinition.properties["maxVolume"]!!,
container = patcherDefinition.properties["container"]!!,
variableName = patcherDefinition.properties["variableName"]!!
)
"EnvVarPatcher" -> EnvVarPatcher(
k8sResource = resource,
container = patcherDefinition.properties["container"]!!,
......
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