3030 REGISTRY : ${{ inputs.registry }}
3131
3232jobs :
33- e2e-test :
33+ e2e-test-policy-export :
3434 timeout-minutes : 5
3535 strategy :
3636 matrix :
@@ -75,15 +75,88 @@ jobs:
7575 sleep 10 ;
7676 fi
7777 done
78-
78+
7979 echo Outputting all logs
8080 echo _SNIFFER LOGS_
8181 kubectl logs -n otterize-system -l app=otterize-network-sniffer --tail=-1
8282 echo _MAPPER LOGS_
8383 kubectl logs -n otterize-system -l app=otterize-network-mapper --tail=-1
84-
84+
8585 echo "export intents and compare to expected file"
8686 otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-mapper --format=json | jq 'sort_by(.metadata.namespace + .metadata.name)' > /tmp/intents.json
8787 diff .github/workflows/tests-expected-results/simple-tutorial-intents.json /tmp/intents.json
8888 echo "expected" && cat .github/workflows/tests-expected-results/simple-tutorial-intents.json
8989 echo "actual" && cat /tmp/intents.json
90+
91+ e2e-test-kafka :
92+ timeout-minutes : 8
93+ runs-on : ubuntu-latest
94+ steps :
95+ - name : Checkout code
96+ uses : actions/checkout@v2
97+
98+ - name : Test setup
99+ uses : ./.github/workflows/e2e-test-setpup-action.yaml
100+ with :
101+ mapper-tag : ${{ inputs.mapper-tag }}
102+ sniffer-tag : ${{ inputs.sniffer-tag }}
103+ mapper-image : ${{ inputs.mapper-image }}
104+ sniffer-image : ${{ inputs.sniffer-image }}
105+ registry : ${{ inputs.registry }}
106+ install-extra-flags : " --set kafkawatcher.enable=true --set kafkawatcher.kafkaServers={\" kafka-0.kafka\" } "
107+
108+ - name : Deploy Kafka
109+ run : |-
110+ helm repo add otterize https://helm.otterize.com
111+ helm repo update
112+ helm install --create-namespace -n kafka -f https://docs.otterize.com/code-examples/kafka-mapping/helm/values.yaml kafka otterize/kafka --version 21.4.4
113+
114+ - name : Deploy Kafka Tutorial services
115+ run : |-
116+ kubectl apply -n otterize-tutorial-kafka-mapping -f https://docs.otterize.com/code-examples/kafka-mapping/all.yaml
117+
118+ - name : Wait for Kafka & Tutorial services
119+ run : |-
120+ kubectl wait pods -n kafka -l app.kubernetes.io/component=kafka --for condition=Ready --timeout=90s
121+ kubectl wait pods -n kafka -l app.kubernetes.io/component=zookeeper --for condition=Ready --timeout=90s
122+ kubectl wait pods -n otterize-system -l app=otterize-kafka-watcher --for condition=Ready --timeout=90s
123+ kubectl wait pods -n otterize-tutorial-kafka-mapping -l app=client --for condition=Ready --timeout=90s
124+ kubectl wait pods -n otterize-tutorial-kafka-mapping -l app=client-2 --for condition=Ready --timeout=90s
125+
126+ - name : Test Policy Export
127+ run : |-
128+ # wait for 2 intents to be discovered with timeout of 30 seconds.
129+ # sleeps 10 because this is the report interval from the watcher to the mapper
130+ for i in {1..5}
131+ do
132+ OUTPUT_JSON=`otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-kafka-mapping --format=json`
133+ if [ `echo "$OUTPUT_JSON" | jq ". | length"` != 2 ] || [ `echo "$OUTPUT_JSON" | jq '[.[] | select(.spec.targets[] | has("kafka"))] | length'` != 2 ] ; then
134+ echo "wait for discovered intents";
135+ echo _SNIFFER LOGS_
136+ kubectl logs --since=15s -n otterize-system -l app=otterize-network-sniffer
137+ echo _MAPPER LOGS_
138+ kubectl logs --since=15s -n otterize-system -l app=otterize-network-mapper
139+ sleep 10 ;
140+ fi
141+ done
142+
143+ echo Outputting all logs
144+ echo _SNIFFER LOGS_
145+ kubectl logs -n otterize-system -l app=otterize-network-sniffer --tail=-1
146+ echo _MAPPER LOGS_
147+ kubectl logs -n otterize-system -l app=otterize-network-mapper --tail=-1
148+
149+ echo "export intents and compare to expected file"
150+ otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-kafka-mapping --format=json | jq 'sort_by(.metadata.namespace + .metadata.name)' > /tmp/intents.json
151+ diff .github/workflows/tests-expected-results/kafka-tutorial-intents.json /tmp/intents.json
152+ echo "expected" && cat .github/workflows/tests-expected-results/kafka-tutorial-intents.json
153+ echo "actual" && cat /tmp/intents.json
154+
155+ e2e-test :
156+ needs :
157+ - e2e-test-policy-export
158+ - e2e-test-kafka
159+ runs-on : ubuntu-latest
160+ steps :
161+ - run : |-
162+ echo Success! This step is only here to depend on the tests.
0 commit comments