You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solr/packaging/test/bats_helper.bash
+14-34Lines changed: 14 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -97,41 +97,21 @@ collection_exists() {
97
97
return 1
98
98
}
99
99
100
-
# Wait for a collection to be queryable
101
-
wait_for_collection() {
102
-
local collection="$1"
103
-
local timeout=${2:-180}
104
-
local start_ts
105
-
start_ts=$(date +%s)
106
-
whiletrue;do
107
-
if curl -s -S -f "http://localhost:${SOLR_PORT}/solr/${collection}/select?q=*:*"| grep -q '"responseHeader"';then
100
+
# Utility function to retry a command until it succeeds or times out
101
+
wait_for() {
102
+
local timeout="${1:-30}"# Default 30 seconds timeout
103
+
local interval="${2:-1}"# Default 1 second between retries
104
+
shift 2 # Remove timeout and interval from args
105
+
local command=("$@") # Remaining args are the command to execute
106
+
107
+
local end_time=$(($(date +%s) + timeout))
108
+
109
+
while [ $(date +%s)-lt$end_time ];do
110
+
if"${command[@]}";then
108
111
return 0
109
112
fi
110
-
local now
111
-
now=$(date +%s)
112
-
if [ $(( now - start_ts ))-ge${timeout} ];then
113
-
echo"Timed out waiting for collection '${collection}' to become queryable">&2
114
-
return 1
115
-
fi
116
-
sleep 3
113
+
sleep "$interval"
117
114
done
118
-
}
119
-
120
-
# Apply the ExtractingRequestHandler via Config API and print error body on failure
121
-
apply_extract_handler() {
122
-
local collection="$1"
123
-
local json="{\"add-requesthandler\":{\"name\":\"/update/extract\",\"class\":\"org.apache.solr.handler.extraction.ExtractingRequestHandler\",\"tikaserver.url\":\"http://localhost:${TIKA_PORT}\",\"defaults\":{\"lowernames\":\"true\",\"captureAttr\":\"true\"}}}"
124
-
local url="http://localhost:${SOLR_PORT}/solr/${collection}/config"
Copy file name to clipboardExpand all lines: solr/packaging/test/test_extraction.bats
+26-10Lines changed: 26 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,25 @@
18
18
19
19
load bats_helper
20
20
21
+
# Apply the ExtractingRequestHandler via Config API and print error body on failure
22
+
apply_extract_handler() {
23
+
local collection="$1"
24
+
local json="{\"add-requesthandler\":{\"name\":\"/update/extract\",\"class\":\"org.apache.solr.handler.extraction.ExtractingRequestHandler\",\"tikaserver.url\":\"http://localhost:${TIKA_PORT}\",\"defaults\":{\"lowernames\":\"true\",\"captureAttr\":\"true\"}}}"
25
+
local url="http://localhost:${SOLR_PORT}/solr/${collection}/config"
0 commit comments