Skip to content

Commit 41d6038

Browse files
committed
foo
1 parent daffc6a commit 41d6038

File tree

10 files changed

+500
-158
lines changed

10 files changed

+500
-158
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,10 @@ jobs:
7979

8080
- name: Wait for K3s readiness
8181
run: |
82-
echo "=== Waiting for K3s cluster to be ready ==="
83-
84-
# The action already sets up kubectl context, just verify it works
85-
kubectl cluster-info
86-
kubectl get nodes
87-
88-
# Wait for core components
89-
kubectl wait --for=condition=Ready pod -l k8s-app=kube-dns -n kube-system --timeout=300s
90-
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=traefik -n kube-system --timeout=300s
91-
92-
# Verify Traefik CRDs
93-
timeout=300; counter=0
94-
for crd in "middlewares.traefik.io" "ingressroutes.traefik.io"; do
95-
while [ $counter -lt $timeout ] && ! kubectl get crd "$crd" &>/dev/null; do
96-
sleep 3; counter=$((counter + 3))
97-
done
98-
[ $counter -ge $timeout ] && { echo "❌ Timeout waiting for $crd"; exit 1; }
99-
done
100-
101-
echo "✅ K3s cluster ready"
82+
# Source validation library and use K3s readiness check
83+
source ./scripts/lib/common.sh
84+
source ./scripts/lib/validation.sh
85+
validate_k3s_readiness
10286
10387
- name: Deploy eoAPI
10488
id: deploy
@@ -127,18 +111,12 @@ jobs:
127111
exit 1
128112
fi
129113
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}"
114+
# Run post-deployment validation
115+
echo "=== Running post-deployment validation ==="
116+
./scripts/deploy.sh validate \
117+
--namespace "${RELEASE_NAME}" \
118+
--release "${RELEASE_NAME}" \
119+
--verbose
142120
143121
- name: Debug session after deployment
144122
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
@@ -147,73 +125,20 @@ jobs:
147125
limit-access-to-keys: ${{ secrets.UPTERM_SSH_KEY }}
148126
wait-timeout-minutes: 30
149127

150-
- name: Validate deployment
128+
- name: Run deployment tests
151129
run: |
152-
echo "=== Post-deployment validation ==="
130+
echo "=== Running deployment tests ==="
153131
export NAMESPACE="${RELEASE_NAME}"
154132
./scripts/test.sh check-deployment
155133
156134
- name: Wait for services to be ready
157135
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
136+
# Use deploy.sh validate command to check service readiness and API connectivity
137+
export INGRESS_HOST="eoapi.local"
138+
./scripts/deploy.sh validate \
139+
--namespace "${RELEASE_NAME}" \
140+
--release "${RELEASE_NAME}" \
141+
--debug
217142
218143
- name: Run integration tests
219144
run: |

CHANGELOG.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
### Fixed
11-
- Fixed integration tests failing with pagination URLs by:
12-
- Using Traefik ingress in CI instead of port-forwarding to properly test ingress configuration
13-
- Adding `ROOT_PATH` environment variable to services (stac, raster, vector, multidim) when ingress is enabled
14-
- This ensures services generate correct URLs with path prefixes (e.g., `/raster/searches/list`) in pagination links
15-
- Added test script `scripts/tests/test-ingress-paths.sh` to validate ROOT_PATH behavior with ingress
10+
### Added
11+
- Comprehensive `validate_eoapi_deployment` function to existing `validation.sh` library
12+
- `validate` command to `deploy.sh` for standalone deployment validation
13+
- `--validate` flag to `deploy.sh` to run validation automatically after deployment
14+
- `make validate` target for running deployment validation from Makefile
15+
- `log_success` function to `common.sh` for consistent success messaging
1616

1717
### Changed
18-
- CI workflow now deploys with Traefik ingress enabled (`--set ingress.className=traefik`) for more realistic testing
19-
- Services now automatically receive their path prefix via `ROOT_PATH` environment variable when behind an ingress
20-
- Refactored test and deployment scripts
18+
- Refactored test and deployment scripts to use centralized validation functions
19+
- Enhanced `debug-deployment.sh` with namespace verification and improved resource listing
20+
- Updated CI workflow to use `deploy.sh validate` command instead of inline checks
21+
- Consolidated validation logic into existing library structure to eliminate code duplication
22+
- Renamed `validate_eoapi_deployment` in `common.sh` to `check_eoapi_services` to avoid naming conflicts
2123

2224
## [0.7.13] - 2025-11-04
2325

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ help: ## Show this help message
2424
@echo " cleanup Clean up eoAPI deployment"
2525
@echo " status Show deployment status"
2626
@echo " info Show deployment info and URLs"
27+
@echo " validate Validate deployment health and API connectivity"
2728
@echo ""
2829
@echo "TESTING:"
2930
@echo " test Run all tests (lint + helm + integration)"
@@ -73,6 +74,9 @@ status: ## Show deployment status
7374
info: ## Show deployment information and URLs
7475
@$(DEPLOY_SCRIPT) info --namespace $(NAMESPACE) --release $(RELEASE_NAME)
7576

77+
validate: ## Validate deployment health and API connectivity
78+
@$(DEPLOY_SCRIPT) validate --namespace $(NAMESPACE) --release $(RELEASE_NAME) --verbose
79+
7680
# Testing commands
7781
test: lint test-helm test-integration ## Run all tests
7882

scripts/debug-deployment.sh

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,24 @@ echo "Using NAMESPACE: $NAMESPACE"
1313
echo ""
1414

1515
# eoAPI specific debugging
16-
echo "--- eoAPI Namespace Status ---"
17-
echo "Namespace info:"
18-
kubectl get namespace "$NAMESPACE" -o wide 2>/dev/null || echo "Namespace $NAMESPACE not found"
16+
echo "=== Verifying namespace creation ==="
17+
if ! kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then
18+
echo "❌ Namespace $NAMESPACE was not created"
19+
echo "Available namespaces:"
20+
kubectl get namespaces
21+
else
22+
echo "✅ Namespace $NAMESPACE exists"
23+
echo ""
24+
echo "--- eoAPI Namespace Status ---"
25+
echo "Namespace info:"
26+
kubectl get namespace "$NAMESPACE" -o wide
27+
fi
28+
echo ""
29+
30+
echo "=== Resources in namespace $NAMESPACE ==="
31+
kubectl get all -n "$NAMESPACE" 2>/dev/null || echo "No resources found in namespace $NAMESPACE"
1932
echo ""
20-
echo "All resources in eoAPI namespace:"
33+
echo "Detailed resource list:"
2134
kubectl get all -n "$NAMESPACE" -o wide 2>/dev/null || echo "No resources found in namespace $NAMESPACE"
2235
echo ""
2336
echo "Jobs in eoAPI namespace:"
@@ -74,10 +87,17 @@ echo ""
7487

7588
# Basic cluster status
7689
echo "--- Cluster Status ---"
77-
kubectl get pods -o wide
78-
kubectl get jobs -o wide
79-
kubectl get services -o wide
80-
kubectl get events --sort-by='.lastTimestamp' | tail -20 || true
90+
echo "Pods across all namespaces:"
91+
kubectl get pods --all-namespaces -o wide
92+
echo ""
93+
echo "Jobs across all namespaces:"
94+
kubectl get jobs --all-namespaces -o wide
95+
echo ""
96+
echo "Services across all namespaces:"
97+
kubectl get services --all-namespaces -o wide
98+
echo ""
99+
echo "Recent cluster events:"
100+
kubectl get events --all-namespaces --sort-by='.lastTimestamp' | tail -20 || true
81101

82102
# PostgreSQL status
83103
echo "--- PostgreSQL Status ---"
@@ -149,15 +169,23 @@ kubectl logs -l serving.knative.dev/service=eoapi-cloudevents-sink -n "$NAMESPAC
149169

150170
# Recent events in eoAPI namespace
151171
echo "--- Recent Events in eoAPI Namespace ---"
152-
kubectl get events -n "$NAMESPACE" --sort-by='.lastTimestamp' | tail -20 2>/dev/null || echo "No events found in namespace $NAMESPACE"
172+
if kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then
173+
kubectl get events -n "$NAMESPACE" --sort-by='.lastTimestamp' | tail -20 2>/dev/null || echo "No events found in namespace $NAMESPACE"
174+
else
175+
echo "Namespace $NAMESPACE does not exist - skipping namespace-specific events"
176+
fi
153177

154178
# Resource usage
155179
echo "--- Resource Usage ---"
156180
echo "Node status:"
157181
kubectl top nodes 2>/dev/null || echo "Metrics not available"
158182
echo ""
159-
echo "Pod resource usage in $NAMESPACE:"
160-
kubectl top pods -n "$NAMESPACE" 2>/dev/null || echo "Pod metrics not available"
183+
if kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then
184+
echo "Pod resource usage in $NAMESPACE:"
185+
kubectl top pods -n "$NAMESPACE" 2>/dev/null || echo "Pod metrics not available"
186+
else
187+
echo "Namespace $NAMESPACE does not exist - skipping pod metrics"
188+
fi
161189
# System controller logs if issues detected
162190
if ! kubectl get pods -n knative-serving &>/dev/null; then
163191
echo "--- Knative Controller Logs ---"

scripts/deploy.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ COMMANDS:
2525
cleanup Clean up eoAPI deployment
2626
status Show deployment status
2727
info Show deployment information and URLs
28+
validate Validate deployment health and connectivity
2829
2930
$(show_common_options)
3031
@@ -103,6 +104,9 @@ main() {
103104
info)
104105
cmd_info
105106
;;
107+
validate)
108+
cmd_validate
109+
;;
106110
--help|-h|help)
107111
show_help
108112
exit 0
@@ -128,6 +132,26 @@ cmd_deploy() {
128132
if deploy_eoapi; then
129133
log_info "🎉 eoAPI deployment completed successfully!"
130134
get_deployment_info
135+
136+
# Run validation if requested
137+
if [ "${VALIDATE:-false}" = "true" ]; then
138+
log_info ""
139+
log_info "Running deployment validation..."
140+
141+
# Set verbosity
142+
local verbose="false"
143+
if [ "${DEBUG_MODE:-false}" = "true" ] || [ "${VERBOSE:-false}" = "true" ]; then
144+
verbose="true"
145+
fi
146+
147+
# Run comprehensive validation
148+
if validate_eoapi_deployment "$NAMESPACE" "$RELEASE_NAME" "${INGRESS_HOST:-eoapi.local}" "$verbose"; then
149+
log_success "✅ Deployment validation passed!"
150+
else
151+
log_warn "⚠️ Deployment validation failed - check logs above"
152+
exit 1
153+
fi
154+
fi
131155
else
132156
log_error "❌ eoAPI deployment failed"
133157
exit 1
@@ -258,6 +282,40 @@ cmd_info() {
258282
get_deployment_info
259283
}
260284

285+
cmd_validate() {
286+
log_info "Running eoAPI deployment validation..."
287+
288+
if ! validate_kubectl; then
289+
exit 1
290+
fi
291+
292+
if ! validate_cluster_connection; then
293+
exit 1
294+
fi
295+
296+
# Auto-detect namespace and release if not specified
297+
if [ "$NAMESPACE" = "eoapi" ]; then
298+
NAMESPACE=$(detect_namespace)
299+
fi
300+
301+
if [ "$RELEASE_NAME" = "eoapi" ]; then
302+
RELEASE_NAME=$(detect_release_name "$NAMESPACE")
303+
fi
304+
305+
# Set verbosity based on debug/verbose flags
306+
local verbose="false"
307+
if [ "${DEBUG_MODE:-false}" = "true" ] || [ "${VERBOSE:-false}" = "true" ]; then
308+
verbose="true"
309+
fi
310+
311+
# Run comprehensive validation
312+
if validate_eoapi_deployment "$NAMESPACE" "$RELEASE_NAME" "${INGRESS_HOST:-eoapi.local}" "$verbose"; then
313+
exit 0
314+
else
315+
exit 1
316+
fi
317+
}
318+
261319
# Error handling
262320
trap 'log_error "Script failed at line $LINENO"' ERR
263321

scripts/lib/README.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)