You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by do...@apache.org on 2019/02/13 15:57:37 UTC

[incubator-iotdb] branch master updated: Add iotdb env script test (#45)

This is an automated email from the ASF dual-hosted git repository.

dope pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 4348849  Add iotdb env script test (#45)
4348849 is described below

commit 4348849c531bbfef21a5a8e9fb56c868bcc00522
Author: XuYi <My...@users.noreply.github.com>
AuthorDate: Wed Feb 13 23:57:33 2019 +0800

    Add iotdb env script test (#45)
---
 iotdb/iotdb/conf/iotdb-env.bat                     |  4 +-
 iotdb/iotdb/conf/iotdb-env.sh                      |  3 +
 ...StartServerScriptTest.java => EnvScriptIT.java} | 69 ++++++----------------
 3 files changed, 23 insertions(+), 53 deletions(-)

diff --git a/iotdb/iotdb/conf/iotdb-env.bat b/iotdb/iotdb/conf/iotdb-env.bat
index 49ba776..a7ef891 100644
--- a/iotdb/iotdb/conf/iotdb-env.bat
+++ b/iotdb/iotdb/conf/iotdb-env.bat
@@ -28,8 +28,8 @@ if "%LOCAL_JMX%" == "yes" (
 	)
 
 IF ["%IOTDB_HEAP_OPTS%"] EQU [""] (
-	rem detect Java 32 or 64 bit
-	IF %JAVA_VERSION% == 8 (
+	rem detect Java 8 or 11
+	IF %%JAVA_VERSION%% == 8 (
 		java -d64 -version >nul 2>&1
 		IF NOT ERRORLEVEL 1 (
 			rem 64-bit Java
diff --git a/iotdb/iotdb/conf/iotdb-env.sh b/iotdb/iotdb/conf/iotdb-env.sh
index 2d6e851..9de5c6d 100755
--- a/iotdb/iotdb/conf/iotdb-env.sh
+++ b/iotdb/iotdb/conf/iotdb-env.sh
@@ -145,3 +145,6 @@ fi
 
 IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -Xms${HEAP_NEWSIZE}"
 IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -Xmx${MAX_HEAP_SIZE}"
+
+echo "Maximum memory allocation pool = ${MAX_HEAP_SIZE}MB, initial memory allocation pool = ${HEAP_NEWSIZE}MB"
+echo "If you want to change this configuration, please check conf/iotdb-env.sh(Unix or OS X, if you use Windows, check conf/iotdb-env.bat)."
\ No newline at end of file
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/script/IoTDBStartServerScriptTest.java b/iotdb/src/test/java/org/apache/iotdb/db/script/EnvScriptIT.java
similarity index 53%
rename from iotdb/src/test/java/org/apache/iotdb/db/script/IoTDBStartServerScriptTest.java
rename to iotdb/src/test/java/org/apache/iotdb/db/script/EnvScriptIT.java
index f798267..2f7e833 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/script/IoTDBStartServerScriptTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/script/EnvScriptIT.java
@@ -28,10 +28,9 @@ import java.util.ArrayList;
 import java.util.List;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Test;
 
-public class IoTDBStartServerScriptTest {
-
-  private final String START_IOTDB_STR = "IoTDB has started.";
+public class EnvScriptIT {
 
   @Before
   public void setUp() throws Exception {
@@ -41,9 +40,7 @@ public class IoTDBStartServerScriptTest {
   public void tearDown() throws Exception {
   }
 
-  // Skip this test for now because if you close IoTDB by stop-server script, it cannot detect whether it is closed or
-  // not.
-  // @Test
+  @Test
   public void test() throws IOException, InterruptedException {
     String os = System.getProperty("os.name").toLowerCase();
     if (os.startsWith("windows")) {
@@ -54,39 +51,28 @@ public class IoTDBStartServerScriptTest {
   }
 
   private void testStartClientOnWindows(String suffix, String os) throws IOException {
-    final String[] output = {"````````````````````````", "Starting IoTDB",
-        "````````````````````````"};
     String dir = getCurrentPath("cmd.exe", "/c", "echo %cd%");
-    String startCMD =
-        dir + File.separator + "iotdb" + File.separator + "bin" + File.separator + "start-server"
-            + suffix;
-    ProcessBuilder startBuilder = new ProcessBuilder("cmd.exe", "/c", startCMD);
-    String stopCMD =
-        dir + File.separator + "iotdb" + File.separator + "bin" + File.separator + "stop-server"
+    final String output = "If you want to change this configuration, please check conf/iotdb-env.sh(Unix or OS X, if you use Windows, check conf/iotdb-env.bat).";
+    String cmd =
+        dir + File.separator + "iotdb" + File.separator + "conf" + File.separator + "iotdb-env"
             + suffix;
-    ProcessBuilder stopBuilder = new ProcessBuilder("cmd.exe", "/c", stopCMD);
-    testOutput(dir, suffix, startBuilder, stopBuilder, output, os);
+    ProcessBuilder startBuilder = new ProcessBuilder("cmd.exe", "/c", cmd);
+    testOutput(dir, suffix, startBuilder, output, os);
   }
 
   private void testStartClientOnUnix(String suffix, String os) throws IOException {
     String dir = getCurrentPath("pwd");
-    final String[] output = {"---------------------", "Starting IoTDB", "---------------------"};
-    String startCMD =
-        dir + File.separator + "iotdb" + File.separator + "bin" + File.separator + "start-server"
+    final String output = "If you want to change this configuration, please check conf/iotdb-env.sh(Unix or OS X, if you use Windows, check conf/iotdb-env.bat).";
+    String cmd = dir + File.separator + "iotdb" + File.separator + "conf" + File.separator + "iotdb-env"
             + suffix;
-    ProcessBuilder startBuilder = new ProcessBuilder("sh", startCMD);
-    String stopCMD =
-        dir + File.separator + "iotdb" + File.separator + "bin" + File.separator + "stop-server"
-            + suffix;
-    ProcessBuilder stopBuilder = new ProcessBuilder("sh", stopCMD);
-    testOutput(dir, suffix, startBuilder, stopBuilder, output, os);
+    ProcessBuilder builder = new ProcessBuilder("bash", cmd);
+    testOutput(cmd, suffix, builder, output, os);
   }
 
-  private void testOutput(String dir, String suffix, ProcessBuilder startBuilder,
-      ProcessBuilder stopBuilder,
-      String[] output, String os) throws IOException {
-    startBuilder.redirectErrorStream(true);
-    Process startProcess = startBuilder.start();
+  private void testOutput(String cmd, String suffix, ProcessBuilder builder,
+      String output, String os) throws IOException {
+	builder.redirectErrorStream(true);
+    Process startProcess = builder.start();
     BufferedReader startReader = new BufferedReader(
         new InputStreamReader(startProcess.getInputStream()));
     List<String> runtimeOuput = new ArrayList<>();
@@ -98,31 +84,12 @@ public class IoTDBStartServerScriptTest {
           break;
         }
         runtimeOuput.add(line);
-        if (line.indexOf(START_IOTDB_STR) > 0) {
-          break;
-        }
-      }
-      for (int i = 0; i < output.length; i++) {
-        assertEquals(output[i], runtimeOuput.get(i));
       }
+      assertEquals(output, runtimeOuput.get(runtimeOuput.size()-1));
     } finally {
       startReader.close();
       startProcess.destroy();
-      if (os.startsWith("windows")) {
-        stopBuilder.redirectErrorStream(true);
-        Process stopProcess = stopBuilder.start();
-        BufferedReader stopReader = new BufferedReader(
-            new InputStreamReader(stopProcess.getInputStream()));
-        while (true) {
-          line = stopReader.readLine();
-          if (line == null) {
-            break;
-          }
-          System.out.println(line);
-        }
-        stopReader.close();
-        stopProcess.destroy();
-      }
+      runtimeOuput.clear();
     }
   }