mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 07:37:19 -04:00
* Change HLRC's LifecyclePolicy to allow all valid ILM actions (#81483) This commit changes the High Level Rest Client's `LifecyclePolicy` implementation to allow all the same valid actions for each phase that ILM supports. It was previously missing actions in the hot and cold phases, as well as missing the frozen phase entirely. This also adds a test that uses the "real" `TimeseriesLifecycleType.ORDERED_*ACTIONS` lists so that if an action is added or removed in the future the test will fail. Resolves #81461 # Conflicts: # client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/LifecyclePolicyTests.java # x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java * Fix test
This commit is contained in:
parent
df63edbf27
commit
cb5766c197
7 changed files with 90 additions and 36 deletions
|
@ -52,7 +52,18 @@ public class LifecyclePolicy implements ToXContentObject {
|
||||||
PHASES_FIELD
|
PHASES_FIELD
|
||||||
);
|
);
|
||||||
|
|
||||||
ALLOWED_ACTIONS.put("hot", Sets.newHashSet(UnfollowAction.NAME, SetPriorityAction.NAME, RolloverAction.NAME));
|
ALLOWED_ACTIONS.put(
|
||||||
|
"hot",
|
||||||
|
Sets.newHashSet(
|
||||||
|
UnfollowAction.NAME,
|
||||||
|
SetPriorityAction.NAME,
|
||||||
|
RolloverAction.NAME,
|
||||||
|
ReadOnlyAction.NAME,
|
||||||
|
ShrinkAction.NAME,
|
||||||
|
ForceMergeAction.NAME,
|
||||||
|
SearchableSnapshotAction.NAME
|
||||||
|
)
|
||||||
|
);
|
||||||
ALLOWED_ACTIONS.put(
|
ALLOWED_ACTIONS.put(
|
||||||
"warm",
|
"warm",
|
||||||
Sets.newHashSet(
|
Sets.newHashSet(
|
||||||
|
@ -73,9 +84,11 @@ public class LifecyclePolicy implements ToXContentObject {
|
||||||
MigrateAction.NAME,
|
MigrateAction.NAME,
|
||||||
AllocateAction.NAME,
|
AllocateAction.NAME,
|
||||||
FreezeAction.NAME,
|
FreezeAction.NAME,
|
||||||
SearchableSnapshotAction.NAME
|
SearchableSnapshotAction.NAME,
|
||||||
|
ReadOnlyAction.NAME
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
ALLOWED_ACTIONS.put("frozen", Sets.newHashSet(UnfollowAction.NAME, SearchableSnapshotAction.NAME));
|
||||||
ALLOWED_ACTIONS.put("delete", Sets.newHashSet(DeleteAction.NAME, WaitForSnapshotAction.NAME));
|
ALLOWED_ACTIONS.put("delete", Sets.newHashSet(DeleteAction.NAME, WaitForSnapshotAction.NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class MigrateAction implements LifecycleAction, ToXContentObject {
|
||||||
|
|
||||||
private static final ConstructingObjectParser<MigrateAction, Void> PARSER = new ConstructingObjectParser<>(
|
private static final ConstructingObjectParser<MigrateAction, Void> PARSER = new ConstructingObjectParser<>(
|
||||||
NAME,
|
NAME,
|
||||||
|
true,
|
||||||
a -> new MigrateAction(a[0] == null ? true : (boolean) a[0])
|
a -> new MigrateAction(a[0] == null ? true : (boolean) a[0])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,8 @@ public class GetLifecyclePolicyResponseTests extends AbstractXContentTestCase<Ge
|
||||||
new ParseField(SearchableSnapshotAction.NAME),
|
new ParseField(SearchableSnapshotAction.NAME),
|
||||||
SearchableSnapshotAction::parse
|
SearchableSnapshotAction::parse
|
||||||
),
|
),
|
||||||
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(UnfollowAction.NAME), UnfollowAction::parse)
|
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(UnfollowAction.NAME), UnfollowAction::parse),
|
||||||
|
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(MigrateAction.NAME), MigrateAction::parse)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return new NamedXContentRegistry(entries);
|
return new NamedXContentRegistry(entries);
|
||||||
|
|
|
@ -80,7 +80,8 @@ public class LifecyclePolicyMetadataTests extends AbstractXContentTestCase<Lifec
|
||||||
new ParseField(SearchableSnapshotAction.NAME),
|
new ParseField(SearchableSnapshotAction.NAME),
|
||||||
SearchableSnapshotAction::parse
|
SearchableSnapshotAction::parse
|
||||||
),
|
),
|
||||||
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(UnfollowAction.NAME), UnfollowAction::parse)
|
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(UnfollowAction.NAME), UnfollowAction::parse),
|
||||||
|
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(MigrateAction.NAME), MigrateAction::parse)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return new NamedXContentRegistry(entries);
|
return new NamedXContentRegistry(entries);
|
||||||
|
|
|
@ -8,17 +8,19 @@
|
||||||
package org.elasticsearch.client.indexlifecycle;
|
package org.elasticsearch.client.indexlifecycle;
|
||||||
|
|
||||||
import org.elasticsearch.cluster.ClusterModule;
|
import org.elasticsearch.cluster.ClusterModule;
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.core.TimeValue;
|
import org.elasticsearch.core.TimeValue;
|
||||||
import org.elasticsearch.test.AbstractXContentTestCase;
|
import org.elasticsearch.test.AbstractXContentTestCase;
|
||||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.xcontent.ParseField;
|
import org.elasticsearch.xcontent.ParseField;
|
||||||
import org.elasticsearch.xcontent.XContentParser;
|
import org.elasticsearch.xcontent.XContentParser;
|
||||||
|
import org.elasticsearch.xpack.core.ilm.TimeseriesLifecycleType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -29,22 +31,11 @@ import java.util.stream.Collectors;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class LifecyclePolicyTests extends AbstractXContentTestCase<LifecyclePolicy> {
|
public class LifecyclePolicyTests extends AbstractXContentTestCase<LifecyclePolicy> {
|
||||||
private static final Set<String> VALID_HOT_ACTIONS = Sets.newHashSet(UnfollowAction.NAME, SetPriorityAction.NAME, RolloverAction.NAME);
|
private static final Set<String> VALID_HOT_ACTIONS = new HashSet<>(TimeseriesLifecycleType.ORDERED_VALID_HOT_ACTIONS);
|
||||||
private static final Set<String> VALID_WARM_ACTIONS = Sets.newHashSet(
|
private static final Set<String> VALID_WARM_ACTIONS = new HashSet<>(TimeseriesLifecycleType.ORDERED_VALID_WARM_ACTIONS);
|
||||||
UnfollowAction.NAME,
|
private static final Set<String> VALID_COLD_ACTIONS = new HashSet<>(TimeseriesLifecycleType.ORDERED_VALID_COLD_ACTIONS);
|
||||||
SetPriorityAction.NAME,
|
private static final Set<String> VALID_FROZEN_ACTIONS = new HashSet<>(TimeseriesLifecycleType.ORDERED_VALID_FROZEN_ACTIONS);
|
||||||
AllocateAction.NAME,
|
private static final Set<String> VALID_DELETE_ACTIONS = new HashSet<>(TimeseriesLifecycleType.ORDERED_VALID_DELETE_ACTIONS);
|
||||||
ForceMergeAction.NAME,
|
|
||||||
ReadOnlyAction.NAME,
|
|
||||||
ShrinkAction.NAME
|
|
||||||
);
|
|
||||||
private static final Set<String> VALID_COLD_ACTIONS = Sets.newHashSet(
|
|
||||||
UnfollowAction.NAME,
|
|
||||||
SetPriorityAction.NAME,
|
|
||||||
AllocateAction.NAME,
|
|
||||||
SearchableSnapshotAction.NAME
|
|
||||||
);
|
|
||||||
private static final Set<String> VALID_DELETE_ACTIONS = Sets.newHashSet(DeleteAction.NAME, WaitForSnapshotAction.NAME);
|
|
||||||
|
|
||||||
private String lifecycleName;
|
private String lifecycleName;
|
||||||
|
|
||||||
|
@ -87,7 +78,8 @@ public class LifecyclePolicyTests extends AbstractXContentTestCase<LifecyclePoli
|
||||||
new ParseField(SearchableSnapshotAction.NAME),
|
new ParseField(SearchableSnapshotAction.NAME),
|
||||||
SearchableSnapshotAction::parse
|
SearchableSnapshotAction::parse
|
||||||
),
|
),
|
||||||
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(UnfollowAction.NAME), UnfollowAction::parse)
|
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(UnfollowAction.NAME), UnfollowAction::parse),
|
||||||
|
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(MigrateAction.NAME), MigrateAction::parse)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return new NamedXContentRegistry(entries);
|
return new NamedXContentRegistry(entries);
|
||||||
|
@ -127,13 +119,17 @@ public class LifecyclePolicyTests extends AbstractXContentTestCase<LifecyclePoli
|
||||||
.map(this::getTestAction)
|
.map(this::getTestAction)
|
||||||
.collect(Collectors.toMap(LifecycleAction::getName, Function.identity()));
|
.collect(Collectors.toMap(LifecycleAction::getName, Function.identity()));
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
invalidAction = getTestAction(randomFrom("allocate", "forcemerge", "delete", "shrink"));
|
invalidAction = getTestAction(randomFrom("allocate", "migrate", "delete"));
|
||||||
actions.put(invalidAction.getName(), invalidAction);
|
actions.put(invalidAction.getName(), invalidAction);
|
||||||
}
|
}
|
||||||
Map<String, Phase> hotPhase = Collections.singletonMap("hot", new Phase("hot", TimeValue.ZERO, actions));
|
Map<String, Phase> hotPhase = Collections.singletonMap("hot", new Phase("hot", TimeValue.ZERO, actions));
|
||||||
|
|
||||||
if (invalidAction != null) {
|
if (invalidAction != null) {
|
||||||
Exception e = expectThrows(IllegalArgumentException.class, () -> new LifecyclePolicy(lifecycleName, hotPhase));
|
Exception e = expectThrows(
|
||||||
|
IllegalArgumentException.class,
|
||||||
|
"expected " + invalidAction + " to throw but it didn't",
|
||||||
|
() -> new LifecyclePolicy(lifecycleName, hotPhase)
|
||||||
|
);
|
||||||
assertThat(e.getMessage(), equalTo("invalid action [" + invalidAction.getName() + "] defined in phase [hot]"));
|
assertThat(e.getMessage(), equalTo("invalid action [" + invalidAction.getName() + "] defined in phase [hot]"));
|
||||||
} else {
|
} else {
|
||||||
new LifecyclePolicy(lifecycleName, hotPhase);
|
new LifecyclePolicy(lifecycleName, hotPhase);
|
||||||
|
@ -146,7 +142,7 @@ public class LifecyclePolicyTests extends AbstractXContentTestCase<LifecyclePoli
|
||||||
.map(this::getTestAction)
|
.map(this::getTestAction)
|
||||||
.collect(Collectors.toMap(LifecycleAction::getName, Function.identity()));
|
.collect(Collectors.toMap(LifecycleAction::getName, Function.identity()));
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
invalidAction = getTestAction(randomFrom("rollover", "delete"));
|
invalidAction = getTestAction(randomFrom("rollover", "delete", "searchable_snapshot"));
|
||||||
actions.put(invalidAction.getName(), invalidAction);
|
actions.put(invalidAction.getName(), invalidAction);
|
||||||
}
|
}
|
||||||
Map<String, Phase> warmPhase = Collections.singletonMap("warm", new Phase("warm", TimeValue.ZERO, actions));
|
Map<String, Phase> warmPhase = Collections.singletonMap("warm", new Phase("warm", TimeValue.ZERO, actions));
|
||||||
|
@ -178,6 +174,25 @@ public class LifecyclePolicyTests extends AbstractXContentTestCase<LifecyclePoli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testValidateFrozenPhase() {
|
||||||
|
LifecycleAction invalidAction = null;
|
||||||
|
Map<String, LifecycleAction> actions = randomSubsetOf(VALID_FROZEN_ACTIONS).stream()
|
||||||
|
.map(this::getTestAction)
|
||||||
|
.collect(Collectors.toMap(LifecycleAction::getName, Function.identity()));
|
||||||
|
if (randomBoolean()) {
|
||||||
|
invalidAction = getTestAction(randomFrom("allocate", "rollover", "delete", "forcemerge", "shrink", "readonly"));
|
||||||
|
actions.put(invalidAction.getName(), invalidAction);
|
||||||
|
}
|
||||||
|
Map<String, Phase> coldPhase = Collections.singletonMap("cold", new Phase("frozen", TimeValue.ZERO, actions));
|
||||||
|
|
||||||
|
if (invalidAction != null) {
|
||||||
|
Exception e = expectThrows(IllegalArgumentException.class, () -> new LifecyclePolicy(lifecycleName, coldPhase));
|
||||||
|
assertThat(e.getMessage(), equalTo("invalid action [" + invalidAction.getName() + "] defined in phase [frozen]"));
|
||||||
|
} else {
|
||||||
|
new LifecyclePolicy(lifecycleName, coldPhase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testValidateDeletePhase() {
|
public void testValidateDeletePhase() {
|
||||||
LifecycleAction invalidAction = null;
|
LifecycleAction invalidAction = null;
|
||||||
Map<String, LifecycleAction> actions = VALID_DELETE_ACTIONS.stream()
|
Map<String, LifecycleAction> actions = VALID_DELETE_ACTIONS.stream()
|
||||||
|
@ -259,12 +274,15 @@ public class LifecyclePolicyTests extends AbstractXContentTestCase<LifecyclePoli
|
||||||
case UnfollowAction.NAME:
|
case UnfollowAction.NAME:
|
||||||
return new UnfollowAction();
|
return new UnfollowAction();
|
||||||
case SearchableSnapshotAction.NAME:
|
case SearchableSnapshotAction.NAME:
|
||||||
return SearchableSnapshotActionTests.randomInstance();
|
return new SearchableSnapshotAction("repo", randomBoolean());
|
||||||
|
case MigrateAction.NAME:
|
||||||
|
return new MigrateAction(randomBoolean());
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("invalid action [" + action + "]");
|
throw new IllegalArgumentException("invalid action [" + action + "]");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TimeValue prev = null;
|
TimeValue prev = null;
|
||||||
|
boolean searchableSnapshotSeen = false;
|
||||||
for (String phase : phaseNames) {
|
for (String phase : phaseNames) {
|
||||||
TimeValue after = prev == null
|
TimeValue after = prev == null
|
||||||
? TimeValue.parseTimeValue(randomTimeValue(0, 10000, "s", "m", "h", "d"), "test_after")
|
? TimeValue.parseTimeValue(randomTimeValue(0, 10000, "s", "m", "h", "d"), "test_after")
|
||||||
|
@ -277,6 +295,24 @@ public class LifecyclePolicyTests extends AbstractXContentTestCase<LifecyclePoli
|
||||||
} else {
|
} else {
|
||||||
actionNames = randomSubsetOf(randomIntBetween(1, validActions.apply(phase).size()), validActions.apply(phase));
|
actionNames = randomSubsetOf(randomIntBetween(1, validActions.apply(phase).size()), validActions.apply(phase));
|
||||||
}
|
}
|
||||||
|
if ("hot".equals(phase)) {
|
||||||
|
actions.put(
|
||||||
|
RolloverAction.NAME,
|
||||||
|
new RolloverAction(null, new ByteSizeValue(randomNonNegativeLong()), null, randomNonNegativeLong())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (searchableSnapshotSeen || actionNames.contains(SearchableSnapshotAction.NAME)) {
|
||||||
|
searchableSnapshotSeen = true;
|
||||||
|
// let's make sure phases don't configure actions that conflict with the `searchable_snapshot` action
|
||||||
|
actionNames.removeAll(TimeseriesLifecycleType.ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT);
|
||||||
|
}
|
||||||
|
if (actionNames.contains(MigrateAction.NAME)) {
|
||||||
|
actionNames.remove(AllocateAction.NAME);
|
||||||
|
}
|
||||||
|
// Remove since this will cause deprecation warnings and test failures
|
||||||
|
if (actionNames.contains(FreezeAction.NAME)) {
|
||||||
|
actionNames.remove(FreezeAction.NAME);
|
||||||
|
}
|
||||||
for (String action : actionNames) {
|
for (String action : actionNames) {
|
||||||
actions.put(action, randomAction.apply(action));
|
actions.put(action, randomAction.apply(action));
|
||||||
}
|
}
|
||||||
|
@ -309,6 +345,8 @@ public class LifecyclePolicyTests extends AbstractXContentTestCase<LifecyclePoli
|
||||||
return SearchableSnapshotActionTests.randomInstance();
|
return SearchableSnapshotActionTests.randomInstance();
|
||||||
case UnfollowAction.NAME:
|
case UnfollowAction.NAME:
|
||||||
return new UnfollowAction();
|
return new UnfollowAction();
|
||||||
|
case MigrateAction.NAME:
|
||||||
|
return new MigrateAction(randomBoolean());
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("unsupported phase action [" + actionName + "]");
|
throw new IllegalArgumentException("unsupported phase action [" + actionName + "]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,12 +54,12 @@ public class TimeseriesLifecycleType implements LifecycleType {
|
||||||
static final String COLD_PHASE = "cold";
|
static final String COLD_PHASE = "cold";
|
||||||
static final String FROZEN_PHASE = "frozen";
|
static final String FROZEN_PHASE = "frozen";
|
||||||
static final String DELETE_PHASE = "delete";
|
static final String DELETE_PHASE = "delete";
|
||||||
static final List<String> ORDERED_VALID_PHASES = Arrays.asList(HOT_PHASE, WARM_PHASE, COLD_PHASE, FROZEN_PHASE, DELETE_PHASE);
|
public static final List<String> ORDERED_VALID_PHASES = Arrays.asList(HOT_PHASE, WARM_PHASE, COLD_PHASE, FROZEN_PHASE, DELETE_PHASE);
|
||||||
|
|
||||||
public static final String FREEZE_ACTION_DEPRECATION_WARNING = "the freeze action has been deprecated and will be removed in a future"
|
public static final String FREEZE_ACTION_DEPRECATION_WARNING = "the freeze action has been deprecated and will be removed in a future"
|
||||||
+ " release";
|
+ " release";
|
||||||
|
|
||||||
static final List<String> ORDERED_VALID_HOT_ACTIONS = Stream.of(
|
public static final List<String> ORDERED_VALID_HOT_ACTIONS = Stream.of(
|
||||||
SetPriorityAction.NAME,
|
SetPriorityAction.NAME,
|
||||||
UnfollowAction.NAME,
|
UnfollowAction.NAME,
|
||||||
RolloverAction.NAME,
|
RolloverAction.NAME,
|
||||||
|
@ -69,7 +69,7 @@ public class TimeseriesLifecycleType implements LifecycleType {
|
||||||
ForceMergeAction.NAME,
|
ForceMergeAction.NAME,
|
||||||
SearchableSnapshotAction.NAME
|
SearchableSnapshotAction.NAME
|
||||||
).filter(Objects::nonNull).collect(toList());
|
).filter(Objects::nonNull).collect(toList());
|
||||||
static final List<String> ORDERED_VALID_WARM_ACTIONS = Arrays.asList(
|
public static final List<String> ORDERED_VALID_WARM_ACTIONS = Arrays.asList(
|
||||||
SetPriorityAction.NAME,
|
SetPriorityAction.NAME,
|
||||||
UnfollowAction.NAME,
|
UnfollowAction.NAME,
|
||||||
ReadOnlyAction.NAME,
|
ReadOnlyAction.NAME,
|
||||||
|
@ -78,7 +78,7 @@ public class TimeseriesLifecycleType implements LifecycleType {
|
||||||
ShrinkAction.NAME,
|
ShrinkAction.NAME,
|
||||||
ForceMergeAction.NAME
|
ForceMergeAction.NAME
|
||||||
);
|
);
|
||||||
static final List<String> ORDERED_VALID_COLD_ACTIONS = Stream.of(
|
public static final List<String> ORDERED_VALID_COLD_ACTIONS = Stream.of(
|
||||||
SetPriorityAction.NAME,
|
SetPriorityAction.NAME,
|
||||||
UnfollowAction.NAME,
|
UnfollowAction.NAME,
|
||||||
ReadOnlyAction.NAME,
|
ReadOnlyAction.NAME,
|
||||||
|
@ -88,8 +88,8 @@ public class TimeseriesLifecycleType implements LifecycleType {
|
||||||
FreezeAction.NAME,
|
FreezeAction.NAME,
|
||||||
RollupV2.isEnabled() ? RollupILMAction.NAME : null
|
RollupV2.isEnabled() ? RollupILMAction.NAME : null
|
||||||
).filter(Objects::nonNull).collect(toList());
|
).filter(Objects::nonNull).collect(toList());
|
||||||
static final List<String> ORDERED_VALID_FROZEN_ACTIONS = Arrays.asList(UnfollowAction.NAME, SearchableSnapshotAction.NAME);
|
public static final List<String> ORDERED_VALID_FROZEN_ACTIONS = Arrays.asList(UnfollowAction.NAME, SearchableSnapshotAction.NAME);
|
||||||
static final List<String> ORDERED_VALID_DELETE_ACTIONS = Arrays.asList(WaitForSnapshotAction.NAME, DeleteAction.NAME);
|
public static final List<String> ORDERED_VALID_DELETE_ACTIONS = Arrays.asList(WaitForSnapshotAction.NAME, DeleteAction.NAME);
|
||||||
|
|
||||||
static final Set<String> VALID_HOT_ACTIONS = Sets.newHashSet(ORDERED_VALID_HOT_ACTIONS);
|
static final Set<String> VALID_HOT_ACTIONS = Sets.newHashSet(ORDERED_VALID_HOT_ACTIONS);
|
||||||
static final Set<String> VALID_WARM_ACTIONS = Sets.newHashSet(ORDERED_VALID_WARM_ACTIONS);
|
static final Set<String> VALID_WARM_ACTIONS = Sets.newHashSet(ORDERED_VALID_WARM_ACTIONS);
|
||||||
|
@ -119,8 +119,8 @@ public class TimeseriesLifecycleType implements LifecycleType {
|
||||||
);
|
);
|
||||||
// Set of actions that cannot be defined (executed) after the managed index has been mounted as searchable snapshot.
|
// Set of actions that cannot be defined (executed) after the managed index has been mounted as searchable snapshot.
|
||||||
// It's ordered to produce consistent error messages which can be unit tested.
|
// It's ordered to produce consistent error messages which can be unit tested.
|
||||||
static final Set<String> ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT = new LinkedHashSet<>(
|
public static final Set<String> ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT = Collections.unmodifiableSet(
|
||||||
Arrays.asList(ForceMergeAction.NAME, FreezeAction.NAME, ShrinkAction.NAME, RollupILMAction.NAME)
|
new LinkedHashSet<>(Arrays.asList(ForceMergeAction.NAME, FreezeAction.NAME, ShrinkAction.NAME, RollupILMAction.NAME))
|
||||||
);
|
);
|
||||||
|
|
||||||
private TimeseriesLifecycleType() {}
|
private TimeseriesLifecycleType() {}
|
||||||
|
|
|
@ -203,8 +203,8 @@ public class TimeseriesLifecycleTypeTests extends ESTestCase {
|
||||||
Map<String, LifecycleAction> actions = randomSubsetOf(VALID_FROZEN_ACTIONS).stream()
|
Map<String, LifecycleAction> actions = randomSubsetOf(VALID_FROZEN_ACTIONS).stream()
|
||||||
.map(this::getTestAction)
|
.map(this::getTestAction)
|
||||||
.collect(Collectors.toMap(LifecycleAction::getWriteableName, Function.identity()));
|
.collect(Collectors.toMap(LifecycleAction::getWriteableName, Function.identity()));
|
||||||
// regardless of the randomised actions, we must have a SearchableSnapshotAction in frozen
|
// Frozen requires the searchable snapshot action to be present
|
||||||
actions.put(SearchableSnapshotAction.NAME, getTestAction(SearchableSnapshotAction.NAME));
|
actions.put(SearchableSnapshotAction.NAME, new SearchableSnapshotAction("repo", randomBoolean()));
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
invalidAction = getTestAction(randomFrom("rollover", "delete", "forcemerge", "shrink"));
|
invalidAction = getTestAction(randomFrom("rollover", "delete", "forcemerge", "shrink"));
|
||||||
actions.put(invalidAction.getWriteableName(), invalidAction);
|
actions.put(invalidAction.getWriteableName(), invalidAction);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue