3030 REGISTRY : ${{ inputs.registry }}
3131
3232jobs :
33- e2e-test :
33+ e2e-test-network-policy :
3434 timeout-minutes : 5
3535 strategy :
3636 matrix :
@@ -42,96 +42,27 @@ jobs:
4242 with :
4343 submodules : recursive
4444
45- - name : Start minikube
46- uses : medyagh/setup-minikube@master
47- with :
48- start-args : " --network-plugin=cni --cni=calico"
49-
50- - name : Load images from GitHub Artifacts
51- if : github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
52- uses : actions/download-artifact@v4
53- with :
54- name : ${{ env.REGISTRY }}_${{ github.actor }}_mapper_${{ github.sha }}.tar
55-
56- - name : Load Docker image
57- if : github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
58- run : |-
59- docker image load -i mapper.tar
60- minikube image load ${{ env.REGISTRY }}/${{ github.actor }}/mapper:${{ github.sha }}
61-
62- - name : Load images from GitHub Artifacts
63- if : github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
64- uses : actions/download-artifact@v4
65- with :
66- name : ${{ env.REGISTRY }}_${{ github.actor }}_sniffer_${{ github.sha }}.tar
67-
68- - name : Load Docker image
69- if : github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
70- run : |-
71- docker image load -i sniffer.tar
72- minikube image load ${{ env.REGISTRY }}/${{ github.actor }}/sniffer:${{ github.sha }}
73-
74- - name : Load images from GitHub Artifacts
75- if : github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
76- uses : actions/download-artifact@v4
77- with :
78- name : ${{ env.REGISTRY }}_${{ github.actor }}_kafka-watcher_${{ github.sha }}.tar
79-
80- - name : Load Docker image
81- if : github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
82- run : |-
83- docker image load -i kafka-watcher.tar
84- minikube image load ${{ env.REGISTRY }}/${{ github.actor }}/kafka-watcher:${{ github.sha }}
85-
86-
87- - name : Login to GCR
45+ - 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 setupGCR
8846 if : (github.event_name == 'push' && github.repository == 'otterize/network-mapper') || github.event.pull_request.head.repo.full_name == 'otterize/network-mapper'
8947 uses : docker/login-action@v2
9048 with :
9149 registry : ${{ env.REGISTRY }}
9250 username : _json_key_base64
9351 password : ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON }}
9452
95- - name : Load Docker images from GCR
96- if : (github.event_name == 'push' && github.repository == 'otterize/network-mapper') || github.event.pull_request.head.repo.full_name == 'otterize/network-mapper'
97- run : |-
98- docker pull ${{ env.REGISTRY }}/mapper:${{ inputs.mapper-tag }}
99- minikube image load ${{ env.REGISTRY }}/mapper:${{ inputs.mapper-tag }}
100- docker pull ${{ env.REGISTRY }}/sniffer:${{ inputs.sniffer-tag }}
101- minikube image load ${{ env.REGISTRY }}/sniffer:${{ inputs.sniffer-tag }}
102-
103- - name : Set up Helm
104- uses : azure/setup-helm@v3
105-
106- - name : Wait for Calico startup
107- run : |-
108- kubectl wait pods -n kube-system -l k8s-app=calico-kube-controllers --for condition=Ready --timeout=90s
109- kubectl wait pods -n kube-system -l k8s-app=calico-node --for condition=Ready --timeout=90s
110- kubectl wait pods -n kube-system -l k8s-app=calico-kube-controllers --for condition=Ready --timeout=90s
111-
112- - name : Deploy Network Mapper
113- run : |-
114- MAPPER_FLAGS="--set-string mapper.repository=${{ env.REGISTRY }} --set-string mapper.image=${{ inputs.mapper-image }} --set-string mapper.tag=${{ inputs.mapper-tag }} --set-string mapper.pullPolicy=Never"
115- SNIFFER_FLAGS="--set-string sniffer.repository=${{ env.REGISTRY }} --set-string sniffer.image=${{ inputs.sniffer-image }} --set-string sniffer.tag=${{ inputs.sniffer-tag }} --set-string sniffer.pullPolicy=Never"
116- TELEMETRY_FLAG="--set global.telemetry.enabled=false"
117- helm dep up ./helm-charts/network-mapper
118- helm install otterize ./helm-charts/network-mapper -n otterize-system --create-namespace --set debug=true $MAPPER_FLAGS $SNIFFER_FLAGS $TELEMETRY_FLAG
119-
120- - name : Install CLI
121- run : |-
122- wget --header="X-Otterize-Test: true" https://get.otterize.com/otterize-cli/v0.1.30/otterize_linux_x86_64.tar.gz
123- tar xf otterize_linux_x86_64.tar.gz
124- sudo cp otterize /usr/local/bin
53+ - name : Test setup
54+ uses : ./.github/actions/e2e-test-setup-action
55+ with :
56+ mapper-tag : ${{ inputs.mapper-tag }}
57+ sniffer-tag : ${{ inputs.sniffer-tag }}
58+ mapper-image : ${{ inputs.mapper-image }}
59+ sniffer-image : ${{ inputs.sniffer-image }}
60+ registry : ${{ inputs.registry }}
12561
12662 - name : Deploy Tutorial services
12763 run : |-
12864 kubectl apply -n otterize-tutorial-mapper -f https://docs.otterize.com/code-examples/network-mapper/all.yaml
12965
130- - name : Wait for Otterize
131- run : |-
132- kubectl wait pods -n otterize-system -l app=otterize-network-sniffer --for condition=Ready --timeout=90s
133- kubectl wait pods -n otterize-system -l app=otterize-network-mapper --for condition=Ready --timeout=90s
134-
13566 - name : Wait for Tutorial services
13667 run : |-
13768 kubectl wait pods -n otterize-tutorial-mapper -l app=client --for condition=Ready --timeout=90s
@@ -154,19 +85,101 @@ jobs:
15485 sleep 10 ;
15586 fi
15687 done
157-
88+
15889 echo Outputting all logs
15990 echo _SNIFFER LOGS_
16091 kubectl logs -n otterize-system -l app=otterize-network-sniffer --tail=-1
16192 echo _MAPPER LOGS_
16293 kubectl logs -n otterize-system -l app=otterize-network-mapper --tail=-1
163-
94+
16495 echo "export intents and compare to expected file"
16596 otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-mapper --format=json | jq 'sort_by(.metadata.namespace + .metadata.name)' > /tmp/intents.json
16697 diff .github/workflows/tests-expected-results/simple-tutorial-intents.json /tmp/intents.json
16798 echo "expected" && cat .github/workflows/tests-expected-results/simple-tutorial-intents.json
16899 echo "actual" && cat /tmp/intents.json
169-
170-
171100
172-
101+ e2e-test-kafka :
102+ timeout-minutes : 8
103+ runs-on : ubuntu-latest
104+ steps :
105+ - name : Checkout
106+ uses : actions/checkout@v2
107+ with :
108+ submodules : recursive
109+
110+ - 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
111+ if : (github.event_name == 'push' && github.repository == 'otterize/network-mapper') || github.event.pull_request.head.repo.full_name == 'otterize/network-mapper'
112+ uses : docker/login-action@v2
113+ with :
114+ registry : ${{ env.REGISTRY }}
115+ username : _json_key_base64
116+ password : ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON }}
117+
118+ - name : Test setup
119+ uses : ./.github/actions/e2e-test-setup-action
120+ with :
121+ mapper-tag : ${{ inputs.mapper-tag }}
122+ sniffer-tag : ${{ inputs.sniffer-tag }}
123+ mapper-image : ${{ inputs.mapper-image }}
124+ sniffer-image : ${{ inputs.sniffer-image }}
125+ registry : ${{ inputs.registry }}
126+ install-extra-flags : " --set kafkawatcher.enable=true --set kafkawatcher.kafkaServers={\" kafka-0.kafka\" } "
127+
128+ - name : Deploy Kafka
129+ run : |-
130+ helm repo add otterize https://helm.otterize.com
131+ helm repo update
132+ 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
133+
134+ - name : Deploy Kafka Tutorial services
135+ run : |-
136+ kubectl apply -n otterize-tutorial-kafka-mapping -f https://docs.otterize.com/code-examples/kafka-mapping/all.yaml
137+
138+ - name : Wait for Kafka & Tutorial services
139+ run : |-
140+ kubectl wait pods -n kafka -l app.kubernetes.io/component=kafka --for condition=Ready --timeout=90s
141+ kubectl wait pods -n kafka -l app.kubernetes.io/component=zookeeper --for condition=Ready --timeout=90s
142+ kubectl wait pods -n otterize-system -l app=otterize-kafka-watcher --for condition=Ready --timeout=90s
143+ kubectl wait pods -n otterize-tutorial-kafka-mapping -l app=client --for condition=Ready --timeout=90s
144+ kubectl wait pods -n otterize-tutorial-kafka-mapping -l app=client-2 --for condition=Ready --timeout=90s
145+
146+ - name : Test Policy Export
147+ run : |-
148+ # wait for 2 intents to be discovered with timeout of 30 seconds.
149+ # sleeps 10 because this is the report interval from the watcher to the mapper
150+ for i in {1..5}
151+ do
152+ OUTPUT_JSON=`otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-kafka-mapping --format=json`
153+ if [ `echo "$OUTPUT_JSON" | jq ". | length"` != 2 ] || [ `echo "$OUTPUT_JSON" | jq '[.[] | select(.spec.targets[] | has("kafka"))] | length'` != 2 ] ; then
154+ echo "wait for discovered intents";
155+ echo _SNIFFER LOGS_
156+ kubectl logs --since=15s -n otterize-system -l app=otterize-network-sniffer
157+ echo _MAPPER LOGS_
158+ kubectl logs --since=15s -n otterize-system -l app=otterize-network-mapper
159+ sleep 10 ;
160+ fi
161+ done
162+
163+ echo Outputting all logs
164+ echo _SNIFFER LOGS_
165+ kubectl logs -n otterize-system -l app=otterize-network-sniffer --tail=-1
166+ echo _MAPPER LOGS_
167+ kubectl logs -n otterize-system -l app=otterize-network-mapper --tail=-1
168+
169+ echo "export intents and compare to expected file"
170+ INTENTS_JSON=`otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-kafka-mapping --format=json`
171+ INTENTS_JSON_NO_KIND=`echo "$INTENTS_JSON" | jq 'map(del(.spec.workload.kind))'`
172+ INTENTS_JSON_NO_KIND_AND_SORTED=`echo "$INTENTS_JSON_NO_KIND" | 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)))'`
173+ echo "$INTENTS_JSON_NO_KIND_AND_SORTED" > /tmp/intents.json
174+ echo "expected" && cat .github/workflows/tests-expected-results/kafka-tutorial-intents.json
175+ echo "actual" && cat /tmp/intents.json
176+ diff .github/workflows/tests-expected-results/kafka-tutorial-intents.json /tmp/intents.json
177+
178+ e2e-test :
179+ needs :
180+ - e2e-test-network-policy
181+ - e2e-test-kafka
182+ runs-on : ubuntu-latest
183+ steps :
184+ - run : |-
185+ echo Success! This step is only here to depend on the tests.
0 commit comments