aboutsummaryrefslogtreecommitdiff
path: root/events-kube/test/events-topic.yml
blob: af8f867d10dca64c1c7309cbf77c94fd12deff3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Note that this test is scaled to zero
# because it will only stay healthy when there are cluster events, at least 1 per periodSeconds
---
kind: ConfigMap
metadata:
  name: events-topic
  namespace: test-kafka
apiVersion: v1
data:

  setup.sh: |-
    touch /tmp/testlog

    tail -f /tmp/testlog

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

    PREVIOUS=$(sha1sum /tmp/event 2>/dev/null || echo "")
    kafkacat -b $BOOTSTRAP -t $TOPIC -C -o -1 -c 1 | tee /tmp/event
    CURRENT=$(sha1sum /tmp/event)
    [ "$PREVIOUS" == "$CURRENT" ] && echo "{\"test-result\": \"No new event in $TOPIC\"}" && exit 1

    exit 0

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

    exit 0

---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: events-topic
  namespace: test-kafka
spec:
  replicas: 0
  strategy:
    type: Recreate
  selector:
    matchLabels:
      test-target: events-topic
      test-type: readiness
  template:
    metadata:
      labels:
        test-target: events-topic
        test-type: readiness
    spec:
      containers:
      - name: testcase
        image: solsson/kafkacat@sha256:2c539e4f58960ab7872976ebc664dd92de18cf27e7cbbeb296d654a2351f6ca4
        env:
        - name: BOOTSTRAP
          value: bootstrap.kafka:9092
        - name: TOPIC
          value: ops.kube-events-all.stream.json.001
        command:
        - /bin/bash
        - -e
        - /test/setup.sh
        readinessProbe:
          exec:
            command:
            - /bin/bash
            - -e
            - /test/test.sh
          initialDelaySeconds: 10
          periodSeconds: 60
        livenessProbe:
          exec:
            command:
            - /bin/bash
            - -e
            - /test/quit-on-nonzero-exit.sh
        volumeMounts:
        - name: config
          mountPath: /test
      volumes:
      - name: config
        configMap:
          name: events-topic