Delete indices after each test

This commit is contained in:
Andrea Cavalli 2021-11-30 23:21:24 +01:00
parent 041804eb1f
commit da55d49316
2 changed files with 8 additions and 3 deletions

View File

@ -1,8 +1,8 @@
package io.volvox.chats;
import io.quarkus.test.junit.NativeImageTest;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@NativeImageTest
@QuarkusIntegrationTest
public class ChatsEndpointTestIT extends ChatsEndpointTest {
// Execute the same tests but in native mode.

View File

@ -7,6 +7,7 @@ import io.vertx.core.json.JsonObject;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.update.UpdateRequest;
@ -34,8 +35,12 @@ public class ChatsServiceWarmup {
}
private void createIndices() {
var req = new CreateIndexRequest("chats");
try {
var req = new DeleteIndexRequest("chats");
restHighLevelClient.indices().deleteAsyncAndAwait(req, RequestOptions.DEFAULT);
} catch (ElasticsearchStatusException ignored) {}
try {
var req = new CreateIndexRequest("chats");
restHighLevelClient.indices().createAsyncAndAwait(req, RequestOptions.DEFAULT);
} catch (ElasticsearchStatusException ex) {
if (ex.status() != RestStatus.BAD_REQUEST) {