Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7ed67d90
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7ed67d90
编写于
6月 21, 2020
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support alter table in random-test.
上级
5d8b4bf7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
90 addition
and
35 deletion
+90
-35
tests/pytest/random-test/random-test-multi-threading.py
tests/pytest/random-test/random-test-multi-threading.py
+2
-2
tests/pytest/random-test/random-test.py
tests/pytest/random-test/random-test.py
+88
-33
未找到文件。
tests/pytest/random-test/random-test-multi-threading.py
浏览文件 @
7ed67d90
...
...
@@ -175,7 +175,7 @@ class Test (threading.Thread):
global
last_stb
global
colAdded
if
last_stb
!=
""
and
colAdded
==
False
:
if
last_stb
!=
""
and
not
colAdded
:
tdSql
.
execute
(
"alter table %s add column col binary(20)"
%
last_stb
)
...
...
@@ -187,7 +187,7 @@ class Test (threading.Thread):
global
last_stb
global
colAdded
if
last_stb
!=
""
and
not
colAdded
:
if
last_stb
!=
""
and
colAdded
:
tdSql
.
execute
(
"alter table %s drop column col"
%
last_stb
)
colAdded
=
False
return
0
...
...
tests/pytest/random-test/random-test.py
浏览文件 @
7ed67d90
...
...
@@ -25,6 +25,7 @@ class Test:
self
.
last_tb
=
""
self
.
last_stb
=
""
self
.
written
=
0
self
.
colAdded
=
False
def
create_table
(
self
):
tdLog
.
info
(
"create_table"
)
...
...
@@ -39,6 +40,7 @@ class Test:
current_tb
)
self
.
last_tb
=
current_tb
self
.
written
=
0
self
.
colAdded
=
False
def
insert_data
(
self
):
tdLog
.
info
(
"insert_data"
)
...
...
@@ -50,12 +52,36 @@ class Test:
insertRows
=
10
tdLog
.
info
(
"insert %d rows to %s"
%
(
insertRows
,
self
.
last_tb
))
for
i
in
range
(
0
,
insertRows
):
if
self
.
colAdded
:
ret
=
tdSql
.
execute
(
'insert into %s values (now + %dm, %d, "%s", "%s")'
%
(
self
.
last_tb
,
i
,
i
,
"->"
+
str
(
i
)),
"col"
)
else
:
ret
=
tdSql
.
execute
(
'insert into %s values (now + %dm, %d, "%s")'
%
(
self
.
last_tb
,
i
,
i
,
"->"
+
str
(
i
)))
self
.
written
=
self
.
written
+
1
tdLog
.
info
(
"insert earlier data"
)
if
self
.
colAdded
:
tdSql
.
execute
(
'insert into %s values (now - 5m , 10, " - 5m", "col")'
%
self
.
last_tb
)
self
.
written
=
self
.
written
+
1
tdSql
.
execute
(
'insert into %s values (now - 6m , 10, " - 6m", "col")'
%
self
.
last_tb
)
self
.
written
=
self
.
written
+
1
tdSql
.
execute
(
'insert into %s values (now - 7m , 10, " - 7m", "col")'
%
self
.
last_tb
)
self
.
written
=
self
.
written
+
1
tdSql
.
execute
(
'insert into %s values (now - 8m , 10, " - 8m", "col")'
%
self
.
last_tb
)
self
.
written
=
self
.
written
+
1
else
:
tdSql
.
execute
(
'insert into %s values (now - 5m , 10, " - 5m")'
%
self
.
last_tb
)
...
...
@@ -88,22 +114,49 @@ class Test:
return
else
:
tdLog
.
info
(
"will create stable %s"
%
current_stb
)
db
=
"db"
tdSql
.
execute
(
"drop database if exists %s"
%
(
db
))
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
execute
(
"create database %s maxrows 200 maxtables 30"
%
(
db
))
tdSql
.
execute
(
"use %s"
%
(
db
))
tdSql
.
execute
(
'create table %s(ts timestamp, c1 int, c2 nchar(10)) tags (t1 int, t2 nchar(10))'
%
current_stb
)
self
.
last_stb
=
current_stb
self
.
colAdded
=
False
for
k
in
range
(
1
,
300
):
current_tb
=
"tb%d"
%
int
(
round
(
time
.
time
()
*
1000
))
sqlcmd
=
"create table %s using %s tags (1, 'test')"
%
(
current_tb
,
self
.
last_stb
)
sqlcmd
=
"create table %s using %s tags (1, 'test')"
%
(
current_tb
,
self
.
last_stb
)
tdSql
.
execute
(
sqlcmd
)
self
.
last_tb
=
current_tb
self
.
written
=
0
for
j
in
range
(
1
,
100
):
tdSql
.
execute
(
"insert into %s values (now
, 27, 'wsnchar')"
%
self
.
last_tb
)
"insert into %s values (now + %da
, 27, 'wsnchar')"
%
(
self
.
last_tb
,
j
)
)
self
.
written
=
self
.
written
+
1
def
alter_table_to_add_col
(
self
):
tdLog
.
info
(
"alter_table_to_add_col"
)
if
self
.
last_stb
!=
""
and
not
self
.
colAdded
:
tdSql
.
execute
(
"alter table %s add column col binary(20)"
%
self
.
last_stb
)
self
.
colAdded
=
True
def
alter_table_to_drop_col
(
self
):
tdLog
.
info
(
"alter_table_to_drop_col"
)
if
self
.
last_stb
!=
""
and
self
.
colAdded
:
tdSql
.
execute
(
"alter table %s drop column col"
%
self
.
last_stb
)
self
.
colAdded
=
False
def
drop_stable
(
self
):
tdLog
.
info
(
"drop_stable"
)
if
(
self
.
last_stb
==
""
):
...
...
@@ -126,16 +179,16 @@ class Test:
tdSql
.
execute
(
'select * from %s'
%
self
.
last_stb
)
def
restart_database
(
self
):
tdLog
.
info
(
"restart_databae"
)
tdLog
.
info
(
"restart_databa
s
e"
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
5
)
tdLog
.
sleep
(
10
)
def
force_restart_database
(
self
):
tdLog
.
info
(
"force_restart_database"
)
tdDnodes
.
forcestop
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
5
)
tdLog
.
sleep
(
10
)
tdSql
.
prepare
()
self
.
last_tb
=
""
self
.
last_stb
=
""
...
...
@@ -161,7 +214,7 @@ class Test:
self
.
last_tb
=
""
self
.
written
=
0
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
5
)
tdLog
.
sleep
(
10
)
tdSql
.
prepare
()
self
.
last_tb
=
""
self
.
last_stb
=
""
...
...
@@ -209,10 +262,12 @@ class TDTestCase:
10
:
test
.
delete_datafiles
,
11
:
test
.
query_data_from_stable
,
12
:
test
.
drop_stable
,
13
:
test
.
alter_table_to_add_col
,
14
:
test
.
alter_table_to_drop_col
,
}
for
x
in
range
(
1
,
1000
):
r
=
random
.
randint
(
1
,
1
2
)
r
=
random
.
randint
(
1
,
1
4
)
tdLog
.
notice
(
"iteration %d run func %d"
%
(
x
,
r
))
switch
.
get
(
r
,
lambda
:
"ERROR"
)()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录