From e2161bfeb583b6897d93535b161e60224d1f2d32 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 11 Dec 2023 14:30:29 +0800 Subject: [PATCH] case: remove util folder --- tests/army/frame/autogen.py | 6 +++--- tests/army/frame/cases.py | 2 +- tests/army/frame/cluster.py | 10 +++++----- tests/army/frame/common.py | 14 +++++++------- tests/army/frame/dnodes-default.py | 2 +- tests/army/frame/dnodes-no-random-fail.py | 2 +- tests/army/frame/dnodes-random-fail.py | 2 +- tests/army/frame/dnodes.py | 2 +- tests/army/frame/pathFinding.py | 2 +- tests/army/frame/sql.py | 12 ++++++------ tests/army/frame/sqlset.py | 2 +- tests/army/frame/sub.py | 2 +- tests/army/frame/taosadapter.py | 4 ++-- tests/army/frame/taosdemoCfg.py | 2 +- tests/army/pytest.sh | 6 ++++++ tests/system-test/1-insert/alter_replica.py | 2 +- tests/system-test/pytest.sh | 6 ++++++ 17 files changed, 45 insertions(+), 33 deletions(-) diff --git a/tests/army/frame/autogen.py b/tests/army/frame/autogen.py index e1227a680f..510402e039 100644 --- a/tests/army/frame/autogen.py +++ b/tests/army/frame/autogen.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- import sys -from util.log import * -from util.cases import * -from util.sql import * +from log import * +from cases import * +from sql import * import threading import random import string diff --git a/tests/army/frame/cases.py b/tests/army/frame/cases.py index 536b8f30d3..f386e1cee3 100644 --- a/tests/army/frame/cases.py +++ b/tests/army/frame/cases.py @@ -18,7 +18,7 @@ import datetime import inspect import importlib import traceback -from util.log import * +from log import * class TDCase: diff --git a/tests/army/frame/cluster.py b/tests/army/frame/cluster.py index 30b70b01fc..c9bf2c9f38 100644 --- a/tests/army/frame/cluster.py +++ b/tests/army/frame/cluster.py @@ -5,11 +5,11 @@ import time import os import socket -from util.log import * -from util.sql import * -from util.cases import * -from util.dnodes import * -from util.common import * +from log import * +from sql import * +from cases import * +from dnodes import * +from common import * class ClusterDnodes(TDDnodes): """rewrite TDDnodes and make MyDdnodes as TDDnodes child class""" diff --git a/tests/army/frame/common.py b/tests/army/frame/common.py index 9c45c09715..45b1c940dd 100644 --- a/tests/army/frame/common.py +++ b/tests/army/frame/common.py @@ -18,14 +18,14 @@ import time import socket import json import toml -from util.boundary import DataBoundary +from boundary import DataBoundary import taos -from util.log import * -from util.sql import * -from util.cases import * -from util.dnodes import * -from util.common import * -from util.constant import * +from log import * +from sql import * +from cases import * +from dnodes import * +from common import * +from constant import * from dataclasses import dataclass,field from typing import List from datetime import datetime diff --git a/tests/army/frame/dnodes-default.py b/tests/army/frame/dnodes-default.py index 6809c1082c..26a2bd812f 100644 --- a/tests/army/frame/dnodes-default.py +++ b/tests/army/frame/dnodes-default.py @@ -15,7 +15,7 @@ import sys import os import os.path import subprocess -from util.log import * +from log import * class TDSimClient: diff --git a/tests/army/frame/dnodes-no-random-fail.py b/tests/army/frame/dnodes-no-random-fail.py index 0e433e9664..7a2e481f11 100644 --- a/tests/army/frame/dnodes-no-random-fail.py +++ b/tests/army/frame/dnodes-no-random-fail.py @@ -15,7 +15,7 @@ import sys import os import os.path import subprocess -from util.log import * +from log import * class TDSimClient: diff --git a/tests/army/frame/dnodes-random-fail.py b/tests/army/frame/dnodes-random-fail.py index 1c527290ec..a0e9e461b8 100644 --- a/tests/army/frame/dnodes-random-fail.py +++ b/tests/army/frame/dnodes-random-fail.py @@ -15,7 +15,7 @@ import sys import os import os.path import subprocess -from util.log import * +from log import * class TDSimClient: diff --git a/tests/army/frame/dnodes.py b/tests/army/frame/dnodes.py index 67c3d37960..5defd26973 100644 --- a/tests/army/frame/dnodes.py +++ b/tests/army/frame/dnodes.py @@ -22,7 +22,7 @@ import base64 import json import copy from fabric2 import Connection -from util.log import * +from log import * from shutil import which diff --git a/tests/army/frame/pathFinding.py b/tests/army/frame/pathFinding.py index 9dee5142ce..03d3978336 100644 --- a/tests/army/frame/pathFinding.py +++ b/tests/army/frame/pathFinding.py @@ -13,7 +13,7 @@ import os -from util.log import * +from log import * diff --git a/tests/army/frame/sql.py b/tests/army/frame/sql.py index c05df0a852..cc577c2b8e 100644 --- a/tests/army/frame/sql.py +++ b/tests/army/frame/sql.py @@ -20,8 +20,8 @@ import traceback import psutil import shutil import pandas as pd -from util.log import * -from util.constant import * +from log import * +from constant import * # from datetime import timezone import time @@ -607,14 +607,14 @@ class TDSql: pstate = 0 for i in range(30): pstate = 0 - pl = psutil.pids() + pl = pspids() for pid in pl: try: - if psutil.Process(pid).name() == 'taosd': + if psProcess(pid).name() == 'taosd': print('have already started') pstate = 1 break - except psutil.NoSuchProcess: + except psNoSuchProcess: pass if pstate == state :break if state or pstate: @@ -646,7 +646,7 @@ class TDSql: tdLog.exit("dir: %s doesn't exist" %dir) def createDir(self, dir): if os.path.exists(dir): - shutil.rmtree(dir) + shrmtree(dir) tdLog.info("dir: %s is removed" %dir) os.makedirs( dir, 755 ) tdLog.info("dir: %s is created" %dir) diff --git a/tests/army/frame/sqlset.py b/tests/army/frame/sqlset.py index 3c1b6cd7f7..3a56090750 100644 --- a/tests/army/frame/sqlset.py +++ b/tests/army/frame/sqlset.py @@ -11,7 +11,7 @@ # -*- coding: utf-8 -*- -from util.sql import tdSql +from sql import tdSql class TDSetSql: def init(self, conn, logSql): diff --git a/tests/army/frame/sub.py b/tests/army/frame/sub.py index 664d830b86..f5dadf1a63 100644 --- a/tests/army/frame/sub.py +++ b/tests/army/frame/sub.py @@ -15,7 +15,7 @@ import sys import os import time import datetime -from util.log import * +from log import * class TDSub: def __init__(self): diff --git a/tests/army/frame/taosadapter.py b/tests/army/frame/taosadapter.py index 1f1c38672e..70af8b9fa9 100644 --- a/tests/army/frame/taosadapter.py +++ b/tests/army/frame/taosadapter.py @@ -1,7 +1,7 @@ import requests from fabric2 import Connection -from util.log import * -from util.common import * +from log import * +from common import * class TAdapter: diff --git a/tests/army/frame/taosdemoCfg.py b/tests/army/frame/taosdemoCfg.py index f708d303de..a2ad56ac94 100644 --- a/tests/army/frame/taosdemoCfg.py +++ b/tests/army/frame/taosdemoCfg.py @@ -19,7 +19,7 @@ import inspect import psutil import shutil import json -from util.log import * +from log import * from multiprocessing import cpu_count diff --git a/tests/army/pytest.sh b/tests/army/pytest.sh index 2c95516d10..bae0fdf278 100755 --- a/tests/army/pytest.sh +++ b/tests/army/pytest.sh @@ -58,6 +58,12 @@ echo "SIM_DIR : $SIM_DIR" echo "CODE_DIR : $CODE_DIR" echo "ASAN_DIR : $ASAN_DIR" +# prevent delete / folder or /usr/bin +if [ ${#SIM_DIR} -lt 10 ]; then + echo "len(SIM_DIR) < 10 , danger so exit. SIM_DIR=$SIM_DIR" + exit 1 +fi + rm -rf $SIM_DIR/* mkdir -p $PRG_DIR diff --git a/tests/system-test/1-insert/alter_replica.py b/tests/system-test/1-insert/alter_replica.py index 900b64d943..2f59bad1b4 100644 --- a/tests/system-test/1-insert/alter_replica.py +++ b/tests/system-test/1-insert/alter_replica.py @@ -12,7 +12,7 @@ from util.cases import * from util.dnodes import * -class TDTestCase: +class TDTestCase(TBaseCase): def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) tdLog.debug("start to execute %s" % __file__) diff --git a/tests/system-test/pytest.sh b/tests/system-test/pytest.sh index 2c95516d10..bae0fdf278 100755 --- a/tests/system-test/pytest.sh +++ b/tests/system-test/pytest.sh @@ -58,6 +58,12 @@ echo "SIM_DIR : $SIM_DIR" echo "CODE_DIR : $CODE_DIR" echo "ASAN_DIR : $ASAN_DIR" +# prevent delete / folder or /usr/bin +if [ ${#SIM_DIR} -lt 10 ]; then + echo "len(SIM_DIR) < 10 , danger so exit. SIM_DIR=$SIM_DIR" + exit 1 +fi + rm -rf $SIM_DIR/* mkdir -p $PRG_DIR