Skip to content

Commit

Permalink
Improve stability of SamlServiceProviderIndexTests (#54241) (#54271)
Browse files Browse the repository at this point in the history
This test assumed cluster events would be processed quickly which is
not always true

Backport of: #54166

Co-authored-by: Tim Vernum <[email protected]>
  • Loading branch information
jkakavas and tvernum authored Mar 26, 2020
1 parent 20e821e commit c466881
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,16 @@ public void testWritesViaAliasIfItExists() {
assertThat(readDocument(document.docId), equalTo(document));
}

public void testInstallTemplateAutomaticallyOnClusterChange() {
public void testInstallTemplateAutomaticallyOnClusterChange() throws Exception {
// Create an index that will trigger a cluster state change
client().admin().indices().create(new CreateIndexRequest(randomAlphaOfLength(7).toLowerCase(Locale.ROOT))).actionGet();
final String indexName = randomAlphaOfLength(7).toLowerCase(Locale.ROOT);
client().admin().indices().create(new CreateIndexRequest(indexName)).actionGet();

ensureGreen(indexName);

IndexTemplateMetaData templateMeta = clusterService.state().metaData().templates().get(SamlServiceProviderIndex.TEMPLATE_NAME);
assertNotNull(templateMeta);

assertBusy(() -> assertThat("template should have been installed", templateMeta, notNullValue()));

final PlainActionFuture<Boolean> installTemplate = new PlainActionFuture<>();
serviceProviderIndex.installIndexTemplate(installTemplate);
Expand All @@ -181,7 +185,7 @@ public void testInstallTemplateAutomaticallyOnDocumentWrite() {
assertThat(readDocument(doc.docId), equalTo(doc));

IndexTemplateMetaData templateMeta = clusterService.state().metaData().templates().get(SamlServiceProviderIndex.TEMPLATE_NAME);
assertNotNull(templateMeta);
assertThat("template should have been installed", templateMeta, notNullValue());

final PlainActionFuture<Boolean> installTemplate = new PlainActionFuture<>();
serviceProviderIndex.installIndexTemplate(installTemplate);
Expand Down

0 comments on commit c466881

Please sign in to comment.