Skip to content

Commit daffc6a

Browse files
committed
Refactored scripts.
1 parent 16631e1 commit daffc6a

File tree

17 files changed

+3147
-1210
lines changed

17 files changed

+3147
-1210
lines changed

.github/workflows/ci.yml

Lines changed: 134 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ on:
55
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
8+
workflow_dispatch:
9+
inputs:
10+
debug_enabled:
11+
type: boolean
12+
description: 'Run with upterm debugging enabled (requires SSH key in secrets)'
13+
required: false
14+
default: false
815

916
env:
1017
HELM_VERSION: v3.15.2
@@ -27,7 +34,7 @@ jobs:
2734
version: ${{ env.HELM_VERSION }}
2835

2936
- name: Setup Helm dependencies
30-
run: ./scripts/deploy.sh setup
37+
run: ./scripts/deploy.sh setup --deps-only
3138

3239
- name: Install ajv-cli
3340
run: npm install -g ajv-cli ajv-formats
@@ -39,7 +46,7 @@ jobs:
3946
run: make validate-schema
4047

4148
- name: Run Helm unit tests
42-
run: make tests
49+
run: make test-helm
4350

4451
integration-tests:
4552
name: Integration tests
@@ -49,6 +56,16 @@ jobs:
4956
steps:
5057
- uses: actions/checkout@v5
5158

59+
- name: Set up Python
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: '3.12'
63+
64+
- name: Install Python dependencies
65+
run: |
66+
python -m pip install --upgrade pip
67+
pip install httpx psycopg2-binary pytest
68+
5269
- name: Start K3s cluster
5370
uses: jupyterhub/action-k3s-helm@v4
5471
with:
@@ -86,24 +103,134 @@ jobs:
86103
- name: Deploy eoAPI
87104
id: deploy
88105
run: |
106+
set -e # Exit on any error
107+
89108
echo "=== eoAPI Deployment ==="
109+
echo "RELEASE_NAME: ${RELEASE_NAME}"
110+
echo "PGO_VERSION: ${{ env.PGO_VERSION }}"
111+
90112
export RELEASE_NAME="${RELEASE_NAME}"
91113
export PGO_VERSION="${{ env.PGO_VERSION }}"
92-
export CI_MODE=true
93114
94-
# Deploy using consolidated script with CI mode
95-
./scripts/deploy.sh --ci
115+
# Deploy using consolidated script with k3s values for testing
116+
echo "Running deploy script..."
117+
if ! ./scripts/deploy.sh deploy --namespace "${RELEASE_NAME}" --release "${RELEASE_NAME}" \
118+
-f charts/eoapi/local-base-values.yaml \
119+
-f charts/eoapi/local-k3s-values.yaml \
120+
--set ingress.host=eoapi.local \
121+
--set eoapi-notifier.config.sources[0].config.connection.existingSecret.name="${RELEASE_NAME}-pguser-eoapi" \
122+
--debug; then
123+
124+
echo "❌ Deploy script failed"
125+
kubectl get namespaces
126+
kubectl get pods -A
127+
exit 1
128+
fi
129+
130+
# Verify namespace was created
131+
echo "=== Verifying namespace creation ==="
132+
if ! kubectl get namespace "${RELEASE_NAME}" >/dev/null 2>&1; then
133+
echo "❌ Namespace ${RELEASE_NAME} was not created"
134+
kubectl get namespaces
135+
exit 1
136+
fi
137+
echo "✅ Namespace ${RELEASE_NAME} exists"
138+
139+
# List resources in namespace
140+
echo "=== Resources in namespace ${RELEASE_NAME} ==="
141+
kubectl get all -n "${RELEASE_NAME}"
142+
143+
- name: Debug session after deployment
144+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
145+
uses: lhotari/action-upterm@v1
146+
with:
147+
limit-access-to-keys: ${{ secrets.UPTERM_SSH_KEY }}
148+
wait-timeout-minutes: 30
96149

97150
- name: Validate deployment
98151
run: |
99152
echo "=== Post-deployment validation ==="
153+
export NAMESPACE="${RELEASE_NAME}"
100154
./scripts/test.sh check-deployment
101155
156+
- name: Wait for services to be ready
157+
run: |
158+
set -e # Exit on any error
159+
160+
echo "=== Waiting for Services to be Ready ==="
161+
echo "RELEASE_NAME: ${RELEASE_NAME}"
162+
163+
# Verify namespace exists first
164+
if ! kubectl get namespace "${RELEASE_NAME}" >/dev/null 2>&1; then
165+
echo "❌ Namespace ${RELEASE_NAME} does not exist!"
166+
kubectl get namespaces
167+
exit 1
168+
fi
169+
170+
echo "Waiting for deployments in namespace ${RELEASE_NAME}..."
171+
kubectl wait --for=condition=available deployment/"${RELEASE_NAME}"-stac -n "${RELEASE_NAME}" --timeout=300s
172+
kubectl wait --for=condition=available deployment/"${RELEASE_NAME}"-raster -n "${RELEASE_NAME}" --timeout=300s
173+
kubectl wait --for=condition=available deployment/"${RELEASE_NAME}"-vector -n "${RELEASE_NAME}" --timeout=300s
174+
175+
# Get the K3s node IP and set up host entry
176+
NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
177+
echo "Node IP: $NODE_IP"
178+
179+
# Add eoapi.local to /etc/hosts for ingress access
180+
echo "$NODE_IP eoapi.local" | sudo tee -a /etc/hosts
181+
182+
# Wait for ingress to be ready
183+
echo "=== Waiting for Ingress to be Ready ==="
184+
kubectl get ingress -n "${RELEASE_NAME}"
185+
186+
# Wait for Traefik to pick up the ingress rules
187+
sleep 10
188+
189+
# Test connectivity through ingress using eoapi.local
190+
echo "=== Testing API connectivity through ingress ==="
191+
for i in {1..30}; do
192+
if curl -s "http://eoapi.local/stac/_mgmt/ping" 2>/dev/null; then
193+
echo "✅ STAC API accessible through ingress"
194+
break
195+
fi
196+
echo "Waiting for STAC API... (attempt $i/30)"
197+
sleep 3
198+
done
199+
200+
for i in {1..30}; do
201+
if curl -s "http://eoapi.local/raster/healthz" 2>/dev/null; then
202+
echo "✅ Raster API accessible through ingress"
203+
break
204+
fi
205+
echo "Waiting for Raster API... (attempt $i/30)"
206+
sleep 3
207+
done
208+
209+
for i in {1..30}; do
210+
if curl -s "http://eoapi.local/vector/healthz" 2>/dev/null; then
211+
echo "✅ Vector API accessible through ingress"
212+
break
213+
fi
214+
echo "Waiting for Vector API... (attempt $i/30)"
215+
sleep 3
216+
done
217+
102218
- name: Run integration tests
103219
run: |
104220
export RELEASE_NAME="$RELEASE_NAME"
221+
export NAMESPACE="$RELEASE_NAME"
222+
export STAC_ENDPOINT="http://eoapi.local/stac"
223+
export RASTER_ENDPOINT="http://eoapi.local/raster"
224+
export VECTOR_ENDPOINT="http://eoapi.local/vector"
105225
./scripts/test.sh integration --debug
106226
227+
- name: Debug session on test failure
228+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled && failure() }}
229+
uses: lhotari/action-upterm@v1
230+
with:
231+
limit-access-to-keys: ${{ secrets.UPTERM_SSH_KEY }}
232+
wait-timeout-minutes: 30
233+
107234
- name: Debug failed deployment
108235
if: failure()
109236
run: |
@@ -112,8 +239,8 @@ jobs:
112239
- name: Cleanup
113240
if: always()
114241
run: |
115-
helm uninstall "$RELEASE_NAME" -n eoapi || true
116-
kubectl delete namespace eoapi || true
242+
helm uninstall "$RELEASE_NAME" -n "$RELEASE_NAME" || true
243+
kubectl delete namespace "$RELEASE_NAME" || true
117244
validate-docs:
118245
name: Validate documentation
119246
runs-on: ubuntu-latest

.github/workflows/tests/test_notifications.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Test notification system deployment and functionality."""
22

33
import json
4+
import os
45
import subprocess
56
import time
67

@@ -9,6 +10,9 @@
910

1011
def test_eoapi_notifier_deployment():
1112
"""Test that eoapi-notifier deployment is running."""
13+
# Get namespace from environment variable
14+
namespace = os.environ.get("NAMESPACE", "eoapi")
15+
1216
# Check if eoapi-notifier deployment exists and is ready
1317
result = subprocess.run(
1418
[
@@ -18,7 +22,7 @@ def test_eoapi_notifier_deployment():
1822
"-l",
1923
"app.kubernetes.io/name=eoapi-notifier",
2024
"-n",
21-
"eoapi",
25+
namespace,
2226
"--no-headers",
2327
"-o",
2428
"custom-columns=READY:.status.readyReplicas",
@@ -40,6 +44,9 @@ def test_eoapi_notifier_deployment():
4044

4145
def test_cloudevents_sink_exists():
4246
"""Test that Knative CloudEvents sink service exists and is accessible."""
47+
# Get namespace from environment variable
48+
namespace = os.environ.get("NAMESPACE", "eoapi")
49+
4350
# Check if Knative service exists
4451
result = subprocess.run(
4552
[
@@ -48,6 +55,8 @@ def test_cloudevents_sink_exists():
4855
"ksvc",
4956
"-l",
5057
"app.kubernetes.io/component=cloudevents-sink",
58+
"-n",
59+
namespace,
5160
"--no-headers",
5261
],
5362
capture_output=True,
@@ -66,6 +75,9 @@ def test_cloudevents_sink_exists():
6675

6776
def test_notification_configuration():
6877
"""Test that eoapi-notifier is configured correctly."""
78+
# Get namespace from environment variable
79+
namespace = os.environ.get("NAMESPACE", "eoapi")
80+
6981
# Get the configmap for eoapi-notifier
7082
result = subprocess.run(
7183
[
@@ -74,6 +86,8 @@ def test_notification_configuration():
7486
"configmap",
7587
"-l",
7688
"app.kubernetes.io/name=eoapi-notifier",
89+
"-n",
90+
namespace,
7791
"-o",
7892
r"jsonpath={.items[0].data.config\.yaml}",
7993
],
@@ -96,6 +110,9 @@ def test_notification_configuration():
96110

97111
def test_cloudevents_sink_logs_show_startup():
98112
"""Test that Knative CloudEvents sink started successfully."""
113+
# Get namespace from environment variable
114+
namespace = os.environ.get("NAMESPACE", "eoapi")
115+
99116
# Get Knative CloudEvents sink pod logs
100117
result = subprocess.run(
101118
[
@@ -104,7 +121,7 @@ def test_cloudevents_sink_logs_show_startup():
104121
"-l",
105122
"serving.knative.dev/service",
106123
"-n",
107-
"eoapi",
124+
namespace,
108125
"--tail=20",
109126
],
110127
capture_output=True,
@@ -115,7 +132,9 @@ def test_cloudevents_sink_logs_show_startup():
115132
pytest.skip("Cannot get Knative CloudEvents sink logs")
116133

117134
logs = result.stdout
118-
assert "listening on port" in logs, "Knative CloudEvents sink should have started successfully"
135+
assert "listening on port" in logs, (
136+
"Knative CloudEvents sink should have started successfully"
137+
)
119138

120139

121140
def test_eoapi_notifier_logs_show_connection():

0 commit comments

Comments
 (0)