aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfunctest/ci/prepare_env.py10
-rwxr-xr-xfunctest/ci/run_tests.py7
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/refstack_client/refstack_client.py6
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/refstack_client/tempest_conf.py2
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/vping/vping_ssh.py2
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/vping/vping_userdata.py17
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/sdn/onos/sfc/sfc.py6
-rw-r--r--functest/tests/unit/ci/test_prepare_env.py6
-rw-r--r--[-rwxr-xr-x]functest/utils/openstack_clean.py7
-rw-r--r--[-rwxr-xr-x]functest/utils/openstack_snapshot.py7
-rw-r--r--setup.cfg7
11 files changed, 32 insertions, 45 deletions
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py
index 64fcc9256..c633ef826 100755
--- a/functest/ci/prepare_env.py
+++ b/functest/ci/prepare_env.py
@@ -358,7 +358,7 @@ def print_deployment_info():
handler.get_deployment_info())
-def main(**kwargs):
+def prepare_env(**kwargs):
try:
if not (kwargs['action'] in actions):
logger.error('Argument not valid.')
@@ -384,9 +384,13 @@ def main(**kwargs):
return 0
-if __name__ == '__main__':
+def main():
logging.config.fileConfig(pkg_resources.resource_filename(
'functest', 'ci/logging.ini'))
parser = PrepareEnvParser()
args = parser.parse_args(sys.argv[1:])
- sys.exit(main(**args))
+ return prepare_env(**args)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index 722df14fe..5155adc46 100755
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -269,10 +269,13 @@ class Runner(object):
return self.overall_result
-if __name__ == '__main__':
+def main():
logging.config.fileConfig(pkg_resources.resource_filename(
'functest', 'ci/logging.ini'))
parser = RunTestsParser()
args = parser.parse_args(sys.argv[1:])
runner = Runner()
- sys.exit(runner.main(**args).value)
+ return runner.main(**args).value
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index c46188947..9edbab5a1 100755..100644
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -218,7 +218,7 @@ class RefstackClientParser(object):
return vars(self.parser.parse_args(argv))
-if __name__ == '__main__':
+def main():
logging.basicConfig()
refstackclient = RefstackClient()
parser = RefstackClientParser()
@@ -226,6 +226,6 @@ if __name__ == '__main__':
try:
result = refstackclient.main(**args)
if result != testcase.TestCase.EX_OK:
- sys.exit(result)
+ return result
except Exception:
- sys.exit(testcase.TestCase.EX_RUN_ERROR)
+ return testcase.TestCase.EX_RUN_ERROR
diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
index 5d429e7c2..30590b9eb 100755..100644
--- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -49,7 +49,7 @@ class TempestConf(object):
logger.error('Error with run: %s', e)
-if __name__ == '__main__':
+def main():
logging.basicConfig()
tempestconf = TempestConf()
tempestconf.main()
diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py
index eacccb988..d4c39ad27 100755..100644
--- a/functest/opnfv_tests/openstack/vping/vping_ssh.py
+++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py
@@ -23,8 +23,8 @@ from snaps.openstack.utils import deploy_utils
from functest.core.testcase import TestCase
from functest.opnfv_tests.openstack.snaps import snaps_utils
+from functest.opnfv_tests.openstack.vping import vping_base
from functest.utils.constants import CONST
-import vping_base
class VPingSSH(vping_base.VPingBase):
diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py
index 718f47f0d..9aed4c10a 100755..100644
--- a/functest/opnfv_tests/openstack/vping/vping_userdata.py
+++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py
@@ -7,17 +7,14 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import argparse
-import sys
import time
-from functest.core.testcase import TestCase
-
from snaps.openstack.utils import deploy_utils
from snaps.openstack.create_instance import VmInstanceSettings
from snaps.openstack.create_network import PortSettings
-import vping_base
+from functest.core.testcase import TestCase
+from functest.opnfv_tests.openstack.vping import vping_base
class VPingUserdata(vping_base.VPingBase):
@@ -142,13 +139,3 @@ def _get_userdata(test_ip):
" sleep 1\n"
"done\n" % test_ip)
return None
-
-
-if __name__ == '__main__':
- args_parser = argparse.ArgumentParser()
- args_parser.add_argument("-r", "--report",
- help="Create json result file",
- action="store_true")
- args = vars(args_parser.parse_args())
-
- sys.exit(vping_base.VPingMain(VPingUserdata).main(**args))
diff --git a/functest/opnfv_tests/sdn/onos/sfc/sfc.py b/functest/opnfv_tests/sdn/onos/sfc/sfc.py
index a2dd7e9a0..2bb9082ca 100755..100644
--- a/functest/opnfv_tests/sdn/onos/sfc/sfc.py
+++ b/functest/opnfv_tests/sdn/onos/sfc/sfc.py
@@ -165,14 +165,10 @@ def PushDB(status, info):
def main():
"""Script to Test the SFC scenarios in ONOS."""
+ logging.basicConfig()
PreConfig()
CreateNodes()
ConfigSfc()
VerifySfcTraffic()
CleanUp()
PushDB("PASS", "")
-
-
-if __name__ == '__main__':
- logging.basicConfig()
- main()
diff --git a/functest/tests/unit/ci/test_prepare_env.py b/functest/tests/unit/ci/test_prepare_env.py
index 69abd6433..7d4b5fb25 100644
--- a/functest/tests/unit/ci/test_prepare_env.py
+++ b/functest/tests/unit/ci/test_prepare_env.py
@@ -441,7 +441,7 @@ class PrepareEnvTesting(unittest.TestCase):
mock_check_env):
with mock.patch("__builtin__.open", mock.mock_open()) as m:
args = {'action': 'start'}
- self.assertEqual(prepare_env.main(**args), 0)
+ self.assertEqual(prepare_env.prepare_env(**args), 0)
mock_logger_info.assert_any_call("######### Preparing Functest "
"environment #########\n")
self.assertTrue(mock_env_var.called)
@@ -459,13 +459,13 @@ class PrepareEnvTesting(unittest.TestCase):
@mock.patch('functest.ci.prepare_env.check_environment')
def test_main_check(self, mock_check_env):
args = {'action': 'check'}
- self.assertEqual(prepare_env.main(**args), 0)
+ self.assertEqual(prepare_env.prepare_env(**args), 0)
self.assertTrue(mock_check_env.called)
@mock.patch('functest.ci.prepare_env.logger.error')
def test_main_no_arg(self, mock_logger_error):
args = {'action': 'not_valid'}
- self.assertEqual(prepare_env.main(**args), -1)
+ self.assertEqual(prepare_env.prepare_env(**args), -1)
mock_logger_error.assert_called_once_with('Argument not valid.')
diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py
index e88245d61..d7df8f848 100755..100644
--- a/functest/utils/openstack_clean.py
+++ b/functest/utils/openstack_clean.py
@@ -23,7 +23,6 @@
#
import logging
-import sys
import time
import yaml
@@ -382,6 +381,7 @@ def remove_tenants(keystone_client, default_tenants):
def main():
+ logging.basicConfig()
logger.info("Cleaning OpenStack resources...")
nova_client = os_utils.get_nova_client()
@@ -430,8 +430,3 @@ def main():
remove_tenants(keystone_client, default_tenants)
separator()
return 0
-
-
-if __name__ == '__main__':
- logging.basicConfig()
- sys.exit(main())
diff --git a/functest/utils/openstack_snapshot.py b/functest/utils/openstack_snapshot.py
index f4ef751c6..3dc6f80c7 100755..100644
--- a/functest/utils/openstack_snapshot.py
+++ b/functest/utils/openstack_snapshot.py
@@ -22,7 +22,6 @@
import logging
import yaml
-import sys
import functest.utils.openstack_utils as os_utils
from functest.utils.constants import CONST
@@ -131,6 +130,7 @@ def get_tenants(keystone_client):
def main():
+ logging.basicConfig()
logger.info("Generating OpenStack snapshot...")
nova_client = os_utils.get_nova_client()
@@ -163,8 +163,3 @@ def main():
logger.debug("NOTE: These objects will NOT be deleted after " +
"running the test.")
return 0
-
-
-if __name__ == '__main__':
- logging.basicConfig()
- sys.exit(main())
diff --git a/setup.cfg b/setup.cfg
index 12da1b63a..f0ed545cb 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -14,3 +14,10 @@ scripts =
console_scripts =
functest = functest.cli.cli_base:cli
functest_odl = functest.opnfv_tests.sdn.odl.odl:main
+ functest_onos_sfc = functest.opnfv_tests.sdn.onos.sfc.sfc:main
+ functest_refstack_client = functest.opnfv_tests.openstack.refstack_client.refstack_client:main
+ functest_tempest_conf = functest.opnfv_tests.openstack.refstack_client.tempest_conf:main
+ openstack_snapshot = functest.utils.openstack_snapshot:main
+ openstack_clean = functest.utils.openstack_clean:main
+ prepare_env = functest.ci.prepare_env:main
+ run_tests = functest.ci.run_tests:main