Rename prelertresults- to .ml-anomalies (elastic/elasticsearch#607)
Original commit: elastic/x-pack-elasticsearch@ad3bb7c819
This commit is contained in:
parent
6de846d4c6
commit
a47c5332d5
|
@ -9,7 +9,7 @@ package org.elasticsearch.xpack.prelert.job.persistence;
|
|||
* Methods for handling index naming related functions
|
||||
*/
|
||||
public final class AnomalyDetectorsIndex {
|
||||
private static final String RESULTS_INDEX_PREFIX = "prelertresults-";
|
||||
private static final String RESULTS_INDEX_PREFIX = ".ml-anomalies-";
|
||||
private static final String STATE_INDEX_NAME = ".ml-state";
|
||||
|
||||
private AnomalyDetectorsIndex() {
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.elasticsearch.client.Response;
|
|||
import org.elasticsearch.client.ResponseException;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.xpack.prelert.PrelertPlugin;
|
||||
import org.elasticsearch.xpack.prelert.job.persistence.AnomalyDetectorsIndex;
|
||||
import org.junit.After;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -191,7 +192,8 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
response = client().performRequest("get", "_aliases");
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
String responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"prelertresults-" + indexName + "\":{\"aliases\":{\"prelertresults-" + jobId + "\""));
|
||||
assertThat(responseAsString, containsString("\"" + AnomalyDetectorsIndex.jobResultsIndexName(indexName)
|
||||
+ "\":{\"aliases\":{\"" + AnomalyDetectorsIndex.jobResultsIndexName(jobId) + "\""));
|
||||
|
||||
response = client().performRequest("get", "_cat/indices");
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
|
@ -205,7 +207,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":2"));
|
||||
|
||||
response = client().performRequest("get", "prelertresults-" + indexName + "/result/_search");
|
||||
response = client().performRequest("get", AnomalyDetectorsIndex.jobResultsIndexName(indexName) + "/result/_search");
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"total\":2"));
|
||||
|
@ -222,7 +224,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
response = client().performRequest("get", "_aliases");
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, not(containsString("prelertresults-" + jobId )));
|
||||
assertThat(responseAsString, not(containsString(AnomalyDetectorsIndex.jobResultsIndexName(jobId))));
|
||||
|
||||
response = client().performRequest("get", "_cat/indices");
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
|
@ -232,7 +234,8 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
|
||||
private Response addBucketResult(String jobId, String timestamp, long bucketSpan) throws Exception {
|
||||
try {
|
||||
client().performRequest("put", "prelertresults-" + jobId, Collections.emptyMap(), new StringEntity(RESULT_MAPPING));
|
||||
client().performRequest("put", AnomalyDetectorsIndex.jobResultsIndexName(jobId),
|
||||
Collections.emptyMap(), new StringEntity(RESULT_MAPPING));
|
||||
} catch (ResponseException e) {
|
||||
// it is ok: the index already exists
|
||||
assertThat(e.getMessage(), containsString("index_already_exists_exception"));
|
||||
|
@ -244,13 +247,14 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
jobId, timestamp, bucketSpan);
|
||||
String id = String.format(Locale.ROOT,
|
||||
"%s_%s_%s", jobId, timestamp, bucketSpan);
|
||||
return client().performRequest("put", "prelertresults-" + jobId + "/result/" + id,
|
||||
return client().performRequest("put", AnomalyDetectorsIndex.jobResultsIndexName(jobId) + "/result/" + id,
|
||||
Collections.singletonMap("refresh", "true"), new StringEntity(bucketResult));
|
||||
}
|
||||
|
||||
private Response addRecordResult(String jobId, String timestamp, long bucketSpan, int sequenceNum) throws Exception {
|
||||
try {
|
||||
client().performRequest("put", "prelertresults-" + jobId, Collections.emptyMap(), new StringEntity(RESULT_MAPPING));
|
||||
client().performRequest("put", AnomalyDetectorsIndex.jobResultsIndexName(jobId), Collections.emptyMap(),
|
||||
new StringEntity(RESULT_MAPPING));
|
||||
} catch (ResponseException e) {
|
||||
// it is ok: the index already exists
|
||||
assertThat(e.getMessage(), containsString("index_already_exists_exception"));
|
||||
|
@ -261,7 +265,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
String.format(Locale.ROOT,
|
||||
"{\"job_id\":\"%s\", \"timestamp\": \"%s\", \"bucket_span\":%d, \"sequence_num\": %d, \"result_type\":\"record\"}",
|
||||
jobId, timestamp, bucketSpan, sequenceNum);
|
||||
return client().performRequest("put", "prelertresults-" + jobId + "/result/" + timestamp,
|
||||
return client().performRequest("put", AnomalyDetectorsIndex.jobResultsIndexName(jobId) + "/result/" + timestamp,
|
||||
Collections.singletonMap("refresh", "true"), new StringEntity(recordResult));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.junit.Before;
|
|||
import org.mockito.Mockito;
|
||||
|
||||
public class ElasticsearchBatchedDocumentsIteratorTests extends ESTestCase {
|
||||
private static final String INDEX_NAME = "prelertresults-foo";
|
||||
private static final String INDEX_NAME = ".ml-anomalies-foo";
|
||||
private static final String SCROLL_ID = "someScrollId";
|
||||
|
||||
private Client client;
|
||||
|
|
|
@ -37,8 +37,8 @@ public class JobResultsPersisterTests extends ESTestCase {
|
|||
BulkResponse response = mock(BulkResponse.class);
|
||||
String responseId = "abcXZY54321";
|
||||
MockClientBuilder clientBuilder = new MockClientBuilder(CLUSTER_NAME)
|
||||
.prepareIndex("prelertresults-" + JOB_ID, Result.TYPE.getPreferredName(), responseId, captor)
|
||||
.prepareIndex("prelertresults-" + JOB_ID, Result.TYPE.getPreferredName(), "", captor)
|
||||
.prepareIndex(AnomalyDetectorsIndex.jobResultsIndexName(JOB_ID), Result.TYPE.getPreferredName(), responseId, captor)
|
||||
.prepareIndex(AnomalyDetectorsIndex.jobResultsIndexName(JOB_ID), Result.TYPE.getPreferredName(), "", captor)
|
||||
.prepareBulk(response);
|
||||
|
||||
Client client = clientBuilder.build();
|
||||
|
@ -91,7 +91,7 @@ public class JobResultsPersisterTests extends ESTestCase {
|
|||
ArgumentCaptor<XContentBuilder> captor = ArgumentCaptor.forClass(XContentBuilder.class);
|
||||
BulkResponse response = mock(BulkResponse.class);
|
||||
MockClientBuilder clientBuilder = new MockClientBuilder(CLUSTER_NAME)
|
||||
.prepareIndex("prelertresults-" + JOB_ID, Result.TYPE.getPreferredName(), "", captor)
|
||||
.prepareIndex(AnomalyDetectorsIndex.jobResultsIndexName(JOB_ID), Result.TYPE.getPreferredName(), "", captor)
|
||||
.prepareBulk(response);
|
||||
Client client = clientBuilder.build();
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class JobResultsPersisterTests extends ESTestCase {
|
|||
ArgumentCaptor<XContentBuilder> captor = ArgumentCaptor.forClass(XContentBuilder.class);
|
||||
BulkResponse response = mock(BulkResponse.class);
|
||||
MockClientBuilder clientBuilder = new MockClientBuilder(CLUSTER_NAME)
|
||||
.prepareIndex("prelertresults-" + JOB_ID, Result.TYPE.getPreferredName(), "", captor)
|
||||
.prepareIndex(AnomalyDetectorsIndex.jobResultsIndexName(JOB_ID), Result.TYPE.getPreferredName(), "", captor)
|
||||
.prepareBulk(response);
|
||||
Client client = clientBuilder.build();
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class UsagePersisterTests extends ESTestCase {
|
|||
verify(updateRequestBuilder, times(2)).setRetryOnConflict(ElasticsearchScripts.UPDATE_JOB_RETRY_COUNT);
|
||||
verify(updateRequestBuilder, times(2)).get();
|
||||
|
||||
assertEquals(Arrays.asList("prelert-usage", "prelertresults-job1"), indexCaptor.getAllValues());
|
||||
assertEquals(Arrays.asList("prelert-usage", AnomalyDetectorsIndex.jobResultsIndexName("job1")), indexCaptor.getAllValues());
|
||||
assertEquals(2, idCaptor.getAllValues().size());
|
||||
String id = idCaptor.getValue();
|
||||
assertEquals(id, idCaptor.getAllValues().get(0));
|
||||
|
@ -62,7 +62,7 @@ public class UsagePersisterTests extends ESTestCase {
|
|||
String timestamp = id.substring("usage-".length());
|
||||
|
||||
assertEquals("prelert-usage", indexCaptor.getAllValues().get(0));
|
||||
assertEquals("prelertresults-job1", indexCaptor.getAllValues().get(1));
|
||||
assertEquals(AnomalyDetectorsIndex.jobResultsIndexName("job1"), indexCaptor.getAllValues().get(1));
|
||||
|
||||
Script script = updateScriptCaptor.getValue();
|
||||
assertEquals("ctx._source.inputBytes += params.bytes;ctx._source.inputFieldCount += params.fieldCount;ctx._source.inputRecordCount"
|
||||
|
|
|
@ -26,7 +26,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: model_snapshot
|
||||
id: "foo1"
|
||||
body: >
|
||||
|
@ -63,7 +63,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: model_snapshot
|
||||
id: "foo2"
|
||||
body: >
|
||||
|
@ -83,7 +83,7 @@ setup:
|
|||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
|
||||
---
|
||||
"Test delete snapshot missing snapshotId":
|
||||
|
@ -121,7 +121,7 @@ setup:
|
|||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
|
||||
- do:
|
||||
indices.refresh:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
body:
|
||||
mappings:
|
||||
model_snapshot:
|
||||
|
@ -13,21 +13,21 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: model_snapshot
|
||||
id: "1"
|
||||
body: { "job_id": "foo", "timestamp": "2016-06-02T00:00:00Z", "restore_priority": "1" }
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: model_snapshot
|
||||
id: "2"
|
||||
body: { "job_id": "foo", "timestamp": "2016-06-01T00:00:00Z", "restore_priority": "2" }
|
||||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
|
||||
---
|
||||
"Test get model snapshots API with no params":
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
- do:
|
||||
indices.get:
|
||||
index: "prelertresults-farequote"
|
||||
index: ".ml-anomalies-farequote"
|
||||
|
||||
- do:
|
||||
indices.get:
|
||||
|
@ -39,7 +39,7 @@
|
|||
|
||||
- do:
|
||||
indices.exists:
|
||||
index: "prelertresults-farequote"
|
||||
index: ".ml-anomalies-farequote"
|
||||
- is_false: ''
|
||||
|
||||
---
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
body:
|
||||
mappings:
|
||||
results:
|
||||
|
@ -15,21 +15,21 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
type: result
|
||||
id: "farequote_1464739200000_1"
|
||||
body: { "job_id": "farequote", "result_type": "bucket", "timestamp": "2016-06-01T00:00:00Z", "bucket_span":1 }
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
type: result
|
||||
id: "farequote_1464739200000_2"
|
||||
body: { "job_id": "farequote", "result_type": "bucket", "timestamp": "2016-08-01T00:00:00Z", "bucket_span":1 }
|
||||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
|
||||
---
|
||||
"Test result buckets api with time range":
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
setup:
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
type: category_definition
|
||||
id: 1
|
||||
body: { "job_id": "farequote", "category_id": 1 }
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
type: category_definition
|
||||
id: 2
|
||||
body: { "job_id": "farequote", "category_id": 2 }
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-unrelated
|
||||
index: .ml-anomalies-unrelated
|
||||
type: category_definition
|
||||
id: 3
|
||||
body: { "job_id": "unrelated", "category_id": 1 }
|
||||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
|
||||
---
|
||||
"Test result categories api":
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
body:
|
||||
mappings:
|
||||
result:
|
||||
|
@ -16,7 +16,7 @@ setup:
|
|||
type: keyword
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
type: result
|
||||
id: farequote_1464739200000_1_1
|
||||
body:
|
||||
|
@ -33,7 +33,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
type: result
|
||||
id: farequote_1464825600000_1_2
|
||||
body:
|
||||
|
@ -49,7 +49,7 @@ setup:
|
|||
}
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
|
||||
---
|
||||
"Test result influencers api":
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
body:
|
||||
mappings:
|
||||
record:
|
||||
|
@ -29,7 +29,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
type: result
|
||||
id: farequote_1464739200000_1_1
|
||||
body:
|
||||
|
@ -44,7 +44,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
type: result
|
||||
id: farequote_1464825600000_1_2
|
||||
body:
|
||||
|
@ -59,7 +59,7 @@ setup:
|
|||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
|
||||
---
|
||||
"Test result records api":
|
||||
|
|
|
@ -52,7 +52,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-job-stats-test
|
||||
index: .ml-anomalies-job-stats-test
|
||||
type: result
|
||||
id: model_size_stats
|
||||
body: {
|
||||
|
|
|
@ -56,7 +56,7 @@ setup:
|
|||
|
||||
- do:
|
||||
get:
|
||||
index: prelertresults-farequote
|
||||
index: .ml-anomalies-farequote
|
||||
type: data_counts
|
||||
id: farequote-data-counts
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
body:
|
||||
mappings:
|
||||
model_snapshot:
|
||||
|
@ -13,7 +13,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: model_snapshot
|
||||
id: "1"
|
||||
body: >
|
||||
|
@ -26,7 +26,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: model_snapshot
|
||||
id: "2"
|
||||
body: >
|
||||
|
@ -40,7 +40,7 @@ setup:
|
|||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
|
||||
---
|
||||
"Test without description":
|
||||
|
@ -78,7 +78,7 @@ setup:
|
|||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
|
||||
- do:
|
||||
xpack.prelert.get_model_snapshots:
|
||||
|
|
|
@ -26,7 +26,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: model_snapshot
|
||||
id: "1"
|
||||
body: >
|
||||
|
@ -42,7 +42,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: model_snapshot
|
||||
id: "2"
|
||||
body: >
|
||||
|
@ -58,42 +58,42 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: result
|
||||
id: "foo_1464825600000_1"
|
||||
body: { "job_id": "foo", "result_type": "bucket", "timestamp": "2016-06-02T00:00:00Z", "bucket_span":1 }
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: result
|
||||
id: "foo_1464782400000_1"
|
||||
body: { "job_id": "foo", "result_type": "bucket", "timestamp": "2016-06-01T12:00:00Z", "bucket_span":1 }
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: result
|
||||
id: "foo_1462060800000_1"
|
||||
body: { "job_id": "foo", "result_type": "bucket", "timestamp": "2016-05-01T00:00:00Z", "bucket_span":1 }
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: result
|
||||
id: "foo_1464825600000_1_1"
|
||||
body: { "job_id": "foo", "result_type": "record", "timestamp": "2016-06-02T00:00:00Z", "bucket_span":1, "sequence_num":1 }
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: result
|
||||
id: "foo_1462060800000_1_2"
|
||||
body: { "job_id": "foo", "result_type": "record", "timestamp": "2016-05-01T00:00:00Z", "bucket_span":1, "sequence_num":2 }
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: result
|
||||
id: "foo_1464825600000_1_3"
|
||||
body: {
|
||||
|
@ -109,7 +109,7 @@ setup:
|
|||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
type: result
|
||||
id: "foo_1462060800000_1_4"
|
||||
body:
|
||||
|
@ -126,7 +126,7 @@ setup:
|
|||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
|
||||
- do:
|
||||
indices.refresh:
|
||||
|
@ -258,7 +258,7 @@ setup:
|
|||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: prelertresults-foo
|
||||
index: .ml-anomalies-foo
|
||||
|
||||
- do:
|
||||
xpack.prelert.get_buckets:
|
||||
|
|
Loading…
Reference in New Issue