Tests suite: fullpath for scripts and config files
[transportpce.git] / tests / transportpce_tests / 2.2.1 / test_utils.py
1 import os
2 import subprocess
3
4 honeynode_executable=os.path.join(
5         os.path.dirname(os.path.realpath(__file__)),
6         "..", "..", "honeynode", "2.2.1", "honeynode-distribution", "target", "honeynode-distribution-1.19.04-hc",
7         "honeynode-distribution-1.19.04", "honeycomb-tpce")
8 samples_directory=os.path.join(
9         os.path.dirname(os.path.realpath(__file__)),
10         "..", "..", "sample_configs", "openroadm", "2.2.1")
11
12 def start_xpdra_honeynode():
13     if os.path.isfile(honeynode_executable):
14         with open('honeynode1.log', 'w') as outfile:
15             return subprocess.Popen(
16                 [honeynode_executable, "17840", os.path.join(samples_directory,"oper-XPDRA.xml")],
17                 stdout=outfile, stderr=outfile)
18
19 def start_roadma_honeynode():
20     if os.path.isfile(honeynode_executable):
21         with open('honeynode2.log', 'w') as outfile:
22             return subprocess.Popen(
23                 [honeynode_executable, "17841", os.path.join(samples_directory,"oper-ROADMA.xml")],
24                 stdout=outfile, stderr=outfile)
25
26 def start_roadmb_honeynode():
27     if os.path.isfile(honeynode_executable):
28         with open('honeynode5.log', 'w') as outfile:
29             return subprocess.Popen(
30                 [honeynode_executable, "17842", os.path.join(samples_directory,"oper-ROADMB.xml")],
31                 stdout=outfile, stderr=outfile)
32
33 def start_roadmc_honeynode():
34     if os.path.isfile(honeynode_executable):
35         with open('honeynode3.log', 'w') as outfile:
36             return subprocess.Popen(
37                 [honeynode_executable, "17843", os.path.join(samples_directory,"oper-ROADMC.xml")],
38                 stdout=outfile, stderr=outfile)
39
40 def start_xpdrc_honeynode():
41     if os.path.isfile(honeynode_executable):
42         with open('honeynode4.log', 'w') as outfile:
43             return subprocess.Popen(
44                 [honeynode_executable, "17844", os.path.join(samples_directory,"oper-XPDRC.xml")],
45                 stdout=outfile, stderr=outfile)
46
47 def start_spdra_honeynode():
48     if os.path.isfile(honeynode_executable):
49         with open('honeynode6.log', 'w') as outfile:
50             return subprocess.Popen(
51                 [honeynode_executable, "17845", os.path.join(samples_directory,"oper-SPDRAv2.xml")],
52                 stdout=outfile, stderr=outfile)
53
54 def start_tpce():
55     if "USE_LIGHTY" in os.environ and os.environ['USE_LIGHTY'] == 'True':
56         print ("starting LIGHTY.IO TransportPCE build...")
57         executable = os.path.join(
58                 os.path.dirname(os.path.realpath(__file__)),
59                 "..", "..", "..", "lighty", "target", "lighty-transportpce-12.0.0-SNAPSHOT",
60                 "clean-start-controller.sh")
61         with open('odl.log', 'w') as outfile:
62             return subprocess.Popen(
63                 ["sh", executable], stdout=outfile, stderr=outfile,
64                 stdin=open(os.devnull))
65     else:
66         print ("starting KARAF TransportPCE build...")
67         executable = os.path.join(
68                 os.path.dirname(os.path.realpath(__file__)),
69                 "..", "..", "..", "karaf", "target", "assembly", "bin", "karaf")
70         with open('odl.log', 'w') as outfile:
71             return subprocess.Popen(
72                 ["sh", executable, "server"], stdout=outfile, stderr=outfile,
73                 stdin=open(os.devnull))