Skip to content
Snippets Groups Projects
Commit 1fab7464 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

minor code changes, helm update, small fixes

>
> update benchark crd and example benchmark,
> renaming, formatting,
> fix test and small issues in different classes
parent 31f9e8c3
No related branches found
No related tags found
1 merge request!171Introduce ResourceSets to make loading of resource files more flexible
Showing
with 173 additions and 103 deletions
...@@ -21,94 +21,160 @@ spec: ...@@ -21,94 +21,160 @@ spec:
properties: properties:
spec: spec:
type: object type: object
required: [] required: ["appResourceSets", "loadGenResourceSets", "resourceTypes", "loadTypes", "kafkaConfig"]
properties: properties:
name: name:
description: This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten.
type: string type: string
appResource:
type: array
minItems: 1
items:
type: string
loadGenResource:
type: array
minItems: 1
items:
type: string
resourceTypes: resourceTypes:
description: A list of resource types that can be scaled for this `benchmark` resource. For each resource type the concrete values are defined in the `execution` object.
type: array type: array
minItems: 1 minItems: 1
items: items:
type: object type: object
required: ["typeName", "patchers"]
properties: properties:
typeName: typeName:
description: Name of the resource type.
type: string type: string
patchers: patchers:
description: List of patchers used to scale this resource type.
examples: test test test
type: array type: array
minItems: 1 minItems: 1
items: items:
type: object type: object
required: ["type", "resource"]
properties: properties:
type: type:
description: Type of the patcher.
type: string type: string
default: "" default: ""
resource: resource:
description: Specifies the Kubernetes resource to be patched.
type: string type: string
default: "" default: ""
properties: properties:
description: (Optional) Patcher specific additional arguments.
type: object type: object
additionalProperties: true additionalProperties: true
x-kubernetes-map-type: "granular" x-kubernetes-map-type: "granular"
default: {} default: {}
loadTypes: loadTypes:
description: A list of load types that can be scaled for this benchmark. For each load type the concrete values are defined in the execution object.
type: array type: array
minItems: 1 minItems: 1
items: items:
type: object type: object
required: ["typeName","patchers"]
properties: properties:
typeName: typeName:
description: Name of the load type.
type: string type: string
patchers: patchers:
description: List of patchers used to scale this resource type.
type: array type: array
minItems: 1 minItems: 1
items: items:
type: object type: object
required: ["type", "resource"]
properties: properties:
type: type:
description: Type of the Patcher.
type: string type: string
default: "" default: ""
resource: resource:
description: Specifies the Kubernetes resource to be patched.
type: string type: string
default: "" default: ""
properties: properties:
description: (Optional) Patcher specific additional arguments.
type: object type: object
additionalProperties: true additionalProperties: true
x-kubernetes-map-type: "granular" x-kubernetes-map-type: "granular"
default: {} default: {}
kafkaConfig: kafkaConfig:
description: Contains the Kafka configuration.
type: object type: object
required: ["bootstrapServer", "topics"]
properties: properties:
bootstrapServer: bootstrapServer:
description: The bootstrap servers connection string.
type: string type: string
topics: topics:
description: List of topics to be created for each experiment. Alternative theodolite offers the possibility to remove certain topics after each experiment.
type: array type: array
minItems: 1 minItems: 1
items: items:
type: object type: object
required: [] required: ["name"]
properties: properties:
name: name:
description: The name of the topic.
type: string type: string
default: "" default: ""
numPartitions: numPartitions:
description: The number of partitions of the topic.
type: integer type: integer
default: 0 default: 0
replicationFactor: replicationFactor:
description: The replication factor of the topic.
type: integer type: integer
default: 0 default: 0
removeOnly: removeOnly:
description: Determines if this topic should only be deleted after each experiement. For removeOnly topics the name can be a RegEx describing the topic.
type: boolean type: boolean
default: false default: false
appResourceSets:
type: array
items:
type: object
properties:
name:
type: string
ConfigMapResourceSet:
type: object
properties:
configmap:
type: string
files:
type: array
items:
type: string
FileSystemResourceSet:
type: object
properties:
path:
type: string
files:
type: array
items:
type: string
loadGenResourceSets:
type: array
items:
type: object
properties:
name:
type: string
ConfigMapResourceSet:
type: object
properties:
configmap:
type: string
files:
type: array
items:
type: string
FileSystemResourceSet:
type: object
properties:
path:
type: string
files:
type: array
items:
type: string
additionalPrinterColumns: additionalPrinterColumns:
- name: Age - name: Age
type: date type: date
......
...@@ -20,23 +20,11 @@ spec: ...@@ -20,23 +20,11 @@ spec:
properties: properties:
spec: spec:
type: object type: object
required: ["appResource", "loadGenResource", "resourceTypes", "loadTypes", "kafkaConfig"] required: ["appResourceSets", "loadGenResourceSets", "resourceTypes", "loadTypes", "kafkaConfig"]
properties: properties:
name: name:
description: This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten. description: This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten.
type: string type: string
appResource:
description: A list of file names that reference Kubernetes resources that are deployed on the cluster for the system under test (SUT).
type: array
minItems: 1
items:
type: string
loadGenResource:
description: A list of file names that reference Kubernetes resources that are deployed on the cluster for the load generator.
type: array
minItems: 1
items:
type: string
resourceTypes: resourceTypes:
description: A list of resource types that can be scaled for this `benchmark` resource. For each resource type the concrete values are defined in the `execution` object. description: A list of resource types that can be scaled for this `benchmark` resource. For each resource type the concrete values are defined in the `execution` object.
type: array type: array
...@@ -118,7 +106,7 @@ spec: ...@@ -118,7 +106,7 @@ spec:
minItems: 1 minItems: 1
items: items:
type: object type: object
required: ["name", "numPartitions", "replicationFactor"] required: ["name"]
properties: properties:
name: name:
description: The name of the topic. description: The name of the topic.
...@@ -148,11 +136,19 @@ spec: ...@@ -148,11 +136,19 @@ spec:
properties: properties:
configmap: configmap:
type: string type: string
files:
type: array
items:
type: string
FileSystemResourceSet: FileSystemResourceSet:
type: object type: object
properties: properties:
path: path:
type: string type: string
files:
type: array
items:
type: string
loadGenResourceSets: loadGenResourceSets:
type: array type: array
items: items:
...@@ -165,11 +161,19 @@ spec: ...@@ -165,11 +161,19 @@ spec:
properties: properties:
configmap: configmap:
type: string type: string
files:
type: array
items:
type: string
FileSystemResourceSet: FileSystemResourceSet:
type: object type: object
properties: properties:
path: path:
type: string type: string
files:
type: array
items:
type: string
additionalPrinterColumns: additionalPrinterColumns:
- name: Age - name: Age
type: date type: date
......
...@@ -3,14 +3,6 @@ kind: benchmark ...@@ -3,14 +3,6 @@ kind: benchmark
metadata: metadata:
name: uc1-kstreams name: uc1-kstreams
spec: spec:
appResource:
- "uc1-kstreams-deployment.yaml"
- "aggregation-service.yaml"
- "jmx-configmap.yaml"
- "uc1-service-monitor.yaml"
loadGenResource:
- "uc1-load-generator-deployment.yaml"
- "uc1-load-generator-service.yaml"
resourceTypes: resourceTypes:
- typeName: "Instances" - typeName: "Instances"
patchers: patchers:
...@@ -42,8 +34,16 @@ spec: ...@@ -42,8 +34,16 @@ spec:
- name: TestAppResources - name: TestAppResources
FileSystemResourceSet: FileSystemResourceSet:
path: ./config path: ./config
files:
- "uc1-kstreams-deployment.yaml"
- "aggregation-service.yaml"
- "jmx-configmap.yaml"
- "uc1-service-monitor.yaml"
loadGenResourceSets: loadGenResourceSets:
- name: RestGenResources - name: RestGenResources
ConfigMapResourceSet: ConfigMapResourceSet:
configmap: "test-configmap" configmap: "test-configmap"
files:
- uc1-load-generator-service.yaml
- uc1-load-generator-deployment.yaml
\ No newline at end of file
...@@ -24,7 +24,7 @@ spec: ...@@ -24,7 +24,7 @@ spec:
loadGenerationDelay: 30 # in seconds loadGenerationDelay: 30 # in seconds
restrictions: restrictions:
- "LowerBound" - "LowerBound"
configOverrides: configOverrides: []
# - patcher: # - patcher:
# type: "NodeSelectorPatcher" # type: "NodeSelectorPatcher"
# resource: "uc1-load-generator-deployment.yaml" # resource: "uc1-load-generator-deployment.yaml"
......
...@@ -9,56 +9,51 @@ import theodolite.k8s.resourceLoader.K8sResourceLoaderFromString ...@@ -9,56 +9,51 @@ import theodolite.k8s.resourceLoader.K8sResourceLoaderFromString
import theodolite.util.YamlParserFromString import theodolite.util.YamlParserFromString
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
private const val DEFAULT_NAMESPACE = "default"
@JsonDeserialize @JsonDeserialize
class ConfigMapResourceSet: ResourceSet { class ConfigMapResourceSet: ResourceSet {
lateinit var configmap: String lateinit var configmap: 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
private val namespace = "default" private val namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
private val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace) // TODO(load namespace from env var) private val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace)
private val loader = K8sResourceLoaderFromString(client) private val loader = K8sResourceLoaderFromString(client)
@OptIn(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
override fun getResourceSet(): List<Pair<String, KubernetesResource>> { override fun getResourceSet(): List<Pair<String, KubernetesResource>> {
logger.info { "Load benchmark resources from configmap with name $configmap" }
var resources = client var resources = client
.configMaps() .configMaps()
.withName(configmap) .withName(configmap)
.get() .get()
.data .data
.filter { it.key.endsWith(".yaml") } // consider only yaml files, e.g. ignore readme files
if (::files.isInitialized){ if (::files.isInitialized){
resources = resources resources = resources
.filterKeys { files.contains(it) } .filter { files.contains(it.key) }
} }
return resources return resources
.map { Pair( .map { Pair(
getKind(resource = it.value), getKind(resource = it.value),
resources) } it) }
.map { Pair( .map {
Pair(
it.first, it.first,
loader.loadK8sResource(it.first, it.second.values.first())) } loader.loadK8sResource(it.first, it.second.value)) }
} }
private fun getKind(resource: String): String { private fun getKind(resource: String): String {
logger.info { "1" }
val parser = YamlParserFromString() val parser = YamlParserFromString()
val resoureceAsMap = parser.parse(resource, HashMap<String, String>()::class.java) val resourceAsMap = parser.parse(resource, HashMap<String, String>()::class.java)
logger.info { "2" }
return try { return try {
val kind = resoureceAsMap?.get("kind")!! resourceAsMap?.get("kind")!!
logger.info { "Kind is $kind" }
kind
} catch (e: Exception) { } catch (e: Exception) {
logger.error { "Could not find field kind of Kubernetes resource: ${resoureceAsMap?.get("name")}" } logger.error { "Could not find field kind of Kubernetes resource: ${resourceAsMap?.get("name")}" }
"" ""
} }
} }
......
...@@ -10,18 +10,17 @@ import theodolite.util.YamlParserFromFile ...@@ -10,18 +10,17 @@ import theodolite.util.YamlParserFromFile
import java.io.File import java.io.File
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
private const val DEFAULT_NAMESPACE = "default"
@JsonDeserialize @JsonDeserialize
class FileSystemResourceSet: ResourceSet { class FileSystemResourceSet: ResourceSet {
lateinit var path: String lateinit var path: String
lateinit var files: List<String> lateinit var files: List<String>
private val parser = YamlParserFromFile() private val parser = YamlParserFromFile()
private val loader = K8sResourceLoaderFromFile(DefaultKubernetesClient().inNamespace("default")) // TODO(set namespace correctly) private val namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
private val loader = K8sResourceLoaderFromFile(DefaultKubernetesClient().inNamespace(namespace))
override fun getResourceSet(): List<Pair<String, KubernetesResource>> { override fun getResourceSet(): List<Pair<String, KubernetesResource>> {
logger.info { "Get fileSystem resource set $path" }
//if files is set ... //if files is set ...
if(::files.isInitialized){ if(::files.isInitialized){
...@@ -33,6 +32,7 @@ class FileSystemResourceSet: ResourceSet { ...@@ -33,6 +32,7 @@ class FileSystemResourceSet: ResourceSet {
return try { return try {
File(path) File(path)
.list() !! .list() !!
.filter { it.endsWith(".yaml") } // consider only yaml files, e.g. ignore readme files
.map { .map {
loadSingleResource(it) loadSingleResource(it)
} }
......
...@@ -34,8 +34,8 @@ private var DEFAULT_NAMESPACE = "default" ...@@ -34,8 +34,8 @@ private var DEFAULT_NAMESPACE = "default"
@RegisterForReflection @RegisterForReflection
class KubernetesBenchmark: KubernetesResource, Benchmark{ class KubernetesBenchmark: KubernetesResource, Benchmark{
lateinit var name: String lateinit var name: String
lateinit var appResource: List<String> // var appResource: List<Pair<String, KubernetesResource>>
lateinit var loadGenResource: List<String> // var loadGenResource: List<Pair<String, KubernetesResource>>
lateinit var resourceTypes: List<TypeName> lateinit var resourceTypes: List<TypeName>
lateinit var loadTypes: List<TypeName> lateinit var loadTypes: List<TypeName>
lateinit var kafkaConfig: KafkaConfig lateinit var kafkaConfig: KafkaConfig
...@@ -44,6 +44,10 @@ class KubernetesBenchmark: KubernetesResource, Benchmark{ ...@@ -44,6 +44,10 @@ class KubernetesBenchmark: KubernetesResource, Benchmark{
var namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE var namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
var path = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config" var path = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config"
// init {
// this.appResource = appResourceSets.flatMap { it.loadResourceSet() }
// this.loadGenResource = loadGenResourceSets.flatMap { it.loadResourceSet() }
// }
/** /**
* Loads [KubernetesResource]s. * Loads [KubernetesResource]s.
......
...@@ -8,8 +8,6 @@ import io.quarkus.runtime.annotations.RegisterForReflection ...@@ -8,8 +8,6 @@ import io.quarkus.runtime.annotations.RegisterForReflection
import mu.KotlinLogging import mu.KotlinLogging
import theodolite.util.DeploymentFailedException import theodolite.util.DeploymentFailedException
private val logger = KotlinLogging.logger {}
@JsonDeserialize @JsonDeserialize
@RegisterForReflection @RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
...@@ -25,7 +23,6 @@ class ResourceSets: KubernetesResource { ...@@ -25,7 +23,6 @@ class ResourceSets: KubernetesResource {
val FileSystemResourceSet: FileSystemResourceSet? = null val FileSystemResourceSet: FileSystemResourceSet? = null
fun loadResourceSet(): List<Pair<String, KubernetesResource>> { fun loadResourceSet(): List<Pair<String, KubernetesResource>> {
logger.info { "LOAD" }
return try { return try {
if (ConfigMapResourceSet != null) { if (ConfigMapResourceSet != null) {
ConfigMapResourceSet.getResourceSet() ConfigMapResourceSet.getResourceSet()
......
...@@ -28,6 +28,7 @@ class TheodoliteController( ...@@ -28,6 +28,7 @@ class TheodoliteController(
private val executionStateHandler: ExecutionStateHandler private val executionStateHandler: ExecutionStateHandler
) { ) {
lateinit var executor: TheodoliteExecutor lateinit var executor: TheodoliteExecutor
/** /**
* *
* Runs the TheodoliteController forever. * Runs the TheodoliteController forever.
...@@ -63,15 +64,18 @@ class TheodoliteController( ...@@ -63,15 +64,18 @@ class TheodoliteController(
private fun runExecution(execution: BenchmarkExecution, benchmark: KubernetesBenchmark) { private fun runExecution(execution: BenchmarkExecution, benchmark: KubernetesBenchmark) {
setAdditionalLabels(execution.name, setAdditionalLabels(execution.name,
"deployed-for-execution", "deployed-for-execution",
benchmark.appResource + benchmark.loadGenResource, benchmark.appResourceSets.flatMap { it -> it.loadResourceSet().map { it.first } }
+ benchmark.loadGenResourceSets.flatMap { it -> it.loadResourceSet().map { it.first } },
execution) execution)
setAdditionalLabels(benchmark.name, setAdditionalLabels(benchmark.name,
"deployed-for-benchmark", "deployed-for-benchmark",
benchmark.appResource + benchmark.loadGenResource, benchmark.appResourceSets.flatMap { it -> it.loadResourceSet().map { it.first } }
+ benchmark.loadGenResourceSets.flatMap { it -> it.loadResourceSet().map { it.first } },
execution) execution)
setAdditionalLabels("theodolite", setAdditionalLabels("theodolite",
"app.kubernetes.io/created-by", "app.kubernetes.io/created-by",
benchmark.appResource + benchmark.loadGenResource, benchmark.appResourceSets.flatMap { it -> it.loadResourceSet().map { it.first } }
+ benchmark.loadGenResourceSets.flatMap { it -> it.loadResourceSet().map { it.first } },
execution) execution)
executionStateHandler.setExecutionState(execution.name, States.RUNNING) executionStateHandler.setExecutionState(execution.name, States.RUNNING)
......
...@@ -9,7 +9,7 @@ private val logger = KotlinLogging.logger {} ...@@ -9,7 +9,7 @@ private val logger = KotlinLogging.logger {}
abstract class AbstractK8sLoader: K8sResourceLoader { abstract class AbstractK8sLoader: K8sResourceLoader {
abstract fun loadCustomResourceWrapper(path: String, context: CustomResourceDefinitionContext): KubernetesResource abstract fun loadCustomResourceWrapper(resource: String, context: CustomResourceDefinitionContext): KubernetesResource
fun loadK8sResource(kind: String, resourceString: String): KubernetesResource { fun loadK8sResource(kind: String, resourceString: String): KubernetesResource {
return when (kind) { return when (kind) {
...@@ -45,33 +45,33 @@ abstract class AbstractK8sLoader: K8sResourceLoader { ...@@ -45,33 +45,33 @@ abstract class AbstractK8sLoader: K8sResourceLoader {
override fun loadServiceMonitor(path: String): KubernetesResource { override fun loadServiceMonitor(resource: String): KubernetesResource {
val context = K8sContextFactory().create( val context = K8sContextFactory().create(
api = "v1", api = "v1",
scope = "Namespaced", scope = "Namespaced",
group = "monitoring.coreos.com", group = "monitoring.coreos.com",
plural = "servicemonitors" plural = "servicemonitors"
) )
return loadCustomResourceWrapper(path, context) return loadCustomResourceWrapper(resource, context)
} }
override fun loadExecution(path: String): KubernetesResource { override fun loadExecution(resource: String): KubernetesResource {
val context = K8sContextFactory().create( val context = K8sContextFactory().create(
api = "v1", api = "v1",
scope = "Namespaced", scope = "Namespaced",
group = "theodolite.com", group = "theodolite.com",
plural = "executions" plural = "executions"
) )
return loadCustomResourceWrapper(path, context) return loadCustomResourceWrapper(resource, context)
} }
override fun loadBenchmark(path: String): KubernetesResource { override fun loadBenchmark(resource: String): KubernetesResource {
val context = K8sContextFactory().create( val context = K8sContextFactory().create(
api = "v1", api = "v1",
scope = "Namespaced", scope = "Namespaced",
group = "theodolite.com", group = "theodolite.com",
plural = "benchmarks" plural = "benchmarks"
) )
return loadCustomResourceWrapper(path, context) return loadCustomResourceWrapper(resource, context)
} }
} }
\ No newline at end of file
...@@ -19,11 +19,11 @@ class K8sResourceLoaderFromFile(private val client: NamespacedKubernetesClient): ...@@ -19,11 +19,11 @@ class K8sResourceLoaderFromFile(private val client: NamespacedKubernetesClient):
/** /**
* Parses a Service from a service yaml * Parses a Service from a service yaml
* @param path of the yaml file * @param resource of the yaml file
* @return Service from fabric8 * @return Service from fabric8
*/ */
override fun loadService(path: String): Service { override fun loadService(resource: String): Service {
return loadGenericResource(path) { x: String -> client.services().load(x).get() } return loadGenericResource(resource) { x: String -> client.services().load(x).get() }
} }
...@@ -33,11 +33,11 @@ class K8sResourceLoaderFromFile(private val client: NamespacedKubernetesClient): ...@@ -33,11 +33,11 @@ class K8sResourceLoaderFromFile(private val client: NamespacedKubernetesClient):
* @param context specific crd context for this custom resource * @param context specific crd context for this custom resource
* @return CustomResourceWrapper from fabric8 * @return CustomResourceWrapper from fabric8
*/ */
override fun loadCustomResourceWrapper(path: String, context: CustomResourceDefinitionContext): CustomResourceWrapper { override fun loadCustomResourceWrapper(resource: String, context: CustomResourceDefinitionContext): CustomResourceWrapper {
return loadGenericResource(path) { return loadGenericResource(resource) {
CustomResourceWrapper( CustomResourceWrapper(
YamlParserFromFile().parse( YamlParserFromFile().parse(
path, resource,
HashMap<String, String>()::class.java HashMap<String, String>()::class.java
)!!, )!!,
context context
...@@ -47,29 +47,29 @@ class K8sResourceLoaderFromFile(private val client: NamespacedKubernetesClient): ...@@ -47,29 +47,29 @@ class K8sResourceLoaderFromFile(private val client: NamespacedKubernetesClient):
/** /**
* Parses a Deployment from a Deployment yaml * Parses a Deployment from a Deployment yaml
* @param path of the yaml file * @param resource of the yaml file
* @return Deployment from fabric8 * @return Deployment from fabric8
*/ */
override fun loadDeployment(path: String): Deployment { override fun loadDeployment(resource: String): Deployment {
return loadGenericResource(path) { x: String -> client.apps().deployments().load(x).get() } return loadGenericResource(resource) { x: String -> client.apps().deployments().load(x).get() }
} }
/** /**
* Parses a ConfigMap from a ConfigMap yaml * Parses a ConfigMap from a ConfigMap yaml
* @param path of the yaml file * @param resource of the yaml file
* @return ConfigMap from fabric8 * @return ConfigMap from fabric8
*/ */
override fun loadConfigmap(path: String): ConfigMap { override fun loadConfigmap(resource: String): ConfigMap {
return loadGenericResource(path) { x: String -> client.configMaps().load(x).get() } return loadGenericResource(resource) { x: String -> client.configMaps().load(x).get() }
} }
/** /**
* Parses a StatefulSet from a StatefulSet yaml * Parses a StatefulSet from a StatefulSet yaml
* @param path of the yaml file * @param resource of the yaml file
* @return StatefulSet from fabric8 * @return StatefulSet from fabric8
*/ */
override fun loadStatefulSet(path: String): KubernetesResource { override fun loadStatefulSet(resource: String): KubernetesResource {
return loadGenericResource(path) { x: String -> client.apps().statefulSets().load(x).get() } return loadGenericResource(resource) { x: String -> client.apps().statefulSets().load(x).get() }
} }
} }
...@@ -13,44 +13,44 @@ class K8sResourceLoaderFromString(private val client: NamespacedKubernetesClient ...@@ -13,44 +13,44 @@ class K8sResourceLoaderFromString(private val client: NamespacedKubernetesClient
K8sResourceLoader { K8sResourceLoader {
@OptIn(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
override fun loadService(resourceStream: String): KubernetesResource { override fun loadService(resource: String): KubernetesResource {
return loadGenericResource(resourceStream) { x: String -> return loadGenericResource(resource) { x: String ->
val stream = ByteArrayInputStream(x.encodeToByteArray()) val stream = ByteArrayInputStream(x.encodeToByteArray())
client.services().load(stream).get() } client.services().load(stream).get() }
} }
@OptIn(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
override fun loadDeployment(path: String): Deployment { override fun loadDeployment(resource: String): Deployment {
return loadGenericResource(path) { x: String -> return loadGenericResource(resource) { x: String ->
val stream = ByteArrayInputStream(x.encodeToByteArray()) val stream = ByteArrayInputStream(x.encodeToByteArray())
client.apps().deployments().load(stream).get() } client.apps().deployments().load(stream).get() }
} }
@OptIn(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
override fun loadConfigmap(path: String): ConfigMap { override fun loadConfigmap(resource: String): ConfigMap {
return loadGenericResource(path) { x: String -> return loadGenericResource(resource) { x: String ->
val stream = ByteArrayInputStream(x.encodeToByteArray()) val stream = ByteArrayInputStream(x.encodeToByteArray())
client.configMaps().load(stream).get() } client.configMaps().load(stream).get() }
} }
@OptIn(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
override fun loadStatefulSet(path: String): KubernetesResource { override fun loadStatefulSet(resource: String): KubernetesResource {
return loadGenericResource(path) { x: String -> return loadGenericResource(resource) { x: String ->
val stream = ByteArrayInputStream(x.encodeToByteArray()) val stream = ByteArrayInputStream(x.encodeToByteArray())
client.apps().statefulSets().load(stream).get() } client.apps().statefulSets().load(stream).get() }
} }
/** /**
* Parses a CustomResource from a yaml * Parses a CustomResource from a yaml
* @param path of the yaml file * @param resource of the yaml file
* @param context specific crd context for this custom resource * @param context specific crd context for this custom resource
* @return CustomResourceWrapper from fabric8 * @return CustomResourceWrapper from fabric8
*/ */
override fun loadCustomResourceWrapper(path: String, context: CustomResourceDefinitionContext): CustomResourceWrapper { override fun loadCustomResourceWrapper(resource: String, context: CustomResourceDefinitionContext): CustomResourceWrapper {
return loadGenericResource(path) { return loadGenericResource(resource) {
CustomResourceWrapper( CustomResourceWrapper(
YamlParserFromString().parse( YamlParserFromString().parse(
path, resource,
HashMap<String, String>()::class.java HashMap<String, String>()::class.java
)!!, )!!,
context context
......
...@@ -24,8 +24,9 @@ class BenchmarkCRDummy(name: String) { ...@@ -24,8 +24,9 @@ class BenchmarkCRDummy(name: String) {
benchmarkCR.kind = "Benchmark" benchmarkCR.kind = "Benchmark"
benchmarkCR.apiVersion = "v1" benchmarkCR.apiVersion = "v1"
benchmark.appResource = emptyList() benchmark.appResourceSets = emptyList()
benchmark.loadGenResource = emptyList() benchmark.loadGenResourceSets = emptyList()
benchmark.resourceTypes = emptyList() benchmark.resourceTypes = emptyList()
benchmark.loadTypes = emptyList() benchmark.loadTypes = emptyList()
benchmark.kafkaConfig = kafkaConfig benchmark.kafkaConfig = kafkaConfig
......
...@@ -2,6 +2,7 @@ package theodolite.execution.operator ...@@ -2,6 +2,7 @@ package theodolite.execution.operator
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import io.fabric8.kubernetes.api.model.Service
import io.fabric8.kubernetes.client.CustomResourceList import io.fabric8.kubernetes.client.CustomResourceList
import io.fabric8.kubernetes.client.server.mock.KubernetesServer import io.fabric8.kubernetes.client.server.mock.KubernetesServer
import io.quarkus.test.junit.QuarkusTest import io.quarkus.test.junit.QuarkusTest
...@@ -146,13 +147,11 @@ class ControllerTest { ...@@ -146,13 +147,11 @@ class ControllerTest {
) )
method.isAccessible = true method.isAccessible = true
this.benchmark.appResource = listOf("test-resource.yaml")
method.invoke( method.invoke(
controller, controller,
"test-value", "test-value",
"test-name", "test-name",
this.benchmark.appResource, listOf("rest-resource.yaml"),
this.execution this.execution
) as BenchmarkExecution? ) as BenchmarkExecution?
......
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