aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/Controllers/ODL/OpenDaylightTesting.py
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2016-07-11 15:19:30 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2016-07-13 12:50:11 +0200
commit230b9df08d040659ba12661a505441f26508ef7a (patch)
tree47f881f5fd9c5674320ba7d49945137c20e690d0 /testcases/Controllers/ODL/OpenDaylightTesting.py
parentc32d05b2c25438997feda781151a4bd09f94cf03 (diff)
Propose a new python file to launch ODL testing
OpenDaylightTesting.py safely replaces start_tests.sh. It also adds the report of the basic test of RESTConf which was previously ignored. JIRA: FUNCTEST-367 Change-Id: I8ba288271455fd9f31cf87aa65bf45cfb53cd8d6 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'testcases/Controllers/ODL/OpenDaylightTesting.py')
-rwxr-xr-xtestcases/Controllers/ODL/OpenDaylightTesting.py116
1 files changed, 116 insertions, 0 deletions
diff --git a/testcases/Controllers/ODL/OpenDaylightTesting.py b/testcases/Controllers/ODL/OpenDaylightTesting.py
new file mode 100755
index 000000000..b1f94b11d
--- /dev/null
+++ b/testcases/Controllers/ODL/OpenDaylightTesting.py
@@ -0,0 +1,116 @@
+#!/usr/bin/python
+
+import argparse
+import fileinput
+import os
+import re
+from robot import run
+import shutil
+import sys
+
+
+class ODLTestCases:
+
+ repos = "/home/opnfv/repos/"
+ odl_test_repo = repos + "odl_test/"
+ neutron_suite_dir = odl_test_repo + "csit/suites/openstack/neutron/"
+ basic_suite_dir = odl_test_repo + "csit/suites/integration/basic/"
+
+ @classmethod
+ def copy_opnf_testcases(cls):
+ opnfv_testcases_dir = (os.path.dirname(os.path.abspath(__file__)) +
+ "/custom_tests/neutron/")
+ files = [opnfv_testcases_dir + "001__reachability.robot",
+ opnfv_testcases_dir + "040__delete_ports.robot",
+ opnfv_testcases_dir + "050__delete_subnets.robot",
+ opnfv_testcases_dir + "060__delete_networks.robot"]
+ for f in files:
+ try:
+ shutil.copy(f, cls.neutron_suite_dir)
+ except IOError as e:
+ print "Cannot copy OPNFV's testcases to ODL directory", e
+ return False
+ return True
+
+ @classmethod
+ def set_robotframework_vars(cls, odlusername="admin", odlpassword="admin"):
+ odl_variables_files = cls.odl_test_repo + 'csit/variables/Variables.py'
+ try:
+ print cls.neutron_suite_dir + '__init__.robot'
+ for line in fileinput.input(odl_variables_files,
+ inplace=True):
+ print re.sub("AUTH = .*",
+ ("AUTH = [u'" + odlusername + "', u'" +
+ odlpassword + "']"),
+ line.rstrip())
+ return True
+ except Exception as e:
+ print "Cannot set ODL creds", e
+ return False
+
+ @classmethod
+ def run(cls, **kwargs):
+ dirs = [cls.basic_suite_dir, cls.neutron_suite_dir]
+ try:
+ odlusername = kwargs['odlusername']
+ odlpassword = kwargs['odlpassword']
+ variables = ['KEYSTONE:' + kwargs['keystoneip'],
+ 'NEUTRON:' + kwargs['neutronip'],
+ 'OSUSERNAME:"' + kwargs['osusername'] + '"',
+ 'OSTENANTNAME:"' + kwargs['ostenantname'] + '"',
+ 'OSPASSWORD:"' + kwargs['ospassword'] + '"',
+ 'ODL_SYSTEM_IP:' + kwargs['odlip'],
+ 'PORT:' + kwargs['odlwebport'],
+ 'RESTCONFPORT:' + kwargs['odlrestconfport']]
+ except KeyError as e:
+ print "Cannot run ODL testcases. Please check", e
+ return False
+ res_dir = '/home/opnfv/functest/results/odl/'
+ if (cls.copy_opnf_testcases() and
+ cls.set_robotframework_vars(odlusername, odlpassword)):
+ try:
+ os.makedirs(res_dir)
+ except OSError:
+ pass
+ return run(*dirs, variable=variables,
+ output=res_dir + 'output.xml',
+ log=res_dir + 'log.html',
+ report=res_dir + 'report.html')
+ else:
+ return False
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-k', '--keystoneip',
+ help='Keystone IP',
+ default='127.0.0.1')
+ parser.add_argument('-n', '--neutronip',
+ help='Neutron IP',
+ default='127.0.0.1')
+ parser.add_argument('-a', '--osusername',
+ help='Username for OpenStack',
+ default='admin')
+ parser.add_argument('-b', '--ostenantname',
+ help='Tenantname for OpenStack',
+ default='admin')
+ parser.add_argument('-c', '--ospassword',
+ help='Password for OpenStack',
+ default='admin')
+ parser.add_argument('-o', '--odlip',
+ help='OpenDaylight IP',
+ default='127.0.0.1')
+ parser.add_argument('-w', '--odlwebport',
+ help='OpenDaylight Web Portal Port',
+ default='8080')
+ parser.add_argument('-r', '--odlrestconfport',
+ help='OpenDaylight RESTConf Port',
+ default='8181')
+ parser.add_argument('-d', '--odlusername',
+ help='Username for ODL',
+ default='admin')
+ parser.add_argument('-e', '--odlpassword',
+ help='Password for ODL',
+ default='admin')
+ args = vars(parser.parse_args())
+ sys.exit(ODLTestCases.run(**args))