Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2a28f3d7
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
2a28f3d7
编写于
8月 30, 2021
作者:
Z
zhaoyanggh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sqlt & sqlutc test script[ci skip]
上级
8c96539b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
264 addition
and
1 deletion
+264
-1
tests/script/http/httpTestSqlUtc.c
tests/script/http/httpTestSqlUtc.c
+128
-0
tests/script/http/httpTestSqlt.c
tests/script/http/httpTestSqlt.c
+128
-0
tests/script/http/makefile
tests/script/http/makefile
+8
-1
未找到文件。
tests/script/http/httpTestSqlUtc.c
0 → 100644
浏览文件 @
2a28f3d7
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <pthread.h>
#define MAXLINE 1024
typedef
struct
{
pthread_t
pid
;
int
threadId
;
int
rows
;
int
tables
;
}
ThreadObj
;
void
post
(
char
*
ip
,
int
port
,
char
*
page
,
char
*
msg
)
{
int
sockfd
,
n
;
char
recvline
[
MAXLINE
];
struct
sockaddr_in
servaddr
;
char
content
[
4096
];
char
content_page
[
50
];
sprintf
(
content_page
,
"POST /%s HTTP/1.1
\r\n
"
,
page
);
char
content_host
[
50
];
sprintf
(
content_host
,
"HOST: %s:%d
\r\n
"
,
ip
,
port
);
char
content_type
[]
=
"Content-Type: text/plain
\r\n
"
;
char
Auth
[]
=
"Authorization: Basic cm9vdDp0YW9zZGF0YQ==
\r\n
"
;
char
content_len
[
50
];
sprintf
(
content_len
,
"Content-Length: %ld
\r\n\r\n
"
,
strlen
(
msg
));
sprintf
(
content
,
"%s%s%s%s%s%s"
,
content_page
,
content_host
,
content_type
,
Auth
,
content_len
,
msg
);
if
((
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
<
0
)
{
printf
(
"socket error
\n
"
);
}
bzero
(
&
servaddr
,
sizeof
(
servaddr
));
servaddr
.
sin_family
=
AF_INET
;
servaddr
.
sin_port
=
htons
(
port
);
if
(
inet_pton
(
AF_INET
,
ip
,
&
servaddr
.
sin_addr
)
<=
0
)
{
printf
(
"inet_pton error
\n
"
);
}
if
(
connect
(
sockfd
,(
struct
sockaddr
*
)
&
servaddr
,
sizeof
(
servaddr
))
<
0
)
{
printf
(
"connect error
\n
"
);
}
write
(
sockfd
,
content
,
strlen
(
content
));
printf
(
"%s
\n
"
,
content
);
while
((
n
=
read
(
sockfd
,
recvline
,
MAXLINE
))
>
0
)
{
recvline
[
n
]
=
0
;
if
(
fputs
(
recvline
,
stdout
)
==
EOF
)
{
printf
(
"fputs error
\n
"
);
}
}
if
(
n
<
0
)
{
printf
(
"read error
\n
"
);
}
}
void
singleThread
()
{
char
ip
[]
=
"127.0.0.1"
;
int
port
=
6041
;
char
page
[]
=
"rest/sqlutc"
;
char
page1
[]
=
"rest/sqlutc/db1"
;
char
page2
[]
=
"rest/sqlutc/db2"
;
char
nonexit
[]
=
"rest/sqlutc/xxdb"
;
post
(
ip
,
port
,
page
,
"drop database if exists db1"
);
post
(
ip
,
port
,
page
,
"create database if not exists db1"
);
post
(
ip
,
port
,
page
,
"drop database if exists db2"
);
post
(
ip
,
port
,
page
,
"create database if not exists db2"
);
post
(
ip
,
port
,
page1
,
"create table t11 (ts timestamp, c1 int)"
);
post
(
ip
,
port
,
page2
,
"create table t21 (ts timestamp, c1 int)"
);
post
(
ip
,
port
,
page1
,
"insert into t11 values (now, 1)"
);
post
(
ip
,
port
,
page2
,
"insert into t21 values (now, 2)"
);
post
(
ip
,
port
,
nonexit
,
"create database if not exists db3"
);
}
void
execute
(
void
*
params
)
{
char
ip
[]
=
"127.0.0.1"
;
int
port
=
6041
;
char
page
[]
=
"rest/sqlutc"
;
char
*
unique
=
calloc
(
1
,
1024
);
char
*
sql
=
calloc
(
1
,
1024
);
ThreadObj
*
pThread
=
(
ThreadObj
*
)
params
;
printf
(
"Thread %d started
\n
"
,
pThread
->
threadId
);
sprintf
(
unique
,
"rest/sql/db%d"
,
pThread
->
threadId
);
sprintf
(
sql
,
"drop database if exists db%d"
,
pThread
->
threadId
);
post
(
ip
,
port
,
page
,
sql
);
sprintf
(
sql
,
"create database if not exists db%d"
,
pThread
->
threadId
);
post
(
ip
,
port
,
page
,
sql
);
for
(
int
i
=
0
;
i
<
pThread
->
tables
;
i
++
)
{
sprintf
(
sql
,
"create table t%d (ts timestamp, c1 int)"
,
i
);
post
(
ip
,
port
,
unique
,
sql
);
}
for
(
int
i
=
0
;
i
<
pThread
->
rows
;
i
++
)
{
sprintf
(
sql
,
"insert into t%d values (now + %ds, %d)"
,
pThread
->
threadId
,
i
,
pThread
->
threadId
);
post
(
ip
,
port
,
unique
,
sql
);
}
free
(
unique
);
free
(
sql
);
return
;
}
void
multiThread
()
{
int
numOfThreads
=
100
;
int
numOfTables
=
100
;
int
numOfRows
=
1
;
ThreadObj
*
threads
=
calloc
((
size_t
)
numOfThreads
,
sizeof
(
ThreadObj
));
for
(
int
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
ThreadObj
*
pthread
=
threads
+
i
;
pthread_attr_t
thattr
;
pthread
->
threadId
=
i
+
1
;
pthread
->
rows
=
numOfRows
;
pthread
->
tables
=
numOfTables
;
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
pthread_create
(
&
pthread
->
pid
,
&
thattr
,
(
void
*
(
*
)(
void
*
))
execute
,
pthread
);
}
for
(
int
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
pthread_join
(
threads
[
i
].
pid
,
NULL
);
}
free
(
threads
);
}
int
main
()
{
singleThread
();
multiThread
();
exit
(
0
);
}
\ No newline at end of file
tests/script/http/httpTestSqlt.c
0 → 100644
浏览文件 @
2a28f3d7
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <pthread.h>
#define MAXLINE 1024
typedef
struct
{
pthread_t
pid
;
int
threadId
;
int
rows
;
int
tables
;
}
ThreadObj
;
void
post
(
char
*
ip
,
int
port
,
char
*
page
,
char
*
msg
)
{
int
sockfd
,
n
;
char
recvline
[
MAXLINE
];
struct
sockaddr_in
servaddr
;
char
content
[
4096
];
char
content_page
[
50
];
sprintf
(
content_page
,
"POST /%s HTTP/1.1
\r\n
"
,
page
);
char
content_host
[
50
];
sprintf
(
content_host
,
"HOST: %s:%d
\r\n
"
,
ip
,
port
);
char
content_type
[]
=
"Content-Type: text/plain
\r\n
"
;
char
Auth
[]
=
"Authorization: Basic cm9vdDp0YW9zZGF0YQ==
\r\n
"
;
char
content_len
[
50
];
sprintf
(
content_len
,
"Content-Length: %ld
\r\n\r\n
"
,
strlen
(
msg
));
sprintf
(
content
,
"%s%s%s%s%s%s"
,
content_page
,
content_host
,
content_type
,
Auth
,
content_len
,
msg
);
if
((
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
<
0
)
{
printf
(
"socket error
\n
"
);
}
bzero
(
&
servaddr
,
sizeof
(
servaddr
));
servaddr
.
sin_family
=
AF_INET
;
servaddr
.
sin_port
=
htons
(
port
);
if
(
inet_pton
(
AF_INET
,
ip
,
&
servaddr
.
sin_addr
)
<=
0
)
{
printf
(
"inet_pton error
\n
"
);
}
if
(
connect
(
sockfd
,(
struct
sockaddr
*
)
&
servaddr
,
sizeof
(
servaddr
))
<
0
)
{
printf
(
"connect error
\n
"
);
}
write
(
sockfd
,
content
,
strlen
(
content
));
printf
(
"%s
\n
"
,
content
);
while
((
n
=
read
(
sockfd
,
recvline
,
MAXLINE
))
>
0
)
{
recvline
[
n
]
=
0
;
if
(
fputs
(
recvline
,
stdout
)
==
EOF
)
{
printf
(
"fputs error
\n
"
);
}
}
if
(
n
<
0
)
{
printf
(
"read error
\n
"
);
}
}
void
singleThread
()
{
char
ip
[]
=
"127.0.0.1"
;
int
port
=
6041
;
char
page
[]
=
"rest/sqlt"
;
char
page1
[]
=
"rest/sqlt/db1"
;
char
page2
[]
=
"rest/sqlt/db2"
;
char
nonexit
[]
=
"rest/sqlt/xxdb"
;
post
(
ip
,
port
,
page
,
"drop database if exists db1"
);
post
(
ip
,
port
,
page
,
"create database if not exists db1"
);
post
(
ip
,
port
,
page
,
"drop database if exists db2"
);
post
(
ip
,
port
,
page
,
"create database if not exists db2"
);
post
(
ip
,
port
,
page1
,
"create table t11 (ts timestamp, c1 int)"
);
post
(
ip
,
port
,
page2
,
"create table t21 (ts timestamp, c1 int)"
);
post
(
ip
,
port
,
page1
,
"insert into t11 values (now, 1)"
);
post
(
ip
,
port
,
page2
,
"insert into t21 values (now, 2)"
);
post
(
ip
,
port
,
nonexit
,
"create database if not exists db3"
);
}
void
execute
(
void
*
params
)
{
char
ip
[]
=
"127.0.0.1"
;
int
port
=
6041
;
char
page
[]
=
"rest/sqlt"
;
char
*
unique
=
calloc
(
1
,
1024
);
char
*
sql
=
calloc
(
1
,
1024
);
ThreadObj
*
pThread
=
(
ThreadObj
*
)
params
;
printf
(
"Thread %d started
\n
"
,
pThread
->
threadId
);
sprintf
(
unique
,
"rest/sql/db%d"
,
pThread
->
threadId
);
sprintf
(
sql
,
"drop database if exists db%d"
,
pThread
->
threadId
);
post
(
ip
,
port
,
page
,
sql
);
sprintf
(
sql
,
"create database if not exists db%d"
,
pThread
->
threadId
);
post
(
ip
,
port
,
page
,
sql
);
for
(
int
i
=
0
;
i
<
pThread
->
tables
;
i
++
)
{
sprintf
(
sql
,
"create table t%d (ts timestamp, c1 int)"
,
i
);
post
(
ip
,
port
,
unique
,
sql
);
}
for
(
int
i
=
0
;
i
<
pThread
->
rows
;
i
++
)
{
sprintf
(
sql
,
"insert into t%d values (now + %ds, %d)"
,
pThread
->
threadId
,
i
,
pThread
->
threadId
);
post
(
ip
,
port
,
unique
,
sql
);
}
free
(
unique
);
free
(
sql
);
return
;
}
void
multiThread
()
{
int
numOfThreads
=
100
;
int
numOfTables
=
100
;
int
numOfRows
=
1
;
ThreadObj
*
threads
=
calloc
((
size_t
)
numOfThreads
,
sizeof
(
ThreadObj
));
for
(
int
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
ThreadObj
*
pthread
=
threads
+
i
;
pthread_attr_t
thattr
;
pthread
->
threadId
=
i
+
1
;
pthread
->
rows
=
numOfRows
;
pthread
->
tables
=
numOfTables
;
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
pthread_create
(
&
pthread
->
pid
,
&
thattr
,
(
void
*
(
*
)(
void
*
))
execute
,
pthread
);
}
for
(
int
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
pthread_join
(
threads
[
i
].
pid
,
NULL
);
}
free
(
threads
);
}
int
main
()
{
singleThread
();
multiThread
();
exit
(
0
);
}
\ No newline at end of file
tests/script/http/makefile
浏览文件 @
2a28f3d7
all
:
gcc
-g
httpTest.c
-o
httpTest
-lpthread
\ No newline at end of file
gcc
-g
httpTest.c
-o
httpTest
-lpthread
gcc
-g
httpTestSqlt.c
-o
httpTestSqlt
-lpthread
gcc
-g
httpTestSqlUtc.c
-o
httpTestSqlUtc
-lpthread
clean
:
rm
httpTest
rm
httpTestSqlt
rm
httpTestSqlUtc
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录