Fix locale lowercase test issue in GenerateSnapshotNameStepTests (#55597) (#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
This commit is contained in:
Tal Levy 2020-04-22 11:29:57 -07:00 committed by GitHub
parent f27ce69f0c
commit c370b83bd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -12,11 +12,13 @@ import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.common.Strings; 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.AbstractStepMasterTimeoutTestCase.emptyClusterState;
import static org.elasticsearch.xpack.core.ilm.GenerateSnapshotNameStep.generateSnapshotName; import static org.elasticsearch.xpack.core.ilm.GenerateSnapshotNameStep.generateSnapshotName;
import static org.elasticsearch.xpack.core.ilm.GenerateSnapshotNameStep.validateGeneratedSnapshotName; import static org.elasticsearch.xpack.core.ilm.GenerateSnapshotNameStep.validateGeneratedSnapshotName;
import static org.hamcrest.Matchers.containsInAnyOrder; 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.greaterThan;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.notNullValue;
@ -75,8 +77,8 @@ public class GenerateSnapshotNameStepTests extends AbstractStepTestCase<Generate
assertThat("the " + GenerateSnapshotNameStep.NAME + " step must generate a snapshot name", executionState.getSnapshotName(), assertThat("the " + GenerateSnapshotNameStep.NAME + " step must generate a snapshot name", executionState.getSnapshotName(),
notNullValue()); notNullValue());
assertThat(executionState.getSnapshotRepository(), is(generateSnapshotNameStep.getSnapshotRepository())); assertThat(executionState.getSnapshotRepository(), is(generateSnapshotNameStep.getSnapshotRepository()));
assertThat(executionState.getSnapshotName(), containsStringIgnoringCase(indexName)); assertThat(executionState.getSnapshotName(), containsString(indexName.toLowerCase(Locale.ROOT)));
assertThat(executionState.getSnapshotName(), containsStringIgnoringCase(policyName)); assertThat(executionState.getSnapshotName(), containsString(policyName.toLowerCase(Locale.ROOT)));
} }
public void testNameGeneration() { public void testNameGeneration() {