summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/action/admin/indices/rollover
diff options
context:
space:
mode:
authorNik Everett <nik9000@gmail.com>2016-08-18 16:51:37 -0400
committerNik Everett <nik9000@gmail.com>2016-08-30 10:15:21 -0400
commitdf73292256850c1391f1ee7f0ea45f03c19d63d4 (patch)
tree422cfa1017eff839eab03e8a715d1677a4a48d7e /core/src/test/java/org/elasticsearch/action/admin/indices/rollover
parent70f4d718f84f392aa63547dcabe569e3b11fc7a6 (diff)
Add an alias action to delete an index
While removing an index isn't actually an alias action, if we add an alias action that deletes an index then we can delete and index and add an alias with the same name as the index atomically, in the same cluster state update. Closes #20064
Diffstat (limited to 'core/src/test/java/org/elasticsearch/action/admin/indices/rollover')
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java
index 0feedd1a5d..2bd4c2883f 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java
@@ -35,12 +35,13 @@ import org.elasticsearch.index.shard.DocsStats;
import org.elasticsearch.test.ESTestCase;
import java.util.HashSet;
+import java.util.List;
import java.util.Locale;
import java.util.Set;
import static org.elasticsearch.action.admin.indices.rollover.TransportRolloverAction.evaluateConditions;
import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.hasSize;
public class TransportRolloverActionTests extends ESTestCase {
@@ -97,19 +98,19 @@ public class TransportRolloverActionTests extends ESTestCase {
final IndicesAliasesClusterStateUpdateRequest updateRequest =
TransportRolloverAction.prepareRolloverAliasesUpdateRequest(sourceIndex, targetIndex, rolloverRequest);
- final AliasAction[] actions = updateRequest.actions();
- assertThat(actions.length, equalTo(2));
+ List<AliasAction> actions = updateRequest.actions();
+ assertThat(actions, hasSize(2));
boolean foundAdd = false;
boolean foundRemove = false;
for (AliasAction action : actions) {
- if (action.actionType() == AliasAction.Type.ADD) {
+ if (action.getIndex().equals(targetIndex)) {
+ assertEquals(sourceAlias, ((AliasAction.Add) action).getAlias());
foundAdd = true;
- assertThat(action.index(), equalTo(targetIndex));
- assertThat(action.alias(), equalTo(sourceAlias));
- } else if (action.actionType() == AliasAction.Type.REMOVE) {
+ } else if (action.getIndex().equals(sourceIndex)) {
+ assertEquals(sourceAlias, ((AliasAction.Remove) action).getAlias());
foundRemove = true;
- assertThat(action.index(), equalTo(sourceIndex));
- assertThat(action.alias(), equalTo(sourceAlias));
+ } else {
+ throw new AssertionError("Unknow index [" + action.getIndex() + "]");
}
}
assertTrue(foundAdd);