[7.x] Rename .ml-state index to .ml-state-000001 to support rollover (#52510) (#52595)

This commit is contained in:
Przemysław Witek 2020-02-21 08:55:59 +01:00 committed by GitHub
parent 1d895118dd
commit b84e8db7b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 143 additions and 70 deletions

View File

@ -23,6 +23,8 @@ import org.elasticsearch.xpack.core.template.TemplateUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.regex.Pattern;
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN; import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin; import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
@ -37,6 +39,29 @@ public final class AnomalyDetectorsIndex {
private static final String RESULTS_MAPPINGS_VERSION_VARIABLE = "xpack.ml.version"; private static final String RESULTS_MAPPINGS_VERSION_VARIABLE = "xpack.ml.version";
private static final String RESOURCE_PATH = "/org/elasticsearch/xpack/core/ml/anomalydetection/"; private static final String RESOURCE_PATH = "/org/elasticsearch/xpack/core/ml/anomalydetection/";
// Visible for testing
static final Comparator<String> STATE_INDEX_NAME_COMPARATOR = new Comparator<String>() {
private final Pattern HAS_SIX_DIGIT_SUFFIX = Pattern.compile("\\d{6}");
@Override
public int compare(String index1, String index2) {
String[] index1Parts = index1.split("-");
String index1Suffix = index1Parts[index1Parts.length - 1];
boolean index1HasSixDigitsSuffix = HAS_SIX_DIGIT_SUFFIX.matcher(index1Suffix).matches();
String[] index2Parts = index2.split("-");
String index2Suffix = index2Parts[index2Parts.length - 1];
boolean index2HasSixDigitsSuffix = HAS_SIX_DIGIT_SUFFIX.matcher(index2Suffix).matches();
if (index1HasSixDigitsSuffix && index2HasSixDigitsSuffix) {
return index1Suffix.compareTo(index2Suffix);
} else if (index1HasSixDigitsSuffix != index2HasSixDigitsSuffix) {
return Boolean.compare(index1HasSixDigitsSuffix, index2HasSixDigitsSuffix);
} else {
return index1.compareTo(index2);
}
}
};
private AnomalyDetectorsIndex() { private AnomalyDetectorsIndex() {
} }
@ -90,8 +115,8 @@ public final class AnomalyDetectorsIndex {
} }
/** /**
* Create the .ml-state index (if necessary) * Creates the .ml-state-000001 index (if necessary)
* Create the .ml-state-write alias for the .ml-state index (if necessary) * Creates the .ml-state-write alias for the .ml-state-000001 index (if necessary)
*/ */
public static void createStateIndexAndAliasIfNecessary(Client client, ClusterState state, final ActionListener<Boolean> finalListener) { public static void createStateIndexAndAliasIfNecessary(Client client, ClusterState state, final ActionListener<Boolean> finalListener) {
@ -123,12 +148,14 @@ public final class AnomalyDetectorsIndex {
IndicesOptions.lenientExpandOpen(), IndicesOptions.lenientExpandOpen(),
jobStateIndexPattern()); jobStateIndexPattern());
if (stateIndices.length > 0) { if (stateIndices.length > 0) {
Arrays.sort(stateIndices, Collections.reverseOrder()); String latestStateIndex = Arrays.stream(stateIndices).max(STATE_INDEX_NAME_COMPARATOR).get();
createAliasListener.onResponse(stateIndices[0]); createAliasListener.onResponse(latestStateIndex);
} else { } else {
// The initial index name must be suitable for rollover functionality.
String initialJobStateIndex = AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX + "-000001";
CreateIndexRequest createIndexRequest = client.admin() CreateIndexRequest createIndexRequest = client.admin()
.indices() .indices()
.prepareCreate(AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX) .prepareCreate(initialJobStateIndex)
.addAlias(new Alias(jobStateIndexWriteAlias())) .addAlias(new Alias(jobStateIndexWriteAlias()))
.request(); .request();
executeAsyncWithOrigin(client.threadPool().getThreadContext(), executeAsyncWithOrigin(client.threadPool().getThreadContext(),
@ -141,7 +168,7 @@ public final class AnomalyDetectorsIndex {
// Adding an alias that already exists is idempotent. So, no need to double check if the alias exists // Adding an alias that already exists is idempotent. So, no need to double check if the alias exists
// as well. // as well.
if (ExceptionsHelper.unwrapCause(createIndexFailure) instanceof ResourceAlreadyExistsException) { if (ExceptionsHelper.unwrapCause(createIndexFailure) instanceof ResourceAlreadyExistsException) {
createAliasListener.onResponse(AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX); createAliasListener.onResponse(initialJobStateIndex);
} else { } else {
finalListener.onFailure(createIndexFailure); finalListener.onFailure(createIndexFailure);
} }

View File

@ -38,9 +38,11 @@ import org.mockito.stubbing.Answer;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toMap;
import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.contains;
@ -55,7 +57,8 @@ import static org.mockito.Mockito.when;
public class AnomalyDetectorsIndexTests extends ESTestCase { public class AnomalyDetectorsIndexTests extends ESTestCase {
private static final String ML_STATE = ".ml-state"; private static final String LEGACY_ML_STATE = ".ml-state";
private static final String INITIAL_ML_STATE = ".ml-state-000001";
private static final String ML_STATE_WRITE_ALIAS = ".ml-state-write"; private static final String ML_STATE_WRITE_ALIAS = ".ml-state-write";
private ThreadPool threadPool; private ThreadPool threadPool;
@ -73,9 +76,9 @@ public class AnomalyDetectorsIndexTests extends ESTestCase {
when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY)); when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY));
indicesAdminClient = mock(IndicesAdminClient.class); indicesAdminClient = mock(IndicesAdminClient.class);
when(indicesAdminClient.prepareCreate(ML_STATE)) when(indicesAdminClient.prepareCreate(INITIAL_ML_STATE))
.thenReturn(new CreateIndexRequestBuilder(client, CreateIndexAction.INSTANCE, ML_STATE)); .thenReturn(new CreateIndexRequestBuilder(client, CreateIndexAction.INSTANCE, INITIAL_ML_STATE));
doAnswer(withResponse(new CreateIndexResponse(true, true, ML_STATE))).when(indicesAdminClient).create(any(), any()); doAnswer(withResponse(new CreateIndexResponse(true, true, INITIAL_ML_STATE))).when(indicesAdminClient).create(any(), any());
when(indicesAdminClient.prepareAliases()).thenReturn(new IndicesAliasesRequestBuilder(client, IndicesAliasesAction.INSTANCE)); when(indicesAdminClient.prepareAliases()).thenReturn(new IndicesAliasesRequestBuilder(client, IndicesAliasesAction.INSTANCE));
doAnswer(withResponse(new AcknowledgedResponse(true))).when(indicesAdminClient).aliases(any(), any()); doAnswer(withResponse(new AcknowledgedResponse(true))).when(indicesAdminClient).aliases(any(), any());
@ -102,12 +105,12 @@ public class AnomalyDetectorsIndexTests extends ESTestCase {
AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, finalListener); AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, finalListener);
InOrder inOrder = inOrder(indicesAdminClient, finalListener); InOrder inOrder = inOrder(indicesAdminClient, finalListener);
inOrder.verify(indicesAdminClient).prepareCreate(ML_STATE); inOrder.verify(indicesAdminClient).prepareCreate(INITIAL_ML_STATE);
inOrder.verify(indicesAdminClient).create(createRequestCaptor.capture(), any()); inOrder.verify(indicesAdminClient).create(createRequestCaptor.capture(), any());
inOrder.verify(finalListener).onResponse(true); inOrder.verify(finalListener).onResponse(true);
CreateIndexRequest createRequest = createRequestCaptor.getValue(); CreateIndexRequest createRequest = createRequestCaptor.getValue();
assertThat(createRequest.index(), equalTo(ML_STATE)); assertThat(createRequest.index(), equalTo(INITIAL_ML_STATE));
assertThat(createRequest.aliases(), equalTo(Collections.singleton(new Alias(ML_STATE_WRITE_ALIAS)))); assertThat(createRequest.aliases(), equalTo(Collections.singleton(new Alias(ML_STATE_WRITE_ALIAS))));
} }
@ -118,8 +121,12 @@ public class AnomalyDetectorsIndexTests extends ESTestCase {
verify(finalListener).onResponse(false); verify(finalListener).onResponse(false);
} }
public void testCreateStateIndexAndAliasIfNecessary_WriteAliasAlreadyExistsAndPointsAtLegacyStateIndex() {
assertNoClientInteractionsWhenWriteAliasAlreadyExists(LEGACY_ML_STATE);
}
public void testCreateStateIndexAndAliasIfNecessary_WriteAliasAlreadyExistsAndPointsAtInitialStateIndex() { public void testCreateStateIndexAndAliasIfNecessary_WriteAliasAlreadyExistsAndPointsAtInitialStateIndex() {
assertNoClientInteractionsWhenWriteAliasAlreadyExists(".ml-state-000001"); assertNoClientInteractionsWhenWriteAliasAlreadyExists(INITIAL_ML_STATE);
} }
public void testCreateStateIndexAndAliasIfNecessary_WriteAliasAlreadyExistsAndPointsAtSubsequentStateIndex() { public void testCreateStateIndexAndAliasIfNecessary_WriteAliasAlreadyExistsAndPointsAtSubsequentStateIndex() {
@ -147,9 +154,14 @@ public class AnomalyDetectorsIndexTests extends ESTestCase {
contains(AliasActions.add().alias(ML_STATE_WRITE_ALIAS).index(expectedWriteIndexName))); contains(AliasActions.add().alias(ML_STATE_WRITE_ALIAS).index(expectedWriteIndexName)));
} }
public void testCreateStateIndexAndAliasIfNecessary_WriteAliasDoesNotExistButLegacyStateIndexExists() {
assertMlStateWriteAliasAddedToMostRecentMlStateIndex(
Arrays.asList(LEGACY_ML_STATE), LEGACY_ML_STATE);
}
public void testCreateStateIndexAndAliasIfNecessary_WriteAliasDoesNotExistButInitialStateIndexExists() { public void testCreateStateIndexAndAliasIfNecessary_WriteAliasDoesNotExistButInitialStateIndexExists() {
assertMlStateWriteAliasAddedToMostRecentMlStateIndex( assertMlStateWriteAliasAddedToMostRecentMlStateIndex(
Arrays.asList(".ml-state-000001"), ".ml-state-000001"); Arrays.asList(INITIAL_ML_STATE), INITIAL_ML_STATE);
} }
public void testCreateStateIndexAndAliasIfNecessary_WriteAliasDoesNotExistButSubsequentStateIndicesExist() { public void testCreateStateIndexAndAliasIfNecessary_WriteAliasDoesNotExistButSubsequentStateIndicesExist() {
@ -159,7 +171,32 @@ public class AnomalyDetectorsIndexTests extends ESTestCase {
public void testCreateStateIndexAndAliasIfNecessary_WriteAliasDoesNotExistButBothLegacyAndNewStateIndicesDoExist() { public void testCreateStateIndexAndAliasIfNecessary_WriteAliasDoesNotExistButBothLegacyAndNewStateIndicesDoExist() {
assertMlStateWriteAliasAddedToMostRecentMlStateIndex( assertMlStateWriteAliasAddedToMostRecentMlStateIndex(
Arrays.asList(ML_STATE, ".ml-state-000003", ".ml-state-000040", ".ml-state-000500"), ".ml-state-000500"); Arrays.asList(LEGACY_ML_STATE, ".ml-state-000003", ".ml-state-000040", ".ml-state-000500"), ".ml-state-000500");
}
public void testStateIndexNameComparator() {
Comparator<String> comparator = AnomalyDetectorsIndex.STATE_INDEX_NAME_COMPARATOR;
assertThat(
Stream.of(".ml-state-000001").max(comparator).get(),
equalTo(".ml-state-000001"));
assertThat(
Stream.of(".ml-state-000002", ".ml-state-000001").max(comparator).get(),
equalTo(".ml-state-000002"));
assertThat(
Stream.of(".ml-state-000003", ".ml-state-000040", ".ml-state-000500").max(comparator).get(),
equalTo(".ml-state-000500"));
assertThat(
Stream.of(".ml-state-000042", ".ml-state-000049", ".ml-state-000038").max(comparator).get(),
equalTo(".ml-state-000049"));
assertThat(
Stream.of(".ml-state", ".ml-state-000003", ".ml-state-000040", ".ml-state-000500").max(comparator).get(),
equalTo(".ml-state-000500"));
assertThat(
Stream.of(".reindexed-6-ml-state", ".ml-state-000042").max(comparator).get(),
equalTo(".ml-state-000042"));
assertThat(
Stream.of(".a-000002", ".b-000001").max(comparator).get(),
equalTo(".a-000002"));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -480,7 +480,7 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
// Now calling the _delete_expired_data API should remove unused state // Now calling the _delete_expired_data API should remove unused state
assertThat(deleteExpiredData().isDeleted(), is(true)); assertThat(deleteExpiredData().isDeleted(), is(true));
SearchResponse stateIndexSearchResponse = client().prepareSearch(".ml-state").execute().actionGet(); SearchResponse stateIndexSearchResponse = client().prepareSearch(".ml-state*").execute().actionGet();
assertThat(stateIndexSearchResponse.getHits().getTotalHits().value, equalTo(0L)); assertThat(stateIndexSearchResponse.getHits().getTotalHits().value, equalTo(0L));
} }

View File

@ -331,7 +331,7 @@ public class RegressionIT extends MlNativeDataFrameAnalyticsIntegTestCase {
// Now calling the _delete_expired_data API should remove unused state // Now calling the _delete_expired_data API should remove unused state
assertThat(deleteExpiredData().isDeleted(), is(true)); assertThat(deleteExpiredData().isDeleted(), is(true));
SearchResponse stateIndexSearchResponse = client().prepareSearch(".ml-state").execute().actionGet(); SearchResponse stateIndexSearchResponse = client().prepareSearch(".ml-state*").execute().actionGet();
assertThat(stateIndexSearchResponse.getHits().getTotalHits().value, equalTo(0L)); assertThat(stateIndexSearchResponse.getHits().getTotalHits().value, equalTo(0L));
} }

View File

@ -156,7 +156,7 @@ public class RevertModelSnapshotIT extends MlNativeAutodetectIntegTestCase {
} }
private Quantiles getQuantiles(String jobId) { private Quantiles getQuantiles(String jobId) {
SearchResponse response = client().prepareSearch(".ml-state") SearchResponse response = client().prepareSearch(".ml-state*")
.setQuery(QueryBuilders.idsQuery().addIds(Quantiles.documentId(jobId))) .setQuery(QueryBuilders.idsQuery().addIds(Quantiles.documentId(jobId)))
.setSize(1) .setSize(1)
.get(); .get();

View File

@ -8,7 +8,6 @@ package org.elasticsearch.xpack.ml.action;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.cluster.routing.IndexRoutingTable;
@ -22,7 +21,6 @@ import org.elasticsearch.index.Index;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex; import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex;
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndexFields;
import java.util.List; import java.util.List;
@ -45,9 +43,6 @@ public class TransportStartDataFrameAnalyticsActionTests extends ESTestCase {
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
); );
if (indexName.equals(AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX)) {
indexMetaData.putAlias(new AliasMetaData.Builder(AnomalyDetectorsIndex.jobStateIndexWriteAlias()));
}
metaData.put(indexMetaData); metaData.put(indexMetaData);
Index index = new Index(indexName, "_uuid"); Index index = new Index(indexName, "_uuid");
ShardId shardId = new ShardId(index, 0); ShardId shardId = new ShardId(index, 0);

View File

@ -960,7 +960,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "delete_foo_regression_state#1" id: "delete_foo_regression_state#1"
body: > body: >
{ {
@ -970,7 +970,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "data_frame_analytics-delete_foo-progress" id: "data_frame_analytics-delete_foo-progress"
body: > body: >
{ {
@ -980,11 +980,11 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: .ml-state index: .ml-state*
- do: - do:
search: search:
index: .ml-state index: .ml-state*
body: body:
size: 0 size: 0
query: query:

View File

@ -55,7 +55,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "delete-model-snapshot_model_state_inactive-snapshot#1" id: "delete-model-snapshot_model_state_inactive-snapshot#1"
body: > body: >
{ {
@ -66,7 +66,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "delete-model-snapshot_model_state_inactive-snapshot#2" id: "delete-model-snapshot_model_state_inactive-snapshot#2"
body: > body: >
{ {
@ -118,7 +118,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: .ml-state index: .ml-state*
- do: - do:
headers: headers:
@ -159,7 +159,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: { count: 3 } - match: { count: 3 }
@ -179,7 +179,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: .ml-state index: .ml-state*
- do: - do:
ml.get_model_snapshots: ml.get_model_snapshots:
@ -191,7 +191,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: { count: 1 } - match: { count: 1 }

View File

@ -37,7 +37,7 @@ setup:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
Content-Type: application/json Content-Type: application/json
index: index:
index: .ml-state index: .ml-state-000001
id: "get-model-snapshots_model_state_1#1" id: "get-model-snapshots_model_state_1#1"
body: > body: >
{ {
@ -62,7 +62,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "get-model-snapshots_model_state_2#1" id: "get-model-snapshots_model_state_2#1"
body: > body: >
{ {
@ -72,7 +72,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "get-model-snapshots_model_state_2#2" id: "get-model-snapshots_model_state_2#2"
body: > body: >
{ {
@ -82,7 +82,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: [.ml-anomalies-get-model-snapshots,.ml-state] index: [.ml-anomalies-get-model-snapshots,.ml-state*]
--- ---
"Test get model snapshots API with no params": "Test get model snapshots API with no params":

View File

@ -97,7 +97,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.exists: indices.exists:
index: ".ml-state" index: ".ml-state-000001"
- is_true: '' - is_true: ''
- do: - do:
@ -117,7 +117,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- gt: {count: 0} - gt: {count: 0}
- do: - do:
@ -186,7 +186,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: index-layout-job2_categorizer_state#1 id: index-layout-job2_categorizer_state#1
body: body:
key: value key: value
@ -195,7 +195,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: index-layout-job2_categorizer_state#2 id: index-layout-job2_categorizer_state#2
body: body:
key: value key: value
@ -216,7 +216,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: {count: 4} - match: {count: 4}
- do: - do:
@ -298,28 +298,28 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: {count: 0} - match: {count: 0}
- do: - do:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: {count: 0} - match: {count: 0}
- do: - do:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: {count: 0} - match: {count: 0}
- do: - do:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: {count: 0} - match: {count: 0}
- do: - do:
@ -436,7 +436,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.exists: indices.exists:
index: ".ml-state" index: ".ml-state-000001"
- is_true: '' - is_true: ''
- do: - do:
@ -450,7 +450,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: {count: 0} - match: {count: 0}
- do: - do:
@ -505,7 +505,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: index-layout-quantiles-job_quantiles id: index-layout-quantiles-job_quantiles
body: body:
state: quantile-state state: quantile-state
@ -525,7 +525,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: {count: 0} - match: {count: 0}
--- ---
@ -571,7 +571,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: index-layout-state-job_model_state_123#1 id: index-layout-state-job_model_state_123#1
body: body:
state: new-model-state state: new-model-state
@ -580,7 +580,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: index-layout-state-job_model_state_123#2 id: index-layout-state-job_model_state_123#2
body: body:
state: more-new-model-state state: more-new-model-state
@ -589,7 +589,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: index-layout-state-job_categorizer_state#1 id: index-layout-state-job_categorizer_state#1
body: body:
state: new-categorizer-state state: new-categorizer-state
@ -598,7 +598,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: index-layout-state-job_categorizer_state#2 id: index-layout-state-job_categorizer_state#2
body: body:
state: more-new-categorizer-state state: more-new-categorizer-state
@ -625,7 +625,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: {count: 0} - match: {count: 0}
--- ---
@ -635,7 +635,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.create: indices.create:
index: .ml-state index: .ml-state-000001
- do: - do:
ml.put_job: ml.put_job:
@ -678,7 +678,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.exists: indices.exists:
index: ".ml-state" index: ".ml-state-000001"
- is_true: '' - is_true: ''
- do: - do:
@ -691,6 +691,6 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
count: count:
index: .ml-state index: .ml-state*
- match: {count: 0} - match: {count: 0}

View File

@ -921,7 +921,7 @@
- do: - do:
index: index:
index: .ml-state index: .ml-state-000001
id: jobs-crud-existing-docs_categorizer_state#1 id: jobs-crud-existing-docs_categorizer_state#1
body: body:
key: value key: value
@ -949,7 +949,7 @@
- do: - do:
index: index:
index: .ml-state index: .ml-state-000001
id: jobs-crud-existing-docs_quantiles id: jobs-crud-existing-docs_quantiles
body: body:
key: value key: value
@ -1130,14 +1130,14 @@
- do: - do:
indices.create: indices.create:
index: ".ml-state" index: ".ml-state-000001"
- do: - do:
indices.close: indices.close:
index: ".ml-state" index: ".ml-state-000001"
- do: - do:
catch: /Cannot create job \[closed-results-job\] as it requires closed index \[\.ml-state\]/ catch: /Cannot create job \[closed-results-job\] as it requires closed index \[\.ml-state-000001\]/
ml.put_job: ml.put_job:
job_id: closed-results-job job_id: closed-results-job
body: > body: >

View File

@ -201,7 +201,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: [.ml-anomalies-revert-model-snapshot,.ml-state] index: [.ml-anomalies-revert-model-snapshot,.ml-state*]
--- ---
"Test revert model with invalid snapshotId": "Test revert model with invalid snapshotId":

View File

@ -37,7 +37,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "update-model-snapshot_model_state_1#1" id: "update-model-snapshot_model_state_1#1"
body: > body: >
{ {
@ -47,7 +47,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "update-model-snapshot_model_state_1#2" id: "update-model-snapshot_model_state_1#2"
body: > body: >
{ {
@ -57,7 +57,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "update-model-snapshot_model_state_1#3" id: "update-model-snapshot_model_state_1#3"
body: > body: >
{ {
@ -84,7 +84,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "update-model-snapshot_model_state_2#1" id: "update-model-snapshot_model_state_2#1"
body: > body: >
{ {
@ -94,7 +94,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
index: index:
index: .ml-state index: .ml-state-000001
id: "update-model-snapshot_model_state_2#2" id: "update-model-snapshot_model_state_2#2"
body: > body: >
{ {
@ -104,7 +104,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: [.ml-anomalies-update-model-snapshot,.ml-state] index: [.ml-anomalies-update-model-snapshot,.ml-state*]
--- ---
"Test with valid description": "Test with valid description":

View File

@ -1,3 +1,17 @@
setup:
- do:
index:
index: .ml-state
id: "dummy-document-to-make-index-creation-idempotent"
body: >
{
}
- do:
cluster.health:
index: [".ml-state"]
wait_for_status: green
--- ---
"Put job on the old cluster and post some data": "Put job on the old cluster and post some data":