aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/tests
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-01-09 09:17:45 +0100
committerMorgan Richomme <morgan.richomme@orange.com>2016-01-11 13:45:53 +0000
commit9fb043eafa37257bf0ee8acd32b169cb7f18e0ca (patch)
treeda77104d194757973d3dc10b445e6399037d2b25 /testcases/tests
parent69a7887f4eb8c931628442ab0a4d3fb298667f8e (diff)
Add mechanism to check whether the test can be run or not according to the scenario/controller
JIRA: FUNCTEST-119 Change-Id: Ida658760484140ff59f7198dbbf4d5620450ff27 Signed-off-by: Morgan Richomme <morgan.richomme@orange.com> (cherry picked from commit 9de9e1226184ede9c5b8aadde9287dec29b422ee)
Diffstat (limited to 'testcases/tests')
-rw-r--r--testcases/tests/TestFunctestUtils.py122
1 files changed, 122 insertions, 0 deletions
diff --git a/testcases/tests/TestFunctestUtils.py b/testcases/tests/TestFunctestUtils.py
new file mode 100644
index 000000000..337e4ee8a
--- /dev/null
+++ b/testcases/tests/TestFunctestUtils.py
@@ -0,0 +1,122 @@
+import unittest
+import os
+import sys
+import yaml
+
+sys.path.append("../")
+from functest_utils import getTestEnv, isTestRunnable, generateTestcaseList
+
+
+class TestFunctestUtils(unittest.TestCase):
+
+ def setUp(self):
+ os.environ["INSTALLER_TYPE"] = "fuel"
+ os.environ["SDN_CONTROLLER"] = "odl"
+ os.environ["OPNFV_FEATURE"] = "ovs2.4"
+
+ global functest_yaml
+
+ with open("../config_functest.yaml") as f:
+ functest_yaml = yaml.safe_load(f)
+ f.close()
+
+ def test_getTestEnv(self):
+
+ env_test = getTestEnv('ovno', functest_yaml)
+ self.assertEqual(env_test, {'controller': 'opencontrail'})
+
+ env_test = getTestEnv('doctor', functest_yaml)
+ self.assertEqual(env_test, None)
+
+ env_test = getTestEnv('promise', functest_yaml)
+ self.assertEqual(env_test, None)
+
+ env_test = getTestEnv('functest/tempest', functest_yaml)
+ self.assertEqual(env_test, None)
+
+ env_test = getTestEnv('functest/vims', functest_yaml)
+ self.assertEqual(env_test, None)
+
+ env_test = getTestEnv('functest/odl', functest_yaml)
+ self.assertEqual(env_test, {'controller': 'odl'})
+
+ env_test = getTestEnv('functest/onos', functest_yaml)
+ self.assertEqual(env_test, {'controller': 'onos'})
+
+ env_test = getTestEnv('functest/onos-ovsdb', functest_yaml)
+ self.assertEqual(env_test, {'controller': 'onos'})
+
+ env_test = getTestEnv('policy-test', functest_yaml)
+ self.assertEqual(env_test, {'controller': 'odl'})
+
+ env_test = getTestEnv('sdnvpn/odl-vpn_service-tests', functest_yaml)
+ self.assertEqual(env_test,
+ {'controller': 'odl', 'scenario': 'os_ovh_ha'})
+
+ env_test = getTestEnv('sdnvpn/opnfv-yardstick-tc026-sdnvpn',
+ functest_yaml)
+ self.assertEqual(env_test,
+ {'controller': 'nosdn', 'scenario': 'os_ovh_ha'})
+
+ env_test = getTestEnv('sdnvpn/openstack-neutron-bgpvpn-api-extension-tests',
+ functest_yaml)
+ self.assertEqual(env_test,
+ {'controller': 'nosdn', 'scenario': 'os_ovh_ha'})
+
+ env_test = getTestEnv('foo', functest_yaml)
+ self.assertEqual(env_test, '')
+
+ def test_isTestRunnable(self):
+
+ test = isTestRunnable('ovno', functest_yaml)
+ self.assertFalse(test)
+
+ test = isTestRunnable('doctor', functest_yaml)
+ self.assertTrue(test)
+
+ test = isTestRunnable('promise', functest_yaml)
+ self.assertTrue(test)
+
+ test = isTestRunnable('functest/onos', functest_yaml)
+ self.assertFalse(test)
+
+ test = isTestRunnable('functest/odl', functest_yaml)
+ self.assertTrue(test)
+
+ test = isTestRunnable('functest/vping', functest_yaml)
+ self.assertTrue(test)
+
+ test = isTestRunnable('functest/tempest', functest_yaml)
+ self.assertTrue(test)
+
+ test = isTestRunnable('functest/rally', functest_yaml)
+ self.assertTrue(test)
+
+ test = isTestRunnable('functest/vims', functest_yaml)
+ self.assertTrue(test)
+
+ test = isTestRunnable('sdnvpn/odl-vpn_service-tests',
+ functest_yaml)
+ self.assertTrue(test)
+
+ test = isTestRunnable('sdnvpn/opnfv-yardstick-tc026-sdnvpn',
+ functest_yaml)
+ self.assertFalse(test)
+
+ def test_generateTestcaseList(self):
+
+ test = generateTestcaseList(functest_yaml)
+ test = sorted(test.split(' '))
+ expected_list = "doctor vims odl rally vping tempest promise policy-test odl-vpn_service-tests "
+ expected_list_array = sorted(expected_list.split(' '))
+
+ self.assertEqual(test, expected_list_array)
+
+ def tearDown(self):
+ os.environ["INSTALLER_TYPE"] = ""
+ os.environ["SDN_CONTROLLER"] = ""
+ os.environ["OPNFV_FEATURE"] = ""
+
+
+if __name__ == '__main__':
+ unittest.main()