Skip to content

fix: Add test for log-server endpoint #657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/templates/kuttl/external-access/50-assert.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
metadata:
name: test-log-endpoint
timeout: 240
commands:
{% if test_scenario['values']['executor'] == 'celery' %}
- script: |
set -eu

# Log-Endpoint Test:
# This is executed from the Webserver as JWT keys must be present.
# A small server is started on each worker that serves the logs on its
# 8793 port for the Webserver: we don't use the token as that is an
# internal implementation, but check that the end-point is reachable,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: You know English way better than me. However, in all the k8s docs I have only seen endpoint so far, do you have any knowledge on this? :)

Suggested change
# internal implementation, but check that the end-point is reachable,
# internal implementation, but check that the endpoint is reachable,

# indicated by a 403.
CURL_RESPONSE=$(
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"'
)

# Log-Endpoint Test Assertion:
echo "The HTTP Code should be 403 to indicate the log server is reachable (the internal JWT token is needed for full access): $CURL_RESPONSE" | grep 403
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit I find the actual assertion a bit confusing.
I think a bash if ["$CURL_RESPONSE" -eq 403] (pseudo code) would be more readable.
Especially as the grep 403 always is true, as the echo result always contains a 403 in "The HTTP Code should be 403"?

{% endif %}
24 changes: 24 additions & 0 deletions tests/templates/kuttl/ldap/95-assert.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
metadata:
name: test-log-endpoint
timeout: 240
commands:
{% if test_scenario['values']['executor'] == 'celery' %}
- script: |
set -eu

# Log-Endpoint Test:
# This is executed from the Webserver as JWT keys must be present.
# A small server is started on each worker that serves the logs on its
# 8793 port for the Webserver: we don't use the token as that is an
# internal implementation, but check that the end-point is reachable,
# indicated by a 403.
CURL_RESPONSE=$(
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"'
)

# Log-Endpoint Test Assertion:
echo "The HTTP Code should be 403 to indicate the log server is reachable (the internal JWT token is needed for full access): $CURL_RESPONSE" | grep 403
{% endif %}
31 changes: 31 additions & 0 deletions tests/templates/kuttl/logging/70-assert.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
metadata:
name: test-log-endpoint
timeout: 240
commands:
{% if test_scenario['values']['executor'] == 'celery' %}
- script: |
set -eu

# Log-Endpoint Test:
# This is executed from the Webserver as JWT keys must be present.
# A small server is started on each worker that serves the logs on its
# 8793 port for the Webserver: we don't use the token as that is an
# internal implementation, but check that the end-point is reachable,
# indicated by a 403.
# Rolegroup custom-log-config
CURL_RESPONSE=$(
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"'
)

# Log-Endpoint Test Assertions:
echo "The HTTP Code should be 403 to indicate the log server is reachable (the internal JWT token is needed for full access): $CURL_RESPONSE" | grep 403

# Rolegroup automatic-log-config
CURL_RESPONSE=$(
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"'
)
echo "The HTTP Code should be 403 to indicate the log server is reachable (the internal JWT token is needed for full access): $CURL_RESPONSE" | grep 403
{% endif %}
24 changes: 24 additions & 0 deletions tests/templates/kuttl/mount-dags-configmap/70-assert.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
metadata:
name: test-log-endpoint
timeout: 240
commands:
{% if test_scenario['values']['executor'] == 'celery' %}
- script: |
set -eu

# Log-Endpoint Test:
# This is executed from the Webserver as JWT keys must be present.
# A small server is started on each worker that serves the logs on its
# 8793 port for the Webserver: we don't use the token as that is an
# internal implementation, but check that the end-point is reachable,
# indicated by a 403.
CURL_RESPONSE=$(
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"'
)

# Log-Endpoint Test Assertion:
echo "The HTTP Code should be 403 to indicate the log server is reachable (the internal JWT token is needed for full access): $CURL_RESPONSE" | grep 403
{% endif %}
24 changes: 24 additions & 0 deletions tests/templates/kuttl/mount-dags-gitsync/70-assert.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
metadata:
name: test-log-endpoint
timeout: 240
commands:
{% if test_scenario['values']['executor'] == 'celery' %}
- script: |
set -eu

# Log-Endpoint Test:
# This is executed from the Webserver as JWT keys must be present.
# A small server is started on each worker that serves the logs on its
# 8793 port for the Webserver: we don't use the token as that is an
# internal implementation, but check that the end-point is reachable,
# indicated by a 403.
CURL_RESPONSE=$(
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"'
)

# Log-Endpoint Test Assertion:
echo "The HTTP Code should be 403 to indicate the log server is reachable (the internal JWT token is needed for full access): $CURL_RESPONSE" | grep 403
{% endif %}
24 changes: 24 additions & 0 deletions tests/templates/kuttl/smoke/80-assert.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
metadata:
name: test-log-endpoint
timeout: 240
commands:
{% if test_scenario['values']['executor'] == 'celery' %}
- script: |
set -eu

# Log-Endpoint Test:
# This is executed from the Webserver as JWT keys must be present.
# A small server is started on each worker that serves the logs on its
# 8793 port for the Webserver: we don't use the token as that is an
# internal implementation, but check that the end-point is reachable,
# indicated by a 403.
CURL_RESPONSE=$(
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"'
)

# Log-Endpoint Test Assertion:
echo "The HTTP Code should be 403 to indicate the log server is reachable (the internal JWT token is needed for full access): $CURL_RESPONSE" | grep 403
{% endif %}