Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c72ca2e9
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看板
未验证
提交
c72ca2e9
编写于
3月 18, 2021
作者:
H
huili
提交者:
GitHub
3月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5492 from taosdata/xiaoping/add_test_case
update docker cluster script
上级
e5387a1d
a9ea81aa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
92 addition
and
31 deletion
+92
-31
tests/pytest/cluster/clusterEnvSetup/basic.py
tests/pytest/cluster/clusterEnvSetup/basic.py
+29
-10
tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh
tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh
+24
-21
tests/pytest/cluster/clusterEnvSetup/cleanClusterEnv.sh
tests/pytest/cluster/clusterEnvSetup/cleanClusterEnv.sh
+39
-0
未找到文件。
tests/pytest/cluster/clusterEnvSetup/basic.py
浏览文件 @
c72ca2e9
...
...
@@ -18,13 +18,15 @@ import argparse
class
BuildDockerCluser
:
def
__init__
(
self
,
hostName
,
user
,
password
,
configDir
,
numOfNodes
,
clusterVersion
):
def
__init__
(
self
,
hostName
,
user
,
password
,
configDir
,
numOfNodes
,
clusterVersion
,
dockerDir
,
removeFlag
):
self
.
hostName
=
hostName
self
.
user
=
user
self
.
password
=
password
self
.
configDir
=
configDir
self
.
numOfNodes
=
numOfNodes
self
.
clusterVersion
=
clusterVersion
self
.
clusterVersion
=
clusterVersion
self
.
dockerDir
=
dockerDir
self
.
removeFlag
=
removeFlag
def
getConnection
(
self
):
self
.
conn
=
taos
.
connect
(
...
...
@@ -42,14 +44,17 @@ class BuildDockerCluser:
print
(
"start arbitrator"
)
os
.
system
(
"docker exec -d $(docker ps|grep tdnode1|awk '{print $1}') tarbitrator"
)
def
run
(
self
):
def
run
(
self
):
if
self
.
numOfNodes
<
2
or
self
.
numOfNodes
>
5
:
print
(
"the number of nodes must be between 2 and 5"
)
exit
(
0
)
os
.
system
(
"./buildClusterEnv.sh -n %d -v %s"
%
(
self
.
numOfNodes
,
self
.
clusterVersion
))
exit
(
0
)
print
(
"remove Flag value %s"
%
self
.
removeFlag
)
if
self
.
removeFlag
==
False
:
os
.
system
(
"./cleanClusterEnv.sh -d %s"
%
self
.
dockerDir
)
os
.
system
(
"./buildClusterEnv.sh -n %d -v %s -d %s"
%
(
self
.
numOfNodes
,
self
.
clusterVersion
,
self
.
dockerDir
))
self
.
getConnection
()
self
.
createDondes
()
self
.
startArbitrator
()
self
.
startArbitrator
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
...
...
@@ -91,10 +96,24 @@ parser.add_argument(
'-v'
,
'--version'
,
action
=
'store'
,
default
=
'2.0.1
4
.1'
,
default
=
'2.0.1
7
.1'
,
type
=
str
,
help
=
'the version of the cluster to be build, Default is 2.0.14.1'
)
help
=
'the version of the cluster to be build, Default is 2.0.17.1'
)
parser
.
add_argument
(
'-d'
,
'--docker-dir'
,
action
=
'store'
,
default
=
'/data'
,
type
=
str
,
help
=
'the data dir for docker, default is /data'
)
parser
.
add_argument
(
'--flag'
,
action
=
'store_true'
,
help
=
'remove docker containers flag, default: True'
)
args
=
parser
.
parse_args
()
cluster
=
BuildDockerCluser
(
args
.
host
,
args
.
user
,
args
.
password
,
args
.
config_dir
,
args
.
num_of_nodes
,
args
.
version
)
cluster
.
run
()
\ No newline at end of file
cluster
=
BuildDockerCluser
(
args
.
host
,
args
.
user
,
args
.
password
,
args
.
config_dir
,
args
.
num_of_nodes
,
args
.
version
,
args
.
docker_dir
,
args
.
flag
)
cluster
.
run
()
# usage 1: python3 basic.py -n 2 --flag (flag is True)
# usage 2: python3 basic.py -n 2 (flag should be False when it is not specified)
\ No newline at end of file
tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh
浏览文件 @
c72ca2e9
#!/bin/bash
echo
"Executing buildClusterEnv.sh"
DOCKER_DIR
=
/data
CURR_DIR
=
`
pwd
`
if
[
$#
!=
4
]
;
then
if
[
$#
!=
6
]
;
then
echo
"argument list need input : "
echo
" -n numOfNodes"
echo
" -v version"
echo
" -v version"
echo
" -d docker dir"
exit
1
fi
NUM_OF_NODES
=
VERSION
=
while
getopts
"n:v:"
arg
DOCKER_DIR
=
while
getopts
"n:v:d:"
arg
do
case
$arg
in
n
)
...
...
@@ -20,6 +21,9 @@ do
;;
v
)
VERSION
=
$OPTARG
;;
d
)
DOCKER_DIR
=
$OPTARG
;;
?
)
echo
"unkonwn argument"
...
...
@@ -31,29 +35,28 @@ function addTaoscfg {
for
i
in
{
1..5
}
do
touch
/data/node
$i
/cfg/taos.cfg
echo
'firstEp tdnode1:6030'
>
/data
/node
$i
/cfg/taos.cfg
echo
'fqdn tdnode'
$i
>>
/data
/node
$i
/cfg/taos.cfg
echo
'arbitrator tdnode1:6042'
>>
/data
/node
$i
/cfg/taos.cfg
echo
'firstEp tdnode1:6030'
>
$DOCKER_DIR
/node
$i
/cfg/taos.cfg
echo
'fqdn tdnode'
$i
>>
$DOCKER_DIR
/node
$i
/cfg/taos.cfg
echo
'arbitrator tdnode1:6042'
>>
$DOCKER_DIR
/node
$i
/cfg/taos.cfg
done
}
function
createDIR
{
for
i
in
{
1..5
}
do
mkdir
-p
/data
/node
$i
/data
mkdir
-p
/data
/node
$i
/log
mkdir
-p
/data
/node
$i
/cfg
mkdir
-p
/data
/node
$i
/core
mkdir
-p
$DOCKER_DIR
/node
$i
/data
mkdir
-p
$DOCKER_DIR
/node
$i
/log
mkdir
-p
$DOCKER_DIR
/node
$i
/cfg
mkdir
-p
$DOCKER_DIR
/node
$i
/core
done
}
function
cleanEnv
{
function
cleanEnv
{
echo
"Clean up docker environment"
for
i
in
{
1..5
}
do
echo
/data/node
$i
/data/
*
rm
-rf
/data/node
$i
/data/
*
echo
/data/node
$i
/log/
*
rm
-rf
/data/node
$i
/log/
*
do
rm
-rf
$DOCKER_DIR
/node
$i
/data/
*
rm
-rf
$DOCKER_DIR
/node
$i
/log/
*
done
}
...
...
@@ -98,19 +101,19 @@ function clusterUp {
if
[
$NUM_OF_NODES
-eq
2
]
;
then
echo
"create 2 dnodes"
PACKAGE
=
TDengine-server-
$VERSION
-Linux-x64
.tar.gz
DIR
=
TDengine-server-
$VERSION
DIR2
=
TDengine-arbitrator-
$VERSION
VERSION
=
$VERSION
docker-compose up
-d
PACKAGE
=
TDengine-server-
$VERSION
-Linux-x64
.tar.gz
TARBITRATORPKG
=
TDengine-arbitrator-
$VERSION
-Linux-x64
.tar.gz
DIR
=
TDengine-server-
$VERSION
DIR2
=
TDengine-arbitrator-
$VERSION
VERSION
=
$VERSION
docker-compose up
-d
fi
if
[
$NUM_OF_NODES
-eq
3
]
;
then
PACKAGE
=
TDengine-server-
$VERSION
-Linux-x64
.tar.gz
DIR
=
TDengine-server-
$VERSION
DIR2
=
TDengine-arbitrator-
$VERSION
VERSION
=
$VERSION
docker-compose
-f
docker-compose.yml
-f
node3.yml up
-d
PACKAGE
=
TDengine-server-
$VERSION
-Linux-x64
.tar.gz
TARBITRATORPKG
=
TDengine-arbitrator-
$VERSION
-Linux-x64
.tar.gz
DIR
=
TDengine-server-
$VERSION
DIR2
=
TDengine-arbitrator-
$VERSION
VERSION
=
$VERSION
docker-compose
-f
docker-compose.yml
-f
node3.yml up
-d
fi
if
[
$NUM_OF_NODES
-eq
4
]
;
then
PACKAGE
=
TDengine-server-
$VERSION
-Linux-x64
.tar.gz
DIR
=
TDengine-server-
$VERSION
DIR2
=
TDengine-arbitrator-
$VERSION
VERSION
=
$VERSION
docker-compose
-f
docker-compose.yml
-f
node3.yml
-f
node4.yml up
-d
PACKAGE
=
TDengine-server-
$VERSION
-Linux-x64
.tar.gz
TARBITRATORPKG
=
TDengine-arbitrator-
$VERSION
-Linux-x64
.tar.gz
DIR
=
TDengine-server-
$VERSION
DIR2
=
TDengine-arbitrator-
$VERSION
VERSION
=
$VERSION
docker-compose
-f
docker-compose.yml
-f
node3.yml
-f
node4.yml up
-d
fi
if
[
$NUM_OF_NODES
-eq
5
]
;
then
PACKAGE
=
TDengine-server-
$VERSION
-Linux-x64
.tar.gz
DIR
=
TDengine-server-
$VERSION
DIR2
=
TDengine-arbitrator-
$VERSION
VERSION
=
$VERSION
docker-compose
-f
docker-compose.yml
-f
node3.yml
-f
node4.yml
-f
node5.yml up
-d
PACKAGE
=
TDengine-server-
$VERSION
-Linux-x64
.tar.gz
TARBITRATORPKG
=
TDengine-arbitrator-
$VERSION
-Linux-x64
.tar.gz
DIR
=
TDengine-server-
$VERSION
DIR2
=
TDengine-arbitrator-
$VERSION
VERSION
=
$VERSION
docker-compose
-f
docker-compose.yml
-f
node3.yml
-f
node4.yml
-f
node5.yml up
-d
fi
echo
"docker compose finish"
...
...
tests/pytest/cluster/clusterEnvSetup/cleanClusterEnv.sh
0 → 100755
浏览文件 @
c72ca2e9
#!/bin/bash
echo
"Executing cleanClusterEnv.sh"
CURR_DIR
=
`
pwd
`
if
[
$#
!=
2
]
;
then
echo
"argument list need input : "
echo
" -d docker dir"
exit
1
fi
DOCKER_DIR
=
while
getopts
"d:"
arg
do
case
$arg
in
d
)
DOCKER_DIR
=
$OPTARG
;;
?
)
echo
"unkonwn argument"
;;
esac
done
function
removeDockerContainers
{
cd
$DOCKER_DIR
docker-compose down
--remove-orphans
}
function
cleanEnv
{
echo
"Clean up docker environment"
for
i
in
{
1..5
}
do
rm
-rf
$DOCKER_DIR
/node
$i
/data/
*
rm
-rf
$DOCKER_DIR
/node
$i
/log/
*
done
}
removeDockerContainers
cleanEnv
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录