aboutsummaryrefslogblamecommitdiff
path: root/test/basic-with-kafkacat.yml
blob: d7a9fe0c4e58507477dfa4985711e5a74cbea5c8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


               

                                


              

                      
 
                        
 
             

                        
 




                                                                                            
 


                                                                 
 
          





                             



                    

                                




                          
                                                                                                          




                                                  
                         
                 
                                    


                              
               




                          

                                

             

                  


             
                              
                            





                                                                                   

                 































                                                                                                       
                      
                                                                                                       

                         

                                                                                                                                                     
                
                   
            
                        



                       
                


                                 



                       
                
                                           





                          
                                        

                    
---
kind: ConfigMap
metadata:
  name: test-basic-with-kafkacat
  namespace: default
apiVersion: v1
data:

  setup.sh: |-
    touch /tmp/testlog

    tail -f /tmp/testlog

  test.sh: |-
    exec >> /tmp/testlog
    exec 2>&1

    LAST_TS=$(kafkacat -C -b $BOOTSTRAP -t test-basic-with-kafkacat -o -1 -f '%T\n' -c 1 -u)
    NOW=$(date -u +%s%3N)
    echo "$NOW ($(date +%FT%H:%M:%S.%3N)):"
    echo "$LAST_TS"
    echo "$((($NOW - $LAST_TS)/1000)) seconds old"

    #Q_TS=$(date -u +%s%3N)
    Q_TS=$LAST_TS
    kafkacat -Q -b $BOOTSTRAP -t test-basic-with-kafkacat:0:$Q_TS

    exit 0

  quit-on-nonzero-exit.sh: |-
    exec >> /tmp/testlog
    exec 2>&1

    exit 0
---
apiVersion: batch/v1
kind: Job
metadata:
  name: test-basic-with-kafkacat
  namespace: default
spec:
  template:
    spec:
      containers:
      - name: topic-create
        image: solsson/kafka:1.0.0@sha256:17fdf1637426f45c93c65826670542e36b9f3394ede1cb61885c6a4befa8f72d
        command:
        - ./bin/kafka-topics.sh
        - --zookeeper
        -   zookeeper.kafka.svc.cluster.local:2181
        - --create
        - --if-not-exists
        - --topic
        -   test-basic-with-kafkacat
        - --partitions
        -   "1"
        - --replication-factor
        -   "2"
      restartPolicy: Never
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: test-basic-with-kafkacat
  namespace: default
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        test-target: kube-test
        test-type: readiness
        # for example:
        # readonly - can be used in production
        # isolated - read/write but in a manner that does not affect other services
        # load - unsuitable for production because it uses significant resources
        # chaos - unsuitable for production because it injects failure modes
        #test-use:
    spec:
      containers:
      - name: producer
        image: solsson/kafkacat@sha256:ebebf47061300b14a4b4c2e1e4303ab29f65e4b95d34af1b14bb8f7ec6da7cef
        env:
        - name: BOOTSTRAP
          value: kafka-0.broker.kafka.svc.cluster.local:9092
        command:
        - /bin/bash
        - -cex
        - >
          echo "--- start $HOSTNAME $(date --iso-8601='ns' -u) ---" >> /shared/produce.tmp;
          tail -f /shared/produce.tmp |
          kafkacat -P -b $BOOTSTRAP -t test-basic-with-kafkacat -v -T;
        volumeMounts:
        - name: config
          mountPath: /test
        - name: shared
          mountPath: /shared
      - name: consumer
        image: solsson/kafkacat@sha256:ebebf47061300b14a4b4c2e1e4303ab29f65e4b95d34af1b14bb8f7ec6da7cef
        env:
        - name: BOOTSTRAP
          value: kafka-0.broker.kafka.svc.cluster.local:9092
        command:
        - /bin/bash
        - -cex
        - >
          kafkacat -C -b $BOOTSTRAP -t test-basic-with-kafkacat -o -1 -f '[%p,%o] %s\n' -u
        volumeMounts:
        - name: config
          mountPath: /test
        - name: shared
          mountPath: /shared
      - name: testcase
        image: solsson/kafkacat@sha256:ebebf47061300b14a4b4c2e1e4303ab29f65e4b95d34af1b14bb8f7ec6da7cef
        env:
        - name: BOOTSTRAP
          #value: kafka-0.broker.kafka.svc.cluster.local:9092,kafka-1.broker.kafka.svc.cluster.local:9092,kafka-2.broker.kafka.svc.cluster.local:9092
          value: kafka-0.broker.kafka.svc.cluster.local:9092
        command:
        - /bin/bash
        - -e
        - /test/setup.sh
        readinessProbe:
          exec:
            command:
            - /bin/bash
            - -e
            - /test/test.sh
          initialDelaySeconds: 10
          periodSeconds: 10
        livenessProbe:
          exec:
            command:
            - /bin/bash
            - -e
            - /test/quit-on-nonzero-exit.sh
        volumeMounts:
        - name: config
          mountPath: /test
      volumes:
      - name: config
        configMap:
          name: test-basic-with-kafkacat
      - name: shared
        emptyDir: {}