Skip to content

Commit

Permalink
Remove flaky CRD spec format testing from e2e test (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
NetanelBollag authored Jan 28, 2024
1 parent dfb2de8 commit 79b9d77
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/intents-spec.yaml

This file was deleted.

17 changes: 11 additions & 6 deletions .github/workflows/netpol-e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ jobs:
echo Client: $CLI1_POD client_other: $CLI2_POD
source .github/workflows/test-bashrc.sh
kubectl apply -f https://docs.otterize.com/code-examples/automate-network-policies/intents.yaml
echo "Validate intents spec format"
kubectl get clientintents.k8s.otterize.com -n otterize-tutorial-npol client -o yaml | sed -n '/spec:/,/status:/p' | diff -s - .github/workflows/intents-spec.yaml
echo "Apply intents"
apply_intents_and_wait_for_webhook https://docs.otterize.com/code-examples/automate-network-policies/intents.yaml
echo "Intents applied"
# should work because there is an applied intent
echo check client log
Expand Down Expand Up @@ -211,8 +210,12 @@ jobs:
- name: Apply intents
run: |-
source .github/workflows/test-bashrc.sh
kubectl create namespace otterize-tutorial-npol
kubectl apply -f https://docs.otterize.com/code-examples/automate-network-policies/intents.yaml
echo "Apply intents"
apply_intents_and_wait_for_webhook https://docs.otterize.com/code-examples/automate-network-policies/intents.yaml
echo "Intents applied"
- name: Deploy Tutorial services
run: |-
Expand Down Expand Up @@ -343,7 +346,9 @@ jobs:
echo Client: $CLI1_POD client_other: $CLI2_POD
source .github/workflows/test-bashrc.sh
kubectl apply -f https://docs.otterize.com/code-examples/automate-network-policies/intents.yaml
echo "Apply intents"
apply_intents_and_wait_for_webhook https://docs.otterize.com/code-examples/automate-network-policies/intents.yaml
echo "Intents applied"
# should not work at first because there is no allow DNS netpol
echo "check client log - should get timed out because it is missing DNS allow netpol"
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/test-bashrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,23 @@ wait_for_log() {
echo "Operator manager logs:"
kubectl logs -n otterize-system -l app=intents-operator --tail 400
exit 1
}
}

apply_intents_and_wait_for_webhook() {
INTENTS_FILE=$1
for i in {1..5}; do
kubectl apply -f "$INTENTS_FILE" 2> error.txt && break;
if grep -q "connection refused" error.txt; then
if [ "$i" -eq 5 ]; then
echo "Failed to apply intents, webhook server is not ready";
cat error.txt;
exit 1;
fi;
echo "Waiting for webhook to be ready, try $i/5";
sleep 5;
else
cat error.txt;
exit 1;
fi;
done
}

0 comments on commit 79b9d77

Please sign in to comment.