From eaf4b6de4feb374a2fb05803d89e9eb5c959ceba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <post@soeren-henning.de>
Date: Fri, 31 Jul 2020 10:59:15 +0200
Subject: [PATCH] Create instances count as required

---
 execution/run_uc2.sh | 6 ++++++
 execution/run_uc4.sh | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/execution/run_uc2.sh b/execution/run_uc2.sh
index c0bbf313b..a68cefb06 100755
--- a/execution/run_uc2.sh
+++ b/execution/run_uc2.sh
@@ -26,7 +26,13 @@ kubectl exec kafka-client -- bash -c "kafka-topics --zookeeper my-confluent-cp-z
 
 # Start workload generator
 NUM_NESTED_GROUPS=$DIM_VALUE
+WL_MAX_RECORDS=150000
+APROX_NUM_SENSORS=$((4**NUM_NESTED_GROUPS))NUM_NESTED_GROUPS
+WL_INSTANCES=$(((APROX_NUM_SENSORS + (WL_MAX_RECORDS -1 ))/ WL_MAX_RECORDS))
+
 sed "s/{{NUM_NESTED_GROUPS}}/$NUM_NESTED_GROUPS/g" uc2-workload-generator/deployment.yaml | kubectl apply -f -
+WORKLOAD_GENERATOR_YAML=$(sed "s/{{NUM_NESTED_GROUPS}}/$NUM_NESTED_GROUPS/g; s/{{INSTANCES}}/$WL_INSTANCES/g" uc2-workload-generator/deployment.yaml)
+echo "$WORKLOAD_GENERATOR_YAML" | kubectl apply -f -
 
 # Start application
 REPLICAS=$INSTANCES
diff --git a/execution/run_uc4.sh b/execution/run_uc4.sh
index 2a3936b71..79bec3081 100755
--- a/execution/run_uc4.sh
+++ b/execution/run_uc4.sh
@@ -26,8 +26,11 @@ kubectl exec kafka-client -- bash -c "kafka-topics --zookeeper my-confluent-cp-z
 
 # Start workload generator
 NUM_SENSORS=$DIM_VALUE
-#NUM_SENSORS=xy
-sed "s/{{NUM_SENSORS}}/$NUM_SENSORS/g" uc4-workload-generator/deployment.yaml | kubectl apply -f -
+WL_MAX_RECORDS=150000
+WL_INSTANCES=$(((NUM_SENSORS + (WL_MAX_RECORDS -1 ))/ WL_MAX_RECORDS))
+
+WORKLOAD_GENERATOR_YAML=$(sed "s/{{NUM_SENSORS}}/$NUM_SENSORS/g; s/{{INSTANCES}}/$WL_INSTANCES/g" uc4-workload-generator/deployment.yaml)
+echo "$WORKLOAD_GENERATOR_YAML" | kubectl apply -f -
 
 # Start application
 REPLICAS=$INSTANCES
-- 
GitLab