Skip to content

Commit

Permalink
chore: improve waiting logic in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jekkel committed Jul 5, 2022
1 parent 98c3a04 commit c3c1dac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,23 @@ jobs:
- name: Install Configmaps and Secrets
run: |
wait_for_pod_log() {
while [[ $(kubectl logs $1 | grep $2) == "" ]]; do echo "waiting 5 more seconds for '$2' to appear in logs of pod '$1'..." && sleep 5; done
echo "Pod '$1' logs contains '$2'"
}
# because the sidecar pods signal ready state before we actually opened up all watching subprocesses, we wait some more time
sleep 15
sleep 20
echo "Installing resources..."
kubectl apply -f "test/resources/resources.yaml"
sleep 15
pods=("sidecar" "sidecar-5xx")
resources=("sample-configmap" "sample-secret-binary" "absolute-configmap" "relative-configmap" "url-configmap-500" "url-configmap-basic-auth" "sample-configmap")
for p in ${pods[*]}; do
for r in ${resources[*]}; do
wait_for_pod_log $p $r
done
done
# 5 more seconds after the last thing appeared in the logs.
sleep 5
- name: Retrieve pod logs
run: |
kubectl logs sidecar > /tmp/sidecar.log
Expand Down
22 changes: 12 additions & 10 deletions test/resources/sidecar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,18 @@ spec:
mountPath: /opt-5xx/script.sh
subPath: script.sh
env:
- name: LABEL
value: "findme"
- name: FOLDER
value: /tmp-5xx/
- name: RESOURCE
value: both
- name: SCRIPT
value: "/opt-5xx/script.sh"
- name: ENABLE_5XX
value: "true"
- name: LABEL
value: "findme"
- name: FOLDER
value: /tmp-5xx/
- name: RESOURCE
value: both
- name: SCRIPT
value: "/opt-5xx/script.sh"
- name: ENABLE_5XX
value: "true"
- name: LOG_LEVEL
value: "DEBUG"
volumes:
- name: shared-volume
emptyDir: {}
Expand Down

0 comments on commit c3c1dac

Please sign in to comment.