Skip to content

Commit f1662ff

Browse files
committed
chore: refact test_grant_basic.py
1 parent 3a89cc9 commit f1662ff

File tree

1 file changed

+30
-80
lines changed

1 file changed

+30
-80
lines changed

test/cases/32-Grants/test_grant_basic.py

Lines changed: 30 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
from new_test_framework.utils import tdLog, tdSql, TDDnodes, tdCom, TDDnode, tdDnodes
2-
from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
3-
import taos
4-
import sys
5-
import time
1+
from new_test_framework.utils import tdLog, tdSql, tdCom, tdDnodes
2+
from new_test_framework.utils.sqlset import TDSetSql
3+
from decimal import Decimal
64
import os
7-
import platform
8-
5+
import random
6+
import string
7+
import taos
8+
import threading
99
import time
10-
import socket
11-
import subprocess
12-
13-
class MyDnodes(TDDnodes):
14-
def __init__(self ,dnodes_lists):
15-
super(MyDnodes,self).__init__()
16-
self.dnodes = dnodes_lists # dnode must be TDDnode instance
17-
if platform.system().lower() == 'windows':
18-
self.simDeployed = True
19-
else:
20-
self.simDeployed = False
21-
22-
class TestGrant:
23-
noConn = True
10+
import shutil
11+
12+
class TestCase:
13+
path_parts = os.getcwd().split(os.sep)
14+
try:
15+
tdinternal_index = path_parts.index("TDinternal")
16+
except ValueError:
17+
raise ValueError("The specified directory 'TDinternal' was not found in the path.")
18+
TDinternal = os.sep.join(path_parts[:tdinternal_index + 1])
19+
dnode1Path = os.path.join(TDinternal, "sim", "dnode1")
20+
configFile = os.path.join(dnode1Path, "cfg", "taos.cfg")
21+
hostPath = os.path.join(dnode1Path, "multi")
22+
localSSPath = os.path.join(TDinternal, "sim", "localSS") # shared storage path for local test
23+
clientCfgDict = {'debugFlag': 135}
2424
encryptConfig = {
2525
"svrKey": "1234567890",
2626
"dbKey": "1234567890",
@@ -29,60 +29,10 @@ class TestGrant:
2929
"generateMeta": True,
3030
"generateData": True
3131
}
32-
def getTDinternalPath():
33-
path_parts = os.getcwd().split(os.sep)
34-
try:
35-
tdinternal_index = path_parts.index("TDinternal")
36-
except ValueError:
37-
raise ValueError("The specified directory 'TDinternal' was not found in the path.")
38-
return os.sep.join(path_parts[:tdinternal_index + 1])
3932

40-
def setup_class(cls):
41-
tdLog.debug(f"start to excute {__file__}")
42-
43-
44-
def deploy_cluster(self ,dnodes_nums):
45-
46-
testCluster = False
47-
valgrind = 0
48-
hostname = self.host
49-
dnodes = []
50-
start_port = 6030
51-
for num in range(1, dnodes_nums+1):
52-
dnode = TDDnode(num)
53-
dnode.addExtraCfg("firstEp", f"{hostname}:{start_port}")
54-
dnode.addExtraCfg("fqdn", f"{hostname}")
55-
dnode.addExtraCfg("serverPort", f"{start_port + (num-1)*100}")
56-
dnode.addExtraCfg("monitorFqdn", hostname)
57-
dnode.addExtraCfg("monitorPort", 7043)
58-
dnode.addExtraCfg("encryptConfig", self.encryptConfig)
59-
dnodes.append(dnode)
60-
61-
self.TDDnodes = MyDnodes(dnodes)
62-
self.TDDnodes.init("", tdDnodes.binPath)
63-
self.TDDnodes.setTestCluster(testCluster)
64-
self.TDDnodes.setValgrind(valgrind)
65-
66-
self.TDDnodes.setAsan(tdDnodes.getAsan())
67-
self.TDDnodes.stopAll()
68-
for dnode in self.TDDnodes.dnodes:
69-
self.TDDnodes.deploy(dnode.index,{})
70-
71-
for dnode in self.TDDnodes.dnodes:
72-
self.TDDnodes.starttaosd(dnode.index)
73-
74-
# create cluster
75-
for dnode in self.TDDnodes.dnodes[1:]:
76-
# print(dnode.cfgDict)
77-
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
78-
dnode_first_host = dnode.cfgDict["firstEp"].split(":")[0]
79-
dnode_first_port = dnode.cfgDict["firstEp"].split(":")[-1]
80-
cmd = f"{tdCom.getBuildPath()}/build/bin/taos -h {dnode_first_host} -P {dnode_first_port} -s \"create dnode \\\"{dnode_id}\\\"\""
81-
print(cmd)
82-
os.system(cmd)
83-
84-
time.sleep(2)
85-
tdLog.info(" create cluster done! ")
33+
def setup_cls(cls):
34+
tdLog.debug("start to execute %s" % __file__)
35+
cls.setsql = TDSetSql()
8636

8737
def s0_five_dnode_one_mnode(self):
8838
tdSql.query("select * from information_schema.ins_dnodes;")
@@ -474,12 +424,12 @@ def test_grant(self):
474424
# print(self.master_dnode.cfgDict)
475425
# keep the order of following steps
476426

477-
self.TDDnodes = None
478-
self.deploy_cluster(5)
479-
self.master_dnode = tdDnodes.dnodes[0]
480-
self.host=self.master_dnode.cfgDict["fqdn"]
481-
conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir)
482-
tdSql.init(conn1.cursor(), True)
427+
# self.TDDnodes = None
428+
# self.deploy_cluster(5)
429+
# self.master_dnode = tdDnodes.dnodes[0]
430+
# self.host=self.master_dnode.cfgDict["fqdn"]
431+
# conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir)
432+
# tdSql.init(conn1.cursor(), True)
483433
self.workPath = os.path.join(tdCom.getBuildPath(), "build", "bin")
484434
tdLog.info(self.workPath)
485435
self.s0_five_dnode_one_mnode()

0 commit comments

Comments
 (0)