Skip to content

Commit

Permalink
Fix locale lowercase test issue in GenerateSnapshotNameStepTests (ela…
Browse files Browse the repository at this point in the history
…stic#55597) (elastic#55605)

The testPerformAction test has been failing periodically due to
how Hamcrest's containsStringIgnoringCase does not lowercase using
the same Locale set in the test infrastructure.

This commit falls back to explicitly lowercasing using the root
locale
  • Loading branch information
talevy authored Apr 22, 2020
1 parent f27ce69 commit c370b83
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.common.Strings;

import java.util.Locale;

import static org.elasticsearch.xpack.core.ilm.AbstractStepMasterTimeoutTestCase.emptyClusterState;
import static org.elasticsearch.xpack.core.ilm.GenerateSnapshotNameStep.generateSnapshotName;
import static org.elasticsearch.xpack.core.ilm.GenerateSnapshotNameStep.validateGeneratedSnapshotName;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsStringIgnoringCase;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
Expand Down Expand Up @@ -75,8 +77,8 @@ public void testPerformAction() {
assertThat("the " + GenerateSnapshotNameStep.NAME + " step must generate a snapshot name", executionState.getSnapshotName(),
notNullValue());
assertThat(executionState.getSnapshotRepository(), is(generateSnapshotNameStep.getSnapshotRepository()));
assertThat(executionState.getSnapshotName(), containsStringIgnoringCase(indexName));
assertThat(executionState.getSnapshotName(), containsStringIgnoringCase(policyName));
assertThat(executionState.getSnapshotName(), containsString(indexName.toLowerCase(Locale.ROOT)));
assertThat(executionState.getSnapshotName(), containsString(policyName.toLowerCase(Locale.ROOT)));
}

public void testNameGeneration() {
Expand Down

0 comments on commit c370b83

Please sign in to comment.