3030 REGISTRY : ${{ inputs.registry }}
3131
3232jobs :
33- e2e-test :
33+ e2e-test-network-policy :
3434 timeout-minutes : 5
3535 strategy :
3636 matrix :
@@ -91,15 +91,104 @@ jobs:
9191 sleep 10 ;
9292 fi
9393 done
94-
94+
9595 echo Outputting all logs
9696 echo _SNIFFER LOGS_
9797 kubectl logs -n otterize-system -l app=otterize-network-sniffer --tail=-1
9898 echo _MAPPER LOGS_
9999 kubectl logs -n otterize-system -l app=otterize-network-mapper --tail=-1
100-
100+
101101 echo "export intents and compare to expected file"
102102 otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-mapper --format=json | jq 'sort_by(.metadata.namespace + .metadata.name)' > /tmp/intents.json
103103 diff .github/workflows/tests-expected-results/simple-tutorial-intents.json /tmp/intents.json
104104 echo "expected" && cat .github/workflows/tests-expected-results/simple-tutorial-intents.json
105105 echo "actual" && cat /tmp/intents.json
106+
107+ e2e-test-kafka :
108+ timeout-minutes : 8
109+ runs-on : ubuntu-latest
110+ steps :
111+ - name : Checkout
112+ uses : actions/checkout@v2
113+ with :
114+ submodules : recursive
115+
116+ - name : Login to GCR # We don't want this to happen in the setup, since we don't want to pass the SA account secret to the setup
117+ if : (github.event_name == 'push' && github.repository == 'otterize/network-mapper') || github.event.pull_request.head.repo.full_name == 'otterize/network-mapper'
118+ uses : docker/login-action@v2
119+ with :
120+ registry : ${{ env.REGISTRY }}
121+ username : _json_key_base64
122+ password : ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON }}
123+
124+ - name : Test setup
125+ uses : ./.github/actions/e2e-test-setup-action
126+ with :
127+ mapper-tag : ${{ inputs.mapper-tag }}
128+ sniffer-tag : ${{ inputs.sniffer-tag }}
129+ mapper-image : ${{ inputs.mapper-image }}
130+ sniffer-image : ${{ inputs.sniffer-image }}
131+ registry : ${{ inputs.registry }}
132+ install-extra-flags : " --set kafkawatcher.enable=true --set kafkawatcher.kafkaServers={\" kafka-0.kafka\" } "
133+
134+ - name : Install CLI
135+ run : |-
136+ wget --header="X-Otterize-Test: true" https://get.otterize.com/otterize-cli/v2.0.3/otterize_linux_x86_64.tar.gz
137+ tar xf otterize_linux_x86_64.tar.gz
138+ sudo cp otterize /usr/local/bin
139+
140+ - name : Deploy Kafka
141+ run : |-
142+ helm repo add otterize https://helm.otterize.com
143+ helm repo update
144+ 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
145+
146+ - name : Deploy Kafka Tutorial services
147+ run : |-
148+ kubectl apply -n otterize-tutorial-kafka-mapping -f https://docs.otterize.com/code-examples/kafka-mapping/all.yaml
149+
150+ - name : Wait for Kafka & Tutorial services
151+ run : |-
152+ kubectl wait pods -n kafka -l app.kubernetes.io/component=kafka --for condition=Ready --timeout=90s
153+ kubectl wait pods -n kafka -l app.kubernetes.io/component=zookeeper --for condition=Ready --timeout=90s
154+ kubectl wait pods -n otterize-system -l app=otterize-kafka-watcher --for condition=Ready --timeout=90s
155+ kubectl wait pods -n otterize-tutorial-kafka-mapping -l app=client --for condition=Ready --timeout=90s
156+ kubectl wait pods -n otterize-tutorial-kafka-mapping -l app=client-2 --for condition=Ready --timeout=90s
157+
158+ - name : Test Policy Export
159+ run : |-
160+ # wait for 2 intents to be discovered with timeout of 30 seconds.
161+ # sleeps 10 because this is the report interval from the watcher to the mapper
162+ for i in {1..5}
163+ do
164+ OUTPUT_JSON=`otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-kafka-mapping --format=json`
165+ if [ `echo "$OUTPUT_JSON" | jq ". | length"` != 2 ] || [ `echo "$OUTPUT_JSON" | jq '[.[] | select(.spec.targets[] | has("kafka"))] | length'` != 2 ] ; then
166+ echo "wait for discovered intents";
167+ echo _SNIFFER LOGS_
168+ kubectl logs --since=15s -n otterize-system -l app=otterize-network-sniffer
169+ echo _MAPPER LOGS_
170+ kubectl logs --since=15s -n otterize-system -l app=otterize-network-mapper
171+ sleep 10 ;
172+ fi
173+ done
174+
175+ echo Outputting all logs
176+ echo _SNIFFER LOGS_
177+ kubectl logs -n otterize-system -l app=otterize-network-sniffer --tail=-1
178+ echo _MAPPER LOGS_
179+ kubectl logs -n otterize-system -l app=otterize-network-mapper --tail=-1
180+
181+ echo "export intents and compare to expected file"
182+ otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-kafka-mapping --format=json | jq 'sort_by(.metadata.namespace + .metadata.name) | map(.spec.targets |= (sort_by(keys_unsorted[0]) | map(if .kafka? then .kafka.topics |= map(.operations |= sort) else . end)))' > /tmp/intents.json
183+ diff .github/workflows/tests-expected-results/kafka-tutorial-intents.json /tmp/intents.json
184+ echo "expected" && cat .github/workflows/tests-expected-results/kafka-tutorial-intents.json
185+ echo "actual" && cat /tmp/intents.json
186+
187+ e2e-test :
188+ needs :
189+ - e2e-test-policy-export
190+ - e2e-test-kafka
191+ runs-on : ubuntu-latest
192+ steps :
193+ - run : |-
194+ echo Success! This step is only here to depend on the tests.
0 commit comments