@@ -63,12 +56,18 @@
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.4
+ 2.0.8
log4j
log4j
1.2.17
+
+ junit
+ junit
+ 4.13.1
+ test
+
diff --git a/tests/examples/JDBC/JDBCDemo/readme.md b/tests/examples/JDBC/JDBCDemo/readme.md
index a91624a9e47a3015d88e2e9aa9f62cf8dd0672cc..9b8790adaddb20246232392dd323ec502102fa18 100644
--- a/tests/examples/JDBC/JDBCDemo/readme.md
+++ b/tests/examples/JDBC/JDBCDemo/readme.md
@@ -2,12 +2,14 @@
TDengine's JDBC demo project is organized in a Maven way so that users can easily compile, package and run the project. If you don't have Maven on your server, you may install it using
sudo apt-get install maven
-## Compile and Install JDBC Driver
-TDengine's JDBC driver jar is not yet published to maven center repo, so we need to manually compile it and install it to the local Maven repository. This can be easily done with Maven. Go to source directory of the JDBC driver ``TDengine/src/connector/jdbc`` and execute
-mvn clean package install
+## Install TDengine Client
+Make sure you have already installed a tdengine client on your current develop environment.
+Download the tdengine package on our website: ``https://www.taosdata.com/cn/all-downloads/`` and install the client.
## Compile the Demo Code and Run It
To compile the demo project, go to the source directory ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute
-mvn clean assembly:single package
-The ``pom.xml`` is configured to package all the dependencies into one executable jar file. To run it, go to ``examples/JDBC/JDBCDemo/target`` and execute
-java -jar jdbcdemo-1.0-SNAPSHOT-jar-with-dependencies.jar
+mvn clean package assembly:single
+The ``pom.xml`` is configured to package all the dependencies into one executable jar file.
+
+To run it, go to ``examples/JDBC/JDBCDemo/target`` and execute
+java -jar jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host localhost
\ No newline at end of file
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/TSDBSyncSample.java b/tests/examples/JDBC/JDBCDemo/src/main/java/TSDBSyncSample.java
deleted file mode 100644
index c093b604da6dc6f815272f99d7fc786dab87928b..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/TSDBSyncSample.java
+++ /dev/null
@@ -1,205 +0,0 @@
-import java.sql.*;
-
-public class TSDBSyncSample {
- private static final String JDBC_PROTOCAL = "jdbc:TAOS://";
- private static final String TSDB_DRIVER = "com.taosdata.jdbc.TSDBDriver";
-
- private String host = "127.0.0.1";
- private String user = "root";
- private String password = "taosdata";
- private int port = 0;
- private String jdbcUrl = "";
-
- private String databaseName = "db";
- private String metricsName = "mt";
- private String tablePrefix = "t";
-
- private int tablesCount = 1;
- private int loopCount = 2;
- private int batchSize = 10;
- private long beginTimestamp = 1519833600000L;
-
- private long rowsInserted = 0;
-
- static {
- try {
- Class.forName(TSDB_DRIVER);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- TSDBSyncSample tester = new TSDBSyncSample();
- tester.doReadArgument(args);
-
- System.out.println("---------------------------------------------------------------");
- System.out.println("Start testing...");
- System.out.println("---------------------------------------------------------------");
-
- tester.doMakeJdbcUrl();
- tester.doCreateDbAndTable();
- tester.doExecuteInsert();
- tester.doExecuteQuery();
-
- System.out.println("\n---------------------------------------------------------------");
- System.out.println("Stop testing...");
- System.out.println("---------------------------------------------------------------");
- }
-
- private void doReadArgument(String[] args) {
- System.out.println("Arguments format: host tables loop batchs");
- if (args.length >= 1) {
- this.host = args[0];
- }
-
- if (args.length >= 2) {
- this.tablesCount = Integer.parseInt(args[1]);
- }
-
- if (args.length >= 3) {
- this.loopCount = Integer.parseInt(args[2]);
- }
-
- if (args.length >= 4) {
- this.batchSize = Integer.parseInt(args[3]);
- }
- }
-
- private void doMakeJdbcUrl() {
- // jdbc:TSDB://127.0.0.1:0/dbname?user=root&password=taosdata
- System.out.println("\nJDBC URL to use:");
- this.jdbcUrl = String.format("%s%s:%d/%s?user=%s&password=%s", JDBC_PROTOCAL, this.host, this.port, "",
- this.user, this.password);
- System.out.println(this.jdbcUrl);
- }
-
- private void doCreateDbAndTable() {
- System.out.println("\n---------------------------------------------------------------");
- System.out.println("Start creating databases and tables...");
- String sql = "";
- try (Connection conn = DriverManager.getConnection(jdbcUrl);
- Statement stmt = conn.createStatement()){
-
- sql = "create database if not exists " + this.databaseName;
- stmt.executeUpdate(sql);
- System.out.printf("Successfully executed: %s\n", sql);
-
- sql = "use " + this.databaseName;
- stmt.executeUpdate(sql);
- System.out.printf("Successfully executed: %s\n", sql);
-
- sql = "create table if not exists " + this.metricsName + " (ts timestamp, v1 int) tags(t1 int)";
- stmt.executeUpdate(sql);
- System.out.printf("Successfully executed: %s\n", sql);
-
- for (int i = 0; i < this.tablesCount; i++) {
- sql = String.format("create table if not exists %s%d using %s tags(%d)", this.tablePrefix, i,
- this.metricsName, i);
- stmt.executeUpdate(sql);
- System.out.printf("Successfully executed: %s\n", sql);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- System.out.printf("Failed to execute SQL: %s\n", sql);
- System.exit(4);
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(4);
- }
- System.out.println("Successfully created databases and tables");
- }
-
- public void doExecuteInsert() {
- System.out.println("\n---------------------------------------------------------------");
- System.out.println("Start inserting data...");
- int start = (int) System.currentTimeMillis();
- StringBuilder sql = new StringBuilder("");
- try (Connection conn = DriverManager.getConnection(jdbcUrl);
- Statement stmt = conn.createStatement()){
- stmt.executeUpdate("use " + databaseName);
- for (int loop = 0; loop < this.loopCount; loop++) {
- for (int table = 0; table < this.tablesCount; ++table) {
- sql = new StringBuilder("insert into ");
- sql.append(this.tablePrefix).append(table).append(" values");
- for (int batch = 0; batch < this.batchSize; ++batch) {
- int rows = loop * this.batchSize + batch;
- sql.append("(").append(this.beginTimestamp + rows).append(",").append(rows).append(")");
- }
- int affectRows = stmt.executeUpdate(sql.toString());
- this.rowsInserted += affectRows;
- }
- }
- } catch (SQLException e) {
- e.printStackTrace();
- System.out.printf("Failed to execute SQL: %s\n", sql.toString());
- System.exit(4);
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(4);
- }
- int end = (int) System.currentTimeMillis();
- System.out.println("Inserting completed!");
- System.out.printf("Total %d rows inserted, %d rows failed, time spend %d seconds.\n", this.rowsInserted,
- this.loopCount * this.batchSize - this.rowsInserted, (end - start) / 1000);
- }
-
- public void doExecuteQuery() {
- System.out.println("\n---------------------------------------------------------------");
- System.out.println("Starting querying data...");
- ResultSet resSet = null;
- StringBuilder sql = new StringBuilder("");
- StringBuilder resRow = new StringBuilder("");
- try (Connection conn = DriverManager.getConnection(jdbcUrl);
- Statement stmt = conn.createStatement()){
- stmt.executeUpdate("use " + databaseName);
- for (int i = 0; i < this.tablesCount; ++i) {
- sql = new StringBuilder("select * from ").append(this.tablePrefix).append(i);
-
- resSet = stmt.executeQuery(sql.toString());
- if (resSet == null) {
- System.out.println(sql + " failed");
- System.exit(4);
- }
-
- ResultSetMetaData metaData = resSet.getMetaData();
- System.out.println("Retrieve metadata of " + tablePrefix + i);
- for (int column = 1; column <= metaData.getColumnCount(); ++column) {
- System.out.printf("Column%d: name = %s, type = %d, type name = %s, display size = %d\n", column, metaData.getColumnName(column), metaData.getColumnType(column),
- metaData.getColumnTypeName(column), metaData.getColumnDisplaySize(column));
- }
- int rows = 0;
- System.out.println("Retrieve data of " + tablePrefix + i);
- while (resSet.next()) {
- resRow = new StringBuilder();
- for (int col = 1; col <= metaData.getColumnCount(); col++) {
- resRow.append(metaData.getColumnName(col)).append("=").append(resSet.getObject(col))
- .append(" ");
- }
- System.out.println(resRow.toString());
- rows++;
- }
-
- try {
- if (resSet != null)
- resSet.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- System.out.printf("Successfully executed query: %s;\nTotal rows returned: %d\n", sql.toString(), rows);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- System.out.printf("Failed to execute query: %s\n", sql.toString());
- System.exit(4);
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(4);
- }
- System.out.println("Query completed!");
- }
-
-}
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcChecker.java
similarity index 98%
rename from tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java
rename to tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcChecker.java
index 74e586d7fdf1a0f8ad65a807134caae7e05f6d4a..4be71c52214c348ed7b41c3e763de0d908514907 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcChecker.java
@@ -5,7 +5,7 @@ import com.taosdata.jdbc.TSDBDriver;
import java.sql.*;
import java.util.Properties;
-public class JDBCConnectorChecker {
+public class JdbcChecker {
private static String host;
private static String dbName = "test";
private static String tbName = "weather";
@@ -120,6 +120,7 @@ public class JDBCConnectorChecker {
printSql(sql, execute, (end - start));
} catch (SQLException e) {
e.printStackTrace();
+
}
}
@@ -157,7 +158,7 @@ public class JDBCConnectorChecker {
return;
}
- JDBCConnectorChecker checker = new JDBCConnectorChecker();
+ JdbcChecker checker = new JdbcChecker();
checker.init();
checker.createDatabase();
checker.useDatabase();
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java
index c30d85a084d7175e9e6861ad33d7374a868553d9..259985ec9f4708b9317575fd97919adcc82d7161 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java
@@ -25,6 +25,7 @@ public class JdbcTaosdemo {
}
public static void main(String[] args) {
+ // parse config from args
JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(args);
boolean isHelp = Arrays.asList(args).contains("--help");
@@ -38,27 +39,51 @@ public class JdbcTaosdemo {
}
JdbcTaosdemo taosdemo = new JdbcTaosdemo(config);
+ // establish connection
taosdemo.init();
+ // drop database
taosdemo.dropDatabase();
+ // create database
taosdemo.createDatabase();
+ // use db
taosdemo.useDatabase();
+ // create super table
taosdemo.createSuperTable();
+ // create sub tables
taosdemo.createTableMultiThreads();
boolean infinite = Arrays.asList(args).contains("--infinite");
if (infinite) {
- logger.info("!!! Infinite Insert Mode Started. !!!!");
+ logger.info("!!! Infinite Insert Mode Started. !!!");
taosdemo.insertInfinite();
} else {
+ // insert into table
taosdemo.insertMultiThreads();
- // single table select
+ // select from sub table
taosdemo.selectFromTableLimit();
taosdemo.selectCountFromTable();
taosdemo.selectAvgMinMaxFromTable();
- // super table select
+ // select last from
+ taosdemo.selectLastFromTable();
+ // select from super table
taosdemo.selectFromSuperTableLimit();
taosdemo.selectCountFromSuperTable();
taosdemo.selectAvgMinMaxFromSuperTable();
+ //select avg ,max from stb where tag
+ taosdemo.selectAvgMinMaxFromSuperTableWhereTag();
+ //select last from stb where location = ''
+ taosdemo.selectLastFromSuperTableWhere();
+ // select group by
+ taosdemo.selectGroupBy();
+ // select like
+ taosdemo.selectLike();
+ // select where ts >= ts<=
+ taosdemo.selectLastOneHour();
+ taosdemo.selectLastOneDay();
+ taosdemo.selectLastOneWeek();
+ taosdemo.selectLastOneMonth();
+ taosdemo.selectLastOneYear();
+
// drop super table
if (config.isDeleteTable())
taosdemo.dropSuperTable();
@@ -196,6 +221,11 @@ public class JdbcTaosdemo {
executeQuery(sql);
}
+ private void selectLastFromTable() {
+ String sql = SqlSpeller.selectLastFromTableSQL(config.getDbName(), config.getTbPrefix(), 1);
+ executeQuery(sql);
+ }
+
private void selectFromSuperTableLimit() {
String sql = SqlSpeller.selectFromSuperTableLimitSQL(config.getDbName(), config.getStbName(), 10, 0);
executeQuery(sql);
@@ -211,6 +241,52 @@ public class JdbcTaosdemo {
executeQuery(sql);
}
+ private void selectAvgMinMaxFromSuperTableWhereTag() {
+ String sql = SqlSpeller.selectAvgMinMaxFromSuperTableWhere("current", config.getDbName(), config.getStbName());
+ executeQuery(sql);
+ }
+
+ private void selectLastFromSuperTableWhere() {
+ String sql = SqlSpeller.selectLastFromSuperTableWhere("current", config.getDbName(), config.getStbName());
+ executeQuery(sql);
+ }
+
+ private void selectGroupBy() {
+ String sql = SqlSpeller.selectGroupBy("current", config.getDbName(), config.getStbName());
+ executeQuery(sql);
+ }
+
+ private void selectLike() {
+ String sql = SqlSpeller.selectLike(config.getDbName(), config.getStbName());
+ executeQuery(sql);
+ }
+
+ private void selectLastOneHour() {
+ String sql = SqlSpeller.selectLastOneHour(config.getDbName(), config.getStbName());
+ executeQuery(sql);
+ }
+
+ private void selectLastOneDay() {
+ String sql = SqlSpeller.selectLastOneDay(config.getDbName(), config.getStbName());
+ executeQuery(sql);
+ }
+
+ private void selectLastOneWeek() {
+ String sql = SqlSpeller.selectLastOneWeek(config.getDbName(), config.getStbName());
+ executeQuery(sql);
+ }
+
+ private void selectLastOneMonth() {
+ String sql = SqlSpeller.selectLastOneMonth(config.getDbName(), config.getStbName());
+ executeQuery(sql);
+ }
+
+ private void selectLastOneYear() {
+ String sql = SqlSpeller.selectLastOneYear(config.getDbName(), config.getStbName());
+ executeQuery(sql);
+ }
+
+
private void close() {
try {
if (connection != null) {
@@ -241,6 +317,7 @@ public class JdbcTaosdemo {
long end = System.currentTimeMillis();
printSql(sql, execute, (end - start));
} catch (SQLException e) {
+ logger.error("ERROR execute SQL ===> " + sql);
logger.error(e.getMessage());
e.printStackTrace();
}
@@ -258,6 +335,7 @@ public class JdbcTaosdemo {
printSql(sql, true, (end - start));
printResult(resultSet);
} catch (SQLException e) {
+ logger.error("ERROR execute SQL ===> " + sql);
logger.error(e.getMessage());
e.printStackTrace();
}
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java
index 3cca9a3d7a8b45be5d733b9f7a4836eb89c828c3..82613037dbccd3be1f2c8a85a2f25e7a25ffad01 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java
@@ -14,9 +14,9 @@ public final class JdbcTaosdemoConfig {
//Destination database. Default is 'test'
private String dbName = "test";
//keep
- private int keep = 365 * 20;
+ private int keep = 3650;
//days
- private int days = 30;
+ private int days = 10;
//Super table Name. Default is 'meters'
private String stbName = "meters";
@@ -35,7 +35,7 @@ public final class JdbcTaosdemoConfig {
private boolean deleteTable = false;
public static void printHelp() {
- System.out.println("Usage: java -jar JDBCConnectorChecker.jar [OPTION...]");
+ System.out.println("Usage: java -jar JdbcTaosDemo.jar [OPTION...]");
System.out.println("-h host The host to connect to TDengine. you must input one");
System.out.println("-p port The TCP/IP port number to use for the connection. Default is 6030");
System.out.println("-u user The TDengine user name to use when connecting to the server. Default is 'root'");
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java
index d6d6ebbff1ac08e68e3e8034a59f84189ad86bf4..a35628bb58c6630d92bd2b6aebb09f9912e57536 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java
@@ -3,44 +3,49 @@ package com.taosdata.example.jdbcTaosdemo.task;
import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig;
import com.taosdata.example.jdbcTaosdemo.utils.ConnectionFactory;
import com.taosdata.example.jdbcTaosdemo.utils.SqlSpeller;
-import com.taosdata.example.jdbcTaosdemo.utils.TimeStampUtil;
import org.apache.log4j.Logger;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.concurrent.atomic.AtomicLong;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
public class InsertTableTask implements Runnable {
private static final Logger logger = Logger.getLogger(InsertTableTask.class);
- private static AtomicLong beginTimestamp = new AtomicLong(TimeStampUtil.datetimeToLong("2005-01-01 00:00:00.000"));
private final JdbcTaosdemoConfig config;
- private final int startIndex;
+ private final int startTbIndex;
private final int tableNumber;
- private final int recordsNumber;
+ private final int recordsNumberPerTable;
- public InsertTableTask(JdbcTaosdemoConfig config, int startIndex, int tableNumber, int recordsNumber) {
+ public InsertTableTask(JdbcTaosdemoConfig config, int startTbIndex, int tableNumber, int recordsNumberPerTable) {
this.config = config;
- this.startIndex = startIndex;
+ this.startTbIndex = startTbIndex;
this.tableNumber = tableNumber;
- this.recordsNumber = recordsNumber;
+ this.recordsNumberPerTable = recordsNumberPerTable;
}
@Override
public void run() {
try {
Connection connection = ConnectionFactory.build(config);
+ int keep = config.getKeep();
+ Instant end = Instant.now();
+ Instant start = end.minus(Duration.ofDays(keep - 1));
+ long timeGap = ChronoUnit.MILLIS.between(start, end) / (recordsNumberPerTable - 1);
+
// iterate insert
- for (int j = 0; j < recordsNumber; j++) {
- long ts = beginTimestamp.getAndIncrement();
+ for (int j = 0; j < recordsNumberPerTable; j++) {
+ long ts = start.toEpochMilli() + (j * timeGap);
// insert data into echo table
- for (int i = startIndex; i < startIndex + tableNumber; i++) {
+ for (int i = startTbIndex; i < startTbIndex + tableNumber; i++) {
String sql = SqlSpeller.insertOneRowSQL(config.getDbName(), config.getTbPrefix(), i + 1, ts);
+ logger.info(Thread.currentThread().getName() + ">>> " + sql);
Statement statement = connection.createStatement();
statement.execute(sql);
statement.close();
- logger.info(Thread.currentThread().getName() + ">>> " + sql);
}
}
connection.close();
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java
index 7af97f3b1baa0206f6f29b18a1ae59d2182c5423..b4a79e9eba47cc947d822b645d0ae1f9952f08f0 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java
@@ -78,5 +78,49 @@ public class SqlSpeller {
return "select avg(" + field + "),min(" + field + "),max(" + field + ") from " + dbName + "." + stbName + "";
}
+ public static String selectLastFromTableSQL(String dbName, String tbPrefix, int tbIndex) {
+ return "select last(*) from " + dbName + "." + tbPrefix + "" + tbIndex;
+ }
+
+ //select avg ,max from stb where tag
+ public static String selectAvgMinMaxFromSuperTableWhere(String field, String dbName, String stbName) {
+ return "select avg(" + field + "),min(" + field + "),max(" + field + ") from " + dbName + "." + stbName + " where location = '" + locations[random.nextInt(locations.length)] + "'";
+ }
+
+ //select last from stb where
+ public static String selectLastFromSuperTableWhere(String field, String dbName, String stbName) {
+ return "select last(" + field + ") from " + dbName + "." + stbName + " where location = '" + locations[random.nextInt(locations.length)] + "'";
+ }
+
+ public static String selectGroupBy(String field, String dbName, String stbName) {
+ return "select avg(" + field + ") from " + dbName + "." + stbName + " group by location";
+ }
+
+ public static String selectLike(String dbName, String stbName) {
+ return "select * from " + dbName + "." + stbName + " where location like 'S%'";
+ }
+
+ public static String selectLastOneHour(String dbName, String stbName) {
+ return "select * from " + dbName + "." + stbName + " where ts >= now - 1h";
+ }
+
+ public static String selectLastOneDay(String dbName, String stbName) {
+ return "select * from " + dbName + "." + stbName + " where ts >= now - 1d";
+ }
+
+ public static String selectLastOneWeek(String dbName, String stbName) {
+ return "select * from " + dbName + "." + stbName + " where ts >= now - 1w";
+ }
+
+ public static String selectLastOneMonth(String dbName, String stbName) {
+ return "select * from " + dbName + "." + stbName + " where ts >= now - 1n";
+ }
+
+ public static String selectLastOneYear(String dbName, String stbName) {
+ return "select * from " + dbName + "." + stbName + " where ts >= now - 1y";
+ }
+ // select group by
+ // select like
+ // select ts >= ts<=
}
\ No newline at end of file
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java
index d00471f58147f9c66f3747c1f8a1eadbae3a6dab..0a345afdd1e45123d889d7ee198cf8efd201176b 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java
@@ -1,8 +1,10 @@
package com.taosdata.example.jdbcTaosdemo.utils;
-import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Date;
public class TimeStampUtil {
private static final String datetimeFormat = "yyyy-MM-dd HH:mm:ss.SSS";
@@ -21,14 +23,14 @@ public class TimeStampUtil {
return sdf.format(new Date(time));
}
- public static void main(String[] args) {
- final String startTime = "2005-01-01 00:00:00.000";
+ public static void main(String[] args) throws ParseException {
+
+// Instant now = Instant.now();
+// System.out.println(now);
+// Instant years20Ago = now.minus(Duration.ofDays(365));
+// System.out.println(years20Ago);
- long start = TimeStampUtil.datetimeToLong(startTime);
- System.out.println(start);
- String datetime = TimeStampUtil.longToDatetime(1519833600000L);
- System.out.println(datetime);
}
diff --git a/tests/examples/JDBC/JDBCDemo/src/test/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtilTest.java b/tests/examples/JDBC/JDBCDemo/src/test/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtilTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..f370b2ef6eaa708b061ebf4a7f58f3d31f78f999
--- /dev/null
+++ b/tests/examples/JDBC/JDBCDemo/src/test/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtilTest.java
@@ -0,0 +1,52 @@
+package com.taosdata.example.jdbcTaosdemo.utils;
+
+import org.junit.Test;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.util.Date;
+
+import static org.junit.Assert.*;
+
+public class TimeStampUtilTest {
+
+ @Test
+ public void datetimeToLong() {
+ final String startTime = "2005-01-01 00:00:00.000";
+ long start = TimeStampUtil.datetimeToLong(startTime);
+ assertEquals(1104508800000l, start);
+ }
+
+ @Test
+ public void longToDatetime() {
+ String datetime = TimeStampUtil.longToDatetime(1510000000000L);
+ assertEquals("2017-11-07 04:26:40.000", datetime);
+ }
+
+ @Test
+ public void getStartDateTime() {
+ int keep = 365;
+
+ Instant end = Instant.now();
+ System.out.println(end.toString());
+ System.out.println(end.toEpochMilli());
+
+ Instant start = end.minus(Duration.ofDays(keep));
+ System.out.println(start.toString());
+ System.out.println(start.toEpochMilli());
+
+ int numberOfRecordsPerTable = 10;
+ long timeGap = ChronoUnit.MILLIS.between(start, end) / (numberOfRecordsPerTable - 1);
+ System.out.println(timeGap);
+
+ System.out.println("===========================");
+ for (int i = 0; i < numberOfRecordsPerTable; i++) {
+ long ts = start.toEpochMilli() + (i * timeGap);
+ System.out.println(i + " : " + ts);
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/examples/nodejs/nodejsChecker.js b/tests/examples/nodejs/nodejsChecker.js
new file mode 100644
index 0000000000000000000000000000000000000000..c77944f75243a50e6e2c738e659cb4e64f3e5574
--- /dev/null
+++ b/tests/examples/nodejs/nodejsChecker.js
@@ -0,0 +1,60 @@
+const taos = require('td2.0-connector');
+
+
+var host = null;
+var port = 6030;
+for(var i = 2; i < global.process.argv.length; i++){
+ var key = global.process.argv[i].split("=")[0];
+ var value = global.process.argv[i].split("=")[1];
+
+ if("host" == key){
+ host = value;
+ }
+ if("port" == key){
+ port = value;
+ }
+}
+
+if(host == null){
+ console.log("Usage: node nodejsChecker.js host= port=");
+ process.exit(0);
+}
+
+// establish connection
+var conn = taos.connect({host:host, user:"root", password:"taosdata",port:port});
+var cursor = conn.cursor();
+// create database
+executeSql("create database if not exists test", 0);
+// use db
+executeSql("use test", 0);
+// drop table
+executeSql("drop table if exists test.weather", 0);
+// create table
+executeSql("create table if not exists test.weather(ts timestamp, temperature float, humidity int)", 0);
+// insert
+executeSql("insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)", 1);
+// select
+executeQuery("select * from test.weather");
+// close connection
+conn.close();
+
+function executeQuery(sql){
+ var start = new Date().getTime();
+ var promise = cursor.query(sql, true);
+ var end = new Date().getTime();
+ printSql(sql, promise != null,(end - start));
+ promise.then(function(result){
+ result.pretty();
+ });
+}
+
+function executeSql(sql, affectRows){
+ var start = new Date().getTime();
+ var promise = cursor.execute(sql);
+ var end = new Date().getTime();
+ printSql(sql, promise == affectRows, (end - start));
+}
+
+function printSql(sql, succeed, cost){
+ console.log("[ "+(succeed ? "OK" : "ERROR!")+" ] time cost: " + cost + " ms, execute statement ====> " + sql);
+}
diff --git a/tests/examples/python/PYTHONConnectorChecker/PythonChecker.py b/tests/examples/python/PYTHONConnectorChecker/PythonChecker.py
new file mode 100644
index 0000000000000000000000000000000000000000..d74f021ffcf3aa33c551cc265243b5139c23b757
--- /dev/null
+++ b/tests/examples/python/PYTHONConnectorChecker/PythonChecker.py
@@ -0,0 +1,114 @@
+import taos
+import time
+import sys
+import getopt
+class ConnectorChecker:
+ def init(self):
+ self.host = "127.0.0.1"
+ self.dbName = "test"
+ self.tbName = "weather"
+ self.user = "root"
+ self.password = "taosdata"
+
+
+ def sethdt(self,FQDN,dbname,tbname):
+ if(FQDN):
+ self.host=FQDN
+ if(dbname):
+ self.dbname=dbname
+ if(tbname):
+ self.tbName
+ def printSql(self,sql,elapsed):
+ print("[ "+"OK"+" ]"+" time cost: %s ms, execute statement ====> %s"
+ %(elapsed,sql))
+ def executeQuery(self,sql):
+ try:
+ start=time.time()
+ execute = self.cl.execute(sql)
+ elapsed = (time.time()-start)*1000
+ self.printSql(sql,elapsed)
+ data = self.cl.fetchall()
+ numOfRows = self.cl.rowcount
+ numOfCols = len(self.cl.description)
+ for irow in range(numOfRows):
+ print("Row%d: ts=%s, temperature=%d, humidity=%f" %(irow, data[irow][0], data[irow][1],data[irow][2]))
+ except Exception as e:
+ print("Failure sql: %s,exception: %s" %sql,str(e))
+ def execute(self,sql):
+ try:
+ start=time.time()
+ execute = self.cl.execute(sql)
+ elapsed = (time.time()-start)*1000
+ self.printSql(sql,elapsed)
+
+ except Exception as e:
+ print("Failure sql: %s,exception: %s" %
+ sql,str(e))
+ def close(self):
+ print("connetion closed.")
+ self.cl.close()
+ self.conn.close()
+ def createDatabase(self):
+ sql="create database if not exists %s" % self.dbName
+ self.execute(sql)
+ def useDatabase(self):
+ sql="use %s" % self.dbName
+ self.execute(sql)
+ def createTable(self):
+ sql="create table if not exists %s.%s (ts timestamp, temperature float, humidity int)"%(self.dbName,self.tbName)
+ self.execute(sql)
+ def checkDropTable(self):
+ sql="drop table if exists " + self.dbName + "." + self.tbName + ""
+ self.execute(sql)
+ def checkInsert(self):
+ sql="insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)"
+ self.execute(sql)
+ def checkSelect(self):
+ sql = "select * from test.weather"
+ self.executeQuery(sql)
+ def srun(self):
+ try:
+ self.conn = taos.connect(host=self.host,user=self.user,password=self.password)
+ #self.conn = taos.connect(self.host,self.user,self.password)
+ except Exception as e:
+ print("connection failed: %s"%self.host)
+ exit(1)
+ print("[ OK ] Connection established.")
+ self.cl = self.conn.cursor()
+
+def main(argv):
+ FQDN=''
+ dbname=''
+ tbname=''
+ try:
+ opts, args = getopt.getopt(argv,"h:d:t:",["FQDN=","ifile=","ofile="])
+ except getopt.GetoptError:
+ print ('PYTHONConnectorChecker.py -h ')
+ sys.exit(2)
+ for opt, arg in opts:
+ if opt in ("-h", "--FQDN"):
+ FQDN=arg
+ elif opt in ("-d", "--dbname"):
+ dbname = arg
+ elif opt in ("-t", "--tbname"):
+ tbname = arg
+
+ checker = ConnectorChecker()
+ checker.init()
+ checker.sethdt(FQDN,dbname,tbname)
+ checker.srun()
+ checker.createDatabase()
+ checker.useDatabase()
+ checker.checkDropTable()
+ checker.createTable()
+ checker.checkInsert()
+ checker.checkSelect()
+ checker.checkDropTable()
+ checker.close()
+
+
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
+
+
diff --git a/tests/gotest/batchtest.bat b/tests/gotest/batchtest.bat
new file mode 100644
index 0000000000000000000000000000000000000000..abe9a58f319068d5e11017abcd721a4c54d6aca9
--- /dev/null
+++ b/tests/gotest/batchtest.bat
@@ -0,0 +1,17 @@
+@echo off
+echo ==== start Go connector test cases test ====
+cd /d %~dp0
+
+set severIp=%1
+set serverPort=%2
+if "%severIp%"=="" (set severIp=127.0.0.1)
+if "%serverPort%"=="" (set serverPort=6030)
+
+cd case001
+case001.bat %severIp% %serverPort%
+
+rem cd case002
+rem case002.bat
+
+:: cd case002
+:: case002.bat
diff --git a/tests/gotest/batchtest.sh b/tests/gotest/batchtest.sh
index a027dd0d7ce04c599233157bdd618fad3885c809..e8ed9ecbed9f70c98e6b5db052c3e69082c1794d 100644
--- a/tests/gotest/batchtest.sh
+++ b/tests/gotest/batchtest.sh
@@ -1,5 +1,18 @@
#!/bin/bash
-bash ./case001/case001.sh
-#bash ./case002/case002.sh
-#bash ./case003/case003.sh
+echo "==== start Go connector test cases test ===="
+
+severIp=$1
+serverPort=$2
+
+if [ ! -n "$severIp" ]; then
+ severIp=127.0.0.1
+fi
+
+if [ ! -n "$serverPort" ]; then
+ serverPort=6030
+fi
+
+bash ./case001/case001.sh $severIp $serverPort
+#bash ./case002/case002.sh $severIp $serverPort
+#bash ./case003/case003.sh $severIp $serverPort
diff --git a/tests/gotest/case001/case001.bat b/tests/gotest/case001/case001.bat
new file mode 100644
index 0000000000000000000000000000000000000000..ebec576e724ccb14319dd380c9783a783ac0db62
--- /dev/null
+++ b/tests/gotest/case001/case001.bat
@@ -0,0 +1,9 @@
+@echo off
+echo ==== start run cases001.go
+
+del go.*
+go mod init demotest
+go build
+demotest.exe -h %1 -p %2
+cd ..
+
diff --git a/tests/gotest/case001/case001.go b/tests/gotest/case001/case001.go
index 1d5ede6d21a0bacad34cb807a16b50e0ae643512..fb94f566dd7fa9ef8932bc28326310681998b410 100644
--- a/tests/gotest/case001/case001.go
+++ b/tests/gotest/case001/case001.go
@@ -16,20 +16,53 @@ package main
import (
"database/sql"
+ "flag"
"fmt"
_ "github.com/taosdata/driver-go/taosSql"
"log"
+ "strconv"
"time"
)
+type config struct {
+ hostName string
+ serverPort int
+ user string
+ password string
+}
+
+var configPara config
+var url string
+
+func init() {
+ flag.StringVar(&configPara.hostName, "h", "127.0.0.1","The host to connect to TDengine server.")
+ flag.IntVar(&configPara.serverPort, "p", 6030, "The TCP/IP port number to use for the connection to TDengine server.")
+ flag.StringVar(&configPara.user, "u", "root", "The TDengine user name to use when connecting to the server.")
+ flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.")
+
+ flag.Parse()
+}
+
+func printAllArgs() {
+ fmt.Printf("\n============= args parse result: =============\n")
+ fmt.Printf("hostName: %v\n", configPara.hostName)
+ fmt.Printf("serverPort: %v\n", configPara.serverPort)
+ fmt.Printf("usr: %v\n", configPara.user)
+ fmt.Printf("password: %v\n", configPara.password)
+ fmt.Printf("================================================\n")
+}
+
func main() {
+ printAllArgs()
taosDriverName := "taosSql"
demodb := "demodb"
demot := "demot"
fmt.Printf("\n======== start demo test ========\n")
+
+ url = "root:taosdata@/tcp(" + configPara.hostName + ":" + strconv.Itoa(configPara.serverPort) + ")/"
// open connect to taos server
- db, err := sql.Open(taosDriverName, "root:taosdata@/tcp(192.168.1.217:7100)/")
+ db, err := sql.Open(taosDriverName, url)
if err != nil {
log.Fatalf("Open database error: %s\n", err)
}
diff --git a/tests/gotest/case001/case001.sh b/tests/gotest/case001/case001.sh
index 5a9034c4d18e257eaaf9324c570fbc17b01c548b..831e9f83ac482c0a2c668e2ad0d16c4bf59f19aa 100644
--- a/tests/gotest/case001/case001.sh
+++ b/tests/gotest/case001/case001.sh
@@ -1,10 +1,6 @@
#!/bin/bash
-##################################################
-#
-# Do go test
-#
-##################################################
+echo "==== start run cases001.go"
set +e
#set -x
@@ -12,59 +8,14 @@ set +e
script_dir="$(dirname $(readlink -f $0))"
#echo "pwd: $script_dir, para0: $0"
-execName=$0
-execName=`echo ${execName##*/}`
-goName=`echo ${execName%.*}`
-
-###### step 1: start one taosd
-scriptDir=$script_dir/../../script/sh
-bash $scriptDir/stop_dnodes.sh
-bash $scriptDir/deploy.sh -n dnode1 -i 1
-bash $scriptDir/cfg.sh -n dnode1 -c walLevel -v 0
-bash $scriptDir/exec.sh -n dnode1 -s start
-
-###### step 2: set config item
-TAOS_CFG=/etc/taos/taos.cfg
-HOSTNAME=`hostname -f`
-
-if [ ! -f ${TAOS_CFG} ]; then
- touch -f $TAOS_CFG
-fi
-
-echo " " > $TAOS_CFG
-echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG
-echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG
-echo "serverPort 7100" >> $TAOS_CFG
-#echo "dataDir $DATA_DIR" >> $TAOS_CFG
-#echo "logDir $LOG_DIR" >> $TAOS_CFG
-#echo "scriptDir ${CODE_DIR}/../script" >> $TAOS_CFG
-echo "numOfLogLines 100000000" >> $TAOS_CFG
-echo "dDebugFlag 135" >> $TAOS_CFG
-echo "mDebugFlag 135" >> $TAOS_CFG
-echo "sdbDebugFlag 135" >> $TAOS_CFG
-echo "rpcDebugFlag 135" >> $TAOS_CFG
-echo "tmrDebugFlag 131" >> $TAOS_CFG
-echo "cDebugFlag 135" >> $TAOS_CFG
-echo "httpDebugFlag 135" >> $TAOS_CFG
-echo "monitorDebugFlag 135" >> $TAOS_CFG
-echo "udebugFlag 135" >> $TAOS_CFG
-echo "tablemetakeeptimer 5" >> $TAOS_CFG
-echo "wal 0" >> $TAOS_CFG
-echo "asyncLog 0" >> $TAOS_CFG
-echo "locale en_US.UTF-8" >> $TAOS_CFG
-echo "enableCoreFile 1" >> $TAOS_CFG
-echo " " >> $TAOS_CFG
-
-ulimit -n 600000
-ulimit -c unlimited
-#
-##sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e
-#
+#execName=$0
+#execName=`echo ${execName##*/}`
+#goName=`echo ${execName%.*}`
###### step 3: start build
cd $script_dir
rm -f go.*
-go mod init $goName
+go mod init demotest
go build
-sleep 1s
-sudo ./$goName
+sleep 1s
+./demotest -h $1 -p $2
diff --git a/tests/pytest/concurrent_inquiry.py b/tests/pytest/concurrent_inquiry.py
index faefc8a1c296c10e8b4fc18c2e72a6b0ff8fda44..2460900891cff4c7f37d4f0c1e782769e0e6b328 100644
--- a/tests/pytest/concurrent_inquiry.py
+++ b/tests/pytest/concurrent_inquiry.py
@@ -27,6 +27,7 @@ query_sql = [
"select count(*) from test.meters where t7 like 'fi%';",
"select count(*) from test.meters where t7 like '_econd';",
"select count(*) from test.meters interval(1n) order by ts desc;",
+"select max(c0) from test.meters group by tbname",
"select first(*) from test.meters;",
"select last(*) from test.meters;",
"select last_row(*) from test.meters;",
@@ -56,6 +57,12 @@ query_sql = [
"select stddev(c6) from test.t1;",
"select sum(c6) from test.meters;",
"select top(c6, 2) from test.meters;",
+#all vnode
+"select count(*) from test.meters where t5 >2500 and t5<7500",
+"select max(c0),avg(c1) from test.meters where t5 >2500 and t5<7500",
+"select sum(c5),avg(c1) from test.meters where t5 >2500 and t5<7500",
+"select max(c0),min(c6) from test.meters where t5 >2500 and t5<7500",
+"select min(c0),avg(c6) from test.meters where t5 >2500 and t5<7500",
# second supertable
"select count(*) from test.meters1 where c1 > 50;",
"select count(*) from test.meters1 where c2 >= 50 and c2 < 100;",
@@ -65,6 +72,7 @@ query_sql = [
"select count(*) from test.meters1 where t7 like 'fi%';",
"select count(*) from test.meters1 where t7 like '_econd';",
"select count(*) from test.meters1 interval(1n) order by ts desc;",
+"select max(c0) from test.meters1 group by tbname",
"select first(*) from test.meters1;",
"select last(*) from test.meters1;",
"select last_row(*) from test.meters1;",
@@ -93,7 +101,19 @@ query_sql = [
"select spread(c6) from test.m1 ;",
"select stddev(c6) from test.m1;",
"select sum(c6) from test.meters1;",
-"select top(c6, 2) from test.meters1;"
+"select top(c6, 2) from test.meters1;",
+"select count(*) from test.meters1 where t5 >2500 and t5<7500",
+#all vnode
+"select count(*) from test.meters1 where t5 >2500 and t5<7500",
+"select max(c0),avg(c1) from test.meters1 where t5 >2500 and t5<7500",
+"select sum(c5),avg(c1) from test.meters1 where t5 >2500 and t5<7500",
+"select max(c0),min(c6) from test.meters1 where t5 >2500 and t5<7500",
+"select min(c0),avg(c6) from test.meters1 where t5 >2500 and t5<7500",
+#join
+"select * from meters,meters1 where meters.ts = meters1.ts and meters.t5 = meters1.t5",
+"select * from meters,meters1 where meters.ts = meters1.ts and meters.t7 = meters1.t7",
+"select * from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8",
+"select meters.ts,meters1.c2 from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8"
]
class ConcurrentInquiry:
@@ -112,6 +132,7 @@ class ConcurrentInquiry:
password,
)
cl = conn.cursor()
+ cl.execute("use test;")
print("Thread %d: starting" % threadID)
diff --git a/tests/pytest/insert/before_1970.py b/tests/pytest/insert/before_1970.py
new file mode 100644
index 0000000000000000000000000000000000000000..cb17b657aad1a3bfdb915c9661bad291b75d6f04
--- /dev/null
+++ b/tests/pytest/insert/before_1970.py
@@ -0,0 +1,80 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import tdLog
+from util.cases import tdCases
+from util.sql import tdSql
+from util.dnodes import tdDnodes
+
+
+class TDTestCase:
+ """
+ add test data before 1970s
+ """
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ tdSql.prepare()
+
+ print("==============step1")
+ tdSql.execute("create database if not exists demo keep 36500;");
+ print("==============create db demo keep 365000 days")
+ tdSql.execute("use demo;")
+ tdSql.execute("CREATE table if not exists test (ts timestamp, f1 int);")
+ print("==============create table test")
+
+ print("==============step2")
+ #TODO : should add more testcases
+ tdSql.execute("insert into test values('1930-12-12 01:19:20.345', 1);")
+ tdSql.execute("insert into test values('1969-12-30 23:59:59.999', 2);")
+ tdSql.execute("insert into test values(-3600, 3);")
+ tdSql.execute("insert into test values('2020-10-20 14:02:53.770', 4);")
+ print("==============insert data")
+
+ # tdSql.query("select * from test;")
+ #
+ # tdSql.checkRows(3)
+ #
+ # tdSql.checkData(0,0,'1969-12-12 01:19:20.345000')
+ # tdSql.checkData(1,0,'1970-01-01 07:00:00.000000')
+ # tdSql.checkData(2,0,'2020-10-20 14:02:53.770000')
+ print("==============step3")
+ tdDnodes.stopAll()
+ tdDnodes.start(1)
+ print("==============restart taosd")
+
+
+ print("==============step4")
+ tdSql.execute("use demo;")
+ tdSql.query("select * from test;")
+ # print(tdSql.queryResult)
+ tdSql.checkRows(4)
+ tdSql.checkData(0,0,'1930-12-12 01:19:20.345000')
+ tdSql.checkData(1,0,'1969-12-30 23:59:59.999000')
+ tdSql.checkData(2,0,'1970-01-01 07:00:00.000000')
+ tdSql.checkData(3,0,'2020-10-20 14:02:53.770000')
+ print("==============check data")
+
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/query/removeDBAndSTable.py b/tests/pytest/query/removeDBAndSTable.py
new file mode 100644
index 0000000000000000000000000000000000000000..4616c7e378326af633a89905d746c7d51ce92139
--- /dev/null
+++ b/tests/pytest/query/removeDBAndSTable.py
@@ -0,0 +1,70 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import tdLog
+from util.cases import tdCases
+from util.sql import tdSql
+from util.dnodes import tdDnodes
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ tdSql.prepare()
+
+ print("==============step1")
+ tdSql.execute("create database db_vplu");
+ tdSql.execute("use db_vplu")
+ tdSql.execute("CREATE table if not exists st (ts timestamp, speed int) tags(id int)")
+ tdSql.execute("CREATE table if not exists st_vplu (ts timestamp, speed int) tags(id int)")
+
+ print("==============step2")
+
+ tdSql.execute("drop table st")
+
+ tdSql.query("show stables")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 0, "st_vplu")
+
+ tdDnodes.stopAll()
+ tdDnodes.start(1)
+
+ tdSql.execute("use db_vplu")
+ tdSql.query("show stables")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 0, "st_vplu")
+
+ tdSql.execute("drop database db")
+ tdSql.query("show databases")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 0, "db_vplu")
+
+ tdDnodes.stopAll()
+ tdDnodes.start(1)
+
+ tdSql.query("show databases")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 0, "db_vplu")
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/table/alter_wal0.py b/tests/pytest/table/alter_wal0.py
new file mode 100644
index 0000000000000000000000000000000000000000..15ad69998f450b8e385cbf58052d246d9de27380
--- /dev/null
+++ b/tests/pytest/table/alter_wal0.py
@@ -0,0 +1,75 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import tdLog
+from util.cases import tdCases
+from util.sql import tdSql
+from util.dnodes import tdDnodes
+
+
+class TDTestCase:
+ """
+ remove last tow bytes of file 'wal0',then restart taosd and create new tables.
+ """
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ tdSql.prepare()
+
+ print("==============step1")
+ tdSql.execute("create database if not exists demo;");
+ tdSql.execute("use demo;")
+ tdSql.execute("create table if not exists meters(ts timestamp, f1 int) tags(t1 int);");
+ for i in range(1,11):
+ tdSql.execute("CREATE table if not exists test{num} using meters tags({num});".format(num=i))
+ print("==============insert 10 tables")
+
+ tdSql.query('show tables;')
+ tdSql.checkRows(10)
+
+ print("==============step2")
+ tdDnodes.stopAll()
+ filename = '/var/lib/taos/mnode/wal/wal0'
+
+ with open(filename, 'rb') as f1:
+ temp = f1.read()
+
+ with open(filename, 'wb') as f2:
+ f2.write(temp[:-2])
+
+ tdDnodes.start(1)
+ print("==============remove last tow bytes of file 'wal0' and restart taosd")
+
+ print("==============step3")
+ tdSql.execute("use demo;")
+ tdSql.query('show tables;')
+ tdSql.checkRows(10)
+ for i in range(11,21):
+ tdSql.execute("CREATE table if not exists test{num} using meters tags({num});".format(num=i))
+
+ tdSql.query('show tables;')
+ tdSql.checkRows(20)
+ print("==============check table numbers and create 10 tables")
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/script/jenkins/basic_1.txt b/tests/script/jenkins/basic_1.txt
index aba2ec945f518b473854eaec23f22fbca51d7192..765e7139163952c43569e596d8ca8cf27d583cf6 100644
--- a/tests/script/jenkins/basic_1.txt
+++ b/tests/script/jenkins/basic_1.txt
@@ -199,4 +199,7 @@
./test.sh -f unique/dnode/vnode_clean.sim
./test.sh -f unique/http/admin.sim
-./test.sh -f unique/http/opentsdb.sim
\ No newline at end of file
+./test.sh -f unique/http/opentsdb.sim
+
+./test.sh -f unique/import/replica2.sim
+./test.sh -f unique/import/replica3.sim
diff --git a/tests/script/jenkins/basic_2.txt b/tests/script/jenkins/basic_2.txt
index 166c732df79197173827af08ec36495dd11cde47..014313fafe9c7974baa7205cca41492dedee213a 100644
--- a/tests/script/jenkins/basic_2.txt
+++ b/tests/script/jenkins/basic_2.txt
@@ -81,3 +81,10 @@ cd ../../../debug; make
./test.sh -f unique/db/replica_reduce32.sim
./test.sh -f unique/db/replica_reduce31.sim
./test.sh -f unique/db/replica_part.sim
+
+./test.sh -f unique/vnode/many.sim
+./test.sh -f unique/vnode/replica2_basic2.sim
+./test.sh -f unique/vnode/replica2_repeat.sim
+./test.sh -f unique/vnode/replica3_basic.sim
+./test.sh -f unique/vnode/replica3_repeat.sim
+./test.sh -f unique/vnode/replica3_vgroup.sim
\ No newline at end of file
diff --git a/tests/script/jenkins/basic_3.txt b/tests/script/jenkins/basic_3.txt
index de5d64b98464d90fafd02c0efe28d444716c8cbd..83b10a371cbc354acc079a6307fe0dbee27e3533 100644
--- a/tests/script/jenkins/basic_3.txt
+++ b/tests/script/jenkins/basic_3.txt
@@ -1,5 +1,3 @@
-./test.sh -f unique/import/replica2.sim
-./test.sh -f unique/import/replica3.sim
./test.sh -f unique/stable/balance_replica1.sim
./test.sh -f unique/stable/dnode2_stop.sim
@@ -21,12 +19,7 @@
./test.sh -f unique/mnode/mgmt34.sim
./test.sh -f unique/mnode/mgmtr2.sim
-./test.sh -f unique/vnode/many.sim
-./test.sh -f unique/vnode/replica2_basic2.sim
-./test.sh -f unique/vnode/replica2_repeat.sim
-./test.sh -f unique/vnode/replica3_basic.sim
-./test.sh -f unique/vnode/replica3_repeat.sim
-./test.sh -f unique/vnode/replica3_vgroup.sim
+
./test.sh -f general/parser/stream_on_sys.sim
./test.sh -f general/stream/metrics_del.sim