Skip to content

Commit

Permalink
Improve JetBrains integration tests to show proper failed message (#2…
Browse files Browse the repository at this point in the history
…0165)

* Improve JetBrains integration tests to show proper failed message

* fixup: show stdout
  • Loading branch information
mustard-mh authored Sep 2, 2024
1 parent 0be8880 commit 896e1eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion test/tests/ide/jetbrains/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions test/tests/ide/jetbrains/warmup-indexing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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

0 comments on commit 896e1eb

Please sign in to comment.