Don't run voltha processes if already running just to avoid multiple running instances.
Change default voltha interface in manifest-voltha to eth0.
Change-Id: I28c19d8c9836e9f5809e1ea12bfcd57b2a596ddc
diff --git a/src/test/setup/manifest-voltha.json b/src/test/setup/manifest-voltha.json
index d73b5d2..1c061a5 100644
--- a/src/test/setup/manifest-voltha.json
+++ b/src/test/setup/manifest-voltha.json
@@ -7,5 +7,5 @@
"jvm_heap_size" : "1G",
"karaf_version" : "3.0.8",
"voltha_loc" : "/home/ubuntu/voltha/incubator/voltha",
- "voltha_intf" : "enp0s9"
+ "voltha_intf" : "eth0"
}
diff --git a/src/test/utils/CordTestUtils.py b/src/test/utils/CordTestUtils.py
index 6d46c16..f21c4e9 100644
--- a/src/test/utils/CordTestUtils.py
+++ b/src/test/utils/CordTestUtils.py
@@ -12,7 +12,7 @@
# we use subprocess as commands.getstatusoutput would be deprecated
def getstatusoutput(cmd):
- command = [ '/bin/sh', '-c', cmd ]
+ command = [ '/bin/bash', '-c', cmd ]
p = subprocess.Popen(command, stdout = subprocess.PIPE)
out, _ = p.communicate()
return p.returncode, out.strip()
diff --git a/src/test/utils/VolthaCtrl.py b/src/test/utils/VolthaCtrl.py
index 19e246c..ea5a306 100644
--- a/src/test/utils/VolthaCtrl.py
+++ b/src/test/utils/VolthaCtrl.py
@@ -45,9 +45,12 @@
--fluentd={}:24224 --grpc-endpoint=localhost:50555 \
>/tmp/chameleon.log 2>&1 &'".format(self.voltha_loc,
self.service_map['fluentd']['ip'])
- ret = os.system(chameleon_start_cmd)
- if ret != 0:
- raise Exception('VOLTHA chameleon service not started. Failed with return code %d' %ret)
+ if not self.service_running('python chameleon/main.py'):
+ ret = os.system(chameleon_start_cmd)
+ if ret != 0:
+ raise Exception('VOLTHA chameleon service not started. Failed with return code %d' %ret)
+ else:
+ print('Chameleon voltha sevice is already running. Skipped start')
#now start voltha and ofagent
voltha_start_cmd = "cd {} && sh -c '. ./env.sh && \
@@ -57,10 +60,12 @@
self.service_map['kafka']['ip'],
self.interface,
self.service_map['fluentd']['ip'])
- ret = os.system(voltha_start_cmd)
- if ret != 0:
- raise Exception('Failed to start VOLTHA. Return code %d' %ret)
-
+ if not self.service_running('python voltha/main.py'):
+ ret = os.system(voltha_start_cmd)
+ if ret != 0:
+ raise Exception('Failed to start VOLTHA. Return code %d' %ret)
+ else:
+ print('VOLTHA core is already running. Skipped start')
ofagent_start_cmd = "cd {} && sh -c '. ./env.sh && \
nohup python ofagent/main.py -v --consul=localhost:8500 \
@@ -68,9 +73,16 @@
>/tmp/ofagent.log 2>&1 &'".format(self.voltha_loc,
self.service_map['fluentd']['ip'],
self.controller)
- ret = os.system(ofagent_start_cmd)
- if ret != 0:
- raise Exception('VOLTHA ofagent not started. Failed with return code %d' %ret)
+ if not self.service_running('python ofagent/main.py'):
+ ret = os.system(ofagent_start_cmd)
+ if ret != 0:
+ raise Exception('VOLTHA ofagent not started. Failed with return code %d' %ret)
+ else:
+ print('VOLTHA ofagent is already running. Skipped start')
+
+ def service_running(self, pattern):
+ st, _ = getstatusoutput('pgrep -f "{}"'.format(pattern))
+ return True if st == 0 else False
def kill_service(self, pattern):
st, output = getstatusoutput('pgrep -f "{}"'.format(pattern))