This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new bcd8990 [IOTDB-931] update start-cli bash (#1847)
bcd8990 is described below
commit bcd89902784ed5578b53c767cfc74214578db128
Author: CRZbulabula <[email protected]>
AuthorDate: Sat Oct 24 09:46:44 2020 +0800
[IOTDB-931] update start-cli bash (#1847)
---
cli/pom.xml | 13 +++++++++++
cli/src/assembly/resources/sbin/start-cli.bat | 8 +++----
cli/src/assembly/resources/sbin/start-cli.sh | 8 +++----
.../java/org/apache/iotdb/cli/AbstractCli.java | 14 +++++++-----
.../org/apache/iotdb/cli/StartClientScriptIT.java | 26 +++++++++++++++++-----
5 files changed, 51 insertions(+), 18 deletions(-)
diff --git a/cli/pom.xml b/cli/pom.xml
index ffc9784..4779c65 100644
--- a/cli/pom.xml
+++ b/cli/pom.xml
@@ -41,6 +41,13 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.iotdb</groupId>
+ <artifactId>iotdb-server</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
@@ -57,6 +64,12 @@
<groupId>jline</groupId>
<artifactId>jline</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.iotdb</groupId>
+ <artifactId>iotdb-server</artifactId>
+ <version>0.11.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/cli/src/assembly/resources/sbin/start-cli.bat
b/cli/src/assembly/resources/sbin/start-cli.bat
index dfe02f4..6d13769 100644
--- a/cli/src/assembly/resources/sbin/start-cli.bat
+++ b/cli/src/assembly/resources/sbin/start-cli.bat
@@ -45,10 +45,10 @@ set PARAMETERS=%*
@REM if "%PARAMETERS%" == "" set PARAMETERS=-h 127.0.0.1 -p 6667 -u root -pw
root
@REM Added parameters when default parameters are missing
-echo %PARAMETERS% | find "-h">nul && (set PARAMETERS=%PARAMETERS%) || (set
PARAMETERS=%PARAMETERS% -h 127.0.0.1)
-echo %PARAMETERS% | find "-p">nul && (set PARAMETERS=%PARAMETERS%) || (set
PARAMETERS=%PARAMETERS% -p 6667)
-echo %PARAMETERS% | find "-u">nul && (set PARAMETERS=%PARAMETERS%) || (set
PARAMETERS=%PARAMETERS% -u root)
-echo %PARAMETERS% | find "-pw">nul && (set PARAMETERS=%PARAMETERS%) || (set
PARAMETERS=%PARAMETERS% -pw root)
+echo %PARAMETERS% | find "-h ">nul && (set PARAMETERS=%PARAMETERS%) || (set
PARAMETERS=%PARAMETERS% -h 127.0.0.1)
+echo %PARAMETERS% | find "-p ">nul && (set PARAMETERS=%PARAMETERS%) || (set
PARAMETERS=%PARAMETERS% -p 6667)
+echo %PARAMETERS% | find "-u ">nul && (set PARAMETERS=%PARAMETERS%) || (set
PARAMETERS=%PARAMETERS% -u root)
+echo %PARAMETERS% | find "-pw ">nul && (set PARAMETERS=%PARAMETERS%) || (set
PARAMETERS=%PARAMETERS% -pw root)
@REM echo %PARAMETERS%
diff --git a/cli/src/assembly/resources/sbin/start-cli.sh
b/cli/src/assembly/resources/sbin/start-cli.sh
index 4e9066c..6554afc 100644
--- a/cli/src/assembly/resources/sbin/start-cli.sh
+++ b/cli/src/assembly/resources/sbin/start-cli.sh
@@ -54,25 +54,25 @@ PARAMETERS="$@"
# fi
# Added parameters when default parameters are missing
-if [[ $PARAMETERS =~ "-h" ]]
+if [[ $PARAMETERS =~ "-h " ]]
then
PARAMETERS=$PARAMETERS
else
PARAMETERS="$PARAMETERS -h 127.0.0.1"
fi
-if [[ $PARAMETERS =~ "-p" ]]
+if [[ $PARAMETERS =~ "-p " ]]
then
PARAMETERS=$PARAMETERS
else
PARAMETERS="$PARAMETERS -p 6667"
fi
-if [[ $PARAMETERS =~ "-u" ]]
+if [[ $PARAMETERS =~ "-u " ]]
then
PARAMETERS=$PARAMETERS
else
PARAMETERS="$PARAMETERS -u root"
fi
-if [[ $PARAMETERS =~ "-pw" ]]
+if [[ $PARAMETERS =~ "-pw " ]]
then
PARAMETERS=$PARAMETERS
else
diff --git a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
index 7138a33..2da461b 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
@@ -344,11 +344,12 @@ public abstract class AbstractCli {
return args;
} else {
StringBuilder executeCommand = new StringBuilder();
- for (int j = index + 1; j < args.length; j++) {
+ /*for (int j = index + 1; j < args.length; j++) {
executeCommand.append(args[j]).append(" ");
- }
+ }*/
+ executeCommand.append(args[index + 1]);
// remove last space
- executeCommand.deleteCharAt(executeCommand.length() - 1);
+ //executeCommand.deleteCharAt(executeCommand.length() - 1);
// some bashes may not remove quotes of parameters automatically, remove
them in that case
if (executeCommand.charAt(0) == '\'' || executeCommand.charAt(0) ==
'\"') {
executeCommand.deleteCharAt(0);
@@ -360,8 +361,11 @@ public abstract class AbstractCli {
execute = executeCommand.toString();
hasExecuteSQL = true;
- args = Arrays.copyOfRange(args, 0, index);
- return args;
+ //args = Arrays.copyOfRange(args, 0, index);
+ // remove "-e" and it's parameter
+ String[] newArgs = ArrayUtils.remove(args, index);
+ newArgs = ArrayUtils.remove(newArgs, index);
+ return newArgs;
}
}
diff --git a/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
b/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
index 39397d5..eda8643 100644
--- a/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
+++ b/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
@@ -21,18 +21,20 @@ package org.apache.iotdb.cli;
import java.io.File;
import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.junit.*;
public class StartClientScriptIT extends AbstractScript {
@Before
public void setUp() throws Exception {
+ EnvironmentUtils.closeStatMonitor();
+ EnvironmentUtils.envSetUp();
}
@After
public void tearDown() throws Exception {
+ EnvironmentUtils.cleanEnv();
}
@Test
@@ -47,25 +49,39 @@ public class StartClientScriptIT extends AbstractScript {
@Override
protected void testOnWindows() throws IOException {
+ String dir = getCliPath();
final String[] output = {
"IoTDB> Connection Error, please check whether the network is
available or the server has started. Host is 127.0.0.1, port is 6668."};
- String dir = getCliPath();
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c",
dir + File.separator + "sbin" + File.separator + "start-cli.bat",
"-h",
"127.0.0.1", "-p", "6668", "-u", "root", "-pw", "root");
testOutput(builder, output);
+
+ final String[] output2 = {
+ "Msg: The statement is executed successfully."};
+ ProcessBuilder builder2 = new ProcessBuilder("cmd.exe", "/c",
+ dir + File.separator + "sbin" + File.separator + "start-cli.bat",
+ "-e", "\"flush\"");
+ testOutput(builder2, output2);
}
@Override
protected void testOnUnix() throws IOException {
+ String dir = getCliPath();
final String[] output = {
"IoTDB> Connection Error, please check whether the network is
available or the server has started. Host is 127.0.0.1, port is 6668."};
- String dir = getCliPath();
ProcessBuilder builder = new ProcessBuilder("sh",
dir + File.separator + "sbin" + File.separator + "start-cli.sh",
"-h",
"127.0.0.1", "-p", "6668", "-u", "root", "-pw", "root");
testOutput(builder, output);
+
+ final String[] output2 = {
+ "Msg: The statement is executed successfully."};
+ ProcessBuilder builder2 = new ProcessBuilder("sh",
+ dir + File.separator + "sbin" + File.separator + "start-cli.sh",
+ "-e", "\"flush\"");
+ testOutput(builder2, output2);
}
}