Skip to content

Commit

Permalink
Refactor nebula test script
Browse files Browse the repository at this point in the history
  • Loading branch information
yixinglu committed Sep 29, 2021
1 parent 16d0ecc commit cb4b57e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
46 changes: 19 additions & 27 deletions tests/common/nebula_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,11 @@ def _check_servers_status(self, ports):
time.sleep(1)
return False

def start(self,
debug_log=True,
multi_graphd=False,
enable_ssl=False,
enable_graph_ssl=False,
enable_meta_ssl=False,
ca_signed=False,
containerized=False):
def start(self, debug_log=True, multi_graphd=False, ca_signed=False, **kwargs):
os.chdir(self.work_dir)

metad_ports = self._find_free_port()
all_ports = [metad_ports[0]]
command = ''
graph_ports = []
server_ports = []
servers = []
Expand All @@ -189,30 +181,30 @@ def start(self,
if server_name != 'metad':
while True:
ports = self._find_free_port()
if all((ports[0] + i) not in all_ports
for i in range(-2, 3)):
if all((ports[0] + i) not in all_ports for i in range(-2, 3)):
all_ports += [ports[0]]
break
else:
ports = metad_ports
server_ports.append(ports[0])
new_name = server_name
new_name = server_name if server_name != 'graphd1' else 'graphd'
command = [
self._format_nebula_command(new_name,
metad_ports[0],
ports,
debug_log,
ca_signed=ca_signed)
]
if server_name == 'graphd1':
new_name = 'graphd'
command = self._format_nebula_command(new_name,
metad_ports[0],
ports,
debug_log,
ca_signed=ca_signed)
if server_name == 'graphd1':
command += ' --log_dir=logs1'
command += ' --pid_file=pids1/nebula-graphd.pid'
command += ' --enable_ssl={}'.format(enable_ssl)
command += ' --enable_graph_ssl={}'.format(enable_graph_ssl)
command += ' --enable_meta_ssl={}'.format(enable_meta_ssl)
command += ' --containerized={}'.format(containerized)
print("exec: " + command)
p = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE)
command.append('--log_dir=logs1')
command.append('--pid_file=pids1/nebula-graphd.pid')

for k,v in kwargs.items():
command.append("--{}={}".format(k, v))

cmd = " ".join(command)
print("exec: " + cmd)
p = subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE)
p.wait()
if p.returncode != 0:
print("error: " + bytes.decode(p.communicate()[0]))
Expand Down
2 changes: 1 addition & 1 deletion tests/nebula-test-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def start_nebula(nb, configs):
ports = nb.start(
debug_log=debug,
multi_graphd=configs.multi_graphd,
ca_signed=configs.ca_signed,
enable_ssl=configs.enable_ssl,
enable_graph_ssl=configs.enable_graph_ssl,
enable_meta_ssl=configs.enable_meta_ssl,
ca_signed=configs.ca_signed,
containerized=configs.containerized
)

Expand Down

0 comments on commit cb4b57e

Please sign in to comment.