Skip to content

Commit c1f81e9

Browse files
committed
Some cleanup.
1 parent 07e512d commit c1f81e9

File tree

2 files changed

+16
-117
lines changed

2 files changed

+16
-117
lines changed

scripts/lib/common.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,7 @@ preflight_test() {
225225
validate_tools kubectl python3 || return 1
226226
validate_cluster || return 1
227227
;;
228-
observability)
229-
validate_tools kubectl python3 || return 1
230-
validate_cluster || return 1
231-
;;
228+
232229
*)
233230
log_error "Unknown test type: $test_type"
234231
return 1

scripts/test.sh

Lines changed: 15 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,51 @@
22

33
# eoAPI Test Suite - Combined Helm and Integration Testing
44

5-
# Source shared utilities
65
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
76
source "$SCRIPT_DIR/lib/common.sh"
87

9-
# Global variables
108
DEBUG_MODE=false
119
NAMESPACE="eoapi"
1210
COMMAND=""
1311
RELEASE_NAME=""
1412

15-
# Auto-detect CI environment
1613
if is_ci_environment; then
1714
DEBUG_MODE=true
1815
RELEASE_NAME="${RELEASE_NAME:-eoapi-$(echo "${GITHUB_SHA:-local}" | cut -c1-8)}"
1916
else
2017
RELEASE_NAME="${RELEASE_NAME:-eoapi}"
2118
fi
2219

23-
# Show help message
2420
show_help() {
2521
cat << EOF
2622
eoAPI Test Suite - Helm and Integration Testing
2723
2824
USAGE: $(basename "$0") [COMMAND] [OPTIONS]
2925
3026
COMMANDS:
31-
helm Run Helm tests (lint, unit tests, template validation)
27+
helm Run Helm tests (lint, template validation)
3228
integration Run integration tests (requires deployed eoAPI)
3329
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-
30+
check-deps Check dependencies only
31+
check-deployment Debug deployment state
3732
OPTIONS:
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-
33+
--debug Enable debug mode
34+
--help, -h Show this help
6735
6836
ENVIRONMENT 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
37+
RELEASE_NAME Helm release name (auto-generated in CI)
38+
NAMESPACE Target namespace (default: eoapi)
39+
RASTER_ENDPOINT Override Raster API endpoint
40+
VECTOR_ENDPOINT Override Vector API endpoint
41+
CI Auto-enables debug mode if set
8742
8843
EOF
8944
}
9045

91-
# Parse command line arguments
9246
parse_args() {
9347
while [[ $# -gt 0 ]]; do
9448
case $1 in
95-
helm|integration|observability|all|check-deps|check-deployment)
49+
helm|integration|all|check-deps|check-deployment)
9650
COMMAND="$1"; shift ;;
9751
--debug)
9852
DEBUG_MODE=true; shift ;;
@@ -105,29 +59,19 @@ parse_args() {
10559
done
10660
}
10761

108-
# Check dependencies for helm tests
10962
check_helm_dependencies() {
11063
preflight_test "helm" || exit 1
11164

112-
# Install unittest plugin if needed
11365
if ! helm plugin list | grep -q unittest; then
11466
log_info "Installing helm unittest plugin..."
11567
helm plugin install https://github.com/helm-unittest/helm-unittest
11668
fi
11769
}
11870

119-
# Check dependencies for integration tests
12071
check_integration_dependencies() {
12172
preflight_test "integration" || exit 1
12273
}
12374

124-
# Check dependencies for observability tests
125-
check_observability_dependencies() {
126-
preflight_test "observability" || exit 1
127-
}
128-
129-
130-
# Install Python test dependencies
13175
install_test_deps() {
13276
log_info "Installing Python test dependencies..."
13377

@@ -145,7 +89,6 @@ install_test_deps() {
14589
log_info "Test dependencies installed."
14690
}
14791

148-
# Detect deployment and set environment variables
14992
detect_deployment() {
15093
if [ -z "${NAMESPACE:-}" ]; then
15194
NAMESPACE=$(detect_namespace)
@@ -158,7 +101,6 @@ detect_deployment() {
158101
log_info "Using namespace: $NAMESPACE, release: $RELEASE_NAME"
159102
}
160103

161-
# Check if eoAPI deployment is healthy
162104
check_eoapi_deployment() {
163105
validate_eoapi_deployment "$NAMESPACE" "$RELEASE_NAME" || {
164106
log_error "eoAPI deployment validation failed"
@@ -167,7 +109,6 @@ check_eoapi_deployment() {
167109
}
168110
}
169111

170-
# Wait for all eoAPI services to be ready
171112
wait_for_services() {
172113
log_info "Waiting for eoAPI services to be ready..."
173114

@@ -183,9 +124,7 @@ wait_for_services() {
183124
log_info "✅ All eoAPI services are ready"
184125
}
185126

186-
# Setup test environment variables
187127
setup_test_environment() {
188-
# Auto-detect service endpoints
189128
local ingress_host
190129
ingress_host=$(kubectl get ingress -n "$NAMESPACE" -o jsonpath='{.items[0].spec.rules[0].host}' 2>/dev/null || echo "localhost")
191130

@@ -199,7 +138,6 @@ setup_test_environment() {
199138
log_info " Vector: $VECTOR_ENDPOINT"
200139
}
201140

202-
# Show debug information about the deployment
203141
show_debug_info() {
204142
log_info "=== Debug Information ==="
205143

@@ -216,7 +154,6 @@ show_debug_info() {
216154
kubectl get events -n "$NAMESPACE" --sort-by='.lastTimestamp' 2>/dev/null | tail -10 || true
217155
}
218156

219-
# Run Helm tests
220157
run_helm_tests() {
221158
log_info "=== Helm Tests ==="
222159

@@ -246,7 +183,6 @@ run_helm_tests() {
246183
done
247184
}
248185

249-
# Debug deployment state
250186
debug_deployment_state() {
251187
log_info "=== Deployment Debug ==="
252188

@@ -277,7 +213,6 @@ debug_deployment_state() {
277213
fi
278214
}
279215

280-
# Run integration tests
281216
run_integration_tests() {
282217
log_info "=== Integration Tests ==="
283218

@@ -338,6 +273,7 @@ run_integration_tests() {
338273
log_error "Observability tests not found - required for autoscaling validation"
339274
exit 1
340275
fi
276+
341277
# Wait for Knative services to be ready if they exist
342278
if kubectl get ksvc -n "$NAMESPACE" >/dev/null 2>&1; then
343279
if kubectl get ksvc eoapi-cloudevents-sink -n "$NAMESPACE" >/dev/null 2>&1; then
@@ -349,49 +285,22 @@ run_integration_tests() {
349285
fi
350286
fi
351287

352-
353-
354288
log_info "✅ Integration tests completed"
355289
}
356290

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
378291
main() {
379292
parse_args "$@"
380293

381-
# Default command
382294
if [ -z "$COMMAND" ]; then
383295
COMMAND="all"
384296
fi
385297

386-
log_info "eoAPI Test Suite - Command: $COMMAND | Debug: $DEBUG_MODE | Release: $RELEASE_NAME"
387-
388298
if [ "$DEBUG_MODE" = true ]; then
389-
log_info "Starting eoAPI test suite (DEBUG MODE) - Command: $COMMAND"
299+
log_info "eoAPI Test Suite (DEBUG) - Command: $COMMAND | Release: $RELEASE_NAME"
390300
else
391-
log_info "Starting eoAPI test suite - Command: $COMMAND"
301+
log_info "eoAPI Test Suite - Command: $COMMAND | Release: $RELEASE_NAME"
392302
fi
393303

394-
# Run tests based on command
395304
case $COMMAND in
396305
helm)
397306
check_helm_dependencies
@@ -431,19 +340,16 @@ main() {
431340
all)
432341
log_info "Running comprehensive test suite (Helm + Integration tests)"
433342

434-
# Run Helm tests first
435343
log_info "=== Phase 1: Helm Tests ==="
436344
check_helm_dependencies
437345
run_helm_tests
438346

439-
# Run Integration tests
440347
log_info "=== Phase 2: Integration Tests ==="
441348
check_integration_dependencies
442349
validate_cluster
443350
install_test_deps
444351
detect_deployment
445352

446-
# Show enhanced debugging in debug mode
447353
if [ "$DEBUG_MODE" = true ]; then
448354
show_debug_info
449355
fi
@@ -471,11 +377,7 @@ main() {
471377
rm -f /tmp/eoapi-port-forward-pids
472378
fi
473379

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
380+
log_info "✅ Test suite complete"
479381
}
480382

481383
# Run main function

0 commit comments

Comments
 (0)