From 9ce0c184a169af5be88ec5c50147b27db363186e Mon Sep 17 00:00:00 2001 From: kailixu Date: Thu, 8 Aug 2024 16:44:15 +0800 Subject: [PATCH 01/19] enh: add passwdTest --- source/client/test/CMakeLists.txt | 11 +++++++++++ tests/script/api/passwdTest.c | 18 +++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/source/client/test/CMakeLists.txt b/source/client/test/CMakeLists.txt index 3d70c67661..8e7056821d 100644 --- a/source/client/test/CMakeLists.txt +++ b/source/client/test/CMakeLists.txt @@ -29,6 +29,12 @@ TARGET_LINK_LIBRARIES( # PUBLIC os util common transport monitor parser catalog scheduler function gtest taos_static qcom executor #) +ADD_EXECUTABLE(passwdTest ../../../tests/script/api/passwdTest.c) +TARGET_LINK_LIBRARIES( + passwdTest + PUBLIC taos +) + TARGET_INCLUDE_DIRECTORIES( clientTest PUBLIC "${TD_SOURCE_DIR}/include/client/" @@ -62,3 +68,8 @@ add_test( # NAME clientMonitorTest # COMMAND clientMonitorTest # ) + +add_test( + NAME passwdTest + COMMAND passwdTest +) diff --git a/tests/script/api/passwdTest.c b/tests/script/api/passwdTest.c index 928525750e..bd5e3af755 100644 --- a/tests/script/api/passwdTest.c +++ b/tests/script/api/passwdTest.c @@ -59,7 +59,8 @@ void __taos_notify_cb(void *param, void *ext, int type) { switch (type) { case TAOS_NOTIFY_PASSVER: { ++nPassVerNotified; - printf("%s:%d type:%d user:%s passVer:%d\n", __func__, __LINE__, type, param ? (char *)param : "NULL", *(int *)ext); + printf("%s:%d type:%d user:%s passVer:%d\n", __func__, __LINE__, type, param ? (char *)param : "NULL", + *(int *)ext); break; } case TAOS_NOTIFY_USER_DROPPED: { @@ -191,11 +192,11 @@ static int printResult(TAOS_RES *res, char *output) { printRow(temp, row, fields, numFields); puts(temp); } + return 0; } int main(int argc, char *argv[]) { char qstr[1024]; - // connect to server if (argc < 2) { printf("please input server-ip \n"); @@ -215,6 +216,7 @@ int main(int argc, char *argv[]) { taos_close(taos); taos_cleanup(); + exit(EXIT_SUCCESS); } void createUsers(TAOS *taos, const char *host, char *qstr) { @@ -234,6 +236,7 @@ void createUsers(TAOS *taos, const char *host, char *qstr) { if (code != 0) { fprintf(stderr, "failed to run: taos_set_notify_cb(TAOS_NOTIFY_PASSVER) for user:%s since %d\n", users[i], code); + exit(EXIT_FAILURE); } else { fprintf(stderr, "success to run: taos_set_notify_cb(TAOS_NOTIFY_PASSVER) for user:%s\n", users[i]); } @@ -260,6 +263,7 @@ void passVerTestMulti(const char *host, char *qstr) { if (code != 0) { fprintf(stderr, "failed to run: taos_set_notify_cb since %d\n", code); + exit(EXIT_FAILURE); } else { fprintf(stderr, "success to run: taos_set_notify_cb\n"); } @@ -301,8 +305,7 @@ void passVerTestMulti(const char *host, char *qstr) { fprintf(stderr, "######## %s #########\n", __func__); if (nPassVerNotified == nConn) { - fprintf(stderr, ">>> succeed to get passVer notification since nNotify %d == nConn %d\n", nPassVerNotified, - nConn); + fprintf(stderr, ">>> succeed to get passVer notification since nNotify %d == nConn %d\n", nPassVerNotified, nConn); } else { fprintf(stderr, ">>> failed to get passVer notification since nNotify %d != nConn %d\n", nPassVerNotified, nConn); exit(1); @@ -337,7 +340,7 @@ void sysInfoTest(TAOS *taosRoot, const char *host, char *qstr) { TAOS_RES *res = NULL; int32_t nRep = 0; -_REP: +_REP: fprintf(stderr, "######## %s loop:%d #########\n", __func__, nRep); res = taos_query(taos[0], qstr); if (taos_errno(res) != 0) { @@ -375,7 +378,7 @@ _REP: sleep(1); } - if(++nRep < 5) { + if (++nRep < 5) { goto _REP; } @@ -390,7 +393,7 @@ _REP: fprintf(stderr, "######## %s #########\n", __func__); } static bool isDropUser = true; -void userDroppedTest(TAOS *taos, const char *host, char *qstr) { +void userDroppedTest(TAOS *taos, const char *host, char *qstr) { // users int nTestUsers = nUser; int nLoop = 0; @@ -408,6 +411,7 @@ _loop: if (code != 0) { fprintf(stderr, "failed to run: taos_set_notify_cb:%d for user:%s since %d\n", TAOS_NOTIFY_USER_DROPPED, users[i], code); + exit(EXIT_FAILURE); } else { fprintf(stderr, "success to run: taos_set_notify_cb:%d for user:%s\n", TAOS_NOTIFY_USER_DROPPED, users[i]); } From a23c187674a5200e74d70a39913edcf4d3437713 Mon Sep 17 00:00:00 2001 From: kailixu Date: Thu, 8 Aug 2024 16:55:17 +0800 Subject: [PATCH 02/19] enh: rename passwdTest --- source/client/test/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/client/test/CMakeLists.txt b/source/client/test/CMakeLists.txt index 8e7056821d..c8b13f6532 100644 --- a/source/client/test/CMakeLists.txt +++ b/source/client/test/CMakeLists.txt @@ -29,9 +29,9 @@ TARGET_LINK_LIBRARIES( # PUBLIC os util common transport monitor parser catalog scheduler function gtest taos_static qcom executor #) -ADD_EXECUTABLE(passwdTest ../../../tests/script/api/passwdTest.c) +ADD_EXECUTABLE(userOperTest ../../../tests/script/api/passwdTest.c) TARGET_LINK_LIBRARIES( - passwdTest + userOperTest PUBLIC taos ) @@ -70,6 +70,6 @@ add_test( # ) add_test( - NAME passwdTest - COMMAND passwdTest + NAME userOperTest + COMMAND userOperTest ) From f887ec2a0d6d4506f2e307273ea03503ce3b20cc Mon Sep 17 00:00:00 2001 From: charles Date: Fri, 9 Aug 2024 09:26:54 +0800 Subject: [PATCH 03/19] add test case test_passwd by charles --- tests/army/user/test_passwd.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/army/user/test_passwd.py diff --git a/tests/army/user/test_passwd.py b/tests/army/user/test_passwd.py new file mode 100644 index 0000000000..2d448b8f0e --- /dev/null +++ b/tests/army/user/test_passwd.py @@ -0,0 +1,20 @@ +import subprocess +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame.epath import * +from frame import * + + +class TDTestCase(TBase): + def run(self): + c_file_path = os.sep.join([binPath(), "passwdTest localhost"]) + p = subprocess.Popen(c_file_path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if 0 != p.returncode: + tdLog.error("Failed to run passwd test with output: %s \n error: %s" % (out, err)) + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) From b330edf535ec3f91aae49abfa0bafa81011be557 Mon Sep 17 00:00:00 2001 From: charles Date: Fri, 9 Aug 2024 09:26:54 +0800 Subject: [PATCH 04/19] add test case test_passwd by charles --- tests/army/user/test_passwd.py | 20 ++++++++++++++++++++ tests/parallel_test/cases.task | 1 + 2 files changed, 21 insertions(+) create mode 100644 tests/army/user/test_passwd.py diff --git a/tests/army/user/test_passwd.py b/tests/army/user/test_passwd.py new file mode 100644 index 0000000000..2d448b8f0e --- /dev/null +++ b/tests/army/user/test_passwd.py @@ -0,0 +1,20 @@ +import subprocess +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame.epath import * +from frame import * + + +class TDTestCase(TBase): + def run(self): + c_file_path = os.sep.join([binPath(), "passwdTest localhost"]) + p = subprocess.Popen(c_file_path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if 0 != p.returncode: + tdLog.error("Failed to run passwd test with output: %s \n error: %s" % (out, err)) + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index e70042001d..bc30701e82 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -35,6 +35,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f storage/compressBasic.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f grant/grantBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/queryBugs.py -N 3 +,,y,army,./pytest.sh python3 ./test.py -f user/test_passwd.py # # system test From 7ff0fb497a7a924a1665c4dfd966b51457b81a64 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Tue, 5 Nov 2024 15:46:36 +0800 Subject: [PATCH 05/19] Update test_passwd.py to replace tdLog.error with tdLog.exit --- tests/army/user/test_passwd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/army/user/test_passwd.py b/tests/army/user/test_passwd.py index 2d448b8f0e..ac82ee0d55 100644 --- a/tests/army/user/test_passwd.py +++ b/tests/army/user/test_passwd.py @@ -13,7 +13,7 @@ class TDTestCase(TBase): p = subprocess.Popen(c_file_path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() if 0 != p.returncode: - tdLog.error("Failed to run passwd test with output: %s \n error: %s" % (out, err)) + tdLog.exit("Failed to run passwd test with output: %s \n error: %s" % (out, err)) tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) From 9003883edc83320300ef2ebf56e89870b7d4d6cc Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Tue, 5 Nov 2024 20:23:45 +0800 Subject: [PATCH 06/19] Update makefile to remove the stmt.c which doesn't exist --- tests/script/api/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/script/api/makefile b/tests/script/api/makefile index 9c2bb6be3d..6b8a920e33 100644 --- a/tests/script/api/makefile +++ b/tests/script/api/makefile @@ -22,7 +22,7 @@ exe: gcc $(CFLAGS) ./insert_stb.c -o $(ROOT)insert_stb $(LFLAGS) gcc $(CFLAGS) ./tmqViewTest.c -o $(ROOT)tmqViewTest $(LFLAGS) gcc $(CFLAGS) ./stmtQuery.c -o $(ROOT)stmtQuery $(LFLAGS) - gcc $(CFLAGS) ./stmt.c -o $(ROOT)stmt $(LFLAGS) + # gcc $(CFLAGS) ./stmt.c -o $(ROOT)stmt $(LFLAGS) gcc $(CFLAGS) ./stmt2.c -o $(ROOT)stmt2 $(LFLAGS) gcc $(CFLAGS) ./stmt2-example.c -o $(ROOT)stmt2-example $(LFLAGS) gcc $(CFLAGS) ./stmt2-get-fields.c -o $(ROOT)stmt2-get-fields $(LFLAGS) From 0d5d88086ae1a2f48309720c2afb0b7f80be697b Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Tue, 5 Nov 2024 20:25:02 +0800 Subject: [PATCH 07/19] Update test_passwd.py --- tests/army/user/test_passwd.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/army/user/test_passwd.py b/tests/army/user/test_passwd.py index ac82ee0d55..cc0ab1a113 100644 --- a/tests/army/user/test_passwd.py +++ b/tests/army/user/test_passwd.py @@ -6,15 +6,37 @@ from frame.caseBase import * from frame.epath import * from frame import * - class TDTestCase(TBase): + def apiPath(self): + apiPath = None + currentFilePath = os.path.dirname(os.path.realpath(__file__)) + if ("community/tests" in currentFilePath): + testFilePath = currentFilePath[:currentFilePath.find("community/tests")] + else: + testFilePath = currentFilePath[:currentFilePath.find("TDengine/tests")] + + for root, dirs, files in os.walk(testFilePath): + if ("passwdTest.c" in files): + apiPath = root + break + return apiPath + def run(self): - c_file_path = os.sep.join([binPath(), "passwdTest localhost"]) - p = subprocess.Popen(c_file_path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + apiPath = self.apiPath() + if apiPath: + p = subprocess.Popen(f"cd {apiPath} && make", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if 0 != p.returncode: + tdLog.exit("Test script passwdTest.c make failed") + test_file_cmd = os.sep.join([apiPath, "passwdTest localhost"]) + else: + tdLog.exit("passwdTest.c not found") + p = subprocess.Popen(test_file_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() if 0 != p.returncode: tdLog.exit("Failed to run passwd test with output: %s \n error: %s" % (out, err)) tdLog.success(f"{__file__} successfully executed") + tdCases.addLinux(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase()) From dcb63d054fb9ee566c754d06ca91b331860eaec3 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Wed, 6 Nov 2024 08:05:51 +0800 Subject: [PATCH 08/19] Update makefile to remove the failed test cases --- tests/script/api/makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/script/api/makefile b/tests/script/api/makefile index 6b8a920e33..ce5980b37a 100644 --- a/tests/script/api/makefile +++ b/tests/script/api/makefile @@ -13,7 +13,7 @@ all: $(TARGET) exe: gcc $(CFLAGS) ./batchprepare.c -o $(ROOT)batchprepare $(LFLAGS) - gcc $(CFLAGS) ./stmt2-test.c -o $(ROOT)stmt2-test $(LFLAGS) + # gcc $(CFLAGS) ./stmt2-test.c -o $(ROOT)stmt2-test $(LFLAGS) gcc $(CFLAGS) ./stopquery.c -o $(ROOT)stopquery $(LFLAGS) gcc $(CFLAGS) ./dbTableRoute.c -o $(ROOT)dbTableRoute $(LFLAGS) gcc $(CFLAGS) ./insertSameTs.c -o $(ROOT)insertSameTs $(LFLAGS) @@ -23,10 +23,10 @@ exe: gcc $(CFLAGS) ./tmqViewTest.c -o $(ROOT)tmqViewTest $(LFLAGS) gcc $(CFLAGS) ./stmtQuery.c -o $(ROOT)stmtQuery $(LFLAGS) # gcc $(CFLAGS) ./stmt.c -o $(ROOT)stmt $(LFLAGS) - gcc $(CFLAGS) ./stmt2.c -o $(ROOT)stmt2 $(LFLAGS) - gcc $(CFLAGS) ./stmt2-example.c -o $(ROOT)stmt2-example $(LFLAGS) - gcc $(CFLAGS) ./stmt2-get-fields.c -o $(ROOT)stmt2-get-fields $(LFLAGS) - gcc $(CFLAGS) ./stmt2-nohole.c -o $(ROOT)stmt2-nohole $(LFLAGS) + # gcc $(CFLAGS) ./stmt2.c -o $(ROOT)stmt2 $(LFLAGS) + # gcc $(CFLAGS) ./stmt2-example.c -o $(ROOT)stmt2-example $(LFLAGS) + # gcc $(CFLAGS) ./stmt2-get-fields.c -o $(ROOT)stmt2-get-fields $(LFLAGS) + # gcc $(CFLAGS) ./stmt2-nohole.c -o $(ROOT)stmt2-nohole $(LFLAGS) gcc $(CFLAGS) ./stmt-crash.c -o $(ROOT)stmt-crash $(LFLAGS) clean: From ffe1776f3e2032f5f74875d5f03a665303de9f24 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Wed, 6 Nov 2024 09:45:19 +0800 Subject: [PATCH 09/19] Update test_passwd.py to add some log for debug --- tests/army/user/test_passwd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/army/user/test_passwd.py b/tests/army/user/test_passwd.py index cc0ab1a113..1017805105 100644 --- a/tests/army/user/test_passwd.py +++ b/tests/army/user/test_passwd.py @@ -23,11 +23,12 @@ class TDTestCase(TBase): def run(self): apiPath = self.apiPath() + tdLog.info(f"api path: {apiPath}") if apiPath: p = subprocess.Popen(f"cd {apiPath} && make", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() if 0 != p.returncode: - tdLog.exit("Test script passwdTest.c make failed") + tdLog.exit(f"Test script passwdTest.c make failed with error: {err}") test_file_cmd = os.sep.join([apiPath, "passwdTest localhost"]) else: tdLog.exit("passwdTest.c not found") From eea5eea7b1af125a17e13c1252dd45e1878e36c4 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Wed, 6 Nov 2024 11:26:22 +0800 Subject: [PATCH 10/19] Update cases.task to close santilizer for case test_passwd.py --- tests/parallel_test/cases.task | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index c85073c951..3dc64e9de1 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -44,7 +44,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f storage/compressBasic.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f grant/grantBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/queryBugs.py -N 3 -,,y,army,./pytest.sh python3 ./test.py -f user/test_passwd.py +,,n,army,./pytest.sh python3 ./test.py -f user/test_passwd.py ,,y,army,./pytest.sh python3 ./test.py -f tmq/tmqBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/fill/fill_compare_asc_desc.py ,,y,army,./pytest.sh python3 ./test.py -f query/last/test_last.py From e5098f82fa3d1ef6e48beba0e40613d8174e9fee Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Wed, 6 Nov 2024 11:33:25 +0800 Subject: [PATCH 11/19] Update cases.task --- tests/parallel_test/cases.task | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 3dc64e9de1..c85073c951 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -44,7 +44,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f storage/compressBasic.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f grant/grantBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/queryBugs.py -N 3 -,,n,army,./pytest.sh python3 ./test.py -f user/test_passwd.py +,,y,army,./pytest.sh python3 ./test.py -f user/test_passwd.py ,,y,army,./pytest.sh python3 ./test.py -f tmq/tmqBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/fill/fill_compare_asc_desc.py ,,y,army,./pytest.sh python3 ./test.py -f query/last/test_last.py From aaddf18e0091a762281afaa07b15b32b45300dbe Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Wed, 6 Nov 2024 11:35:42 +0800 Subject: [PATCH 12/19] Update test_passwd.py --- tests/army/user/test_passwd.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/army/user/test_passwd.py b/tests/army/user/test_passwd.py index 1017805105..62dc5782b7 100644 --- a/tests/army/user/test_passwd.py +++ b/tests/army/user/test_passwd.py @@ -28,16 +28,18 @@ class TDTestCase(TBase): p = subprocess.Popen(f"cd {apiPath} && make", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() if 0 != p.returncode: - tdLog.exit(f"Test script passwdTest.c make failed with error: {err}") + tdLog.info(f"Test script passwdTest.c make failed with error: {err}") test_file_cmd = os.sep.join([apiPath, "passwdTest localhost"]) else: tdLog.exit("passwdTest.c not found") - p = subprocess.Popen(test_file_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - if 0 != p.returncode: - tdLog.exit("Failed to run passwd test with output: %s \n error: %s" % (out, err)) - tdLog.success(f"{__file__} successfully executed") - + try: + p = subprocess.Popen(test_file_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if 0 != p.returncode: + tdLog.exit("Failed to run passwd test with output: %s \n error: %s" % (out, err)) + tdLog.success(f"{__file__} successfully executed") + except Exception as e: + tdLog.exit(f"Failed to execute {__file__} with error: {e}") tdCases.addLinux(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase()) From f78124ff3a9675750d840ba37d4c44f58f695a9d Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Wed, 6 Nov 2024 15:05:39 +0800 Subject: [PATCH 13/19] Update cases.task to remove santilizer to avoid the make failed --- tests/parallel_test/cases.task | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index c85073c951..3dc64e9de1 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -44,7 +44,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f storage/compressBasic.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f grant/grantBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/queryBugs.py -N 3 -,,y,army,./pytest.sh python3 ./test.py -f user/test_passwd.py +,,n,army,./pytest.sh python3 ./test.py -f user/test_passwd.py ,,y,army,./pytest.sh python3 ./test.py -f tmq/tmqBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/fill/fill_compare_asc_desc.py ,,y,army,./pytest.sh python3 ./test.py -f query/last/test_last.py From c196dd86e08e91d396696385aca9d8d2bce8a44f Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Thu, 7 Nov 2024 07:55:47 +0800 Subject: [PATCH 14/19] Update cases.task --- tests/parallel_test/cases.task | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 3dc64e9de1..cf3452b056 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -44,7 +44,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f storage/compressBasic.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f grant/grantBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/queryBugs.py -N 3 -,,n,army,./pytest.sh python3 ./test.py -f user/test_passwd.py +,,n,army,python3 ./test.py -f user/test_passwd.py ,,y,army,./pytest.sh python3 ./test.py -f tmq/tmqBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/fill/fill_compare_asc_desc.py ,,y,army,./pytest.sh python3 ./test.py -f query/last/test_last.py From 089456fa5be415b4c7edfee3e01f74144b02c6ba Mon Sep 17 00:00:00 2001 From: kailixu Date: Thu, 7 Nov 2024 13:43:08 +0800 Subject: [PATCH 15/19] enh: add makefile of passwdTest.c for windows --- tests/script/api/makefile_win64.mak | 20 +++++++++++++++ tests/script/api/passwdTest.c | 39 +++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 tests/script/api/makefile_win64.mak diff --git a/tests/script/api/makefile_win64.mak b/tests/script/api/makefile_win64.mak new file mode 100644 index 0000000000..9963ef4133 --- /dev/null +++ b/tests/script/api/makefile_win64.mak @@ -0,0 +1,20 @@ +# Makefile.mak for win64 + +TARGET = passwdTest.exe +CC = cl +CFLAGS = /W4 /EHsc /I"C:\TDengine\include" /D_WINDOWS +LDFLAGS = /link /LIBPATH:"C:\TDengine\driver" taos.lib + +SRCS = passwdTest.c +OBJS = $(SRCS:.c=.obj) + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CC) $(OBJS) $(LDFLAGS) + +.c.obj: + $(CC) $(CFLAGS) /c $< + +clean: + del $(OBJS) $(TARGET) \ No newline at end of file diff --git a/tests/script/api/passwdTest.c b/tests/script/api/passwdTest.c index 928525750e..7d35b8cc19 100644 --- a/tests/script/api/passwdTest.c +++ b/tests/script/api/passwdTest.c @@ -20,12 +20,27 @@ * passwdTest.c * - Run the test case in clear TDengine environment with default root passwd 'taosdata' */ +#ifdef WINDOWS +#include +#include +#include +#ifndef PRId64 +#define PRId64 "I64d" +#endif + +#ifndef PRIu64 +#define PRIu64 "I64u" +#endif + +#else #include +#include +#endif + #include #include #include -#include #include "taos.h" // TAOS header file #define nDup 1 @@ -50,6 +65,16 @@ void sysInfoTest(TAOS *taos, const char *host, char *qstr); void userDroppedTest(TAOS *taos, const char *host, char *qstr); void clearTestEnv(TAOS *taos, const char *host, char *qstr); +void taosMsleep(int64_t ms) { + if (ms < 0) return; +#ifdef WINDOWS + Sleep(ms); +#else + usleep(ms * 1000); +#endif +} + + int nPassVerNotified = 0; int nUserDropped = 0; TAOS *taosu[nRoot] = {0}; @@ -283,20 +308,20 @@ void passVerTestMulti(const char *host, char *qstr) { printf("%s:%d [%d] second(s) elasped, passVer notification received:%d, total:%d\n", __func__, __LINE__, i, nPassVerNotified, nConn); if (nPassVerNotified >= nConn) break; - sleep(1); + taosMsleep(1000); } // close the taos_conn for (int i = 0; i < nRoot; ++i) { taos_close(taos[i]); printf("%s:%d close taos[%d]\n", __func__, __LINE__, i); - // sleep(1); + // taosMsleep(1000); } for (int i = 0; i < nUser; ++i) { taos_close(taosu[i]); printf("%s:%d close taosu[%d]\n", __func__, __LINE__, i); - // sleep(1); + // taosMsleep(1000); } fprintf(stderr, "######## %s #########\n", __func__); @@ -356,7 +381,7 @@ _REP: fprintf(stderr, "%s:%d sleep 2 seconds to wait HB take effect\n", __func__, __LINE__); for (int i = 1; i <= 2; ++i) { - sleep(1); + taosMsleep(1000); } res = taos_query(taos[0], qstr); @@ -372,7 +397,7 @@ _REP: queryDB(taosRoot, "alter user user0 sysinfo 1"); fprintf(stderr, "%s:%d sleep 2 seconds to wait HB take effect\n", __func__, __LINE__); for (int i = 1; i <= 2; ++i) { - sleep(1); + taosMsleep(1000); } if(++nRep < 5) { @@ -426,7 +451,7 @@ _loop: printf("%s:%d [%d] second(s) elasped, user dropped notification received:%d, total:%d\n", __func__, __LINE__, i, nUserDropped, nConn); if (nUserDropped >= nConn) break; - sleep(1); + taosMsleep(1000); } for (int i = 0; i < nTestUsers; ++i) { From 907cbe99edcfdca2d581989ccca1442b2914cbe4 Mon Sep 17 00:00:00 2001 From: kailixu Date: Thu, 7 Nov 2024 14:38:51 +0800 Subject: [PATCH 16/19] enh: adjust macro for makefile_win64.mak --- tests/script/api/makefile_win64.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/script/api/makefile_win64.mak b/tests/script/api/makefile_win64.mak index 9963ef4133..50a2447a06 100644 --- a/tests/script/api/makefile_win64.mak +++ b/tests/script/api/makefile_win64.mak @@ -2,7 +2,7 @@ TARGET = passwdTest.exe CC = cl -CFLAGS = /W4 /EHsc /I"C:\TDengine\include" /D_WINDOWS +CFLAGS = /W4 /EHsc /I"C:\TDengine\include" /DWINDOWS LDFLAGS = /link /LIBPATH:"C:\TDengine\driver" taos.lib SRCS = passwdTest.c From 21ceac423f087e7e21a867824f1855fae4984424 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Thu, 7 Nov 2024 15:14:47 +0800 Subject: [PATCH 17/19] Update test_passwd.py to remove make operation --- tests/army/user/test_passwd.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/army/user/test_passwd.py b/tests/army/user/test_passwd.py index 62dc5782b7..08445b4523 100644 --- a/tests/army/user/test_passwd.py +++ b/tests/army/user/test_passwd.py @@ -1,3 +1,4 @@ +import os import subprocess from frame.log import * from frame.cases import * @@ -10,11 +11,11 @@ class TDTestCase(TBase): def apiPath(self): apiPath = None currentFilePath = os.path.dirname(os.path.realpath(__file__)) - if ("community/tests" in currentFilePath): - testFilePath = currentFilePath[:currentFilePath.find("community/tests")] + if (os.sep.join(["community", "tests"]) in currentFilePath): + testFilePath = currentFilePath[:currentFilePath.find(os.sep.join(["community", "tests"]))] else: - testFilePath = currentFilePath[:currentFilePath.find("TDengine/tests")] - + testFilePath = currentFilePath[:currentFilePath.find(os.sep.join(["TDengine", "tests"]))] + for root, dirs, files in os.walk(testFilePath): if ("passwdTest.c" in files): apiPath = root @@ -25,21 +26,20 @@ class TDTestCase(TBase): apiPath = self.apiPath() tdLog.info(f"api path: {apiPath}") if apiPath: - p = subprocess.Popen(f"cd {apiPath} && make", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - if 0 != p.returncode: - tdLog.info(f"Test script passwdTest.c make failed with error: {err}") test_file_cmd = os.sep.join([apiPath, "passwdTest localhost"]) + try: + p = subprocess.Popen(test_file_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if 0 != p.returncode: + tdLog.exit("Failed to run passwd test with output: %s \n error: %s" % (out, err)) + else: + tdLog.info(out) + tdLog.success(f"{__file__} successfully executed") + except Exception as e: + tdLog.exit(f"Failed to execute {__file__} with error: {e}") else: tdLog.exit("passwdTest.c not found") - try: - p = subprocess.Popen(test_file_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - if 0 != p.returncode: - tdLog.exit("Failed to run passwd test with output: %s \n error: %s" % (out, err)) - tdLog.success(f"{__file__} successfully executed") - except Exception as e: - tdLog.exit(f"Failed to execute {__file__} with error: {e}") + tdCases.addLinux(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase()) From f97e42e957e55c1091a1a9327e7ebe3dfa7c901d Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Thu, 7 Nov 2024 17:23:52 +0800 Subject: [PATCH 18/19] Update test_passwd.py to add debug logs --- tests/army/user/test_passwd.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/army/user/test_passwd.py b/tests/army/user/test_passwd.py index 08445b4523..c205273973 100644 --- a/tests/army/user/test_passwd.py +++ b/tests/army/user/test_passwd.py @@ -25,6 +25,9 @@ class TDTestCase(TBase): def run(self): apiPath = self.apiPath() tdLog.info(f"api path: {apiPath}") + p = subprocess.Popen(f"ls {apiPath}", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + tdLog.info(f"test files: {out}") if apiPath: test_file_cmd = os.sep.join([apiPath, "passwdTest localhost"]) try: From b929a735262050d545679c1fbc6d6ab50c4c81f7 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Fri, 8 Nov 2024 08:02:50 +0800 Subject: [PATCH 19/19] Update test_passwd.py --- tests/army/user/test_passwd.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/army/user/test_passwd.py b/tests/army/user/test_passwd.py index c205273973..dfec175824 100644 --- a/tests/army/user/test_passwd.py +++ b/tests/army/user/test_passwd.py @@ -1,4 +1,5 @@ import os +import platform import subprocess from frame.log import * from frame.cases import * @@ -25,6 +26,12 @@ class TDTestCase(TBase): def run(self): apiPath = self.apiPath() tdLog.info(f"api path: {apiPath}") + if platform.system().lower() == 'linux': + p = subprocess.Popen(f"cd {apiPath} && make", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if 0 != p.returncode: + tdLog.exit("Test script passwdTest.c make failed") + p = subprocess.Popen(f"ls {apiPath}", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() tdLog.info(f"test files: {out}")