Skip to content

Commit

Permalink
Make ConfigurationTests.test20HostnameSubstitution more resilient (el…
Browse files Browse the repository at this point in the history
…astic#111216)

This is an attempt to fix occasional test failures where asserting on a
request response fails because the cluster has not finished
initialization and cannot yet serve requests.

Closes elastic#109660
  • Loading branch information
mark-vieira committed Jul 23, 2024
1 parent 00cfa68 commit 25949bf
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static java.nio.file.attribute.PosixFilePermissions.fromString;
import static org.elasticsearch.packaging.util.FileUtils.append;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assume.assumeFalse;

public class ConfigurationTests extends PackagingTestCase {
Expand Down Expand Up @@ -50,13 +49,15 @@ public void test20HostnameSubstitution() throws Exception {
// security auto-config requires that the archive owner and the node process user be the same
Platforms.onWindows(() -> sh.chown(confPath, installation.getOwner()));
assertWhileRunning(() -> {
final String nameResponse = ServerUtils.makeRequest(
Request.Get("https://localhost:9200/_cat/nodes?h=name"),
"test_superuser",
"test_superuser_password",
ServerUtils.getCaCert(confPath)
).strip();
assertThat(nameResponse, equalTo("mytesthost"));
assertBusy(() -> {
final String nameResponse = ServerUtils.makeRequest(
Request.Get("https://localhost:9200/_cat/nodes?h=name"),
"test_superuser",
"test_superuser_password",
ServerUtils.getCaCert(confPath)
).strip();
assertEquals("mytesthost", nameResponse);
});
});
Platforms.onWindows(() -> sh.chown(confPath));
});
Expand Down

0 comments on commit 25949bf

Please sign in to comment.