File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
tests/integration/tools/mongodb/search Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -106,20 +106,22 @@ describeWithMongoDB(
106
106
const SEARCH_RETRIES = 10_000 ;
107
107
async function waitUntilSearchIsReady ( provider : NodeDriverServiceProvider , abortSignal : AbortSignal ) : Promise < void > {
108
108
let success = true ;
109
+ let lastError : unknown = false ;
110
+
109
111
for ( let i = 0 ; i < SEARCH_RETRIES && ! abortSignal . aborted ; i ++ ) {
110
112
try {
111
113
await provider . insertOne ( "tmp" , "test" , { field1 : "yay" } ) ;
112
114
await provider . createSearchIndexes ( "tmp" , "test" , [ { definition : { mappings : { dynamic : true } } } ] ) ;
113
115
success = true ;
114
116
break ;
115
117
} catch ( err ) {
116
- void err ;
118
+ lastError = err ;
117
119
await sleep ( 100 ) ;
118
120
}
119
121
}
120
122
121
123
if ( ! success ) {
122
- throw new Error ( " Search Management Index is not ready." ) ;
124
+ throw new Error ( ` Search Management Index is not ready.\nlastError: ${ lastError } ` ) ;
123
125
}
124
126
}
125
127
@@ -131,20 +133,27 @@ async function waitUntilIndexIsQueryable(
131
133
abortSignal : AbortSignal
132
134
) : Promise < void > {
133
135
let success = false ;
136
+ let lastIndexStatus : unknown = false ;
137
+ let lastError : unknown = false ;
138
+
134
139
for ( let i = 0 ; i < SEARCH_RETRIES && ! abortSignal . aborted ; i ++ ) {
135
140
try {
136
141
const [ indexStatus ] = await provider . getSearchIndexes ( database , collection , indexName ) ;
142
+ lastIndexStatus = indexStatus ;
143
+
137
144
if ( indexStatus ?. queryable === true ) {
138
145
success = true ;
139
146
break ;
140
147
}
141
148
} catch ( err ) {
142
- void err ;
149
+ lastError = err ;
143
150
await sleep ( 100 ) ;
144
151
}
145
152
}
146
153
147
154
if ( ! success ) {
148
- throw new Error ( `Index ${ indexName } in ${ database } .${ collection } is not ready.` ) ;
155
+ throw new Error (
156
+ `Index ${ indexName } in ${ database } .${ collection } is not ready: \nlastIndexStatus: ${ lastIndexStatus } \nlastError: ${ lastError } `
157
+ ) ;
149
158
}
150
159
}
You can’t perform that action at this time.
0 commit comments