From 2f7a5e5dfee7095e7b7ee0eda28041d269fe021b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Vonheiden?= <bjoern.vonheiden@hotmail.de>
Date: Tue, 15 Sep 2020 14:56:37 +0200
Subject: [PATCH] Fix running of workload generator in run_uc py

Run uc py still used statefullSet instead of deployment
---
 execution/run_uc.py                           | 19 +++++++++++++------
 execution/run_uc1.sh                          |  2 +-
 execution/run_uc2.sh                          |  2 +-
 execution/run_uc3.sh                          |  2 +-
 execution/run_uc4.sh                          |  2 +-
 .../base/workloadGenerator.yaml               | 14 ++++++++------
 .../uc1-workload-generator/set_paramters.yaml |  2 +-
 .../uc2-workload-generator/set_paramters.yaml |  2 +-
 .../uc3-workload-generator/set_paramters.yaml |  2 +-
 .../uc4-workload-generator/set_paramters.yaml |  2 +-
 10 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/execution/run_uc.py b/execution/run_uc.py
index b19692b0f..04d38eea7 100644
--- a/execution/run_uc.py
+++ b/execution/run_uc.py
@@ -147,6 +147,7 @@ def start_workload_generator(wg_yaml):
         the yaml object.
     """
     print('Start workload generator')
+
     num_sensors = args.dim_value
     wl_max_records = 150000
     # TODO: How is this calculation done?
@@ -157,20 +158,20 @@ def start_workload_generator(wg_yaml):
     # TODO: acces over name of container
     wg_containter = wg_yaml['spec']['template']['spec']['containers'][0]
     wg_containter['image'] = 'theodolite/theodolite-uc' + args.uc_id + \
-        + '-workload-generator:latest'
+        '-workload-generator:latest'
     # TODO: acces over name of attribute
     wg_containter['env'][1]['value'] = str(num_sensors)
     wg_containter['env'][2]['value'] = str(wl_instances)
 
     try:
-        wg_ss = appsApi.create_namespaced_stateful_set(
+        wg_ss = appsApi.create_namespaced_deployment(
             namespace="default",
             body=wg_yaml
         )
-        print("StatefulSet '%s' created." % wg_ss.metadata.name)
+        print("Deployment '%s' created." % wg_ss.metadata.name)
         return wg_ss
     except client.rest.ApiException as e:
-        print("StatefulSet creation error: %s" % e.reason)
+        print("Deployment creation error: %s" % e.reason)
         return wg_yaml
 
 
@@ -277,7 +278,7 @@ def delete_resource(obj, del_func):
             del_func(obj['metadata']['name'], 'default')
         except Exception as e:
             print("Error deleting resource")
-            log.error(e)
+            logging.error(e)
             return
     print('Resource deleted')
 
@@ -293,7 +294,7 @@ def stop_applications(wg, app_svc, app_svc_monitor, app_jmx, app_deploy):
     print('Stop use case application and workload generator')
 
     print('Delete workload generator')
-    delete_resource(wg, appsApi.delete_namespaced_stateful_set)
+    delete_resource(wg, appsApi.delete_namespaced_deployment)
 
     print('Delete app service')
     delete_resource(app_svc, coreApi.delete_namespaced_service)
@@ -392,6 +393,11 @@ def stop_lag_exporter():
     print(output)
     return
 
+# def start():
+#
+#
+# def stop():
+#
 
 def main():
     load_variables()
@@ -400,6 +406,7 @@ def main():
     print('---------------------')
     topics = [('input', args.partitions),
               ('output', args.partitions),
+              ('aggregation-feedback', args.partitions),
               ('configuration', 1)]
     create_topics(topics)
     print('---------------------')
diff --git a/execution/run_uc1.sh b/execution/run_uc1.sh
index 9ab082a52..b6dae93aa 100755
--- a/execution/run_uc1.sh
+++ b/execution/run_uc1.sh
@@ -31,7 +31,7 @@ WL_INSTANCES=$(((NUM_SENSORS + (WL_MAX_RECORDS -1 ))/ WL_MAX_RECORDS))
 
 cat <<EOF >uc-workload-generator/overlay/uc1-workload-generator/set_paramters.yaml
 apiVersion: apps/v1
-kind: StatefulSet
+kind: Deployment
 metadata:
   name: titan-ccp-load-generator
 spec:
diff --git a/execution/run_uc2.sh b/execution/run_uc2.sh
index 741acaa89..7ba3c3960 100755
--- a/execution/run_uc2.sh
+++ b/execution/run_uc2.sh
@@ -32,7 +32,7 @@ WL_INSTANCES=$(((APPROX_NUM_SENSORS + (WL_MAX_RECORDS -1 ))/ WL_MAX_RECORDS))
 
 cat <<EOF >uc-workload-generator/overlay/uc2-workload-generator/set_paramters.yaml
 apiVersion: apps/v1
-kind: StatefulSet
+kind: Deployment
 metadata:
   name: titan-ccp-load-generator
 spec:
diff --git a/execution/run_uc3.sh b/execution/run_uc3.sh
index ff61e7587..5066ee9ef 100755
--- a/execution/run_uc3.sh
+++ b/execution/run_uc3.sh
@@ -31,7 +31,7 @@ WL_INSTANCES=$(((NUM_SENSORS + (WL_MAX_RECORDS -1 ))/ WL_MAX_RECORDS))
 
 cat <<EOF >uc-workload-generator/overlay/uc3-workload-generator/set_paramters.yaml
 apiVersion: apps/v1
-kind: StatefulSet
+kind: Deployment
 metadata:
   name: titan-ccp-load-generator
 spec:
diff --git a/execution/run_uc4.sh b/execution/run_uc4.sh
index 4d558dca3..673c6cb00 100755
--- a/execution/run_uc4.sh
+++ b/execution/run_uc4.sh
@@ -31,7 +31,7 @@ WL_INSTANCES=$(((NUM_SENSORS + (WL_MAX_RECORDS -1 ))/ WL_MAX_RECORDS))
 
 cat <<EOF >uuc-workload-generator/overlay/uc4-workload-generator/set_paramters.yaml
 apiVersion: apps/v1
-kind: StatefulSet
+kind: Deployment
 metadata:
   name: titan-ccp-load-generator
 spec:
diff --git a/execution/uc-workload-generator/base/workloadGenerator.yaml b/execution/uc-workload-generator/base/workloadGenerator.yaml
index 1f21776c7..794468b18 100644
--- a/execution/uc-workload-generator/base/workloadGenerator.yaml
+++ b/execution/uc-workload-generator/base/workloadGenerator.yaml
@@ -6,7 +6,6 @@ spec:
   selector:
     matchLabels:
       app: titan-ccp-load-generator
-  serviceName: titan-ccp-load-generator
   replicas: 1
   template:
     metadata:
@@ -16,8 +15,15 @@ spec:
       terminationGracePeriodSeconds: 0
       containers:
       - name: workload-generator
-        image: uc-workload-generator:latest
+        image: workload-generator:latest
         env:
+        # Order need to be preserved for run_uc.py
+        - name: NUM_SENSORS
+          value: "25000"
+        - name: INSTANCES
+          value: "1"
+        - name: NUM_NESTED_GROUPS
+          value: "5"
         - name: ZK_HOST
           value: "my-confluent-cp-zookeeper"
         - name: ZK_PORT
@@ -26,10 +32,6 @@ spec:
           value: "my-confluent-cp-kafka:9092"
         - name: SCHEMA_REGISTRY_URL
           value: "http://my-confluent-cp-schema-registry:8081"
-        - name: NUM_SENSORS
-          value: "25000"
-        - name: INSTANCES
-          value: "1"
         - name: POD_NAME
           valueFrom:
             fieldRef:
diff --git a/execution/uc-workload-generator/overlay/uc1-workload-generator/set_paramters.yaml b/execution/uc-workload-generator/overlay/uc1-workload-generator/set_paramters.yaml
index a63afa46f..b275607c2 100644
--- a/execution/uc-workload-generator/overlay/uc1-workload-generator/set_paramters.yaml
+++ b/execution/uc-workload-generator/overlay/uc1-workload-generator/set_paramters.yaml
@@ -1,5 +1,5 @@
 apiVersion: apps/v1
-kind: StatefulSet
+kind: Deployment
 metadata:
   name: titan-ccp-load-generator
 spec:
diff --git a/execution/uc-workload-generator/overlay/uc2-workload-generator/set_paramters.yaml b/execution/uc-workload-generator/overlay/uc2-workload-generator/set_paramters.yaml
index 9fdac91cb..187cb4717 100644
--- a/execution/uc-workload-generator/overlay/uc2-workload-generator/set_paramters.yaml
+++ b/execution/uc-workload-generator/overlay/uc2-workload-generator/set_paramters.yaml
@@ -1,5 +1,5 @@
 apiVersion: apps/v1
-kind: StatefulSet
+kind: Deployment
 metadata:
   name: titan-ccp-load-generator
 spec:
diff --git a/execution/uc-workload-generator/overlay/uc3-workload-generator/set_paramters.yaml b/execution/uc-workload-generator/overlay/uc3-workload-generator/set_paramters.yaml
index a63afa46f..b275607c2 100644
--- a/execution/uc-workload-generator/overlay/uc3-workload-generator/set_paramters.yaml
+++ b/execution/uc-workload-generator/overlay/uc3-workload-generator/set_paramters.yaml
@@ -1,5 +1,5 @@
 apiVersion: apps/v1
-kind: StatefulSet
+kind: Deployment
 metadata:
   name: titan-ccp-load-generator
 spec:
diff --git a/execution/uc-workload-generator/overlay/uc4-workload-generator/set_paramters.yaml b/execution/uc-workload-generator/overlay/uc4-workload-generator/set_paramters.yaml
index a63afa46f..b275607c2 100644
--- a/execution/uc-workload-generator/overlay/uc4-workload-generator/set_paramters.yaml
+++ b/execution/uc-workload-generator/overlay/uc4-workload-generator/set_paramters.yaml
@@ -1,5 +1,5 @@
 apiVersion: apps/v1
-kind: StatefulSet
+kind: Deployment
 metadata:
   name: titan-ccp-load-generator
 spec:
-- 
GitLab