From 2f027acdd549b728af2dc8194473d6c3e357691c Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 15:47:50 +0800 Subject: [PATCH 01/12] [TD-2598] feature: C# taosdemo, cleanup and minor fix. --- tests/examples/C#/taosdemo/README.md | 7 +--- tests/examples/C#/taosdemo/taosdemo.cs | 55 ++++++++++++++++---------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/tests/examples/C#/taosdemo/README.md b/tests/examples/C#/taosdemo/README.md index 82a8dc674a..9bceb84cd0 100644 --- a/tests/examples/C#/taosdemo/README.md +++ b/tests/examples/C#/taosdemo/README.md @@ -19,13 +19,8 @@ Usage: mono taosdemo.exe [OPTION...] -d database, Destination database. Default is 'test'. -a replica, Set the replica parameters of the database, Default 1, min: 1, max: 5. -m table_prefix, Table prefix name. Default is 't'. - -s sql file, The select sql file. -M stable, Use super table. - -o outputfile, Direct output to the named file. Default is './output.txt'. - -q query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC. - -b type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'. - -w length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8 - -l num_of_cols_per_record, The number of columns per record. Default is 3. + -s stable_prefix, STable prefix name. Default is 'st' -T num_of_threads, The number of threads. Default is 10. -r num_of_records_per_req, The number of records per request. Default is 1000. -t num_of_tables, The number of tables. Default is 1. diff --git a/tests/examples/C#/taosdemo/taosdemo.cs b/tests/examples/C#/taosdemo/taosdemo.cs index 7e7c18db26..68eefdd161 100644 --- a/tests/examples/C#/taosdemo/taosdemo.cs +++ b/tests/examples/C#/taosdemo/taosdemo.cs @@ -34,7 +34,7 @@ namespace TDengineDriver //sql parameters private string dbName = "db"; - private string stableName = "st"; + private string stablePrefix = "st"; private string tablePrefix = "t"; private bool isInsertOnly = false; @@ -52,7 +52,7 @@ namespace TDengineDriver private bool useStable = false; private short methodOfDelete = 0; private long numOfThreads = 1; - private long rateOfOutorder = 0; + private short rateOfOutorder = 10; private bool order = true; private bool skipReadKey = false; private bool verbose = false; @@ -83,10 +83,11 @@ namespace TDengineDriver Console.Write("{0}{1}{2}\n", indent, indent, "replica, Set the replica parameters of the database, Default 1, min: 1, max: 5."); Console.Write("{0}{1}", indent, "-m"); Console.Write("{0}{1}{2}\n", indent, indent, "table_prefix, Table prefix name. Default is 't'."); - Console.Write("{0}{1}", indent, "-s"); - Console.Write("{0}{1}{2}\n", indent, indent, "sql file, The select sql file."); Console.Write("{0}{1}", indent, "-M"); Console.Write("{0}{1}{2}\n", indent, indent, "stable, Use super table."); + Console.Write("{0}{1}", indent, "-s"); + Console.Write("{0}{1}{2}\n", indent, indent, "stable_prefix, STable prefix name. Default is 'st'"); +/* NOT SUPPORT Console.Write("{0}{1}", indent, "-o"); Console.Write("{0}{1}{2}\n", indent, indent, "outputfile, Direct output to the named file. Default is './output.txt'."); Console.Write("{0}{1}", indent, "-q"); @@ -97,6 +98,7 @@ namespace TDengineDriver Console.Write("{0}{1}{2}\n", indent, indent, "length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"); Console.Write("{0}{1}", indent, "-l"); Console.Write("{0}{1}{2}\n", indent, indent, "num_of_cols_per_record, The number of columns per record. Default is 3."); + */ Console.Write("{0}{1}", indent, "-T"); Console.Write("{0}{1}{2}\n", indent, indent, "num_of_threads, The number of threads. Default is 10."); Console.Write("{0}{1}", indent, "-r"); @@ -132,7 +134,7 @@ namespace TDengineDriver user = this.GetArgumentAsString(argv, "-u", "root"); password = this.GetArgumentAsString(argv, "-P", "taosdata"); dbName = this.GetArgumentAsString(argv, "-d", "db"); - stableName = this.GetArgumentAsString(argv, "-s", "st"); + stablePrefix = this.GetArgumentAsString(argv, "-s", "st"); tablePrefix = this.GetArgumentAsString(argv, "-m", "t"); isInsertOnly = this.GetArgumentAsFlag(argv, "-x"); queryMode = (int)this.GetArgumentAsLong(argv, "-q", 0, 1, 0); @@ -148,7 +150,7 @@ namespace TDengineDriver methodOfDelete = (short)this.GetArgumentAsLong(argv, "-D", 0, 3, 0); numOfThreads = (short)this.GetArgumentAsLong(argv, "-T", 1, 10000, 1); order = this.GetArgumentAsFlag(argv, "-O"); - rateOfOutorder = this.GetArgumentAsLong(argv, "-R", 0, 100, 0); + rateOfOutorder = (short)this.GetArgumentAsLong(argv, "-R", 0, 50, 10); skipReadKey = this.GetArgumentAsFlag(argv, "-y"); verbose = this.GetArgumentAsFlag(argv, "-v"); @@ -166,6 +168,10 @@ namespace TDengineDriver Console.Write("# Replica: {0}\n", replica); Console.Write("# Use STable: {0}\n", useStable); Console.Write("# Table prefix: {0}\n", tablePrefix); + if (useStable == true) + { + Console.Write("# STable prefix: {0}\n", stablePrefix); + } Console.Write("# Data order: {0}\n", order); Console.Write("# Data out of order rate: {0}\n", rateOfOutorder); Console.Write("# Delete method: {0}\n", methodOfDelete); @@ -217,7 +223,7 @@ namespace TDengineDriver long tmpVal = Convert.ToInt64(tmp); if (tmpVal < minVal || tmpVal > maxVal) { - Console.WriteLine("option {0:G} should in range [{1:G}, {2:G}]", argName, minVal, maxVal); + Console.WriteLine("option {0:G} value should in range [{1:G}, {2:G}]", argName, minVal, maxVal); ExitProgram(); } @@ -252,12 +258,17 @@ namespace TDengineDriver return defaultValue; } - static void ExitProgram() + static void CleanAndExitProgram() { TDengine.Cleanup(); System.Environment.Exit(0); } + static void ExitProgram() + { + System.Environment.Exit(0); + } + private void DebugPrintFormat(string format, params object[] parameters) { if (verbose == true) @@ -291,7 +302,7 @@ namespace TDengineDriver if (this.conn == IntPtr.Zero) { Console.WriteLine("Connect to TDengine failed"); - ExitProgram(); + CleanAndExitProgram(); } else { @@ -328,7 +339,7 @@ namespace TDengineDriver createTableThread.useStable = useStable; if (useStable) { - createTableThread.stableName = stableName; + createTableThread.stablePrefix = stablePrefix; } createTableThread.conn = conn; @@ -361,7 +372,7 @@ namespace TDengineDriver else { Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); - ExitProgram(); + CleanAndExitProgram(); } } @@ -378,7 +389,7 @@ namespace TDengineDriver else { Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); - ExitProgram(); + CleanAndExitProgram(); } TDengine.FreeResult(res); } @@ -389,7 +400,7 @@ namespace TDengineDriver sql.Clear(); sql.Append("CREATE TABLE IF NOT EXISTS "). - Append(this.dbName).Append(".").Append(this.stableName). + Append(this.dbName).Append(".").Append(this.stablePrefix). Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)"); IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) @@ -399,7 +410,7 @@ namespace TDengineDriver else { Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); - ExitProgram(); + CleanAndExitProgram(); } TDengine.FreeResult(res); } @@ -433,9 +444,11 @@ namespace TDengineDriver insertThread.verbose = verbose; insertThread.dbName = this.dbName; insertThread.tablePrefix = this.tablePrefix; + insertThread.order = this.order; + insertThread.rateOfOutorder = this.rateOfOutorder; if (useStable) { - // insertThread.stableName = stableName; + insertThread.stablePrefix = stablePrefix; } insertThread.conn = conn; @@ -470,7 +483,7 @@ namespace TDengineDriver if (res == IntPtr.Zero) { Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res)); - ExitProgram(); + CleanAndExitProgram(); } int fieldCount = TDengine.FieldCount(res); @@ -630,11 +643,13 @@ namespace TDengineDriver public string dbName { set; get; } public IntPtr conn { set; get; } public string tablePrefix { set; get; } - // public string stableName { set; get; } + public string stablePrefix { set; get; } public long recordsPerTable { set; get; } public long batchRows { set; get; } public long numOfTables { set; get; } public bool verbose { set; get; } + public bool order { set; get; } + public short rateOfOutorder { set; get; } private void DebugPrintFormat(string format, params object[] parameters) { @@ -723,7 +738,7 @@ namespace TDengineDriver public string dbName { set; get; } public IntPtr conn { set; get; } public string tablePrefix { set; get; } - public string stableName { set; get; } + public string stablePrefix { set; get; } public bool verbose { set; get; } public bool useStable { set; get; } @@ -756,7 +771,7 @@ namespace TDengineDriver Append(this.dbName).Append(".").Append(this.tablePrefix).Append(tableId); if (useStable == true) { - sql = sql.Append(" USING ").Append(this.dbName).Append(".").Append(this.stableName). + sql = sql.Append(" USING ").Append(this.dbName).Append(".").Append(this.stablePrefix). Append(" TAGS(").Append(tableId).Append(")"); } else @@ -771,7 +786,7 @@ namespace TDengineDriver else { DebugPrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); - ExitProgram(); + CleanAndExitProgram(); } TDengine.FreeResult(res); } From 7b476ef75f781703660adc31f5f2709181d651e5 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 18:52:35 +0800 Subject: [PATCH 02/12] [TD-2598] feature: C# taosdemo, support query command. --- tests/examples/C#/taosdemo/README.md | 44 +++-- tests/examples/C#/taosdemo/taosdemo.cs | 264 +++++++++++++++---------- 2 files changed, 185 insertions(+), 123 deletions(-) diff --git a/tests/examples/C#/taosdemo/README.md b/tests/examples/C#/taosdemo/README.md index 9bceb84cd0..2d125fb140 100644 --- a/tests/examples/C#/taosdemo/README.md +++ b/tests/examples/C#/taosdemo/README.md @@ -10,25 +10,27 @@ run C# version taosdemo === Usage: mono taosdemo.exe [OPTION...] - --help Show usage. + --help Show usage. - -h host, The host to connect to TDengine. Default is localhost. - -p port, The TCP/IP port number to use for the connection. Default is 0. - -u user, The user name to use when connecting to the server. Default is 'root'. - -P password, The password to use when connecting to the server. Default is 'taosdata'. - -d database, Destination database. Default is 'test'. - -a replica, Set the replica parameters of the database, Default 1, min: 1, max: 5. - -m table_prefix, Table prefix name. Default is 't'. - -M stable, Use super table. - -s stable_prefix, STable prefix name. Default is 'st' - -T num_of_threads, The number of threads. Default is 10. - -r num_of_records_per_req, The number of records per request. Default is 1000. - -t num_of_tables, The number of tables. Default is 1. - -n num_of_records_per_table, The number of records per table. Default is 1. - -c config_directory, Configuration directory. Default is '/etc/taos/'. - -x flag, Insert only flag. - -O order, Insert mode--0: In order, 1: Out of order. Default is in order. - -R rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50. - -D Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database. - -v Print verbose output - -y Skip read key for continous test, default is not skip + -h host, The host to connect to TDengine. Default is localhost. + -p port, The TCP/IP port number to use for the connection. Default is 0. + -u user, The user name to use when connecting to the server. Default is 'root'. + -P password, The password to use when connecting to the server. Default is 'taosdata'. + -d database, Destination database. Default is 'test'. + -a replica, Set the replica parameters of the database, Default 1, min: 1, max: 5. + -m table_prefix, Table prefix name. Default is 't'. + -M stable, Use super table. + -s stable_prefix, STable prefix name. Default is 'st' + -Q query, Execute query command. set 'DEFAULT' means select * from each table + -T num_of_threads, The number of threads. Default is 10. + -r num_of_records_per_req, The number of records per request. Default is 1000. + -t num_of_tables, The number of tables. Default is 1. + -n num_of_records_per_table, The number of records per table. Default is 1. + -c config_directory, Configuration directory. Default is '/etc/taos/'. + -x flag, Insert only flag. + -O order, Insert mode--0: In order, 1: Out of order. Default is in order. + -R rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50. + -D Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database. + -v Print verbose output + -g Print debug output + -y Skip read key for continous test, default is not skip diff --git a/tests/examples/C#/taosdemo/taosdemo.cs b/tests/examples/C#/taosdemo/taosdemo.cs index 68eefdd161..6e1cbd2088 100644 --- a/tests/examples/C#/taosdemo/taosdemo.cs +++ b/tests/examples/C#/taosdemo/taosdemo.cs @@ -38,7 +38,8 @@ namespace TDengineDriver private string tablePrefix = "t"; private bool isInsertOnly = false; - private int queryMode = 1; + private string query = "NONE"; + private short queryMode = 1; private long recordsPerTable = 1; private int recordsPerRequest = 1; @@ -56,8 +57,15 @@ namespace TDengineDriver private bool order = true; private bool skipReadKey = false; private bool verbose = false; + private bool debug = false; + static void HelpPrint(string arg, string desc) + { + string indent = " "; + Console.WriteLine("{0}{1}", indent, arg.PadRight(25)+desc); + } + static void PrintHelp(String[] argv) { for (int i = 0; i < argv.Length; ++i) @@ -66,61 +74,38 @@ namespace TDengineDriver { Console.WriteLine("Usage: mono taosdemo.exe [OPTION...]"); Console.WriteLine(""); - string indent = " "; - Console.WriteLine("{0}{1}", indent, "--help Show usage."); + HelpPrint("--help", "Show usage."); Console.WriteLine(""); - Console.Write("{0}{1}", indent, "-h"); - Console.Write("{0}{1}{2}\n", indent, indent, "host, The host to connect to TDengine. Default is localhost."); - Console.Write("{0}{1}", indent, "-p"); - Console.Write("{0}{1}{2}\n", indent, indent, "port, The TCP/IP port number to use for the connection. Default is 0."); - Console.Write("{0}{1}", indent, "-u"); - Console.Write("{0}{1}{2}\n", indent, indent, "user, The user name to use when connecting to the server. Default is 'root'."); - Console.Write("{0}{1}", indent, "-P"); - Console.Write("{0}{1}{2}\n", indent, indent, "password, The password to use when connecting to the server. Default is 'taosdata'."); - Console.Write("{0}{1}", indent, "-d"); - Console.Write("{0}{1}{2}\n", indent, indent, "database, Destination database. Default is 'test'."); - Console.Write("{0}{1}", indent, "-a"); - Console.Write("{0}{1}{2}\n", indent, indent, "replica, Set the replica parameters of the database, Default 1, min: 1, max: 5."); - Console.Write("{0}{1}", indent, "-m"); - Console.Write("{0}{1}{2}\n", indent, indent, "table_prefix, Table prefix name. Default is 't'."); - Console.Write("{0}{1}", indent, "-M"); - Console.Write("{0}{1}{2}\n", indent, indent, "stable, Use super table."); - Console.Write("{0}{1}", indent, "-s"); - Console.Write("{0}{1}{2}\n", indent, indent, "stable_prefix, STable prefix name. Default is 'st'"); -/* NOT SUPPORT - Console.Write("{0}{1}", indent, "-o"); - Console.Write("{0}{1}{2}\n", indent, indent, "outputfile, Direct output to the named file. Default is './output.txt'."); - Console.Write("{0}{1}", indent, "-q"); - Console.Write("{0}{1}{2}\n", indent, indent, "query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC."); - Console.Write("{0}{1}", indent, "-b"); - Console.Write("{0}{1}{2}\n", indent, indent, "type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."); - Console.Write("{0}{1}", indent, "-w"); - Console.Write("{0}{1}{2}\n", indent, indent, "length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"); - Console.Write("{0}{1}", indent, "-l"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_cols_per_record, The number of columns per record. Default is 3."); + + HelpPrint("-h ", "host, The host to connect to TDengine. Default is localhost."); + HelpPrint("-p ", "port, The TCP/IP port number to use for the connection. Default is 0."); + HelpPrint("-u ", "user, The user name to use when connecting to the server. Default is 'root'."); + HelpPrint("-P ", "password, The password to use when connecting to the server. Default is 'taosdata'."); + HelpPrint("-d ", "database, Destination database. Default is 'test'."); + HelpPrint("-a ", "replica, Set the replica parameters of the database, Default 1, min: 1, max: 5."); + HelpPrint("-m
", "table_prefix, Table prefix name. Default is 't'."); + HelpPrint("-M", "stable, Use super table."); + HelpPrint("-s ", "stable_prefix, STable prefix name. Default is 'st'"); + HelpPrint("-Q ", "query, Execute query command. set 'DEFAULT' means select * from each table"); + /* NOT SUPPORT SO FAR + HelpPrint("-o", "outputfile, Direct output to the named file. Default is './output.txt'."); + HelpPrint("-q", "query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC."); + HelpPrint("-b", "type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."); + HelpPrint("-w", "length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"); + HelpPrint("-l", "num_of_cols_per_record, The number of columns per record. Default is 3."); */ - Console.Write("{0}{1}", indent, "-T"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_threads, The number of threads. Default is 10."); - Console.Write("{0}{1}", indent, "-r"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_records_per_req, The number of records per request. Default is 1000."); - Console.Write("{0}{1}", indent, "-t"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_tables, The number of tables. Default is 1."); - Console.Write("{0}{1}", indent, "-n"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_records_per_table, The number of records per table. Default is 1."); - Console.Write("{0}{1}", indent, "-c"); - Console.Write("{0}{1}{2}\n", indent, indent, "config_directory, Configuration directory. Default is '/etc/taos/'."); - Console.Write("{0}{1}", indent, "-x"); - Console.Write("{0}{1}{2}\n", indent, indent, "flag, Insert only flag."); - Console.Write("{0}{1}", indent, "-O"); - Console.Write("{0}{1}{2}\n", indent, indent, "order, Insert mode--0: In order, 1: Out of order. Default is in order."); - Console.Write("{0}{1}", indent, "-R"); - Console.Write("{0}{1}{2}\n", indent, indent, "rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."); - Console.Write("{0}{1}", indent, "-D"); - Console.Write("{0}{1}{2}\n", indent, indent, "Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."); - Console.Write("{0}{1}", indent, "-v"); - Console.Write("{0}{1}{2}\n", indent, indent, "Print verbose output"); - Console.Write("{0}{1}", indent, "-y"); - Console.Write("{0}{1}{2}\n", indent, indent, "Skip read key for continous test, default is not skip"); + HelpPrint("-T ", "num_of_threads, The number of threads. Default is 10."); + HelpPrint("-r ", "num_of_records_per_req, The number of records per request. Default is 1000."); + HelpPrint("-t ", "num_of_tables, The number of tables. Default is 1."); + HelpPrint("-n ", "num_of_records_per_table, The number of records per table. Default is 1."); + HelpPrint("-c ", "config_directory, Configuration directory. Default is '/etc/taos/'."); + HelpPrint("-x", "flag, Insert only flag."); + HelpPrint("-O", "order, Insert mode--0: In order, 1: Out of order. Default is in order."); + HelpPrint("-R ", "rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."); + HelpPrint("-D ", "Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."); + HelpPrint("-v", "Print verbose output"); + HelpPrint("-g", "Print debug output"); + HelpPrint("-y", "Skip read key for continous test, default is not skip"); System.Environment.Exit(0); } @@ -136,24 +121,26 @@ namespace TDengineDriver dbName = this.GetArgumentAsString(argv, "-d", "db"); stablePrefix = this.GetArgumentAsString(argv, "-s", "st"); tablePrefix = this.GetArgumentAsString(argv, "-m", "t"); - isInsertOnly = this.GetArgumentAsFlag(argv, "-x"); - queryMode = (int)this.GetArgumentAsLong(argv, "-q", 0, 1, 0); + isInsertOnly = this.GetArgumentAsFlag(argv, "-x", true); + query = this.GetArgumentAsString(argv, "-Q", "NONE"); + queryMode = (short)this.GetArgumentAsLong(argv, "-q", 0, 1, 0); numOfTables = this.GetArgumentAsLong(argv, "-t", 1, 1000000000, 1); batchRows = this.GetArgumentAsLong(argv, "-r", 1, 10000, 1000); recordsPerTable = this.GetArgumentAsLong(argv, "-n", 1, 100000000000, 1); recordsPerRequest = (int)this.GetArgumentAsLong(argv, "-r", 1, 10000, 1); colsPerRecord = (int)this.GetArgumentAsLong(argv, "-l", 1, 1024, 3); configDir = this.GetArgumentAsString(argv, "-c", "C:/TDengine/cfg"); - useStable = this.GetArgumentAsFlag(argv, "-M"); + useStable = this.GetArgumentAsFlag(argv, "-M", true); replica = (short)this.GetArgumentAsLong(argv, "-a", 1, 5, 1); methodOfDelete = (short)this.GetArgumentAsLong(argv, "-D", 0, 3, 0); numOfThreads = (short)this.GetArgumentAsLong(argv, "-T", 1, 10000, 1); - order = this.GetArgumentAsFlag(argv, "-O"); + order = this.GetArgumentAsFlag(argv, "-O", false); rateOfOutorder = (short)this.GetArgumentAsLong(argv, "-R", 0, 50, 10); - skipReadKey = this.GetArgumentAsFlag(argv, "-y"); - verbose = this.GetArgumentAsFlag(argv, "-v"); + skipReadKey = this.GetArgumentAsFlag(argv, "-y", true); + verbose = this.GetArgumentAsFlag(argv, "-v", true); + debug = this.GetArgumentAsFlag(argv, "-g", true); Console.Write("###################################################################\n"); Console.Write("# Server IP: {0}\n", host); @@ -162,7 +149,7 @@ namespace TDengineDriver Console.Write("# Number of Columns per record: {0}\n", colsPerRecord); Console.Write("# Number of Threads: {0}\n", numOfThreads); Console.Write("# Number of Tables: {0}\n", numOfTables); - Console.Write("# Number of Data per Table: {0}\n", recordsPerTable); + Console.Write("# Number of records per Table: {0}\n", recordsPerTable); Console.Write("# Records/Request: {0}\n", recordsPerRequest); Console.Write("# Database name: {0}\n", dbName); Console.Write("# Replica: {0}\n", replica); @@ -175,6 +162,7 @@ namespace TDengineDriver Console.Write("# Data order: {0}\n", order); Console.Write("# Data out of order rate: {0}\n", rateOfOutorder); Console.Write("# Delete method: {0}\n", methodOfDelete); + Console.Write("# Query command: {0}\n", query); Console.Write("# Query Mode: {0}\n", queryMode); Console.Write("# Insert Only: {0}\n", isInsertOnly); Console.Write("# Verbose output {0}\n", verbose); @@ -189,17 +177,17 @@ namespace TDengineDriver } } - public bool GetArgumentAsFlag(String[] argv, String argName) + public bool GetArgumentAsFlag(String[] argv, String argName, bool defaultValue) { int argc = argv.Length; for (int i = 0; i < argc; ++i) { if (argName == argv[i]) { - return true; + return defaultValue; } } - return false; + return !defaultValue; } public long GetArgumentAsLong(String[] argv, String argName, int minVal, long maxVal, int defaultValue) @@ -269,7 +257,7 @@ namespace TDengineDriver System.Environment.Exit(0); } - private void DebugPrintFormat(string format, params object[] parameters) + private void VerbosePrintFormat(string format, params object[] parameters) { if (verbose == true) { @@ -277,7 +265,7 @@ namespace TDengineDriver } } - private void DebugPrint(string str) + private void VerbosePrint(string str) { if (verbose == true) { @@ -285,18 +273,34 @@ namespace TDengineDriver } } + private void DebugPrintFormat(string format, params object[] parameters) + { + if (debug == true) + { + Console.Write(format, parameters); + } + } + + private void DebugPrint(string str) + { + if (debug == true) + { + Console.Write(str); + } + } + public void InitTDengine() { TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); TDengine.Init(); - DebugPrint("TDengine Initialization finished\n"); + VerbosePrint("TDengine Initialization finished\n"); } public void ConnectTDengine() { string db = ""; - DebugPrintFormat("host:{0} user:{1}, pass:{2}; db:{3}, port:{4}\n", + VerbosePrintFormat("host:{0} user:{1}, pass:{2}; db:{3}, port:{4}\n", this.host, this.user, this.password, db, this.port); this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port); if (this.conn == IntPtr.Zero) @@ -306,7 +310,7 @@ namespace TDengineDriver } else { - DebugPrint("Connect to TDengine success\n"); + VerbosePrint("Connect to TDengine success\n"); } } @@ -334,6 +338,7 @@ namespace TDengineDriver CreateTableThread createTableThread = new CreateTableThread(); createTableThread.id = i; createTableThread.verbose = verbose; + createTableThread.debug = debug; createTableThread.dbName = this.dbName; createTableThread.tablePrefix = this.tablePrefix; createTableThread.useStable = useStable; @@ -367,7 +372,7 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { @@ -384,7 +389,7 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { @@ -405,7 +410,7 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { @@ -442,6 +447,7 @@ namespace TDengineDriver insertThread.batchRows = batchRows; insertThread.numOfTables = numOfTables; insertThread.verbose = verbose; + insertThread.debug = debug; insertThread.dbName = this.dbName; insertThread.tablePrefix = this.tablePrefix; insertThread.order = this.order; @@ -471,15 +477,24 @@ namespace TDengineDriver public void ExecuteQuery() { - // System.DateTime start = new System.DateTime(); long queryRows = 0; - for (int i = 0; i < 1/*this.numOfTables*/; ++i) + for (int i = 0; i < this.numOfTables; ++i) { - String sql = "select * from " + this.dbName + "." + tablePrefix + i; - // Console.WriteLine(sql); + string sql; + + if (query == "DEFAULT") + { + sql = "select * from " + this.dbName + "." + tablePrefix + i; + } + else + { + sql = query; + } + DebugPrintFormat("query: {0}, sql:{1}\n", query, sql); IntPtr res = TDengine.Query(conn, sql); + DebugPrintFormat("res: {0}\n", res); if (res == IntPtr.Zero) { Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res)); @@ -487,17 +502,18 @@ namespace TDengineDriver } int fieldCount = TDengine.FieldCount(res); - // Console.WriteLine("field count: " + fieldCount); + DebugPrint("field count: " + fieldCount + "\n"); List metas = TDengine.FetchFields(res); for (int j = 0; j < metas.Count; j++) { TDengineMeta meta = (TDengineMeta)metas[j]; - // Console.WriteLine("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size); + DebugPrint("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size + "\n"); } IntPtr rowdata; StringBuilder builder = new StringBuilder(); + while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) { queryRows++; @@ -561,10 +577,7 @@ namespace TDengineDriver } builder.Append("---"); - if (queryRows <= 10) - { - Console.WriteLine(builder.ToString()); - } + VerbosePrint(builder.ToString() + "\n"); builder.Clear(); } @@ -576,13 +589,6 @@ namespace TDengineDriver TDengine.FreeResult(res); } - /* - System.DateTime end = new System.DateTime(); - TimeSpan ts = end - start; - - Console.Write("Total {0:G} rows inserted, {1:G} rows query, time spend {2:G} seconds.\n" - , this.rowsInserted, queryRows, ts.TotalSeconds); - */ } public void CloseConnection() @@ -629,7 +635,18 @@ namespace TDengineDriver tester.batchRows, (tester.recordsPerTable * tester.numOfTables * 1000) / elapsedMs); - tester.ExecuteQuery(); + tester.DebugPrintFormat("query command:{0}\n", tester.query); + if (tester.query != "NONE") + { + watch = Stopwatch.StartNew(); + tester.ExecuteQuery(); + watch.Stop(); + elapsedMs = watch.Elapsed.TotalMilliseconds; + Console.WriteLine("Spent {0} seconds to query {1} records.\n", + elapsedMs/1000, + tester.recordsPerTable * tester.numOfTables + ); + } tester.CloseConnection(); Console.WriteLine("End."); @@ -648,10 +665,11 @@ namespace TDengineDriver public long batchRows { set; get; } public long numOfTables { set; get; } public bool verbose { set; get; } + public bool debug { set; get; } public bool order { set; get; } public short rateOfOutorder { set; get; } - private void DebugPrintFormat(string format, params object[] parameters) + private void VerbosePrintFormat(string format, params object[] parameters) { if (verbose == true) { @@ -659,7 +677,7 @@ namespace TDengineDriver } } - private void DebugPrint(string str) + private void VerbosePrint(string str) { if (verbose == true) { @@ -667,9 +685,25 @@ namespace TDengineDriver } } + private void DebugPrintFormat(string format, params object[] parameters) + { + if (debug == true) + { + Console.Write(format, parameters); + } + } + + private void DebugPrint(string str) + { + if (debug == true) + { + Console.Write(str); + } + } + public void ThreadMain() { - DebugPrintFormat("InsertDataThread {0} from {1} to {2}\n", id, start, end); + VerbosePrintFormat("InsertDataThread {0} from {1} to {2}\n", id, start, end); StringBuilder sql = new StringBuilder(); DateTime now = DateTime.Now; @@ -678,12 +712,12 @@ namespace TDengineDriver int s = now.Second; long baseTimestamp = 1609430400000; // 2021/01/01 0:0:0 - DebugPrintFormat("beginTime is {0} + {1}h:{2}m:{3}s\n", baseTimestamp, h, m, s); + VerbosePrintFormat("beginTime is {0} + {1}h:{2}m:{3}s\n", baseTimestamp, h, m, s); long beginTimestamp = baseTimestamp + ((h*60 + m) * 60 + s) * 1000; + Random random = new Random(); long rowsInserted = 0; - // System.DateTime startTime = new System.DateTime(); long i = 0; while (i < recordsPerTable) { @@ -701,8 +735,25 @@ namespace TDengineDriver } for (int batch = 0; batch < batchRows; ++batch) { + long writeTimeStamp = beginTimestamp + i + batch; + int rnd = 100; + if (this.order == false) + { + rnd = random.Next(1, 100); + if (rnd <= this.rateOfOutorder) + { + writeTimeStamp = writeTimeStamp + rnd * 10000; + DebugPrint("### "); + } + DebugPrintFormat("order:{0} rnd:{1} timestamp:{2}\n", this.order, rnd, writeTimeStamp); + } + else + { + DebugPrintFormat("order:{0} timestamp:{1}\n", this.order, writeTimeStamp); + } + sql.Append("(") - .Append(beginTimestamp + i + batch) + .Append(writeTimeStamp) .Append(", 1, 2, 3,") .Append(i + batch) .Append(", 5, 6, 7, 'abc', 'def')"); @@ -711,7 +762,7 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res == IntPtr.Zero) { - DebugPrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); + VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); } inserted += this.batchRows; @@ -740,9 +791,10 @@ namespace TDengineDriver public string tablePrefix { set; get; } public string stablePrefix { set; get; } public bool verbose { set; get; } + public bool debug { set; get; } public bool useStable { set; get; } - private void DebugPrintFormat(string format, params object[] parameters) + private void VerbosePrintFormat(string format, params object[] parameters) { if (verbose == true) { @@ -750,7 +802,7 @@ namespace TDengineDriver } } - private void DebugPrint(string str) + private void VerbosePrint(string str) { if (verbose == true) { @@ -758,9 +810,17 @@ namespace TDengineDriver } } + private void DebugPrintFormat(string format, params object[] parameters) + { + if (debug == true) + { + Console.Write(format, parameters); + } + } + public void ThreadMain() { - DebugPrintFormat("CreateTable {0} from {1} to {2}\n", id, start, end); + VerbosePrintFormat("CreateTable {0} from {1} to {2}\n", id, start, end); StringBuilder sql = new StringBuilder(); @@ -781,11 +841,11 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { - DebugPrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); + VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); CleanAndExitProgram(); } TDengine.FreeResult(res); From 68a9a2ae442f1e87b5770c7b023642f2d66cd796 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 19:14:01 +0800 Subject: [PATCH 03/12] [TD-2598] feature: C# taosdemo, CI integration. --- .travis.yml | 10 ++++++++++ tests/examples/C#/taosdemo/taosdemo.cs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8c57085296..f389d9472b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ matrix: - psmisc - unixodbc - unixodbc-dev + - mono-complete before_script: - export TZ=Asia/Harbin @@ -74,6 +75,15 @@ matrix: ./valgrind-test.sh 2>&1 > mem-error-out.log sleep 1 + cd ${TRAVIS_BUILD_DIR}/tests/examples/C#/taosdemo + mcs -output:taosdemo *.cs || travis_terminate $? + pkill -TERM -x taosd + fuser -k -n tcp 6030 + sleep 1 + taosd > /dev/null & + sleep 1 + mono taosdemo -Q -y || travis_terminate $? + # Color setting RED='\033[0;31m' GREEN='\033[1;32m' diff --git a/tests/examples/C#/taosdemo/taosdemo.cs b/tests/examples/C#/taosdemo/taosdemo.cs index 6e1cbd2088..1d8daac9b9 100644 --- a/tests/examples/C#/taosdemo/taosdemo.cs +++ b/tests/examples/C#/taosdemo/taosdemo.cs @@ -204,7 +204,7 @@ namespace TDengineDriver String tmp = argv[i + 1]; if (tmp[0] == '-') { - Console.WriteLine("option {0:G} requires an argument", tmp); + Console.WriteLine("option {0:G} requires an argument", argName); ExitProgram(); } @@ -236,7 +236,7 @@ namespace TDengineDriver String tmp = argv[i + 1]; if (tmp[0] == '-') { - Console.WriteLine("option {0:G} requires an argument", tmp); + Console.WriteLine("option {0:G} requires an argument", argName); ExitProgram(); } return tmp; From 4acd2069e6250e2eaf4dbb67ac587ea0d0d3e00f Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 19:24:33 +0800 Subject: [PATCH 04/12] [TD-2598] feature: C# taosdemo, use return value. --- tests/examples/C#/taosdemo/taosdemo.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/examples/C#/taosdemo/taosdemo.cs b/tests/examples/C#/taosdemo/taosdemo.cs index 1d8daac9b9..0685498790 100644 --- a/tests/examples/C#/taosdemo/taosdemo.cs +++ b/tests/examples/C#/taosdemo/taosdemo.cs @@ -205,14 +205,14 @@ namespace TDengineDriver if (tmp[0] == '-') { Console.WriteLine("option {0:G} requires an argument", argName); - ExitProgram(); + ExitProgram(1); } long tmpVal = Convert.ToInt64(tmp); if (tmpVal < minVal || tmpVal > maxVal) { Console.WriteLine("option {0:G} value should in range [{1:G}, {2:G}]", argName, minVal, maxVal); - ExitProgram(); + ExitProgram(1); } return tmpVal; @@ -237,7 +237,7 @@ namespace TDengineDriver if (tmp[0] == '-') { Console.WriteLine("option {0:G} requires an argument", argName); - ExitProgram(); + ExitProgram(1); } return tmp; } @@ -246,15 +246,15 @@ namespace TDengineDriver return defaultValue; } - static void CleanAndExitProgram() + static void CleanAndExitProgram(int ret) { TDengine.Cleanup(); - System.Environment.Exit(0); + System.Environment.Exit(ret); } - static void ExitProgram() + static void ExitProgram(int ret) { - System.Environment.Exit(0); + System.Environment.Exit(ret); } private void VerbosePrintFormat(string format, params object[] parameters) @@ -306,7 +306,7 @@ namespace TDengineDriver if (this.conn == IntPtr.Zero) { Console.WriteLine("Connect to TDengine failed"); - CleanAndExitProgram(); + CleanAndExitProgram(1); } else { @@ -377,7 +377,7 @@ namespace TDengineDriver else { Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); - CleanAndExitProgram(); + CleanAndExitProgram(1); } } @@ -394,7 +394,7 @@ namespace TDengineDriver else { Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); - CleanAndExitProgram(); + CleanAndExitProgram(1); } TDengine.FreeResult(res); } @@ -415,7 +415,7 @@ namespace TDengineDriver else { Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); - CleanAndExitProgram(); + CleanAndExitProgram(1); } TDengine.FreeResult(res); } @@ -498,7 +498,7 @@ namespace TDengineDriver if (res == IntPtr.Zero) { Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res)); - CleanAndExitProgram(); + CleanAndExitProgram(1); } int fieldCount = TDengine.FieldCount(res); @@ -846,7 +846,7 @@ namespace TDengineDriver else { VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); - CleanAndExitProgram(); + CleanAndExitProgram(1); } TDengine.FreeResult(res); } From 3a9c9984dee2bc2a603877ade7ca382baeacf018 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 19:45:19 +0800 Subject: [PATCH 05/12] [TD-2598] feature: C# taosdemo, fix command line in CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f389d9472b..f9499882bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,7 +76,7 @@ matrix: sleep 1 cd ${TRAVIS_BUILD_DIR}/tests/examples/C#/taosdemo - mcs -output:taosdemo *.cs || travis_terminate $? + mcs -out:taosdemo *.cs || travis_terminate $? pkill -TERM -x taosd fuser -k -n tcp 6030 sleep 1 From a26e2733038a779ed699b5c1115ae06170db3f3f Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 21:59:20 +0800 Subject: [PATCH 06/12] [TD-2598] feature: C# taosdemo, fix command line in CI. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9499882bb..41d5ee7ab2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,7 +82,7 @@ matrix: sleep 1 taosd > /dev/null & sleep 1 - mono taosdemo -Q -y || travis_terminate $? + mono taosdemo -Q DEFAULT -y || travis_terminate $? # Color setting RED='\033[0;31m' From 5970814900a63babd2c041aa74e85ddeb0f5072e Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 22:33:41 +0800 Subject: [PATCH 07/12] [TD-2598] feature: C# taosdemo, move test case early. --- .travis.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 41d5ee7ab2..e8514c29f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,15 @@ matrix: pip3 install guppy3 pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/ + cd ${TRAVIS_BUILD_DIR}/tests/examples/C#/taosdemo + mcs -out:taosdemo *.cs || travis_terminate $? + pkill -TERM -x taosd + fuser -k -n tcp 6030 + sleep 1 + taosd > /dev/null & + sleep 1 + mono taosdemo -Q DEFAULT -y || travis_terminate $? + cd ${TRAVIS_BUILD_DIR}/tests ./test-all.sh smoke || travis_terminate $? sleep 1 @@ -75,14 +84,6 @@ matrix: ./valgrind-test.sh 2>&1 > mem-error-out.log sleep 1 - cd ${TRAVIS_BUILD_DIR}/tests/examples/C#/taosdemo - mcs -out:taosdemo *.cs || travis_terminate $? - pkill -TERM -x taosd - fuser -k -n tcp 6030 - sleep 1 - taosd > /dev/null & - sleep 1 - mono taosdemo -Q DEFAULT -y || travis_terminate $? # Color setting RED='\033[0;31m' From 1263d2e1c0e115807c0a7369619e21d85fc76aec Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 22:49:09 +0800 Subject: [PATCH 08/12] [TD-2598] feature: C# taosdemo, sleep 10s after start taosd. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e8514c29f1..835a734eb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,7 +66,7 @@ matrix: fuser -k -n tcp 6030 sleep 1 taosd > /dev/null & - sleep 1 + sleep 10 mono taosdemo -Q DEFAULT -y || travis_terminate $? cd ${TRAVIS_BUILD_DIR}/tests From 9e0f9f4aecc4338138b10e552c148c209984d991 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 23:09:52 +0800 Subject: [PATCH 09/12] [TD-2598] feature: C# taosdemo, taosd -c cfgDir. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 835a734eb0..d482a0930c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,7 +65,7 @@ matrix: pkill -TERM -x taosd fuser -k -n tcp 6030 sleep 1 - taosd > /dev/null & + ${TRAVIS_BUILD_DIR}/debug/build/bin/taosd -c ${TRAVIS_BUILD_DIR}/debug/test/cfg & sleep 10 mono taosdemo -Q DEFAULT -y || travis_terminate $? From 6d27ca402d89c7bde91ad41c6aa96650bd8e8dbc Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 23:19:55 +0800 Subject: [PATCH 10/12] [TD-2598] feature: C# taosdemo, taosd > /dev/null. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d482a0930c..a140915fd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,8 +65,8 @@ matrix: pkill -TERM -x taosd fuser -k -n tcp 6030 sleep 1 - ${TRAVIS_BUILD_DIR}/debug/build/bin/taosd -c ${TRAVIS_BUILD_DIR}/debug/test/cfg & - sleep 10 + ${TRAVIS_BUILD_DIR}/debug/build/bin/taosd -c ${TRAVIS_BUILD_DIR}/debug/test/cfg > /dev/null & + sleep 5 mono taosdemo -Q DEFAULT -y || travis_terminate $? cd ${TRAVIS_BUILD_DIR}/tests From 686b90998dcb4e59f885fcf04aaa90b2033c8b65 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 23:34:43 +0800 Subject: [PATCH 11/12] [TD-2598] feature: C# taosdemo, hide config print. --- tests/examples/C#/taosdemo/taosdemo.cs | 50 +++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/examples/C#/taosdemo/taosdemo.cs b/tests/examples/C#/taosdemo/taosdemo.cs index 0685498790..df52acc99d 100644 --- a/tests/examples/C#/taosdemo/taosdemo.cs +++ b/tests/examples/C#/taosdemo/taosdemo.cs @@ -142,33 +142,33 @@ namespace TDengineDriver verbose = this.GetArgumentAsFlag(argv, "-v", true); debug = this.GetArgumentAsFlag(argv, "-g", true); - Console.Write("###################################################################\n"); - Console.Write("# Server IP: {0}\n", host); - Console.Write("# User: {0}\n", user); - Console.Write("# Password: {0}\n", password); - Console.Write("# Number of Columns per record: {0}\n", colsPerRecord); - Console.Write("# Number of Threads: {0}\n", numOfThreads); - Console.Write("# Number of Tables: {0}\n", numOfTables); - Console.Write("# Number of records per Table: {0}\n", recordsPerTable); - Console.Write("# Records/Request: {0}\n", recordsPerRequest); - Console.Write("# Database name: {0}\n", dbName); - Console.Write("# Replica: {0}\n", replica); - Console.Write("# Use STable: {0}\n", useStable); - Console.Write("# Table prefix: {0}\n", tablePrefix); + VerbosePrint ("###################################################################\n"); + VerbosePrintFormat ("# Server IP: {0}\n", host); + VerbosePrintFormat ("# User: {0}\n", user); + VerbosePrintFormat ("# Password: {0}\n", password); + VerbosePrintFormat ("# Number of Columns per record: {0}\n", colsPerRecord); + VerbosePrintFormat ("# Number of Threads: {0}\n", numOfThreads); + VerbosePrintFormat ("# Number of Tables: {0}\n", numOfTables); + VerbosePrintFormat ("# Number of records per Table: {0}\n", recordsPerTable); + VerbosePrintFormat ("# Records/Request: {0}\n", recordsPerRequest); + VerbosePrintFormat ("# Database name: {0}\n", dbName); + VerbosePrintFormat ("# Replica: {0}\n", replica); + VerbosePrintFormat ("# Use STable: {0}\n", useStable); + VerbosePrintFormat ("# Table prefix: {0}\n", tablePrefix); if (useStable == true) { - Console.Write("# STable prefix: {0}\n", stablePrefix); + VerbosePrintFormat("# STable prefix: {0}\n", stablePrefix); } - Console.Write("# Data order: {0}\n", order); - Console.Write("# Data out of order rate: {0}\n", rateOfOutorder); - Console.Write("# Delete method: {0}\n", methodOfDelete); - Console.Write("# Query command: {0}\n", query); - Console.Write("# Query Mode: {0}\n", queryMode); - Console.Write("# Insert Only: {0}\n", isInsertOnly); - Console.Write("# Verbose output {0}\n", verbose); - Console.Write("# Test time: {0}\n", DateTime.Now.ToString("h:mm:ss tt")); + VerbosePrintFormat ("# Data order: {0}\n", order); + VerbosePrintFormat ("# Data out of order rate: {0}\n", rateOfOutorder); + VerbosePrintFormat ("# Delete method: {0}\n", methodOfDelete); + VerbosePrintFormat ("# Query command: {0}\n", query); + VerbosePrintFormat ("# Query Mode: {0}\n", queryMode); + VerbosePrintFormat ("# Insert Only: {0}\n", isInsertOnly); + VerbosePrintFormat ("# Verbose output {0}\n", verbose); + VerbosePrintFormat ("# Test time: {0}\n", DateTime.Now.ToString("h:mm:ss tt")); - Console.Write("###################################################################\n"); + VerbosePrint ("###################################################################\n"); if (skipReadKey == false) { @@ -629,7 +629,7 @@ namespace TDengineDriver watch.Stop(); double elapsedMs = watch.Elapsed.TotalMilliseconds; - Console.WriteLine("Spent {0} seconds to insert {1} records with {2} record(s) per request: {3} records/second", + Console.WriteLine("C# taosdemo: Spent {0} seconds to insert {1} records with {2} record(s) per request: {3} records/second", elapsedMs / 1000, tester.recordsPerTable * tester.numOfTables, tester.batchRows, @@ -642,7 +642,7 @@ namespace TDengineDriver tester.ExecuteQuery(); watch.Stop(); elapsedMs = watch.Elapsed.TotalMilliseconds; - Console.WriteLine("Spent {0} seconds to query {1} records.\n", + Console.WriteLine("C# taosdemo: Spent {0} seconds to query {1} records.\n", elapsedMs/1000, tester.recordsPerTable * tester.numOfTables ); From b99e6b571ffb377c1a58cdf457903f81fe557cca Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 13 Jan 2021 10:53:59 +0800 Subject: [PATCH 12/12] [TD-2598] feature: C# taosdemo, CI integration. kill taosd after test. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index a140915fd4..9aac6c597c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,6 +68,9 @@ matrix: ${TRAVIS_BUILD_DIR}/debug/build/bin/taosd -c ${TRAVIS_BUILD_DIR}/debug/test/cfg > /dev/null & sleep 5 mono taosdemo -Q DEFAULT -y || travis_terminate $? + pkill -KILL -x taosd + fuser -k -n tcp 6030 + sleep 1 cd ${TRAVIS_BUILD_DIR}/tests ./test-all.sh smoke || travis_terminate $?