diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2017-06-30 06:24:11 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2017-06-30 14:32:52 +0200 |
commit | 678609610f4ccbcb19438cbce5d84bd376010596 (patch) | |
tree | f79c8abd8f04d99e586317e426fc05a68992badf /functest | |
parent | c426ee40d40434ea3a5d085f7b98d28fcdb063ff (diff) |
Define console_scripts
Only prepare_env.py and run_tests.py remain executable to avoid
breaking the gate.
As soon as the jenkins jobs are updated to run them from $PATH, tox
will be updated to protect against chmod a+x py files. Dockerfile
will be simplified as well.
Change-Id: Iac1a7ceb6b344e800177226ea39919826f6d3735
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest')
-rwxr-xr-x | functest/ci/prepare_env.py | 10 | ||||
-rwxr-xr-x | functest/ci/run_tests.py | 7 | ||||
-rw-r--r--[-rwxr-xr-x] | functest/opnfv_tests/openstack/refstack_client/refstack_client.py | 6 | ||||
-rw-r--r--[-rwxr-xr-x] | functest/opnfv_tests/openstack/refstack_client/tempest_conf.py | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | functest/opnfv_tests/openstack/vping/vping_ssh.py | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | functest/opnfv_tests/openstack/vping/vping_userdata.py | 17 | ||||
-rw-r--r--[-rwxr-xr-x] | functest/opnfv_tests/sdn/onos/sfc/sfc.py | 6 | ||||
-rw-r--r-- | functest/tests/unit/ci/test_prepare_env.py | 6 | ||||
-rw-r--r--[-rwxr-xr-x] | functest/utils/openstack_clean.py | 7 | ||||
-rw-r--r--[-rwxr-xr-x] | functest/utils/openstack_snapshot.py | 7 |
10 files changed, 25 insertions, 45 deletions
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py index 64fcc925..c633ef82 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 722df14f..5155adc4 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 c4618894..9edbab5a 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 5d429e7c..30590b9e 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 eacccb98..d4c39ad2 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 718f47f0..9aed4c10 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 a2dd7e9a..2bb9082c 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 69abd643..7d4b5fb2 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 e88245d6..d7df8f84 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 f4ef751c..3dc6f80c 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()) |