Skip to content

Commit b38492d

Browse files
adwk67sbernauer
andauthored
fix: Add test for log-server endpoint (#657)
* fix: Add test for log-server endpoint * Update tests/templates/kuttl/external-access/50-assert.yaml.j2 Co-authored-by: Sebastian Bernauer <[email protected]> * corrected testing of return code --------- Co-authored-by: Sebastian Bernauer <[email protected]>
1 parent ddc2f0c commit b38492d

File tree

6 files changed

+157
-0
lines changed

6 files changed

+157
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
metadata:
5+
name: test-log-endpoint
6+
timeout: 240
7+
commands:
8+
{% if test_scenario['values']['executor'] == 'celery' %}
9+
- script: |
10+
set -eu
11+
12+
# Log-Endpoint Test:
13+
# This is executed from the Webserver as JWT keys must be present.
14+
# A small server is started on each worker that serves the logs on its
15+
# 8793 port for the Webserver: we don't use the token as that is an
16+
# internal implementation, but check that the endpoint is reachable,
17+
# indicated by a 403.
18+
CURL_RESPONSE=$(
19+
kubectl -n $NAMESPACE exec airflow-webserver-default-0 -- sh -c 'CODE=$(curl -s -o /dev/null -w "%{http_code}" http://airflow-worker-default-headless:8793 2>/dev/null || true);echo "$CODE"'
20+
)
21+
22+
# Log-Endpoint Test Assertion:
23+
echo "The HTTP Code is $CURL_RESPONSE (an internal JWT token is needed for full access)"
24+
[ "$CURL_RESPONSE" -eq 403 ]
25+
{% endif %}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
metadata:
5+
name: test-log-endpoint
6+
timeout: 240
7+
commands:
8+
{% if test_scenario['values']['executor'] == 'celery' %}
9+
- script: |
10+
set -eu
11+
12+
# Log-Endpoint Test:
13+
# This is executed from the Webserver as JWT keys must be present.
14+
# A small server is started on each worker that serves the logs on its
15+
# 8793 port for the Webserver: we don't use the token as that is an
16+
# internal implementation, but check that the endpoint is reachable,
17+
# indicated by a 403.
18+
CURL_RESPONSE=$(
19+
kubectl -n $NAMESPACE exec airflow-webserver-default-0 -- sh -c 'CODE=$(curl -s -o /dev/null -w "%{http_code}" http://airflow-worker-default-headless:8793 2>/dev/null || true);echo "$CODE"'
20+
)
21+
22+
# Log-Endpoint Test Assertion:
23+
echo "The HTTP Code is $CURL_RESPONSE (an internal JWT token is needed for full access)"
24+
[ "$CURL_RESPONSE" -eq 403 ]
25+
{% endif %}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
metadata:
5+
name: test-log-endpoint
6+
timeout: 240
7+
commands:
8+
{% if test_scenario['values']['executor'] == 'celery' %}
9+
- script: |
10+
set -eu
11+
12+
# Log-Endpoint Test:
13+
# This is executed from the Webserver as JWT keys must be present.
14+
# A small server is started on each worker that serves the logs on its
15+
# 8793 port for the Webserver: we don't use the token as that is an
16+
# internal implementation, but check that the endpoint is reachable,
17+
# indicated by a 403.
18+
# Rolegroup custom-log-config
19+
CURL_RESPONSE_CUSTOM=$(
20+
kubectl -n $NAMESPACE exec airflow-webserver-custom-log-config-0 -- sh -c 'CODE=$(curl -s -o /dev/null -w "%{http_code}" http://airflow-worker-custom-log-config-headless:8793 2>/dev/null || true);echo "$CODE"'
21+
)
22+
23+
# Log-Endpoint Test Assertions:
24+
echo "The HTTP Code is $CURL_RESPONSE_CUSTOM (an internal JWT token is needed for full access)"
25+
26+
# Rolegroup automatic-log-config
27+
CURL_RESPONSE_AUTO=$(
28+
kubectl -n $NAMESPACE exec airflow-webserver-automatic-log-config-0 -- sh -c 'CODE=$(curl -s -o /dev/null -w "%{http_code}" http://airflow-worker-automatic-log-config-headless:8793 2>/dev/null || true);echo "$CODE"'
29+
)
30+
echo "The HTTP Code is $CURL_RESPONSE_AUTO (an internal JWT token is needed for full access)"
31+
[ "$CURL_RESPONSE_CUSTOM" -eq 403 ] && [ "$CURL_RESPONSE_AUTO" -eq 403 ]
32+
{% endif %}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
metadata:
5+
name: test-log-endpoint
6+
timeout: 240
7+
commands:
8+
{% if test_scenario['values']['executor'] == 'celery' %}
9+
- script: |
10+
set -eu
11+
12+
# Log-Endpoint Test:
13+
# This is executed from the Webserver as JWT keys must be present.
14+
# A small server is started on each worker that serves the logs on its
15+
# 8793 port for the Webserver: we don't use the token as that is an
16+
# internal implementation, but check that the endpoint is reachable,
17+
# indicated by a 403.
18+
CURL_RESPONSE=$(
19+
kubectl -n $NAMESPACE exec airflow-webserver-default-0 -- sh -c 'CODE=$(curl -s -o /dev/null -w "%{http_code}" http://airflow-worker-default-headless:8793 2>/dev/null || true);echo "$CODE"'
20+
)
21+
22+
# Log-Endpoint Test Assertion:
23+
echo "The HTTP Code is $CURL_RESPONSE (an internal JWT token is needed for full access)"
24+
[ "$CURL_RESPONSE" -eq 403 ]
25+
{% endif %}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
metadata:
5+
name: test-log-endpoint
6+
timeout: 240
7+
commands:
8+
{% if test_scenario['values']['executor'] == 'celery' %}
9+
- script: |
10+
set -eu
11+
12+
# Log-Endpoint Test:
13+
# This is executed from the Webserver as JWT keys must be present.
14+
# A small server is started on each worker that serves the logs on its
15+
# 8793 port for the Webserver: we don't use the token as that is an
16+
# internal implementation, but check that the endpoint is reachable,
17+
# indicated by a 403.
18+
CURL_RESPONSE=$(
19+
kubectl -n $NAMESPACE exec airflow-webserver-default-0 -- sh -c 'CODE=$(curl -s -o /dev/null -w "%{http_code}" http://airflow-worker-default-headless:8793 2>/dev/null || true);echo "$CODE"'
20+
)
21+
22+
# Log-Endpoint Test Assertion:
23+
echo "The HTTP Code is $CURL_RESPONSE (an internal JWT token is needed for full access)"
24+
[ "$CURL_RESPONSE" -eq 403 ]
25+
{% endif %}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
metadata:
5+
name: test-log-endpoint
6+
timeout: 240
7+
commands:
8+
{% if test_scenario['values']['executor'] == 'celery' %}
9+
- script: |
10+
set -eu
11+
12+
# Log-Endpoint Test:
13+
# This is executed from the Webserver as JWT keys must be present.
14+
# A small server is started on each worker that serves the logs on its
15+
# 8793 port for the Webserver: we don't use the token as that is an
16+
# internal implementation, but check that the endpoint is reachable,
17+
# indicated by a 403.
18+
CURL_RESPONSE=$(
19+
kubectl -n $NAMESPACE exec airflow-webserver-default-0 -- sh -c 'CODE=$(curl -s -o /dev/null -w "%{http_code}" http://airflow-worker-default-headless:8793 2>/dev/null || true);echo "$CODE"'
20+
)
21+
22+
# Log-Endpoint Test Assertion:
23+
echo "The HTTP Code is $CURL_RESPONSE (an internal JWT token is needed for full access)"
24+
[ "$CURL_RESPONSE" -eq 403 ]
25+
{% endif %}

0 commit comments

Comments
 (0)