apiVersion: theodolite.com/v1
kind: benchmark
metadata:
  name: uc2-beam-samza
spec:
  sut:
    resources:
      - configMap:
          name: "benchmark-resources-uc2-beam-samza"
          files:
          - "uc2-beam-samza-deployment.yaml"
          - "uc2-beam-samza-service.yaml"
          - "uc2-service-monitor.yaml"
    # beforeActions:
    #   - selector: # delete zookeeper nodes to reset zookeeper
    #       pod:
    #         matchLabels:
    #           app: "cp-zookeeper"
    #       container: "cp-zookeeper-server"
    #     exec:
    #       command: ["/usr/bin/zookeeper-shell", "localhost:2181", "ls" , "/"]
    #       timeoutSeconds: 60
      # - selector: #Create input topic for samza with 10 partitions
      #     pod:
      #        matchLabels:
      #          app: "cp-zookeeper"
      #      container: "cp-zookeeper-server"
      #    exec:
      #      command: ["kafka-topics", "--zookeeper", "localhost:2181",
      #               "--topic", "input", "--partitions", "10", "--create"]
      #      timeoutSeconds: 90
    afterActions:
      - selector: # delete zookeeper nodes to reset zookeeper
          pod:
            matchLabels:
              app: "cp-zookeeper"
          container: "cp-zookeeper-server"
        exec:
          command: ["zookeeper-shell", "localhost:2181",
           "deleteall", "/app-theodolite-uc2-application-1"]
          timeoutSeconds: 60
  loadGenerator:
    resources:
      - configMap:
          name: "benchmark-resources-uc2-load-generator"
          files:
          - "uc2-load-generator-deployment.yaml"
          - "uc2-load-generator-service.yaml"
  resourceTypes:
    - typeName: "Instances"
      patchers:
        - type: "ReplicaPatcher"
          resource: "uc2-beam-samza-deployment.yaml"
  loadTypes:
    - typeName: "NumSensors"
      patchers:
        - type: "EnvVarPatcher"
          resource: "uc2-load-generator-deployment.yaml"
          properties:
            container: "workload-generator"
            variableName: "NUM_SENSORS"
        - type: NumSensorsLoadGeneratorReplicaPatcher
          resource: "uc2-load-generator-deployment.yaml"
          properties:
            loadGenMaxRecords: "150000"
  kafkaConfig:
    bootstrapServer: "theodolite-cp-kafka:9092"
    topics:
      - name: "input"
        numPartitions: 40
        replicationFactor: 1
      - name: "output"
        numPartitions: 40
        replicationFactor: 1
      - name: ".*samza.*"
        removeOnly: true
      - name: ".*uc2-application.*"
        removeOnly: true