Path: blob/main/test/tests/ide/jetbrains/warmup-indexing.sh
2500 views
#!/usr/bin/env bash1# Copyright (c) 2024 Gitpod GmbH. All rights reserved.2# Licensed under the GNU Affero General Public License (AGPL).3# See License.AGPL.txt in the project root for license information.45# This script is used to test JetBrains prebuild warmup indexing (search warmup-indexing.sh in codebase)6# It will get the last indexing json file (scan reason `On project open`)7# and check if the scheduled indexing count is greater than a specified threshold8#9# `exit 0` means JetBrains IDEs no need to indexing again10# Example: ./warmup-indexing.sh /workspace 11112set -euo pipefail13SystemDir=$114Threshold=$21516ProjectIndexingFolder=$(find "$SystemDir"/log/indexing-diagnostic -type d -name "spring*" -print -quit)17JsonFiles=$(find "$ProjectIndexingFolder" -type f -name "*.json")1819FilteredJsonFiles=()20for jsonFile in $JsonFiles; do21if jq -e '.projectIndexingActivityHistory.times.scanningReason == "On project open"' "$jsonFile" > /dev/null; then22FilteredJsonFiles+=("$jsonFile")23fi24done25mapfile -t sortedFiles < <(printf "%s\n" "${FilteredJsonFiles[@]}" | sort -r)2627targetFile=${sortedFiles[0]}28echo "Target indexing json file: $targetFile"29scheduledIndexing=$(jq '.projectIndexingActivityHistory.fileCount.numberOfFilesScheduledForIndexingAfterScan' "$targetFile")30echo "Scheduled indexing count: $scheduledIndexing, threshold: $Threshold"3132if [ "$scheduledIndexing" -gt "$Threshold" ]; then33echo "Error: Scheduled indexing count $scheduledIndexing > $Threshold" >&234exit 135else36exit 037fi383940