9393 */
9494public class DockerTests extends PackagingTestCase {
9595 private Path tempDir ;
96- private static final String USERNAME = "elastic" ;
9796 private static final String PASSWORD = "nothunter2" ;
9897
9998 @ BeforeClass
@@ -125,13 +124,8 @@ public void test010Install() throws Exception {
125124 * Check that security is enabled
126125 */
127126 public void test011SecurityEnabledStatus () throws Exception {
128- waitForElasticsearch (installation , USERNAME , PASSWORD );
129- final int statusCode = ServerUtils .makeRequestAndGetStatus (
130- Request .Get ("https://localhost:9200" ),
131- USERNAME ,
132- "wrong_password" ,
133- ServerUtils .getCaCert (installation )
134- );
127+ waitForElasticsearch (installation , "elastic" , PASSWORD );
128+ final int statusCode = makeRequestAsElastic ("wrong_password" );
135129 assertThat (statusCode , equalTo (401 ));
136130 }
137131
@@ -226,7 +220,7 @@ public void test041AmazonCaCertsAreInTheKeystore() {
226220 * Check that when the keystore is created on startup, it is created with the correct permissions.
227221 */
228222 public void test042KeystorePermissionsAreCorrect () {
229- waitForElasticsearch (installation , USERNAME , PASSWORD );
223+ waitForElasticsearch (installation , "elastic" , PASSWORD );
230224
231225 assertThat (installation .config ("elasticsearch.keystore" ), file (p660 ));
232226 }
@@ -236,11 +230,11 @@ public void test042KeystorePermissionsAreCorrect() {
236230 * is minimally functional.
237231 */
238232 public void test050BasicApiTests () throws Exception {
239- waitForElasticsearch (installation , USERNAME , PASSWORD );
233+ waitForElasticsearch (installation , "elastic" , PASSWORD );
240234
241235 assertTrue (existsInContainer (installation .logs .resolve ("gc.log" )));
242236
243- ServerUtils . runElasticsearchTests ( USERNAME , PASSWORD , ServerUtils . getCaCert ( installation ) );
237+ runElasticsearchTestsAsElastic ( PASSWORD );
244238 }
245239
246240 /**
@@ -276,9 +270,9 @@ public void test070BindMountCustomPathConfAndJvmOptions() throws Exception {
276270 .envVar ("ELASTIC_PASSWORD" , PASSWORD )
277271 );
278272
279- waitForElasticsearch (installation , USERNAME , PASSWORD );
273+ waitForElasticsearch (installation , "elastic" , PASSWORD );
280274
281- final JsonNode nodes = getJson ("/_nodes" , USERNAME , PASSWORD , ServerUtils .getCaCert (installation )).get ("nodes" );
275+ final JsonNode nodes = getJson ("/_nodes" , "elastic" , PASSWORD , ServerUtils .getCaCert (installation )).get ("nodes" );
282276 final String nodeId = nodes .fieldNames ().next ();
283277
284278 final int heapSize = nodes .at ("/" + nodeId + "/jvm/mem/heap_init_in_bytes" ).intValue ();
@@ -304,9 +298,9 @@ public void test071BindMountCustomPathWithDifferentUID() throws Exception {
304298 distribution (),
305299 builder ().volume (tempEsDataDir .toAbsolutePath (), installation .data ).envVar ("ELASTIC_PASSWORD" , PASSWORD )
306300 );
307- waitForElasticsearch (installation , USERNAME , PASSWORD );
301+ waitForElasticsearch (installation , "elastic" , PASSWORD );
308302
309- final JsonNode nodes = getJson ("/_nodes" , USERNAME , PASSWORD , ServerUtils .getCaCert (installation ));
303+ final JsonNode nodes = getJson ("/_nodes" , "elastic" , PASSWORD , ServerUtils .getCaCert (installation ));
310304
311305 assertThat (nodes .at ("/_nodes/total" ).intValue (), equalTo (1 ));
312306 assertThat (nodes .at ("/_nodes/successful" ).intValue (), equalTo (1 ));
@@ -360,7 +354,7 @@ public void test072RunEsAsDifferentUserAndGroup() throws Exception {
360354 .volume (tempEsLogsDir .toAbsolutePath (), installation .logs )
361355 );
362356
363- waitForElasticsearch (installation , USERNAME , PASSWORD );
357+ waitForElasticsearch (installation , "elastic" , PASSWORD );
364358 rmDirWithPrivilegeEscalation (tempEsConfigDir );
365359 rmDirWithPrivilegeEscalation (tempEsDataDir );
366360 rmDirWithPrivilegeEscalation (tempEsLogsDir );
@@ -374,7 +368,7 @@ public void test073RunEsAsDifferentUserAndGroupWithoutBindMounting() {
374368 // Restart the container
375369 runContainer (distribution (), builder ().extraArgs ("--group-add 0" ).uid (501 , 501 ).envVar ("ELASTIC_PASSWORD" , PASSWORD ));
376370
377- waitForElasticsearch (installation , USERNAME , PASSWORD );
371+ waitForElasticsearch (installation , "elastic" , PASSWORD );
378372 }
379373
380374 /**
@@ -778,7 +772,7 @@ public void test110OrgOpencontainersLabels() throws Exception {
778772 * Check that the container logs contain the expected content for Elasticsearch itself.
779773 */
780774 public void test120DockerLogsIncludeElasticsearchLogs () {
781- waitForElasticsearch (installation , USERNAME , PASSWORD );
775+ waitForElasticsearch (installation , "elastic" , PASSWORD );
782776 final Result containerLogs = getContainerLogs ();
783777
784778 assertThat ("Container logs should contain full class names" , containerLogs .stdout , containsString ("org.elasticsearch.node.Node" ));
@@ -791,7 +785,7 @@ public void test120DockerLogsIncludeElasticsearchLogs() {
791785 public void test121CanUseStackLoggingConfig () {
792786 runContainer (distribution (), builder ().envVar ("ES_LOG_STYLE" , "file" ).envVar ("ELASTIC_PASSWORD" , PASSWORD ));
793787
794- waitForElasticsearch (installation , USERNAME , PASSWORD );
788+ waitForElasticsearch (installation , "elastic" , PASSWORD );
795789
796790 final Result containerLogs = getContainerLogs ();
797791 final List <String > stdout = containerLogs .stdout .lines ().collect (Collectors .toList ());
@@ -806,7 +800,7 @@ public void test121CanUseStackLoggingConfig() {
806800 public void test122CanUseDockerLoggingConfig () {
807801 runContainer (distribution (), builder ().envVar ("ES_LOG_STYLE" , "console" ).envVar ("ELASTIC_PASSWORD" , PASSWORD ));
808802
809- waitForElasticsearch (installation , USERNAME , PASSWORD );
803+ waitForElasticsearch (installation , "elastic" , PASSWORD );
810804
811805 final Result containerLogs = getContainerLogs ();
812806 final List <String > stdout = containerLogs .stdout .lines ().collect (Collectors .toList ());
@@ -830,12 +824,12 @@ public void test123CannotUseUnknownLoggingConfig() {
830824 public void test124CanRestartContainerWithStackLoggingConfig () {
831825 runContainer (distribution (), builder ().envVar ("ES_LOG_STYLE" , "file" ).envVar ("ELASTIC_PASSWORD" , PASSWORD ));
832826
833- waitForElasticsearch (installation , USERNAME , PASSWORD );
827+ waitForElasticsearch (installation , "elastic" , PASSWORD );
834828
835829 restartContainer ();
836830
837831 // If something went wrong running Elasticsearch the second time, this will fail.
838- waitForElasticsearch (installation , USERNAME , PASSWORD );
832+ waitForElasticsearch (installation , "elastic" , PASSWORD );
839833 }
840834
841835 /**
@@ -871,9 +865,9 @@ public void test131InitProcessHasCorrectPID() {
871865 * Check that Elasticsearch reports per-node cgroup information.
872866 */
873867 public void test140CgroupOsStatsAreAvailable () throws Exception {
874- waitForElasticsearch (installation , USERNAME , PASSWORD );
868+ waitForElasticsearch (installation , "elastic" , PASSWORD );
875869
876- final JsonNode nodes = getJson ("/_nodes/stats/os" , USERNAME , PASSWORD , ServerUtils .getCaCert (installation )).get ("nodes" );
870+ final JsonNode nodes = getJson ("/_nodes/stats/os" , "elastic" , PASSWORD , ServerUtils .getCaCert (installation )).get ("nodes" );
877871
878872 final String nodeId = nodes .fieldNames ().next ();
879873
@@ -907,7 +901,7 @@ public void test150MachineDependentHeap() throws Exception {
907901 builder ().memory ("942m" ).volume (jvmOptionsPath , containerJvmOptionsPath ).envVar ("ELASTIC_PASSWORD" , PASSWORD )
908902 );
909903
910- waitForElasticsearch (installation , USERNAME , PASSWORD );
904+ waitForElasticsearch (installation , "elastic" , PASSWORD );
911905
912906 // Grab the container output and find the line where it print the JVM arguments. This will
913907 // let us see what the automatic heap sizing calculated.
0 commit comments