2323# Show help message
2424show_help () {
2525 cat << EOF
26- eoAPI Test Suite - Helm and Integration Testing
26+ eoAPI Test Suite - Combined Helm and Integration Testing
2727
2828USAGE: $( basename " $0 " ) [COMMAND] [OPTIONS]
2929
3030COMMANDS:
31- helm Run Helm tests (lint, unit tests, template validation)
31+ helm Run Helm tests (lint, template validation)
3232 integration Run integration tests (requires deployed eoAPI)
3333 all Run both Helm and integration tests [default]
34- check-deps Check and install dependencies only
35- check-deployment Check eoAPI deployment status only
36-
34+ check-deps Check dependencies only
35+ check-deployment Debug deployment state
3736OPTIONS:
38- --debug Enable debug mode with enhanced logging and diagnostics
39- --help, -h Show this help message
40-
41- DESCRIPTION:
42- This script provides comprehensive testing for eoAPI:
43-
44- Helm Tests:
45- - Chart linting with strict validation
46- - Helm unit tests (if test files exist)
47- - Template validation and rendering
48- - Kubernetes manifest validation (if kubeval available)
49-
50- Integration Tests:
51- - Deployment verification
52- - Service readiness checks
53-
54- Observability Tests:
55- - Monitoring stack deployment verification (Prometheus, Grafana, metrics-server)
56- - HPA (Horizontal Pod Autoscaler) configuration validation
57- - Metrics collection and custom metrics API testing
58- - Autoscaling behavior validation
59- - API endpoint testing
60- - Comprehensive failure debugging
61-
62- REQUIREMENTS:
63- Helm Tests: helm, helm unittest plugin
64- Integration Tests: kubectl, python/pytest, deployed eoAPI instance
65- Observability Tests: kubectl, python/pytest, deployed eoAPI with monitoring enabled
66-
37+ --debug Enable debug mode
38+ --help, -h Show this help
6739
6840ENVIRONMENT VARIABLES:
69- RELEASE_NAME Override release name detection
70- STAC_ENDPOINT Override STAC API endpoint
71- RASTER_ENDPOINT Override Raster API endpoint
72- VECTOR_ENDPOINT Override Vector API endpoint
73-
74- CI Auto-enables debug mode if set
75-
76- EXAMPLES:
77- $( basename " $0 " ) # Run all tests
78- $( basename " $0 " ) helm # Run only Helm tests
79- $( basename " $0 " ) integration # Run only integration tests
80- $( basename " $0 " ) observability # Run only observability tests
81- $( basename " $0 " ) check-deps # Check dependencies only
82- $( basename " $0 " ) check-deployment # Check deployment status only
83- $( basename " $0 " ) all --debug # Run all tests with debug output
84- $( basename " $0 " ) integration --debug # Run integration tests with enhanced logging
85- $( basename " $0 " ) observability --debug # Run observability tests with debug output
86- $( basename " $0 " ) --help # Show this help
41+ RELEASE_NAME Helm release name (auto-generated in CI)
42+ NAMESPACE Target namespace (default: eoapi)
8743
8844EOF
8945}
9046
91- # Parse command line arguments
9247parse_args () {
9348 while [[ $# -gt 0 ]]; do
9449 case $1 in
95- helm|integration|observability| all|check-deps|check-deployment)
50+ helm|integration|all|check-deps|check-deployment)
9651 COMMAND=" $1 " ; shift ;;
9752 --debug)
9853 DEBUG_MODE=true; shift ;;
@@ -105,29 +60,19 @@ parse_args() {
10560 done
10661}
10762
108- # Check dependencies for helm tests
10963check_helm_dependencies () {
11064 preflight_test " helm" || exit 1
11165
112- # Install unittest plugin if needed
11366 if ! helm plugin list | grep -q unittest; then
11467 log_info " Installing helm unittest plugin..."
11568 helm plugin install https://github.com/helm-unittest/helm-unittest
11669 fi
11770}
11871
119- # Check dependencies for integration tests
12072check_integration_dependencies () {
12173 preflight_test " integration" || exit 1
12274}
12375
124- # Check dependencies for observability tests
125- check_observability_dependencies () {
126- preflight_test " observability" || exit 1
127- }
128-
129-
130- # Install Python test dependencies
13176install_test_deps () {
13277 log_info " Installing Python test dependencies..."
13378
@@ -145,7 +90,6 @@ install_test_deps() {
14590 log_info " Test dependencies installed."
14691}
14792
148- # Detect deployment and set environment variables
14993detect_deployment () {
15094 if [ -z " ${NAMESPACE:- } " ]; then
15195 NAMESPACE=$( detect_namespace)
@@ -158,7 +102,6 @@ detect_deployment() {
158102 log_info " Using namespace: $NAMESPACE , release: $RELEASE_NAME "
159103}
160104
161- # Check if eoAPI deployment is healthy
162105check_eoapi_deployment () {
163106 validate_eoapi_deployment " $NAMESPACE " " $RELEASE_NAME " || {
164107 log_error " eoAPI deployment validation failed"
@@ -167,7 +110,6 @@ check_eoapi_deployment() {
167110 }
168111}
169112
170- # Wait for all eoAPI services to be ready
171113wait_for_services () {
172114 log_info " Waiting for eoAPI services to be ready..."
173115
@@ -183,9 +125,7 @@ wait_for_services() {
183125 log_info " ✅ All eoAPI services are ready"
184126}
185127
186- # Setup test environment variables
187128setup_test_environment () {
188- # Auto-detect service endpoints
189129 local ingress_host
190130 ingress_host=$( kubectl get ingress -n " $NAMESPACE " -o jsonpath=' {.items[0].spec.rules[0].host}' 2> /dev/null || echo " localhost" )
191131
@@ -199,7 +139,6 @@ setup_test_environment() {
199139 log_info " Vector: $VECTOR_ENDPOINT "
200140}
201141
202- # Show debug information about the deployment
203142show_debug_info () {
204143 log_info " === Debug Information ==="
205144
@@ -338,6 +277,7 @@ run_integration_tests() {
338277 log_error " Observability tests not found - required for autoscaling validation"
339278 exit 1
340279 fi
280+
341281 # Wait for Knative services to be ready if they exist
342282 if kubectl get ksvc -n " $NAMESPACE " > /dev/null 2>&1 ; then
343283 if kubectl get ksvc eoapi-cloudevents-sink -n " $NAMESPACE " > /dev/null 2>&1 ; then
@@ -349,49 +289,22 @@ run_integration_tests() {
349289 fi
350290 fi
351291
352-
353-
354292 log_info " ✅ Integration tests completed"
355293}
356294
357- # Run observability checks (simplified helper)
358- run_observability_checks () {
359- log_info " Checking monitoring stack status..."
360-
361- # Check for monitoring components (required for autoscaling)
362- kubectl get pods -n " $NAMESPACE " | grep -E " (prometheus|grafana|metrics-server)" || {
363- log_error " No monitoring components found - required for autoscaling"
364- return 1
365- }
366-
367- # Check HPA resources
368- kubectl get hpa -n " $NAMESPACE " || {
369- log_error " No HPA resources found - autoscaling not configured"
370- return 1
371- }
372-
373- return 0
374- }
375-
376-
377- # Main function
378295main () {
379296 parse_args " $@ "
380297
381- # Default command
382298 if [ -z " $COMMAND " ]; then
383299 COMMAND=" all"
384300 fi
385301
386- log_info " eoAPI Test Suite - Command: $COMMAND | Debug: $DEBUG_MODE | Release: $RELEASE_NAME "
387-
388302 if [ " $DEBUG_MODE " = true ]; then
389- log_info " Starting eoAPI test suite (DEBUG MODE ) - Command: $COMMAND "
303+ log_info " eoAPI Test Suite (DEBUG) - Command: $COMMAND | Release: $RELEASE_NAME "
390304 else
391- log_info " Starting eoAPI test suite - Command: $COMMAND "
305+ log_info " eoAPI Test Suite - Command: $COMMAND | Release: $RELEASE_NAME "
392306 fi
393307
394- # Run tests based on command
395308 case $COMMAND in
396309 helm)
397310 check_helm_dependencies
@@ -431,19 +344,16 @@ main() {
431344 all)
432345 log_info " Running comprehensive test suite (Helm + Integration tests)"
433346
434- # Run Helm tests first
435347 log_info " === Phase 1: Helm Tests ==="
436348 check_helm_dependencies
437349 run_helm_tests
438350
439- # Run Integration tests
440351 log_info " === Phase 2: Integration Tests ==="
441352 check_integration_dependencies
442353 validate_cluster
443354 install_test_deps
444355 detect_deployment
445356
446- # Show enhanced debugging in debug mode
447357 if [ " $DEBUG_MODE " = true ]; then
448358 show_debug_info
449359 fi
@@ -462,20 +372,7 @@ main() {
462372 ;;
463373 esac
464374
465- # Clean up port forwarding if it was set up
466- if [ -f /tmp/eoapi-port-forward-pids ]; then
467- log_info " Cleaning up port forwarding..."
468- while read -r pid; do
469- kill " $pid " 2> /dev/null || true
470- done < /tmp/eoapi-port-forward-pids
471- rm -f /tmp/eoapi-port-forward-pids
472- fi
473-
474- if [ " $DEBUG_MODE " = true ]; then
475- log_info " eoAPI test suite complete (DEBUG MODE)!"
476- else
477- log_info " eoAPI test suite complete!"
478- fi
375+ log_info " ✅ Test suite complete"
479376}
480377
481378# Run main function
0 commit comments