From 9f71100bac3b9ba71924a3c7ba6a15bc8655f2bf Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Thu, 28 Dec 2017 21:40:03 -0500 Subject: [PATCH] SQL: Fix CLI tests with security on Windows We test on Windows with the terminal in unix mode, so we need to make sure we send `\n` instead of `\r\n`. In this case the extra `\n` after password was causing an extra new line in tests breaking them on Windows. Original commit: elastic/x-pack-elasticsearch@721ba32bd668aeb6f02c0de486d0cc6651bed4e1 --- .../elasticsearch/xpack/qa/sql/cli/RemoteCli.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/RemoteCli.java b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/RemoteCli.java index 5b805933f5e..4b1c00e57dd 100644 --- a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/RemoteCli.java +++ b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/RemoteCli.java @@ -101,16 +101,21 @@ public class RemoteCli implements Closeable { if (false == checkConnectionOnStartup) { command += " -check false"; } - out.println(command); + /* Don't use println because it emits \r\n on windows but we put the + * terminal in unix mode to make the tests consistent. */ + out.print(command + "\n"); + out.flush(); // Feed it passwords if needed if (security != null && security.keystoreLocation != null) { assertEquals("keystore password: ", readUntil(s -> s.endsWith(": "))); - out.println(security.keystorePassword); + out.print(security.keystorePassword + "\n"); + out.flush(); } if (security != null) { assertEquals("password: ", readUntil(s -> s.endsWith(": "))); - out.println(security.password); + out.print(security.password + "\n"); + out.flush(); } // Throw out the logo and warnings about making a dumb terminal @@ -152,7 +157,7 @@ public class RemoteCli implements Closeable { public String command(String command) throws IOException { assertThat("; automatically added", command, not(endsWith(";"))); logger.info("out: {};", command); - /* Don't use println because it enits \r\n on windows but we put the + /* Don't use println because it emits \r\n on windows but we put the * terminal in unix mode to make the tests consistent. */ out.print(command + ";\n"); out.flush();