From ead4bf349c5dd29d198d3f36a37960663d764d78 Mon Sep 17 00:00:00 2001 From: hongwei Date: Thu, 8 Jan 2026 19:17:24 +0100 Subject: [PATCH 01/12] refactor/ (run_all_tests.sh): enhance terminal styling and add phase timing - Update set_terminal_style() to use phase-specific background colors (gray for starting, orange for building, blue for testing, green for complete) - Add get_time_ms() function to capture millisecond timestamps across macOS and Linux platforms - Implement record_phase_time() function to track duration of each test execution phase (starting, building, testing, complete) - Store phase timing data in temporary file for performance analysis - Replace grep -P (PCRE) with sed-based parsing for macOS compatibility in generate_summary() - Update test statistics extraction to sum values across all modules instead of just the last run - Add cleanup for stale phase_timing.tmp file during initialization - Improve parsing of Maven output for duration, test counts, and test results using portable sed commands --- run_all_tests.sh | 327 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 298 insertions(+), 29 deletions(-) diff --git a/run_all_tests.sh b/run_all_tests.sh index 0169debafc..ead65e037a 100755 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -31,13 +31,38 @@ fi # TERMINAL STYLING FUNCTIONS ################################################################################ -# Set terminal to "test mode" - blue background, special title +# Set terminal to "test mode" - different colors for different phases set_terminal_style() { local phase="${1:-Running}" - echo -ne "\033]0;OBP-API Tests ${phase}...\007" # Title - echo -ne "\033]11;#001f3f\007" # Dark blue background - echo -ne "\033]10;#ffffff\007" # White text - # Print header bar + + # Set different background colors for different phases + case "$phase" in + "Starting") + echo -ne "\033]11;#4a4a4a\007" # Dark gray background + echo -ne "\033]10;#ffffff\007" # White text + ;; + "Building") + echo -ne "\033]11;#ff6b35\007" # Orange background + echo -ne "\033]10;#ffffff\007" # White text + ;; + "Testing") + echo -ne "\033]11;#001f3f\007" # Dark blue background + echo -ne "\033]10;#ffffff\007" # White text + ;; + "Complete") + echo -ne "\033]11;#2ecc40\007" # Green background + echo -ne "\033]10;#ffffff\007" # White text + ;; + *) + echo -ne "\033]11;#001f3f\007" # Default blue background + echo -ne "\033]10;#ffffff\007" # White text + ;; + esac + + # Set window title + echo -ne "\033]0;OBP-API Tests ${phase}...\007" + + # Print header bar with phase-specific styling printf "\033[44m\033[1;37m%-$(tput cols)s\r OBP-API TEST RUNNER ACTIVE - ${phase} \n%-$(tput cols)s\033[0m\n" " " " " } @@ -91,8 +116,74 @@ DETAIL_LOG="${LOG_DIR}/last_run.log" # Full Maven output SUMMARY_LOG="${LOG_DIR}/last_run_summary.log" # Summary only FAILED_TESTS_FILE="${LOG_DIR}/failed_tests.txt" # Failed test list for run_specific_tests.sh +# Phase timing variables (stored in temporary file) +PHASE_START_TIME=0 + mkdir -p "${LOG_DIR}" +# Function to get current time in milliseconds +get_time_ms() { + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + python3 -c "import time; print(int(time.time() * 1000))" + else + # Linux + date +%s%3N + fi +} + +# Function to record phase timing +record_phase_time() { + local phase="$1" + local current_time=$(get_time_ms) + local timing_file="${LOG_DIR}/phase_timing.tmp" + + case "$phase" in + "starting") + echo "PHASE_START_TIME=$current_time" > "$timing_file" + ;; + "building") + if [ -f "$timing_file" ]; then + local phase_start=$(grep "PHASE_START_TIME=" "$timing_file" | cut -d= -f2) + if [ "$phase_start" -gt 0 ]; then + local starting_time=$((current_time - phase_start)) + echo "STARTING_TIME=$starting_time" >> "$timing_file" + fi + fi + echo "PHASE_START_TIME=$current_time" >> "$timing_file" + ;; + "testing") + if [ -f "$timing_file" ]; then + local phase_start=$(grep "PHASE_START_TIME=" "$timing_file" | tail -1 | cut -d= -f2) + if [ "$phase_start" -gt 0 ]; then + local building_time=$((current_time - phase_start)) + echo "BUILDING_TIME=$building_time" >> "$timing_file" + fi + fi + echo "PHASE_START_TIME=$current_time" >> "$timing_file" + ;; + "complete") + if [ -f "$timing_file" ]; then + local phase_start=$(grep "PHASE_START_TIME=" "$timing_file" | tail -1 | cut -d= -f2) + if [ "$phase_start" -gt 0 ]; then + local testing_time=$((current_time - phase_start)) + echo "TESTING_TIME=$testing_time" >> "$timing_file" + fi + fi + echo "PHASE_START_TIME=$current_time" >> "$timing_file" + ;; + "end") + if [ -f "$timing_file" ]; then + local phase_start=$(grep "PHASE_START_TIME=" "$timing_file" | tail -1 | cut -d= -f2) + if [ "$phase_start" -gt 0 ]; then + local complete_time=$((current_time - phase_start)) + echo "COMPLETE_TIME=$complete_time" >> "$timing_file" + fi + fi + ;; + esac +} + # If summary-only mode, skip to summary generation if [ "$SUMMARY_ONLY" = true ]; then if [ ! -f "${DETAIL_LOG}" ]; then @@ -130,6 +221,10 @@ fi rm -f "${LOG_DIR}/recent_lines.tmp" echo " - Removed stale temp file" fi + if [ -f "${LOG_DIR}/phase_timing.tmp" ]; then + rm -f "${LOG_DIR}/phase_timing.tmp" + echo " - Removed stale timing file" + fi fi # End of if [ "$SUMMARY_ONLY" = true ] ################################################################################ @@ -231,8 +326,10 @@ generate_summary() { # If no timing info (summary-only mode), extract from log if [ $duration -eq 0 ] && grep -q "Total time:" "$detail_log"; then local time_str=$(grep "Total time:" "$detail_log" | tail -1) - duration_min=$(echo "$time_str" | grep -oP '\d+(?= min)' || echo "0") - duration_sec=$(echo "$time_str" | grep -oP '\d+(?=\.\d+ s)' || echo "0") + duration_min=$(echo "$time_str" | sed 's/.*: //' | sed 's/ min.*//' | grep -o '[0-9]*' | head -1) + [ -z "$duration_min" ] && duration_min="0" + duration_sec=$(echo "$time_str" | sed 's/.* min //' | sed 's/\..*//' | grep -o '[0-9]*' | head -1) + [ -z "$duration_sec" ] && duration_sec="0" fi print_header "Test Results Summary" @@ -244,22 +341,36 @@ generate_summary() { # Suites: completed M, aborted 0 # Tests: succeeded N, failed 0, canceled 0, ignored 0, pending 0 # All tests passed. - # We need to extract the stats from the last test run (in case there are multiple modules) - SCALATEST_SECTION=$(grep -A 4 "Run completed" "${detail_log}" | tail -5) - if [ -n "$SCALATEST_SECTION" ]; then - TOTAL_TESTS=$(echo "$SCALATEST_SECTION" | grep -oP "Total number of tests run: \K\d+" || echo "UNKNOWN") - SUCCEEDED=$(echo "$SCALATEST_SECTION" | grep -oP "succeeded \K\d+" || echo "UNKNOWN") - FAILED=$(echo "$SCALATEST_SECTION" | grep -oP "failed \K\d+" || echo "UNKNOWN") - ERRORS=$(echo "$SCALATEST_SECTION" | grep -oP "errors \K\d+" || echo "0") - SKIPPED=$(echo "$SCALATEST_SECTION" | grep -oP "ignored \K\d+" || echo "UNKNOWN") + # We need to sum stats from ALL test runs (multiple modules: obp-commons, obp-api, etc.) + + # Sum up all "Total number of tests run" values (macOS compatible - no grep -P) + TOTAL_TESTS=$(grep "Total number of tests run:" "${detail_log}" | sed 's/.*Total number of tests run: //' | awk '{sum+=$1} END {print sum}') + [ -z "$TOTAL_TESTS" ] || [ "$TOTAL_TESTS" = "0" ] && TOTAL_TESTS="UNKNOWN" + + # Sum up all succeeded from "Tests: succeeded N, ..." lines + SUCCEEDED=$(grep "Tests: succeeded" "${detail_log}" | sed 's/.*succeeded //' | sed 's/,.*//' | awk '{sum+=$1} END {print sum}') + [ -z "$SUCCEEDED" ] && SUCCEEDED="UNKNOWN" + + # Sum up all failed from "Tests: ... failed N, ..." lines + FAILED=$(grep "Tests:.*failed" "${detail_log}" | sed 's/.*failed //' | sed 's/,.*//' | awk '{sum+=$1} END {print sum}') + [ -z "$FAILED" ] && FAILED="0" + + # Sum up all ignored from "Tests: ... ignored N, ..." lines + IGNORED=$(grep "Tests:.*ignored" "${detail_log}" | sed 's/.*ignored //' | sed 's/,.*//' | awk '{sum+=$1} END {print sum}') + [ -z "$IGNORED" ] && IGNORED="0" + + # Sum up errors (if any) + ERRORS=$(grep "errors" "${detail_log}" | grep -v "ERROR" | sed 's/.*errors //' | sed 's/[^0-9].*//' | awk '{sum+=$1} END {print sum}') + [ -z "$ERRORS" ] && ERRORS="0" + + # Calculate total including ignored (like IntelliJ does) + if [ "$TOTAL_TESTS" != "UNKNOWN" ] && [ "$IGNORED" != "0" ]; then + TOTAL_WITH_IGNORED=$((TOTAL_TESTS + IGNORED)) else - TOTAL_TESTS="UNKNOWN" - SUCCEEDED="UNKNOWN" - FAILED="UNKNOWN" - ERRORS="0" - SKIPPED="UNKNOWN" + TOTAL_WITH_IGNORED="$TOTAL_TESTS" fi - WARNINGS=$(grep -c "WARNING" "${detail_log}" || echo "UNKNOWN") + + WARNINGS=$(grep -c "WARNING" "${detail_log}" || echo "0") # Determine build status if grep -q "BUILD SUCCESS" "${detail_log}"; then @@ -276,16 +387,153 @@ generate_summary() { # Print summary log_message "Test Run Summary" log_message "================" - log_message "Timestamp: $(date)" - log_message "Duration: ${duration_min}m ${duration_sec}s" + + # Extract Maven timestamps and calculate Terminal timestamps + local maven_start_timestamp="" + local maven_end_timestamp="" + local terminal_start_timestamp="" + local terminal_end_timestamp=$(date) + + if [ "$start_time" -gt 0 ] && [ "$end_time" -gt 0 ]; then + # Use actual terminal start/end times if available + terminal_start_timestamp=$(date -r "$start_time" 2>/dev/null || date -d "@$start_time" 2>/dev/null || echo "Unknown") + terminal_end_timestamp=$(date -r "$end_time" 2>/dev/null || date -d "@$end_time" 2>/dev/null || echo "Unknown") + else + # Calculate terminal start time by subtracting duration from current time + if [ "$duration_min" -gt 0 -o "$duration_sec" -gt 0 ]; then + local total_seconds=$((duration_min * 60 + duration_sec)) + local approx_start_epoch=$(($(date "+%s") - total_seconds)) + terminal_start_timestamp=$(date -r "$approx_start_epoch" 2>/dev/null || echo "Approx. ${duration_min}m ${duration_sec}s ago") + else + terminal_start_timestamp="Unknown" + fi + fi + + # Extract Maven timestamps from log + maven_end_timestamp=$(grep "Finished at:" "${detail_log}" | tail -1 | sed 's/.*Finished at: //' | sed 's/T/ /' | sed 's/+.*//' || echo "Unknown") + + # Calculate Maven start time from Maven's "Total time" if available + local maven_total_time=$(grep "Total time:" "${detail_log}" | tail -1 | sed 's/.*Total time: *//' | sed 's/ .*//' || echo "") + if [ -n "$maven_total_time" ] && [ "$maven_end_timestamp" != "Unknown" ]; then + # Parse Maven duration (e.g., "02:06" for "02:06 min" or "43.653" for "43.653 s") + local maven_seconds=0 + if echo "$maven_total_time" | grep -q ":"; then + # Format like "02:06" (minutes:seconds) + local maven_min=$(echo "$maven_total_time" | sed 's/:.*//') + local maven_sec=$(echo "$maven_total_time" | sed 's/.*://') + # Remove leading zeros to avoid octal interpretation + maven_min=$(echo "$maven_min" | sed 's/^0*//' | sed 's/^$/0/') + maven_sec=$(echo "$maven_sec" | sed 's/^0*//' | sed 's/^$/0/') + maven_seconds=$((maven_min * 60 + maven_sec)) + else + # Format like "43.653" (seconds) + maven_seconds=$(echo "$maven_total_time" | sed 's/\..*//') + fi + + # Calculate Maven start time + if [ "$maven_seconds" -gt 0 ]; then + local maven_end_epoch=$(date -j -f "%Y-%m-%d %H:%M:%S" "$maven_end_timestamp" "+%s" 2>/dev/null || echo "0") + if [ "$maven_end_epoch" -gt 0 ]; then + local maven_start_epoch=$((maven_end_epoch - maven_seconds)) + maven_start_timestamp=$(date -r "$maven_start_epoch" 2>/dev/null || echo "Unknown") + else + maven_start_timestamp="Unknown" + fi + else + maven_start_timestamp="Unknown" + fi + else + maven_start_timestamp="Unknown" + fi + + # Format Maven end timestamp nicely + if [ "$maven_end_timestamp" != "Unknown" ]; then + maven_end_timestamp=$(date -j -f "%Y-%m-%d %H:%M:%S" "$maven_end_timestamp" "+%a %b %d %H:%M:%S %Z %Y" 2>/dev/null || echo "$maven_end_timestamp") + fi + + # Display both timelines + log_message "Terminal Timeline:" + log_message " Started: ${terminal_start_timestamp}" + log_message " Completed: ${terminal_end_timestamp}" + log_message " Duration: ${duration_min}m ${duration_sec}s" + log_message "" + log_message "Maven Timeline:" + log_message " Started: ${maven_start_timestamp}" + log_message " Completed: ${maven_end_timestamp}" + if [ -n "$maven_total_time" ]; then + local maven_duration_display=$(grep "Total time:" "${detail_log}" | tail -1 | sed 's/.*Total time: *//' || echo "Unknown") + log_message " Duration: ${maven_duration_display}" + fi + log_message "" log_message "Build Status: ${BUILD_STATUS}" log_message "" + + # Phase timing breakdown (if available) + local timing_file="${LOG_DIR}/phase_timing.tmp" + if [ -f "$timing_file" ]; then + # Read timing values from file + local start_ms=$(grep "STARTING_TIME=" "$timing_file" | cut -d= -f2 2>/dev/null || echo "0") + local build_ms=$(grep "BUILDING_TIME=" "$timing_file" | cut -d= -f2 2>/dev/null || echo "0") + local test_ms=$(grep "TESTING_TIME=" "$timing_file" | cut -d= -f2 2>/dev/null || echo "0") + local complete_ms=$(grep "COMPLETE_TIME=" "$timing_file" | cut -d= -f2 2>/dev/null || echo "0") + + # Ensure we have numeric values (default to 0 if empty) + [ -z "$start_ms" ] && start_ms=0 + [ -z "$build_ms" ] && build_ms=0 + [ -z "$test_ms" ] && test_ms=0 + [ -z "$complete_ms" ] && complete_ms=0 + + # Clean up timing file + rm -f "$timing_file" + + if [ "$start_ms" -gt 0 ] 2>/dev/null || [ "$build_ms" -gt 0 ] 2>/dev/null || [ "$test_ms" -gt 0 ] 2>/dev/null || [ "$complete_ms" -gt 0 ] 2>/dev/null; then + log_message "Phase Timing Breakdown:" + + if [ "$start_ms" -gt 0 ] 2>/dev/null; then + log_message " Starting: ${start_ms}ms ($(printf "%.2f" $(echo "scale=2; $start_ms/1000" | bc))s)" + fi + if [ "$build_ms" -gt 0 ] 2>/dev/null; then + log_message " Building: ${build_ms}ms ($(printf "%.2f" $(echo "scale=2; $build_ms/1000" | bc))s)" + fi + if [ "$test_ms" -gt 0 ] 2>/dev/null; then + log_message " Testing: ${test_ms}ms ($(printf "%.2f" $(echo "scale=2; $test_ms/1000" | bc))s)" + fi + if [ "$complete_ms" -gt 0 ] 2>/dev/null; then + log_message " Complete: ${complete_ms}ms ($(printf "%.2f" $(echo "scale=2; $complete_ms/1000" | bc))s)" + fi + + # Calculate percentages + local total_phase_time=$((start_ms + build_ms + test_ms + complete_ms)) + if [ "$total_phase_time" -gt 0 ]; then + log_message "" + log_message "Phase Distribution:" + if [ "$start_ms" -gt 0 ] 2>/dev/null; then + local starting_pct=$(echo "scale=1; $start_ms * 100 / $total_phase_time" | bc) + log_message " Starting: ${starting_pct}%" + fi + if [ "$build_ms" -gt 0 ] 2>/dev/null; then + local building_pct=$(echo "scale=1; $build_ms * 100 / $total_phase_time" | bc) + log_message " Building: ${building_pct}%" + fi + if [ "$test_ms" -gt 0 ] 2>/dev/null; then + local testing_pct=$(echo "scale=1; $test_ms * 100 / $total_phase_time" | bc) + log_message " Testing: ${testing_pct}%" + fi + if [ "$complete_ms" -gt 0 ] 2>/dev/null; then + local complete_pct=$(echo "scale=1; $complete_ms * 100 / $total_phase_time" | bc) + log_message " Complete: ${complete_pct}%" + fi + fi + log_message "" + fi + fi + log_message "Test Statistics:" - log_message " Total: ${TOTAL_TESTS}" + log_message " Total: ${TOTAL_WITH_IGNORED} (${TOTAL_TESTS} run + ${IGNORED} ignored)" log_message " Succeeded: ${SUCCEEDED}" log_message " Failed: ${FAILED}" + log_message " Ignored: ${IGNORED}" log_message " Errors: ${ERRORS}" - log_message " Skipped: ${SKIPPED}" log_message " Warnings: ${WARNINGS}" log_message "" @@ -320,7 +568,7 @@ generate_summary() { # Extract test class names from failures grep -B 20 "\*\*\* FAILED \*\*\*" "${detail_log}" | \ - grep -oP "^[A-Z][a-zA-Z0-9_]+(?=:)" | \ + grep -E "^[A-Z][a-zA-Z0-9_]+:" | sed 's/:$//' | \ sort -u | \ while read test_class; do # Try to find package by searching for the class in test files @@ -375,6 +623,8 @@ fi # START TEST RUN ################################################################################ +# Record starting phase +record_phase_time "starting" set_terminal_style "Starting" # Start the test run @@ -481,7 +731,6 @@ log_message "" ################################################################################ print_header "Running Tests" -update_terminal_title "Building" log_message "Executing: mvn clean test" echo "" @@ -500,6 +749,7 @@ touch "${MONITOR_FLAG}" done phase="Building" + in_building=false in_testing=false # Keep monitoring until flag file is removed @@ -508,10 +758,22 @@ touch "${MONITOR_FLAG}" # This ensures O(1) performance regardless of log file size recent_lines=$(tail -n 500 "${DETAIL_LOG}" 2>/dev/null) + # Switch to "Building" phase when Maven starts compiling + if ! $in_building && echo "$recent_lines" | grep -q -E "Compiling|Building.*Open Bank Project" 2>/dev/null; then + phase="Building" + in_building=true + # Record building phase start and change terminal color to orange for building phase + record_phase_time "building" + set_terminal_style "Building" + fi + # Switch to "Testing" phase when tests start if ! $in_testing && echo "$recent_lines" | grep -q "Run starting" 2>/dev/null; then phase="Testing" in_testing=true + # Record testing phase start and change terminal color to blue for testing phase + record_phase_time "testing" + set_terminal_style "Testing" fi # Extract current running test suite and scenario from recent lines @@ -568,11 +830,15 @@ DURATION_SEC=$((DURATION % 60)) # Update title with final results (no suite/scenario name for Complete phase) FINAL_ELAPSED=$(printf "%dm %ds" $DURATION_MIN $DURATION_SEC) # Build final counts with module context -FINAL_COMMONS=$(sed -n '/Building Open Bank Project Commons/,/Building Open Bank Project API/{/Tests: succeeded/p;}' "${DETAIL_LOG}" 2>/dev/null | grep -oP "succeeded \K\d+" | head -1) -FINAL_API=$(sed -n '/Building Open Bank Project API/,/OBP Http4s Runner/{/Tests: succeeded/p;}' "${DETAIL_LOG}" 2>/dev/null | grep -oP "succeeded \K\d+" | tail -1) +FINAL_COMMONS=$(sed -n '/Building Open Bank Project Commons/,/Building Open Bank Project API/{/Tests: succeeded/p;}' "${DETAIL_LOG}" 2>/dev/null | sed 's/.*succeeded //' | sed 's/,.*//' | head -1) +FINAL_API=$(sed -n '/Building Open Bank Project API/,/OBP Http4s Runner/{/Tests: succeeded/p;}' "${DETAIL_LOG}" 2>/dev/null | sed 's/.*succeeded //' | sed 's/,.*//' | tail -1) FINAL_COUNTS="" [ -n "$FINAL_COMMONS" ] && FINAL_COUNTS="commons:+${FINAL_COMMONS}" [ -n "$FINAL_API" ] && FINAL_COUNTS="${FINAL_COUNTS:+${FINAL_COUNTS} }api:+${FINAL_API}" + +# Record complete phase start and change to green for completion phase +record_phase_time "complete" +set_terminal_style "Complete" update_terminal_title "Complete" "$FINAL_ELAPSED" "$FINAL_COUNTS" "" "" ################################################################################ @@ -585,6 +851,9 @@ else EXIT_CODE=1 fi +# Record end time for complete phase +record_phase_time "end" + log_message "" log_message "Logs saved to:" log_message " ${DETAIL_LOG}" From 1428b52905e9e17c621f93fbc3f23d3c37fb4b82 Mon Sep 17 00:00:00 2001 From: hongwei Date: Thu, 8 Jan 2026 19:28:20 +0100 Subject: [PATCH 02/12] refactor/(run_all_tests.sh): enhance logging to write to detail log file - Update log_message function to write messages to both summary and detail log files - Add output redirection to DETAIL_LOG in addition to existing SUMMARY_LOG - Improve logging documentation comment to reflect dual log file writes - Ensures comprehensive logging across all test execution phases --- run_all_tests.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_all_tests.sh b/run_all_tests.sh index ead65e037a..1d006bc5bb 100755 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -231,10 +231,11 @@ fi # End of if [ "$SUMMARY_ONLY" = true ] # HELPER FUNCTIONS ################################################################################ -# Log message to terminal and summary file +# Log message to terminal and both log files log_message() { echo "$1" echo "[$(date +"%Y-%m-%d %H:%M:%S")] $1" >> "${SUMMARY_LOG}" + echo "$1" >> "${DETAIL_LOG}" } # Print section header From 31e39e37739b220cd703e6fa87aa33d00f156ea3 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 01:43:16 +0100 Subject: [PATCH 03/12] refactor(build): optimize JVM memory allocation and enable parallel test execution - Increase JVM heap memory from 512m to 2-4G for faster test execution - Add G1GC garbage collector and tiered compilation for improved performance - Enable parallel test execution with threadCount=4 to avoid shared state issues - Add incremental recompilation mode and Zinc server for faster builds - Increase Scala compiler JVM memory from 64m/1024m to 512m/2G - Add language feature flags to suppress compiler warnings - Add test-results directory to .gitignore for cleaner repository - Apply optimizations consistently across obp-api, obp-commons, and root pom.xml - These changes reduce build and test execution time while maintaining stability --- .gitignore | 1 + obp-api/pom.xml | 16 +++++++++++++++- obp-commons/pom.xml | 6 +++++- pom.xml | 14 ++++++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c057cc52c2..7e1e1bd937 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ project/project coursier metals.sbt obp-http4s-runner/src/main/resources/git.properties +test-results \ No newline at end of file diff --git a/obp-api/pom.xml b/obp-api/pom.xml index 7af24246b6..1a05e030cf 100644 --- a/obp-api/pom.xml +++ b/obp-api/pom.xml @@ -586,9 +586,13 @@ once . WDF TestSuite.txt - -Drun.mode=test -XX:MaxMetaspaceSize=512m -Xms512m -Xmx512m --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.jar=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED + + -Drun.mode=test -XX:MaxMetaspaceSize=1G -Xms2G -Xmx4G -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseStringDeduplication --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.jar=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED code.external ${maven.test.failure.ignore} + + true + 4 @@ -667,15 +671,25 @@ 4.8.1 true + incremental + true -Xms4G -Xmx12G -XX:MaxMetaspaceSize=4G -XX:+UseG1GC + -XX:+TieredCompilation + -XX:TieredStopAtLevel=1 -deprecation -feature + + -language:implicitConversions + -language:reflectiveCalls + -language:postfixOps + + -Wconf:cat=deprecation&msg=auto-application:s diff --git a/obp-commons/pom.xml b/obp-commons/pom.xml index be37971105..de9d694ff7 100644 --- a/obp-commons/pom.xml +++ b/obp-commons/pom.xml @@ -113,9 +113,13 @@ once . WDF TestSuite.txt - -Drun.mode=test -XX:MaxMetaspaceSize=512m -Xms512m -Xmx512m + + -Drun.mode=test -XX:MaxMetaspaceSize=1G -Xms2G -Xmx4G -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseStringDeduplication code.external ${maven.test.failure.ignore} + + true + 4 diff --git a/pom.xml b/pom.xml index 082e269b9e..16c10205f2 100644 --- a/pom.xml +++ b/pom.xml @@ -134,10 +134,14 @@ ${scala.compiler} ${project.build.sourceEncoding} true + incremental + true -DpackageLinkDefs=file://${project.build.directory}/packageLinkDefs.properties - -Xms64m - -Xmx1024m + -Xms512m + -Xmx2G + -XX:+TieredCompilation + -XX:TieredStopAtLevel=1 -unchecked @@ -147,6 +151,12 @@ -deprecation --> -Ypartial-unification + + -language:implicitConversions + -language:reflectiveCalls + -language:postfixOps + + -Wconf:cat=deprecation&msg=auto-application:s From f2b9b2a33db455acc6c03ae94038fbd53b6b5d68 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 11:04:50 +0100 Subject: [PATCH 04/12] rafactor/ ci(workflows): update branch pattern matching for container build - Change branch filter pattern from '*' to '**' for improved glob matching - Ensures workflow triggers on all branches except develop with correct pattern syntax - Improves CI/CD pipeline reliability by using proper wildcard pattern matching --- .github/workflows/build_container_non_develop_branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_container_non_develop_branch.yml b/.github/workflows/build_container_non_develop_branch.yml index ac188991e9..fda13bb721 100644 --- a/.github/workflows/build_container_non_develop_branch.yml +++ b/.github/workflows/build_container_non_develop_branch.yml @@ -3,7 +3,7 @@ name: Build and publish container non develop on: push: branches: - - '*' + - '**' - '!develop' env: From 2f68e00c2a936be8038a2ca32b8d5c11695a2dd1 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 12:25:30 +0100 Subject: [PATCH 05/12] refactor/(run_all_tests.sh): add HTML report generation and display functionality - Add HTML report generation step using mvn surefire-report:report-only - Create dedicated html-reports directory in test results for organized report storage - Copy surefire HTML reports from both obp-api and obp-commons modules - Check multiple report locations (target/surefire-reports and target/site) - Display generated HTML report paths in final test summary output - Improve test result accessibility by centralizing HTML reports in one location --- run_all_tests.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) mode change 100755 => 100644 run_all_tests.sh diff --git a/run_all_tests.sh b/run_all_tests.sh old mode 100755 new mode 100644 index 1d006bc5bb..826b089d70 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -817,6 +817,46 @@ else RESULT_COLOR="" fi +################################################################################ +# GENERATE HTML REPORT +################################################################################ + +print_header "Generating HTML Report" +log_message "Running: mvn surefire-report:report-only -DskipTests" + +# Generate HTML report from surefire XML files (without re-running tests) +if mvn surefire-report:report-only -DskipTests 2>&1 | tee -a "${DETAIL_LOG}"; then + log_message "[OK] HTML report generated" + + # Copy HTML reports to test-results directory for easy access + HTML_REPORT_DIR="${LOG_DIR}/html-reports" + mkdir -p "${HTML_REPORT_DIR}" + + # Copy reports from both modules + if [ -f "obp-api/target/surefire-reports/surefire-report.html" ]; then + cp "obp-api/target/surefire-reports/surefire-report.html" "${HTML_REPORT_DIR}/obp-api-report.html" + log_message " - obp-api report: ${HTML_REPORT_DIR}/obp-api-report.html" + fi + if [ -f "obp-commons/target/surefire-reports/surefire-report.html" ]; then + cp "obp-commons/target/surefire-reports/surefire-report.html" "${HTML_REPORT_DIR}/obp-commons-report.html" + log_message " - obp-commons report: ${HTML_REPORT_DIR}/obp-commons-report.html" + fi + + # Also check for site reports location + if [ -f "obp-api/target/site/surefire-report.html" ]; then + cp "obp-api/target/site/surefire-report.html" "${HTML_REPORT_DIR}/obp-api-report.html" + log_message " - obp-api report: ${HTML_REPORT_DIR}/obp-api-report.html" + fi + if [ -f "obp-commons/target/site/surefire-report.html" ]; then + cp "obp-commons/target/site/surefire-report.html" "${HTML_REPORT_DIR}/obp-commons-report.html" + log_message " - obp-commons report: ${HTML_REPORT_DIR}/obp-commons-report.html" + fi +else + log_message "[WARNING] Failed to generate HTML report" +fi + +log_message "" + # Stop background monitor by removing flag file rm -f "${MONITOR_FLAG}" sleep 1 @@ -862,6 +902,13 @@ log_message " ${SUMMARY_LOG}" if [ -f "${FAILED_TESTS_FILE}" ]; then log_message " ${FAILED_TESTS_FILE}" fi +if [ -d "${LOG_DIR}/html-reports" ]; then + log_message "" + log_message "HTML Reports:" + for report in "${LOG_DIR}/html-reports"/*.html; do + [ -f "$report" ] && log_message " $report" + done +fi echo "" exit ${EXIT_CODE} From 5251d79051cd347cb74c892c260a3f443b7d8777 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 11:45:41 +0100 Subject: [PATCH 06/12] rafactor/ perf(pom.xml): optimize Scala compiler JVM memory configuration - Reduce initial heap size from 4G to 1G for faster startup - Lower maximum heap size from 12G to 3G for resource efficiency - Add stack size configuration (-Xss4m) for thread optimization - Reduce metaspace size from 4G to 1G to minimize memory overhead - Improve build performance on resource-constrained environments while maintaining compilation stability --- obp-api/pom.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/obp-api/pom.xml b/obp-api/pom.xml index 1a05e030cf..5d6df26b86 100644 --- a/obp-api/pom.xml +++ b/obp-api/pom.xml @@ -674,9 +674,10 @@ incremental true - -Xms4G - -Xmx12G - -XX:MaxMetaspaceSize=4G + -Xms1G + -Xmx3G + -Xss4m + -XX:MaxMetaspaceSize=1G -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 From fa57525093dbe0c278c42e7b211ea90a1a7719f7 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 12:56:48 +0100 Subject: [PATCH 07/12] refactor/(run_all_tests.sh): enhance HTML report generation with asset copying - Update surefire report filename from surefire-report.html to surefire.html - Add copying of CSS, JS, images, fonts, and img directories for proper report rendering - Copy report assets for both obp-api and obp-commons modules - Add error suppression for missing asset directories to prevent script failures - Clarify alternative naming convention in site reports location comment - Ensure HTML reports render correctly with all required static assets --- run_all_tests.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/run_all_tests.sh b/run_all_tests.sh index 826b089d70..78fcaf3c11 100644 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -833,16 +833,22 @@ if mvn surefire-report:report-only -DskipTests 2>&1 | tee -a "${DETAIL_LOG}"; th mkdir -p "${HTML_REPORT_DIR}" # Copy reports from both modules - if [ -f "obp-api/target/surefire-reports/surefire-report.html" ]; then - cp "obp-api/target/surefire-reports/surefire-report.html" "${HTML_REPORT_DIR}/obp-api-report.html" + if [ -f "obp-api/target/surefire-reports/surefire.html" ]; then + cp "obp-api/target/surefire-reports/surefire.html" "${HTML_REPORT_DIR}/obp-api-report.html" + # Also copy CSS, JS, images for proper rendering + cp -r "obp-api/target/surefire-reports/css" "${HTML_REPORT_DIR}/" 2>/dev/null || true + cp -r "obp-api/target/surefire-reports/js" "${HTML_REPORT_DIR}/" 2>/dev/null || true + cp -r "obp-api/target/surefire-reports/images" "${HTML_REPORT_DIR}/" 2>/dev/null || true + cp -r "obp-api/target/surefire-reports/fonts" "${HTML_REPORT_DIR}/" 2>/dev/null || true + cp -r "obp-api/target/surefire-reports/img" "${HTML_REPORT_DIR}/" 2>/dev/null || true log_message " - obp-api report: ${HTML_REPORT_DIR}/obp-api-report.html" fi - if [ -f "obp-commons/target/surefire-reports/surefire-report.html" ]; then - cp "obp-commons/target/surefire-reports/surefire-report.html" "${HTML_REPORT_DIR}/obp-commons-report.html" + if [ -f "obp-commons/target/surefire-reports/surefire.html" ]; then + cp "obp-commons/target/surefire-reports/surefire.html" "${HTML_REPORT_DIR}/obp-commons-report.html" log_message " - obp-commons report: ${HTML_REPORT_DIR}/obp-commons-report.html" fi - # Also check for site reports location + # Also check for site reports location (alternative naming) if [ -f "obp-api/target/site/surefire-report.html" ]; then cp "obp-api/target/site/surefire-report.html" "${HTML_REPORT_DIR}/obp-api-report.html" log_message " - obp-api report: ${HTML_REPORT_DIR}/obp-api-report.html" From b575771d2e848f168f90a84ee5dffb90c2383381 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 13:25:03 +0100 Subject: [PATCH 08/12] refactor/ fix(pom.xml): enforce test failure detection in Maven build - Change maven.test.failure.ignore property from true to false - Enable Maven to fail the build when tests fail instead of ignoring failures - Ensure build pipeline properly detects and reports test failures - This change restores strict test failure handling for CI/CD pipelines --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16c10205f2..af0637b254 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ UTF-8 ${project.build.sourceEncoding} - true + false 1.2-m1 scaladocs/ From 3703ab1a002bbb54c59cb6d1aced6c9b00acd85f Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 13:30:45 +0100 Subject: [PATCH 09/12] refactor/(pom.xml): disable parallel test execution to prevent database conflicts - Disable parallel test execution in obp-api module to avoid shared H2 database state issues - Disable parallel test execution in obp-commons module for consistency - Set parallel configuration to false across both modules - Comment out threadCount configuration as it is no longer needed - Tests share an in-memory H2 database which causes conflicts when run concurrently - This resolves intermittent test failures caused by database state contamination between parallel test runs --- obp-api/pom.xml | 8 +++++--- obp-commons/pom.xml | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/obp-api/pom.xml b/obp-api/pom.xml index 5d6df26b86..7b59ac0722 100644 --- a/obp-api/pom.xml +++ b/obp-api/pom.xml @@ -590,9 +590,11 @@ -Drun.mode=test -XX:MaxMetaspaceSize=1G -Xms2G -Xmx4G -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseStringDeduplication --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.jar=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED code.external ${maven.test.failure.ignore} - - true - 4 + + + + + false diff --git a/obp-commons/pom.xml b/obp-commons/pom.xml index de9d694ff7..a41f81a4e2 100644 --- a/obp-commons/pom.xml +++ b/obp-commons/pom.xml @@ -117,9 +117,10 @@ -Drun.mode=test -XX:MaxMetaspaceSize=1G -Xms2G -Xmx4G -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseStringDeduplication code.external ${maven.test.failure.ignore} - - true - 4 + + + + false From e9f1ea21679dc3d4ee17ededf48ee6b9a2d9a36c Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 14:02:24 +0100 Subject: [PATCH 10/12] refactor/(run_all_tests.sh): enhance port management and add timeout support - Make script executable by updating file permissions - Remove global `set -e` to prevent grep failures and handle errors explicitly - Add `--timeout=` command line argument for test execution timeout - Enhance command line argument parsing to support multiple arguments via case statement - Improve port availability checking with fallback to alternative ports - Add `find_available_port()` function to search for available ports in range - Implement dynamic port configuration when primary port is unavailable - Add error handling with `2>/dev/null` redirects to grep commands in summary generation - Improve stale process cleanup with safer command substitution - Add timeout variable initialization for future timeout implementation - Enhance logging messages with variable port numbers instead of hardcoded values - Improve robustness of port killing and verification logic with explicit checks --- run_all_tests.sh | 188 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 142 insertions(+), 46 deletions(-) mode change 100644 => 100755 run_all_tests.sh diff --git a/run_all_tests.sh b/run_all_tests.sh old mode 100644 new mode 100755 index 78fcaf3c11..37ef30a439 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -14,18 +14,29 @@ # Usage: # ./run_all_tests.sh - Run full test suite # ./run_all_tests.sh --summary-only - Regenerate summary from existing log +# ./run_all_tests.sh --timeout=60 - Run with 60 minute timeout ################################################################################ -set -e +# Don't use set -e globally - it causes issues with grep returning 1 when no match +# Instead, we handle errors explicitly where needed ################################################################################ # PARSE COMMAND LINE ARGUMENTS ################################################################################ SUMMARY_ONLY=false -if [ "$1" = "--summary-only" ]; then - SUMMARY_ONLY=true -fi +TIMEOUT_MINUTES=0 # 0 means no timeout + +for arg in "$@"; do + case $arg in + --summary-only) + SUMMARY_ONLY=true + ;; + --timeout=*) + TIMEOUT_MINUTES="${arg#*=}" + ;; + esac +done ################################################################################ # TERMINAL STYLING FUNCTIONS @@ -345,23 +356,23 @@ generate_summary() { # We need to sum stats from ALL test runs (multiple modules: obp-commons, obp-api, etc.) # Sum up all "Total number of tests run" values (macOS compatible - no grep -P) - TOTAL_TESTS=$(grep "Total number of tests run:" "${detail_log}" | sed 's/.*Total number of tests run: //' | awk '{sum+=$1} END {print sum}') + TOTAL_TESTS=$(grep "Total number of tests run:" "${detail_log}" 2>/dev/null | sed 's/.*Total number of tests run: //' | awk '{sum+=$1} END {print sum}' || echo "0") [ -z "$TOTAL_TESTS" ] || [ "$TOTAL_TESTS" = "0" ] && TOTAL_TESTS="UNKNOWN" # Sum up all succeeded from "Tests: succeeded N, ..." lines - SUCCEEDED=$(grep "Tests: succeeded" "${detail_log}" | sed 's/.*succeeded //' | sed 's/,.*//' | awk '{sum+=$1} END {print sum}') + SUCCEEDED=$(grep "Tests: succeeded" "${detail_log}" 2>/dev/null | sed 's/.*succeeded //' | sed 's/,.*//' | awk '{sum+=$1} END {print sum}' || echo "0") [ -z "$SUCCEEDED" ] && SUCCEEDED="UNKNOWN" # Sum up all failed from "Tests: ... failed N, ..." lines - FAILED=$(grep "Tests:.*failed" "${detail_log}" | sed 's/.*failed //' | sed 's/,.*//' | awk '{sum+=$1} END {print sum}') + FAILED=$(grep "Tests:.*failed" "${detail_log}" 2>/dev/null | sed 's/.*failed //' | sed 's/,.*//' | awk '{sum+=$1} END {print sum}' || echo "0") [ -z "$FAILED" ] && FAILED="0" # Sum up all ignored from "Tests: ... ignored N, ..." lines - IGNORED=$(grep "Tests:.*ignored" "${detail_log}" | sed 's/.*ignored //' | sed 's/,.*//' | awk '{sum+=$1} END {print sum}') + IGNORED=$(grep "Tests:.*ignored" "${detail_log}" 2>/dev/null | sed 's/.*ignored //' | sed 's/,.*//' | awk '{sum+=$1} END {print sum}' || echo "0") [ -z "$IGNORED" ] && IGNORED="0" # Sum up errors (if any) - ERRORS=$(grep "errors" "${detail_log}" | grep -v "ERROR" | sed 's/.*errors //' | sed 's/[^0-9].*//' | awk '{sum+=$1} END {print sum}') + ERRORS=$(grep "errors" "${detail_log}" 2>/dev/null | grep -v "ERROR" | sed 's/.*errors //' | sed 's/[^0-9].*//' | awk '{sum+=$1} END {print sum}' || echo "0") [ -z "$ERRORS" ] && ERRORS="0" # Calculate total including ignored (like IntelliJ does) @@ -371,7 +382,7 @@ generate_summary() { TOTAL_WITH_IGNORED="$TOTAL_TESTS" fi - WARNINGS=$(grep -c "WARNING" "${detail_log}" || echo "0") + WARNINGS=$(grep -c "WARNING" "${detail_log}" 2>/dev/null || echo "0") # Determine build status if grep -q "BUILD SUCCESS" "${detail_log}"; then @@ -665,24 +676,67 @@ fi ################################################################################ print_header "Checking Test Server Ports" -log_message "Checking if test server port 8018 is available..." -# Check if port 8018 is in use -if lsof -i :8018 >/dev/null 2>&1; then - log_message "[WARNING] Port 8018 is in use - attempting to kill process" - # Try to kill the process using the port - PORT_PID=$(lsof -t -i :8018 2>/dev/null) +# Default test port (can be overridden) +TEST_PORT=8018 +MAX_PORT_ATTEMPTS=5 + +log_message "Checking if test server port ${TEST_PORT} is available..." + +# Function to find an available port +find_available_port() { + local port=$1 + local max_attempts=$2 + local attempt=0 + + while [ $attempt -lt $max_attempts ]; do + if ! lsof -i :$port >/dev/null 2>&1; then + echo $port + return 0 + fi + port=$((port + 1)) + attempt=$((attempt + 1)) + done + + echo "" + return 1 +} + +# Check if port is in use +if lsof -i :${TEST_PORT} >/dev/null 2>&1; then + log_message "[WARNING] Port ${TEST_PORT} is in use - attempting to kill process" + PORT_PID=$(lsof -t -i :${TEST_PORT} 2>/dev/null || true) if [ -n "$PORT_PID" ]; then kill -9 $PORT_PID 2>/dev/null || true sleep 2 - log_message "[OK] Killed process $PORT_PID using port 8018" + + # Verify port is now free + if lsof -i :${TEST_PORT} >/dev/null 2>&1; then + log_message "[WARNING] Could not free port ${TEST_PORT}, searching for alternative..." + NEW_PORT=$(find_available_port $((TEST_PORT + 1)) $MAX_PORT_ATTEMPTS) + if [ -n "$NEW_PORT" ]; then + log_message "[OK] Found available port: ${NEW_PORT}" + # Update test.default.props with new port + if [ -f "${PROPS_FILE}" ]; then + sed -i.bak "s/hostname=127.0.0.1:${TEST_PORT}/hostname=127.0.0.1:${NEW_PORT}/" "${PROPS_FILE}" 2>/dev/null || \ + sed -i '' "s/hostname=127.0.0.1:${TEST_PORT}/hostname=127.0.0.1:${NEW_PORT}/" "${PROPS_FILE}" + log_message "[OK] Updated test.default.props to use port ${NEW_PORT}" + TEST_PORT=$NEW_PORT + fi + else + log_message "[ERROR] No available ports found in range ${TEST_PORT}-$((TEST_PORT + MAX_PORT_ATTEMPTS))" + exit 1 + fi + else + log_message "[OK] Killed process $PORT_PID, port ${TEST_PORT} is now available" + fi fi else - log_message "[OK] Port 8018 is available" + log_message "[OK] Port ${TEST_PORT} is available" fi # Also check for any stale Java test processes -STALE_TEST_PROCS=$(ps aux | grep -E "TestServer|ScalaTest.*obp-api" | grep -v grep | awk '{print $2}' || true) +STALE_TEST_PROCS=$(ps aux | grep -E "TestServer|ScalaTest.*obp-api" | grep -v grep | awk '{print $2}' 2>/dev/null || true) if [ -n "$STALE_TEST_PROCS" ]; then log_message "[WARNING] Found stale test processes - cleaning up" echo "$STALE_TEST_PROCS" | xargs kill -9 2>/dev/null || true @@ -742,6 +796,13 @@ export START_TIME MONITOR_FLAG="${LOG_DIR}/monitor.flag" touch "${MONITOR_FLAG}" +# Optional timeout handling +MAVEN_PID="" +if [ "$TIMEOUT_MINUTES" -gt 0 ] 2>/dev/null; then + log_message "[INFO] Test timeout set to ${TIMEOUT_MINUTES} minutes" + TIMEOUT_SECONDS=$((TIMEOUT_MINUTES * 60)) +fi + # Background process: Monitor log file and update title bar with progress ( # Wait for log file to be created and have Maven output @@ -752,46 +813,48 @@ touch "${MONITOR_FLAG}" phase="Building" in_building=false in_testing=false + timing_file="${LOG_DIR}/phase_timing.tmp" # Keep monitoring until flag file is removed while [ -f "${MONITOR_FLAG}" ]; do # Use tail to look at recent lines only (last 500 lines for performance) - # This ensures O(1) performance regardless of log file size - recent_lines=$(tail -n 500 "${DETAIL_LOG}" 2>/dev/null) + recent_lines=$(tail -n 500 "${DETAIL_LOG}" 2>/dev/null || true) # Switch to "Building" phase when Maven starts compiling if ! $in_building && echo "$recent_lines" | grep -q -E "Compiling|Building.*Open Bank Project" 2>/dev/null; then phase="Building" in_building=true - # Record building phase start and change terminal color to orange for building phase - record_phase_time "building" - set_terminal_style "Building" + # Record building phase and update terminal (inline to avoid subshell issues) + current_time=$(python3 -c "import time; print(int(time.time() * 1000))" 2>/dev/null || date +%s000) + if [ -f "$timing_file" ]; then + phase_start=$(grep "PHASE_START_TIME=" "$timing_file" 2>/dev/null | tail -1 | cut -d= -f2 || echo "0") + [ -n "$phase_start" ] && [ "$phase_start" -gt 0 ] 2>/dev/null && echo "STARTING_TIME=$((current_time - phase_start))" >> "$timing_file" + fi + echo "PHASE_START_TIME=$current_time" >> "$timing_file" + echo -ne "\033]11;#ff6b35\007\033]10;#ffffff\007" # Orange background fi # Switch to "Testing" phase when tests start if ! $in_testing && echo "$recent_lines" | grep -q "Run starting" 2>/dev/null; then phase="Testing" in_testing=true - # Record testing phase start and change terminal color to blue for testing phase - record_phase_time "testing" - set_terminal_style "Testing" + # Record testing phase + current_time=$(python3 -c "import time; print(int(time.time() * 1000))" 2>/dev/null || date +%s000) + if [ -f "$timing_file" ]; then + phase_start=$(grep "PHASE_START_TIME=" "$timing_file" 2>/dev/null | tail -1 | cut -d= -f2 || echo "0") + [ -n "$phase_start" ] && [ "$phase_start" -gt 0 ] 2>/dev/null && echo "BUILDING_TIME=$((current_time - phase_start))" >> "$timing_file" + fi + echo "PHASE_START_TIME=$current_time" >> "$timing_file" + echo -ne "\033]11;#001f3f\007\033]10;#ffffff\007" # Blue background fi # Extract current running test suite and scenario from recent lines suite="" scenario="" if $in_testing; then - # Find the most recent test suite name (pattern like "SomeTest:") - # Pipe directly to avoid temp file I/O - suite=$(echo "$recent_lines" | grep -E "Test:" | tail -1 | sed 's/\x1b\[[0-9;]*m//g' | sed 's/:$//' | tr -d '\n\r') - - # Find the most recent scenario name (pattern like " Scenario: ..." or "- Scenario: ...") - scenario=$(echo "$recent_lines" | grep -i "scenario:" | tail -1 | sed 's/\x1b\[[0-9;]*m//g' | sed 's/^[[:space:]]*-*[[:space:]]*//' | sed -E 's/^[Ss]cenario:[[:space:]]*//' | tr -d '\n\r') - - # Truncate scenario if too long (max 50 chars) - if [ -n "$scenario" ] && [ ${#scenario} -gt 50 ]; then - scenario="${scenario:0:47}..." - fi + suite=$(echo "$recent_lines" | grep -E "Test:" 2>/dev/null | tail -1 | sed 's/\x1b\[[0-9;]*m//g' | sed 's/:$//' | tr -d '\n\r' || true) + scenario=$(echo "$recent_lines" | grep -i "scenario:" 2>/dev/null | tail -1 | sed 's/\x1b\[[0-9;]*m//g' | sed 's/^[[:space:]]*-*[[:space:]]*//' | sed -E 's/^[Ss]cenario:[[:space:]]*//' | tr -d '\n\r' || true) + [ -n "$scenario" ] && [ ${#scenario} -gt 50 ] && scenario="${scenario:0:47}..." fi # Calculate elapsed time @@ -800,21 +863,54 @@ touch "${MONITOR_FLAG}" seconds=$((duration % 60)) elapsed=$(printf "%dm %ds" $minutes $seconds) - # Update title: "Testing: DynamicEntityTest - Scenario name [5m 23s]" - update_terminal_title "$phase" "$elapsed" "" "$suite" "$scenario" + # Update title + title="OBP-API ${phase}" + [ -n "$suite" ] && title="${title}: ${suite}" + [ -n "$scenario" ] && title="${title} - ${scenario}" + title="${title}... [${elapsed}]" + echo -ne "\033]0;${title}\007" sleep 5 done ) & MONITOR_PID=$! -# Run Maven (all output goes to terminal AND log file) -if mvn clean test 2>&1 | tee "${DETAIL_LOG}"; then - TEST_RESULT="SUCCESS" - RESULT_COLOR="" +# Run Maven with optional timeout +if [ "$TIMEOUT_MINUTES" -gt 0 ] 2>/dev/null; then + # Run Maven in background and monitor for timeout + mvn clean test 2>&1 | tee "${DETAIL_LOG}" & + MAVEN_PID=$! + + elapsed=0 + while kill -0 $MAVEN_PID 2>/dev/null; do + sleep 10 + elapsed=$((elapsed + 10)) + if [ $elapsed -ge $TIMEOUT_SECONDS ]; then + log_message "" + log_message "[TIMEOUT] Test execution exceeded ${TIMEOUT_MINUTES} minutes - terminating" + kill -9 $MAVEN_PID 2>/dev/null || true + # Also kill any child Java processes + pkill -9 -P $MAVEN_PID 2>/dev/null || true + TEST_RESULT="TIMEOUT" + break + fi + done + + if [ "$TEST_RESULT" != "TIMEOUT" ]; then + wait $MAVEN_PID + if [ $? -eq 0 ]; then + TEST_RESULT="SUCCESS" + else + TEST_RESULT="FAILURE" + fi + fi else - TEST_RESULT="FAILURE" - RESULT_COLOR="" + # Run Maven normally (all output goes to terminal AND log file) + if mvn clean test 2>&1 | tee "${DETAIL_LOG}"; then + TEST_RESULT="SUCCESS" + else + TEST_RESULT="FAILURE" + fi fi ################################################################################ From 8b39edb6183244a6657ceff1e528cf354ddef114 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 14:29:16 +0100 Subject: [PATCH 11/12] refactor/(run_all_tests.sh): fix grep pattern quoting for consistency - Change double quotes to single quotes in grep regex pattern - Improve shell script best practices for pattern matching - Ensure consistent quoting style with grep -E flag usage --- run_all_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_all_tests.sh b/run_all_tests.sh index 37ef30a439..894429fe6e 100755 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -821,7 +821,7 @@ fi recent_lines=$(tail -n 500 "${DETAIL_LOG}" 2>/dev/null || true) # Switch to "Building" phase when Maven starts compiling - if ! $in_building && echo "$recent_lines" | grep -q -E "Compiling|Building.*Open Bank Project" 2>/dev/null; then + if ! $in_building && echo "$recent_lines" | grep -q -E 'Compiling|Building.*Open Bank Project' 2>/dev/null; then phase="Building" in_building=true # Record building phase and update terminal (inline to avoid subshell issues) From 3c9ecdfbfa4d94a67d7c8ac072d2e5afbf43ce70 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 9 Jan 2026 14:39:54 +0100 Subject: [PATCH 12/12] refactor/(pom.xml): increase Scala compiler JVM memory allocation - Increase initial heap size from 1G to 4G (-Xms) - Increase maximum heap size from 3G to 12G (-Xmx) - Increase metaspace size from 1G to 4G (-XX:MaxMetaspaceSize) - Improve compilation performance and reduce out-of-memory errors during large-scale builds --- obp-api/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/obp-api/pom.xml b/obp-api/pom.xml index 7b59ac0722..7379ff5662 100644 --- a/obp-api/pom.xml +++ b/obp-api/pom.xml @@ -676,10 +676,10 @@ incremental true - -Xms1G - -Xmx3G + -Xms4G + -Xmx12G -Xss4m - -XX:MaxMetaspaceSize=1G + -XX:MaxMetaspaceSize=4G -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1