Skip to content

Commit

Permalink
[7.x] Fix ChangePolicyforIndexIT.testChangePolicyForIndex (elastic#67493
Browse files Browse the repository at this point in the history
) (elastic#67494)

This test was doing some sophisticated policy switching to test phase caching and updated policies,
but as part of it, it was unnecessarily restricting where an index could be allocated.

This change relaxes those restrictions and fixes an issue where the second policy was
misnamed (leading to some confusing log messages)

Resolves elastic#66960
  • Loading branch information
dakrone authored Jan 14, 2021
1 parent 7797f88 commit 2bdd200
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public void testChangePolicyForIndex() throws Exception {
Map<String, Phase> phases2 = new HashMap<>();
phases2.put("hot", new Phase("hot", TimeValue.ZERO, singletonMap(RolloverAction.NAME, new RolloverAction(null, null, 1000L))));
phases2.put("warm", new Phase("warm", TimeValue.ZERO,
singletonMap(AllocateAction.NAME, new AllocateAction(1, singletonMap("_name", "javaRestTest-1,javaRestTest-2"), null, null))));
LifecyclePolicy lifecyclePolicy2 = new LifecyclePolicy("policy_1", phases2);
singletonMap(AllocateAction.NAME,
new AllocateAction(1, singletonMap("_name", "javaRestTest-0,javaRestTest-1,javaRestTest-2,javaRestTest-3"),
null, null))));
LifecyclePolicy lifecyclePolicy2 = new LifecyclePolicy("policy_2", phases2);
// PUT policy_1 and policy_2
XContentBuilder builder1 = jsonBuilder();
lifecyclePolicy1.toXContent(builder1, null);
Expand Down Expand Up @@ -118,7 +120,7 @@ public void testChangePolicyForIndex() throws Exception {
// Check index is allocated on javaRestTest-1 and javaRestTest-2 as per policy_2
Map<String, Object> indexSettings = getIndexSettingsAsMap(indexName);
String includesAllocation = (String) indexSettings.get("index.routing.allocation.include._name");
assertEquals("javaRestTest-1,javaRestTest-2", includesAllocation);
assertEquals("javaRestTest-0,javaRestTest-1,javaRestTest-2,javaRestTest-3", includesAllocation);
}

private void assertStep(String indexName, StepKey expectedStep) throws IOException {
Expand Down

0 comments on commit 2bdd200

Please sign in to comment.