From 13d7629c055941e08cd35c07dd04793d5cf0295f Mon Sep 17 00:00:00 2001 From: zhiyong Date: Thu, 4 Jul 2024 09:13:56 +0800 Subject: [PATCH] add ci case for TS-5105 --- tests/army/query/query_last_row_repeatly.py | 44 +++++++++++++++++++++ tests/parallel_test/cases.task | 1 + 2 files changed, 45 insertions(+) create mode 100644 tests/army/query/query_last_row_repeatly.py diff --git a/tests/army/query/query_last_row_repeatly.py b/tests/army/query/query_last_row_repeatly.py new file mode 100644 index 0000000000..3cca032176 --- /dev/null +++ b/tests/army/query/query_last_row_repeatly.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame import * + + +class TDTestCase(TBase): + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + sqls = [ + "drop database if exists ts_5101", + "create database ts_5101 cachemodel 'both';", + "use ts_5101;", + "CREATE STABLE meters (ts timestamp, current float) TAGS (location binary(64), groupId int);", + "CREATE TABLE d1001 USING meters TAGS ('California.B', 2);", + "CREATE TABLE d1002 USING meters TAGS ('California.S', 3);", + "INSERT INTO d1001 VALUES ('2024-07-03 10:00:00.000', 10);", + "INSERT INTO d1002 VALUES ('2024-07-03 13:00:00.000', 13);", + ] + tdSql.executes(sqls) + + # 执行多次,有些时候last_row(ts)会返回错误的值,详见TS-5105 + for i in range(1, 10): + sql = "select last(ts), last_row(ts) from meters;" + tdLog.debug(f"{i}th execute sql: {sql}") + tdSql.query(sql) + tdSql.checkRows(1) + tdSql.checkData(0, 0, "2024-07-03 13:00:00.000") + tdSql.checkData(0, 1, "2024-07-03 13:00:00.000") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 750736731e..c6c00fdbec 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -20,6 +20,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f insert/test_column_tag_boundary.py ,,y,army,./pytest.sh python3 ./test.py -f query/fill/fill_desc.py -N 3 -L 3 -D 2 ,,y,army,./pytest.sh python3 ./test.py -f query/fill/fill_null.py +,,y,army,./pytest.sh python3 ./test.py -f query/query_last_row_repeatly.py ,,y,army,./pytest.sh python3 ./test.py -f cluster/incSnapshot.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/query_basic.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/accuracy/test_query_accuracy.py