|
@@ -12,12 +12,8 @@ import org.apache.http.HttpHost;
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
import org.apache.lucene.util.TimeUnits;
|
|
import org.apache.lucene.util.TimeUnits;
|
|
|
-import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
|
|
|
|
|
-import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
|
|
|
|
|
import org.elasticsearch.client.HttpAsyncResponseConsumerFactory;
|
|
import org.elasticsearch.client.HttpAsyncResponseConsumerFactory;
|
|
|
-import org.elasticsearch.client.Request;
|
|
|
|
|
import org.elasticsearch.client.RequestOptions;
|
|
import org.elasticsearch.client.RequestOptions;
|
|
|
-import org.elasticsearch.client.ResponseException;
|
|
|
|
|
import org.elasticsearch.client.RestClient;
|
|
import org.elasticsearch.client.RestClient;
|
|
|
import org.elasticsearch.client.RestClientBuilder;
|
|
import org.elasticsearch.client.RestClientBuilder;
|
|
|
import org.elasticsearch.client.RestHighLevelClient;
|
|
import org.elasticsearch.client.RestHighLevelClient;
|
|
@@ -47,7 +43,6 @@ public class EsEQLCorrectnessIT extends ESRestTestCase {
|
|
|
|
|
|
|
|
private static final String PARAM_FORMATTING = "%1$s";
|
|
private static final String PARAM_FORMATTING = "%1$s";
|
|
|
private static final String QUERIES_FILENAME = "queries.toml";
|
|
private static final String QUERIES_FILENAME = "queries.toml";
|
|
|
- private static final String PROPERTIES_FILENAME = "config.properties";
|
|
|
|
|
|
|
|
|
|
private static Properties CFG;
|
|
private static Properties CFG;
|
|
|
private static RestHighLevelClient highLevelClient;
|
|
private static RestHighLevelClient highLevelClient;
|
|
@@ -58,10 +53,7 @@ public class EsEQLCorrectnessIT extends ESRestTestCase {
|
|
|
|
|
|
|
|
@BeforeClass
|
|
@BeforeClass
|
|
|
public static void init() throws IOException {
|
|
public static void init() throws IOException {
|
|
|
- try (InputStream is = EsEQLCorrectnessIT.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME)) {
|
|
|
|
|
- CFG = new Properties();
|
|
|
|
|
- CFG.load(is);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ CFG = EqlDataLoader.loadConfiguration();
|
|
|
|
|
|
|
|
RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
|
|
RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
|
|
|
builder.setHttpAsyncResponseConsumerFactory(
|
|
builder.setHttpAsyncResponseConsumerFactory(
|
|
@@ -72,27 +64,7 @@ public class EsEQLCorrectnessIT extends ESRestTestCase {
|
|
|
|
|
|
|
|
@Before
|
|
@Before
|
|
|
public void restoreDataFromGcsRepo() throws Exception {
|
|
public void restoreDataFromGcsRepo() throws Exception {
|
|
|
- if (client().performRequest(new Request("HEAD", "/" + CFG.getProperty("index_name"))).getStatusLine().getStatusCode() == 404) {
|
|
|
|
|
- highLevelClient().snapshot()
|
|
|
|
|
- .createRepository(
|
|
|
|
|
- new PutRepositoryRequest(CFG.getProperty("gcs_repo_name")).type("gcs")
|
|
|
|
|
- .settings(
|
|
|
|
|
- Settings.builder()
|
|
|
|
|
- .put("bucket", CFG.getProperty("gcs_bucket_name"))
|
|
|
|
|
- .put("base_path", CFG.getProperty("gcs_base_path"))
|
|
|
|
|
- .put("client", CFG.getProperty("gcs_client_name"))
|
|
|
|
|
- .build()
|
|
|
|
|
- ),
|
|
|
|
|
- RequestOptions.DEFAULT
|
|
|
|
|
- );
|
|
|
|
|
- highLevelClient().snapshot()
|
|
|
|
|
- .restore(
|
|
|
|
|
- new RestoreSnapshotRequest(CFG.getProperty("gcs_repo_name"), CFG.getProperty("gcs_snapshot_name")).waitForCompletion(
|
|
|
|
|
- true
|
|
|
|
|
- ),
|
|
|
|
|
- RequestOptions.DEFAULT
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ EqlDataLoader.restoreSnapshot(highLevelClient(), CFG);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@After
|
|
@After
|
|
@@ -105,18 +77,6 @@ public class EsEQLCorrectnessIT extends ESRestTestCase {
|
|
|
LOGGER.info("Total time: {} ms", totalTime);
|
|
LOGGER.info("Total time: {} ms", totalTime);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @AfterClass
|
|
|
|
|
- public static void wipeTestData() throws IOException {
|
|
|
|
|
- try {
|
|
|
|
|
- adminClient().performRequest(new Request("DELETE", "/*"));
|
|
|
|
|
- } catch (ResponseException e) {
|
|
|
|
|
- // 404 here just means we had no indexes
|
|
|
|
|
- if (e.getResponse().getStatusLine().getStatusCode() != 404) {
|
|
|
|
|
- throw e;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected boolean preserveClusterUponCompletion() {
|
|
protected boolean preserveClusterUponCompletion() {
|
|
|
// Need to preserve data between parameterized tests runs
|
|
// Need to preserve data between parameterized tests runs
|