-
Notifications
You must be signed in to change notification settings - Fork 24
172 lines (143 loc) · 8.07 KB
/
e2e-test.yaml
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: E2E Test # this test is based on this tutorial: https://docs.otterize.com/quick-tutorials/k8s-network-mapper
on:
workflow_call: # To support triggering from another workflow (build.yaml)
# When triggering a workflow from another workflow the triggered workflow does not have access to any secrets,
# and they must be passed from the caller
secrets:
B64_GCLOUD_SERVICE_ACCOUNT_JSON:
required: false
inputs:
mapper-tag:
required: true
type: string
sniffer-tag:
required: true
type: string
mapper-image:
required: true
type: string
sniffer-image:
required: true
type: string
registry:
required: true
type: string
default: us-central1-docker.pkg.dev/main-383408/otterize
env:
REGISTRY: ${{ inputs.registry }}
jobs:
e2e-test:
timeout-minutes: 5
strategy:
matrix:
workers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Start minikube
uses: medyagh/setup-minikube@master
with:
start-args: "--network-plugin=cni --cni=calico"
- name: Load images from GitHub Artifacts
if: github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
uses: actions/download-artifact@v3
with:
name: ${{ env.REGISTRY }}_${{ github.actor }}_mapper_${{ github.sha }}.tar
- name: Load Docker image
if: github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
run: |-
docker image load -i mapper.tar
minikube image load ${{ env.REGISTRY }}/${{ github.actor }}/mapper:${{ github.sha }}
- name: Load images from GitHub Artifacts
if: github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
uses: actions/download-artifact@v3
with:
name: ${{ env.REGISTRY }}_${{ github.actor }}_sniffer_${{ github.sha }}.tar
- name: Load Docker image
if: github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
run: |-
docker image load -i sniffer.tar
minikube image load ${{ env.REGISTRY }}/${{ github.actor }}/sniffer:${{ github.sha }}
- name: Load images from GitHub Artifacts
if: github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
uses: actions/download-artifact@v3
with:
name: ${{ env.REGISTRY }}_${{ github.actor }}_kafka-watcher_${{ github.sha }}.tar
- name: Load Docker image
if: github.repository != 'otterize/network-mapper' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'otterize/network-mapper')
run: |-
docker image load -i kafka-watcher.tar
minikube image load ${{ env.REGISTRY }}/${{ github.actor }}/kafka-watcher:${{ github.sha }}
- name: Login to GCR
if: (github.event_name == 'push' && github.repository == 'otterize/network-mapper') || github.event.pull_request.head.repo.full_name == 'otterize/network-mapper'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: _json_key_base64
password: ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON }}
- name: Load Docker images from GCR
if: (github.event_name == 'push' && github.repository == 'otterize/network-mapper') || github.event.pull_request.head.repo.full_name == 'otterize/network-mapper'
run: |-
docker pull ${{ env.REGISTRY }}/mapper:${{ inputs.mapper-tag }}
minikube image load ${{ env.REGISTRY }}/mapper:${{ inputs.mapper-tag }}
docker pull ${{ env.REGISTRY }}/sniffer:${{ inputs.sniffer-tag }}
minikube image load ${{ env.REGISTRY }}/sniffer:${{ inputs.sniffer-tag }}
- name: Set up Helm
uses: azure/setup-helm@v3
- name: Wait for Calico startup
run: |-
kubectl wait pods -n kube-system -l k8s-app=calico-kube-controllers --for condition=Ready --timeout=90s
kubectl wait pods -n kube-system -l k8s-app=calico-node --for condition=Ready --timeout=90s
kubectl wait pods -n kube-system -l k8s-app=calico-kube-controllers --for condition=Ready --timeout=90s
- name: Deploy Network Mapper
run: |-
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"
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"
TELEMETRY_FLAG="--set global.telemetry.enabled=false"
helm dep up ./helm-charts/network-mapper
helm install otterize ./helm-charts/network-mapper -n otterize-system --create-namespace --set debug=true $MAPPER_FLAGS $SNIFFER_FLAGS $TELEMETRY_FLAG
- name: Install CLI
run: |-
wget --header="X-Otterize-Test: true" https://get.otterize.com/otterize-cli/v0.1.30/otterize_linux_x86_64.tar.gz
tar xf otterize_linux_x86_64.tar.gz
sudo cp otterize /usr/local/bin
- name: Deploy Tutorial services
run: |-
kubectl apply -n otterize-tutorial-mapper -f https://docs.otterize.com/code-examples/network-mapper/all.yaml
- name: Wait for Otterize
run: |-
kubectl wait pods -n otterize-system -l app=otterize-network-sniffer --for condition=Ready --timeout=90s
kubectl wait pods -n otterize-system -l app=otterize-network-mapper --for condition=Ready --timeout=90s
- name: Wait for Tutorial services
run: |-
kubectl wait pods -n otterize-tutorial-mapper -l app=client --for condition=Ready --timeout=90s
kubectl wait pods -n otterize-tutorial-mapper -l app=client2 --for condition=Ready --timeout=90s
kubectl wait pods -n otterize-tutorial-mapper -l app=server --for condition=Ready --timeout=90s
- name: Test Policy Export
run: |-
# wait for 2 intents to be discovered with timeout of 30 seconds.
# sleeps 10 because this is the report interval from the watcher to the mapper
for i in {1..5}
do
if [ `otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-mapper --format=json | jq ". | length"` != 2 ]; then
echo "wait for discovered intents";
echo _SNIFFER LOGS_
kubectl logs --since=15s -n otterize-system -l app=otterize-network-sniffer
echo _MAPPER LOGS_
kubectl logs --since=15s -n otterize-system -l app=otterize-network-mapper
sleep 10 ;
fi
done
echo Outputting all logs
echo _SNIFFER LOGS_
kubectl logs -n otterize-system -l app=otterize-network-sniffer --tail=-1
echo _MAPPER LOGS_
kubectl logs -n otterize-system -l app=otterize-network-mapper --tail=-1
echo "export intents and compare to expected file"
otterize network-mapper export --telemetry-enabled=false -n otterize-tutorial-mapper --format=json | jq 'sort_by(.metadata.namespace + .metadata.name)' > /tmp/intents.json
diff .github/workflows/tests-expected-results/simple-tutorial-intents.json /tmp/intents.json
echo "expected" && cat .github/workflows/tests-expected-results/simple-tutorial-intents.json
echo "actual" && cat /tmp/intents.json