Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
support tck to test remote nebula graph
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisChu committed Jun 28, 2021
1 parent 94a6da1 commit 8277a56
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions tests/nebula-test-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,27 @@ def init_parser():
dest='multi_graphd',
default='',
help='Support multi graphds')
opt_parser.add_option('--address',
dest='address',
default='',
help='Address of the Nebula')
return opt_parser


def start_nebula(nb, configs):
nb.install()
port = nb.start(multi_graphd=configs.multi_graphd)
if configs.address is not None and configs.address != "":
print('test remote nebula graph, address is {}'.format(configs.address))
if len(configs.address.split(':')) != 2:
raise Exception('Invalid address, address is {}'.format(configs.address))
address, port = configs.address.split(':')
port = int(port)
else:
nb.install()
address = "localhost"
port = nb.start(multi_graphd=configs.multi_graphd)

# Load csv data
pool = get_conn_pool("localhost", port)
pool = get_conn_pool(address, port)
sess = pool.get_session(configs.user, configs.password)

if not os.path.exists(TMP_DIR):
Expand All @@ -76,7 +88,11 @@ def start_nebula(nb, configs):
print('Start nebula successfully')


def stop_nebula(nb):
def stop_nebula(nb, configs=None):
if configs.address is not None and configs.address != "":
print('test remote nebula graph, no need to stop nebula.')
return

with open(NB_TMP_PATH, "r") as f:
data = json.loads(f.readline())
nb.set_work_dir(data["work_dir"])
Expand All @@ -101,7 +117,7 @@ def opt_is(val, expect):
if opt_is(configs.cmd, "start"):
start_nebula(nebula_svc, configs)
elif opt_is(configs.cmd, "stop"):
stop_nebula(nebula_svc)
stop_nebula(nebula_svc, configs)
else:
raise ValueError(f"Invalid parser args: {configs.cmd}")
except Exception as x:
Expand Down

0 comments on commit 8277a56

Please sign in to comment.