Skip to content

Commit d7a0868

Browse files
committed
More robust marking of cleaning up of resources
1 parent db9a2b6 commit d7a0868

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ protected EsqlSpecTestCase(
126126
}
127127

128128
private static class Protected {
129-
private final Object lock = new Object();
130129
private volatile boolean completed = false;
131130
private volatile boolean started = false;
132131
private volatile Throwable failure = null;
@@ -136,7 +135,7 @@ private void protectedBlock(Callable<Void> callable) {
136135
return;
137136
}
138137
// In case tests get run in parallel, we ensure only one setup is run, and other tests wait for this
139-
synchronized (lock) {
138+
synchronized (this) {
140139
if (completed) {
141140
return;
142141
}
@@ -157,6 +156,12 @@ private void protectedBlock(Callable<Void> callable) {
157156
}
158157
}
159158
}
159+
160+
private synchronized void reset() {
161+
completed = false;
162+
started = false;
163+
failure = null;
164+
}
160165
}
161166

162167
private static final Protected INGEST = new Protected();
@@ -184,15 +189,16 @@ public void setup() {
184189
@AfterClass
185190
public static void wipeTestData() throws IOException {
186191
try {
187-
INGEST.completed = false;
188192
adminClient().performRequest(new Request("DELETE", "/*"));
189193
} catch (ResponseException e) {
190194
// 404 here just means we had no indexes
191195
if (e.getResponse().getStatusLine().getStatusCode() != 404) {
192196
throw e;
193197
}
194198
}
199+
INGEST.reset();
195200
deleteViews(adminClient());
201+
VIEWS.reset();
196202
deleteInferenceEndpoints(adminClient());
197203
}
198204

0 commit comments

Comments
 (0)