From 896e1ebb87003d9aa0c06c8b24fd8ad75ce9a464 Mon Sep 17 00:00:00 2001 From: mustard Date: Mon, 2 Sep 2024 18:03:45 +0800 Subject: [PATCH] Improve JetBrains integration tests to show proper failed message (#20165) * Improve JetBrains integration tests to show proper failed message * fixup: show stdout --- test/tests/ide/jetbrains/gateway_test.go | 3 ++- test/tests/ide/jetbrains/warmup-indexing.sh | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/tests/ide/jetbrains/gateway_test.go b/test/tests/ide/jetbrains/gateway_test.go index 28241a3bf11529..bf32e4ecfbacd5 100644 --- a/test/tests/ide/jetbrains/gateway_test.go +++ b/test/tests/ide/jetbrains/gateway_test.go @@ -275,15 +275,16 @@ func TestIntelliJWarmup(t *testing.T) { string(warmupIndexingShell), "--", jbCtx.SystemDir, + "1", }, }, &resp) if err != nil { return fmt.Errorf("failed to warmup indexing: %v", err) } + t.Logf("stdout:\n%s", string(resp.Stdout)) if resp.ExitCode != 0 { return fmt.Errorf("failed to warmup indexing: %s, %d", resp.Stderr, resp.ExitCode) } - t.Logf("output:\n%s", string(resp.Stdout)) return nil })) return testCtx diff --git a/test/tests/ide/jetbrains/warmup-indexing.sh b/test/tests/ide/jetbrains/warmup-indexing.sh index 3e35c386346acc..ceaab40845223e 100755 --- a/test/tests/ide/jetbrains/warmup-indexing.sh +++ b/test/tests/ide/jetbrains/warmup-indexing.sh @@ -5,12 +5,14 @@ # This script is used to test JetBrains prebuild warmup indexing (search warmup-indexing.sh in codebase) # It will get the last indexing json file (scan type FULL_ON_PROJECT_OPEN) -# and check if the scheduled indexing count is 0 +# and check if the scheduled indexing count is greater than a specified threshold # # `exit 0` means JetBrains IDEs no need to indexing again +# Example: ./warmup-indexing.sh /workspace 1 set -euo pipefail SystemDir=$1 +Threshold=$2 ProjectIndexingFolder=$(find "$SystemDir"/log/indexing-diagnostic -type d -name "spring*" -print -quit) JsonFiles=$(find "$ProjectIndexingFolder" -type f -name "*.json") @@ -26,6 +28,11 @@ mapfile -t sortedFiles < <(printf "%s\n" "${FilteredJsonFiles[@]}" | sort -r) targetFile=${sortedFiles[0]} echo "Target indexing json file: $targetFile" scheduledIndexing=$(jq '.projectIndexingActivityHistory.fileCount.numberOfFilesScheduledForIndexingAfterScan' "$targetFile") -echo "Scheduled indexing count: $scheduledIndexing" +echo "Scheduled indexing count: $scheduledIndexing, threshold: $Threshold" -[ "$scheduledIndexing" -ne 0 ] && exit 1 || exit 0 +if [ "$scheduledIndexing" -gt "$Threshold" ]; then + echo "Error: Scheduled indexing count $scheduledIndexing > $Threshold" >&2 + exit 1 +else + exit 0 +fi