Test: Also shutdown cord-tester daemon with cord-test.py cleanup
Change-Id: I90427aea7f172c191444fb762309213f5bbfd21c
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 4c71a8c..c2e8ebe 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -23,7 +23,7 @@
from OltConfig import OltConfig
from threadPool import ThreadPool
from CordContainer import *
-from CordTestServer import cord_test_server_start, cord_test_server_stop, CORD_TEST_HOST, CORD_TEST_PORT
+from CordTestServer import cord_test_server_start,cord_test_server_stop,cord_test_server_shutdown,CORD_TEST_HOST,CORD_TEST_PORT
from TestManifest import TestManifest
from docker import Client
from docker.utils import kwargs_from_env
@@ -733,6 +733,12 @@
print('Cleaning up XOS image: %s' %img)
Container.cleanup(img)
+ server_params = args.server.split(':')
+ server_host = server_params[0]
+ server_port = CORD_TEST_PORT
+ if len(server_params) > 1:
+ server_port = int(server_params[1])
+ cord_test_server_shutdown(server_host, server_port)
return 0
def listTests(args):
@@ -987,7 +993,8 @@
help='ONOS container image to cleanup')
parser_cleanup.add_argument('-x', '--xos', action='store_true',
help='Cleanup XOS containers')
-
+ parser_cleanup.add_argument('-r', '--server', default=cord_test_server_address, type=str,
+ help='ip:port address for cord test server to cleanup')
parser_cleanup.set_defaults(func=cleanupTests)
c = Client(**(kwargs_from_env()))
diff --git a/src/test/utils/CordTestServer.py b/src/test/utils/CordTestServer.py
index 7b60620..45183d3 100644
--- a/src/test/utils/CordTestServer.py
+++ b/src/test/utils/CordTestServer.py
@@ -19,6 +19,7 @@
import daemon
import xmlrpclib
import os
+import signal
import json
import time
import threading
@@ -53,10 +54,7 @@
if self.onos_cord:
self.onos_cord.start(restart = True, network_cfg = config)
else:
- if Onos.cluster_mode is True:
- Onos.restart_cluster(network_cfg = config)
- else:
- Onos(restart = True, network_cfg = config, image = Onos.IMAGE, tag = Onos.TAG)
+ Onos(restart = True, network_cfg = config, image = Onos.IMAGE, tag = Onos.TAG)
return 'DONE'
def restart_onos(self, kwargs):
@@ -109,6 +107,11 @@
Radius(prefix = Container.IMAGE_PREFIX, restart = True)
return 'DONE'
+ def shutdown(self):
+ print('Shutting down cord test server')
+ os.kill(0, signal.SIGKILL)
+ return 'DONE'
+
@nottest
def cord_test_server_start(daemonize = True, cord_test_host = CORD_TEST_HOST,
cord_test_port = CORD_TEST_PORT, onos_cord = None):
@@ -201,3 +204,13 @@
if data == 'DONE':
return True
return False
+
+@nottest
+def cord_test_server_shutdown(host, port):
+ '''Shutdown the cord test server'''
+ rpc_server = 'http://{}:{}'.format(host, port)
+ try:
+ xmlrpclib.Server(rpc_server, allow_none = True).shutdown()
+ except: pass
+
+ return True