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
34+ check-deps Check dependencies only
35+ check-deployment Debug deployment state
3636
3737OPTIONS:
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-
38+ --debug Enable debug mode
39+ --help, -h Show this help
6740
6841ENVIRONMENT 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
42+ RELEASE_NAME Helm release name (auto-generated in CI)
43+ NAMESPACE Target namespace (default: eoapi)
8744
8845EOF
8946}
9047
91- # Parse command line arguments
9248parse_args () {
9349 while [[ $# -gt 0 ]]; do
9450 case $1 in
95- helm|integration|observability| all|check-deps|check-deployment)
51+ helm|integration|all|check-deps|check-deployment)
9652 COMMAND=" $1 " ; shift ;;
9753 --debug)
9854 DEBUG_MODE=true; shift ;;
@@ -105,29 +61,19 @@ parse_args() {
10561 done
10662}
10763
108- # Check dependencies for helm tests
10964check_helm_dependencies () {
11065 preflight_test " helm" || exit 1
11166
112- # Install unittest plugin if needed
11367 if ! helm plugin list | grep -q unittest; then
11468 log_info " Installing helm unittest plugin..."
11569 helm plugin install https://github.com/helm-unittest/helm-unittest
11670 fi
11771}
11872
119- # Check dependencies for integration tests
12073check_integration_dependencies () {
12174 preflight_test " integration" || exit 1
12275}
12376
124- # Check dependencies for observability tests
125- check_observability_dependencies () {
126- preflight_test " observability" || exit 1
127- }
128-
129-
130- # Install Python test dependencies
13177install_test_deps () {
13278 log_info " Installing Python test dependencies..."
13379
@@ -145,7 +91,6 @@ install_test_deps() {
14591 log_info " Test dependencies installed."
14692}
14793
148- # Detect deployment and set environment variables
14994detect_deployment () {
15095 if [ -z " ${NAMESPACE:- } " ]; then
15196 NAMESPACE=$( detect_namespace)
@@ -158,7 +103,6 @@ detect_deployment() {
158103 log_info " Using namespace: $NAMESPACE , release: $RELEASE_NAME "
159104}
160105
161- # Check if eoAPI deployment is healthy
162106check_eoapi_deployment () {
163107 validate_eoapi_deployment " $NAMESPACE " " $RELEASE_NAME " || {
164108 log_error " eoAPI deployment validation failed"
@@ -167,7 +111,6 @@ check_eoapi_deployment() {
167111 }
168112}
169113
170- # Wait for all eoAPI services to be ready
171114wait_for_services () {
172115 log_info " Waiting for eoAPI services to be ready..."
173116
@@ -183,9 +126,7 @@ wait_for_services() {
183126 log_info " ✅ All eoAPI services are ready"
184127}
185128
186- # Setup test environment variables
187129setup_test_environment () {
188- # Auto-detect service endpoints
189130 local ingress_host
190131 ingress_host=$( kubectl get ingress -n " $NAMESPACE " -o jsonpath=' {.items[0].spec.rules[0].host}' 2> /dev/null || echo " localhost" )
191132
@@ -199,7 +140,6 @@ setup_test_environment() {
199140 log_info " Vector: $VECTOR_ENDPOINT "
200141}
201142
202- # Show debug information about the deployment
203143show_debug_info () {
204144 log_info " === Debug Information ==="
205145
@@ -338,6 +278,7 @@ run_integration_tests() {
338278 log_error " Observability tests not found - required for autoscaling validation"
339279 exit 1
340280 fi
281+
341282 # Wait for Knative services to be ready if they exist
342283 if kubectl get ksvc -n " $NAMESPACE " > /dev/null 2>&1 ; then
343284 if kubectl get ksvc eoapi-cloudevents-sink -n " $NAMESPACE " > /dev/null 2>&1 ; then
@@ -349,49 +290,22 @@ run_integration_tests() {
349290 fi
350291 fi
351292
352-
353-
354293 log_info " ✅ Integration tests completed"
355294}
356295
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
378296main () {
379297 parse_args " $@ "
380298
381- # Default command
382299 if [ -z " $COMMAND " ]; then
383300 COMMAND=" all"
384301 fi
385302
386- log_info " eoAPI Test Suite - Command: $COMMAND | Debug: $DEBUG_MODE | Release: $RELEASE_NAME "
387-
388303 if [ " $DEBUG_MODE " = true ]; then
389- log_info " Starting eoAPI test suite (DEBUG MODE ) - Command: $COMMAND "
304+ log_info " eoAPI Test Suite (DEBUG) - Command: $COMMAND | Release: $RELEASE_NAME "
390305 else
391- log_info " Starting eoAPI test suite - Command: $COMMAND "
306+ log_info " eoAPI Test Suite - Command: $COMMAND | Release: $RELEASE_NAME "
392307 fi
393308
394- # Run tests based on command
395309 case $COMMAND in
396310 helm)
397311 check_helm_dependencies
@@ -431,19 +345,16 @@ main() {
431345 all)
432346 log_info " Running comprehensive test suite (Helm + Integration tests)"
433347
434- # Run Helm tests first
435348 log_info " === Phase 1: Helm Tests ==="
436349 check_helm_dependencies
437350 run_helm_tests
438351
439- # Run Integration tests
440352 log_info " === Phase 2: Integration Tests ==="
441353 check_integration_dependencies
442354 validate_cluster
443355 install_test_deps
444356 detect_deployment
445357
446- # Show enhanced debugging in debug mode
447358 if [ " $DEBUG_MODE " = true ]; then
448359 show_debug_info
449360 fi
@@ -462,20 +373,7 @@ main() {
462373 ;;
463374 esac
464375
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
376+ log_info " ✅ Test suite complete"
479377}
480378
481379# Run main function
0 commit comments