diff --git a/MANIFEST.in b/MANIFEST.in index 8a2a9e9b..455d1943 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ recursive-include fuel_health * -recursive-include fuel_plugin * \ No newline at end of file +recursive-include fuel_plugin * +include requirements.txt \ No newline at end of file diff --git a/README.md b/README.md index 09fc1829..6ab0df45 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ fuel-ostf-tests =============== + +In order to start tests you will need to perform next commands: + fab unit + fab testall + +Ideally tests should be runned with tox, e.g: + tox -e py27 + + or + + tox + diff --git a/fabfile.py b/fabfile.py index 36b9e95c..96a1c5f3 100644 --- a/fabfile.py +++ b/fabfile.py @@ -37,7 +37,6 @@ def startserver(): def startdebugserver(): local(('ostf-server ' '--debug ' - '--nailgun-port=8888 ' '--debug_tests=fuel_plugin/testing/fixture/dummy_tests')) diff --git a/fuel_health/tests/platform_tests/test_ceilometer.py b/fuel_health/tests/platform_tests/test_ceilometer.py index c8c47ac8..c60eefde 100644 --- a/fuel_health/tests/platform_tests/test_ceilometer.py +++ b/fuel_health/tests/platform_tests/test_ceilometer.py @@ -14,7 +14,6 @@ import logging from fuel_health import ceilometermanager -from fuel_health import nmanager from fuel_health.common.utils.data_utils import rand_name LOG = logging.getLogger(__name__) diff --git a/fuel_plugin/bin/__init__.py b/fuel_plugin/bin/__init__.py deleted file mode 100644 index 141ca6ab..00000000 --- a/fuel_plugin/bin/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2013 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. diff --git a/fuel_plugin/bin/adapter_api.py b/fuel_plugin/bin/adapter_api.py deleted file mode 100644 index 99ff5362..00000000 --- a/fuel_plugin/bin/adapter_api.py +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright 2013 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import os -import logging -import signal -import sys -import pecan -from gevent import pywsgi - -from oslo.config import cfg - -from fuel_plugin.ostf_adapter import cli_config -from fuel_plugin.ostf_adapter import nailgun_hooks -from fuel_plugin.ostf_adapter import logger -from fuel_plugin.ostf_adapter.wsgi import app -from fuel_plugin.ostf_adapter.nose_plugin import nose_discovery -from fuel_plugin.ostf_adapter.storage import engine -from fuel_plugin.ostf_adapter import mixins - -adapter_group = cfg.OptGroup(name='adapter', - title='Adapter Options') -AdapterGroup = [ - cfg.StrOpt('server_host', - default='127.0.0.1', - help="adapter host"), - cfg.StrOpt('server_port', - default='8777', - help="Port number"), - cfg.StrOpt('dbpath', - default='postgresql+psycopg2://ostf:ostf@localhost/ostf', - help=""), - cfg.StrOpt('lock_dir', - default='/var/lock', - help=""), - cfg.StrOpt('nailgun_host', - default='127.0.0.1', - help=""), - cfg.StrOpt('nailgun_port', - default='8000', - help=""), - cfg.StrOpt('log_file', - default='/var/log/ostf.log', - help=""), - cfg.BoolOpt('after_init_hook', - default='False', - help='Should be true when we need migrate data to db') - ] - - -def register_adapter_opts(conf): - conf.register_group(adapter_group) - for opt in AdapterGroup: - conf.register_opt(opt, group='adapter') - - -class Ostf_Config(object): - - DEFAULT_CONFIG_DIR = os.path.join(os.path.abspath( - os.path.dirname(__file__)), '/etc') - - DEFAULT_CONFIG_FILE = "ostf.conf" - - def __init__(self): - """Initialize a configuration from a conf directory and conf file.""" - config_files = [] - - failsafe_path = "/etc/ostf/" + self.DEFAULT_CONFIG_FILE - - # Environment variables override defaults... - custom_config = os.environ.get('CUSTOM_OSTF_CONFIG') - if custom_config: - path = custom_config - else: - conf_dir = os.environ.get('OSTF_CONFIG_DIR', - self.DEFAULT_CONFIG_DIR) - conf_file = os.environ.get('OSTF_CONFIG', self.DEFAULT_CONFIG_FILE) - - path = os.path.join(conf_dir, conf_file) - - if not (os.path.isfile(path) - or 'OSTF_CONFIG_DIR' in os.environ - or 'OSTF_CONFIG' in os.environ): - path = failsafe_path - - if not os.path.exists(path): - msg = "Config file %(path)s not found" % locals() - print >> sys.stderr, RuntimeError(msg) - else: - config_files.append(path) - - cfg.CONF([], project='ostf', default_config_files=config_files) - - register_adapter_opts(cfg.CONF) - self.adapter = cfg.CONF.adapter - - -def main(): - - settings = Ostf_Config() - - cli_args = cli_config.parse_cli() - - config = { - 'server': { - 'host': settings.adapter.server_host or cli_args.host, - 'port': settings.adapter.server_port or cli_args.port - }, - 'dbpath': settings.adapter.dbpath or cli_args.dbpath, - 'debug': cli_args.debug, - 'debug_tests': cli_args.debug_tests, - 'lock_dir': settings.adapter.lock_dir or cli_args.lock_dir, - 'nailgun': { - 'host': settings.adapter.nailgun_host or cli_args.nailgun_host, - 'port': settings.adapter.nailgun_port or cli_args.nailgun_port - } - } - logger.setup(log_file=( - settings.adapter.log_file or cli_args.log_file)) - - log = logging.getLogger(__name__) - - root = app.setup_app(config=config) - - if settings.adapter.after_init_hook or\ - getattr(cli_args, 'after_init_hook'): - return nailgun_hooks.after_initialization_environment_hook() - - with engine.contexted_session(pecan.conf.dbpath) as session: - # performing cleaning of expired data (if any) in db - mixins.clean_db(session) - - # discover testsets and their tests - CORE_PATH = pecan.conf.debug_tests if \ - pecan.conf.get('debug_tests') else 'fuel_health' - - nose_discovery.discovery(path=CORE_PATH, session=session) - - # cache needed data from test repository - mixins.cache_test_repository(session) - - host, port = pecan.conf.server.host, pecan.conf.server.port - srv = pywsgi.WSGIServer((host, int(port)), root) - - log.info('Starting server in PID %s', os.getpid()) - log.info("serving on http://%s:%s", host, port) - - try: - signal.signal(signal.SIGCHLD, signal.SIG_IGN) - srv.serve_forever() - except KeyboardInterrupt: - pass - - -if __name__ == '__main__': - main() diff --git a/fuel_plugin/ostf_adapter/cli_config.py b/fuel_plugin/ostf_adapter/cli_config.py deleted file mode 100644 index e9ba352f..00000000 --- a/fuel_plugin/ostf_adapter/cli_config.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2013 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import argparse -import sys - - -def parse_cli(): - parser = argparse.ArgumentParser() - parser.add_argument('--after-initialization-environment-hook', - action='store_true', dest='after_init_hook') - parser.add_argument('--debug', - action='store_true', dest='debug') - parser.add_argument( - '--dbpath', metavar='DB_PATH', - default='postgresql+psycopg2://ostf:ostf@localhost/ostf') - parser.add_argument('--host', default='127.0.0.1') - parser.add_argument('--port', default='8989') - parser.add_argument('--log_file', default=None, metavar='PATH') - parser.add_argument('--nailgun-host', default='127.0.0.1') - parser.add_argument('--nailgun-port', default='8000') - parser.add_argument('--debug_tests', default=None) - parser.add_argument('--lock_dir', default='/var/lock') - - return parser.parse_args(sys.argv[1:]) diff --git a/fuel_plugin/ostf_adapter/config.py b/fuel_plugin/ostf_adapter/config.py new file mode 100644 index 00000000..e46624b6 --- /dev/null +++ b/fuel_plugin/ostf_adapter/config.py @@ -0,0 +1,96 @@ +# Copyright 2013 Mirantis, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import logging + +from oslo.config import cfg + + +LOG = logging.getLogger(__name__) + +adapter_group = cfg.OptGroup(name='adapter', + title='Adapter Options') + +adapter_opts = [ + cfg.StrOpt('server_host', + default='127.0.0.1', + help="adapter host"), + cfg.IntOpt('server_port', + default=8777, + help="Port number"), + cfg.StrOpt('dbpath', + default='postgresql+psycopg2://ostf:ostf@localhost/ostf', + help=""), + cfg.StrOpt('lock_dir', + default='/var/lock', + help=""), + cfg.StrOpt('nailgun_host', + default='127.0.0.1', + help=""), + cfg.StrOpt('nailgun_port', + default='8000', + help=""), + cfg.StrOpt('log_file', + default='/var/log/ostf.log', + help="") +] + +cli_opts = [ + cfg.BoolOpt('debug', default=False), + cfg.BoolOpt('after-initialization-environment-hook', default=False), + cfg.StrOpt('debug_tests') +] + + +cfg.CONF.register_cli_opts(cli_opts) +cfg.CONF.register_opts(adapter_opts, group='adapter') + + +DEFAULT_CONFIG_DIR = os.path.join(os.path.abspath( + os.path.dirname(__file__)), '/etc') + +DEFAULT_CONFIG_FILE = "ostf.conf" + + +def init_config(args=[]): + + config_files = [] + + failsafe_path = "/etc/ostf/" + DEFAULT_CONFIG_FILE + + # Environment variables override defaults... + custom_config = os.environ.get('CUSTOM_OSTF_CONFIG') + if custom_config: + path = custom_config + else: + conf_dir = os.environ.get('OSTF_CONFIG_DIR', + DEFAULT_CONFIG_DIR) + conf_file = os.environ.get('OSTF_CONFIG', DEFAULT_CONFIG_FILE) + + path = os.path.join(conf_dir, conf_file) + + if not (os.path.isfile(path) + or 'OSTF_CONFIG_DIR' in os.environ + or 'OSTF_CONFIG' in os.environ): + path = failsafe_path + + if not os.path.exists(path): + msg = "Config file {0} not found".format(path) + LOG.warning(msg) + # No need to fail here! If config doesnot exist defaults are used + else: + config_files.append(path) + + cfg.CONF(args, project='ostf', default_config_files=config_files) diff --git a/fuel_plugin/ostf_adapter/mixins.py b/fuel_plugin/ostf_adapter/mixins.py index 3a47f502..3b9d16fe 100644 --- a/fuel_plugin/ostf_adapter/mixins.py +++ b/fuel_plugin/ostf_adapter/mixins.py @@ -14,13 +14,15 @@ import requests -from pecan import conf from sqlalchemy.orm import joinedload import logging +from oslo.config import cfg + from fuel_plugin.ostf_adapter.storage import models from fuel_plugin.ostf_adapter.nose_plugin import nose_utils + LOG = logging.getLogger(__name__) REQ_SES = requests.Session() @@ -33,6 +35,7 @@ TEST_REPOSITORY = [] def clean_db(session): + LOG.info('Starting clean db action.') session.query(models.ClusterTestingPattern).delete() session.query(models.ClusterState).delete() session.query(models.TestSet).delete() @@ -105,15 +108,15 @@ def discovery_check(session, cluster): def _get_cluster_depl_tags(cluster_id): cluster_url = NAILGUN_API_URL.format(cluster_id) - request_url = URL.format(conf.nailgun.host, - conf.nailgun.port, + request_url = URL.format(cfg.CONF.adapter.nailgun_host, + cfg.CONF.adapter.nailgun_port, cluster_url) response = REQ_SES.get(request_url).json() release_id = response.get('release_id', 'failed to get id') release_url = URL.format( - conf.nailgun.host, conf.nailgun.port, + cfg.CONF.adapter.nailgun_host, cfg.CONF.adapter.nailgun_port, 'api/releases/{0}'.format(release_id)) deployment_tags = set() diff --git a/fuel_plugin/ostf_adapter/nose_plugin/nose_adapter.py b/fuel_plugin/ostf_adapter/nose_plugin/nose_adapter.py index 8e165dd3..6c95f6ec 100644 --- a/fuel_plugin/ostf_adapter/nose_plugin/nose_adapter.py +++ b/fuel_plugin/ostf_adapter/nose_plugin/nose_adapter.py @@ -17,7 +17,7 @@ import os import logging import signal -from pecan import conf +from oslo.config import cfg from fuel_plugin.ostf_adapter.nose_plugin import nose_test_runner from fuel_plugin.ostf_adapter.nose_plugin import nose_utils @@ -48,7 +48,7 @@ class NoseDriver(object): else: argv_add = [test_set.test_path] + test_set.additional_arguments - lock_path = conf.lock_dir + lock_path = cfg.CONF.adapter.lock_dir test_run.pid = nose_utils.run_proc(self._run_tests, lock_path, dbpath, @@ -132,8 +132,8 @@ class NoseDriver(object): try: module_obj = __import__(cleanup, -1) - os.environ['NAILGUN_HOST'] = str(conf.nailgun.host) - os.environ['NAILGUN_PORT'] = str(conf.nailgun.port) + os.environ['NAILGUN_HOST'] = str(cfg.CONF.adapter.nailgun_host) + os.environ['NAILGUN_PORT'] = str(cfg.CONF.adapter.nailgun_port) os.environ['CLUSTER_ID'] = str(cluster_id) module_obj.cleanup.cleanup(cluster_deployment_info) diff --git a/fuel_plugin/ostf_adapter/nose_plugin/nose_storage_plugin.py b/fuel_plugin/ostf_adapter/nose_plugin/nose_storage_plugin.py index 793723ad..6449528d 100644 --- a/fuel_plugin/ostf_adapter/nose_plugin/nose_storage_plugin.py +++ b/fuel_plugin/ostf_adapter/nose_plugin/nose_storage_plugin.py @@ -16,11 +16,14 @@ from time import time import logging import os from nose import plugins -from pecan import conf + +from oslo.config import cfg from fuel_plugin.ostf_adapter.nose_plugin import nose_utils from fuel_plugin.ostf_adapter.storage import models +CONF = cfg.CONF + LOG = logging.getLogger(__name__) @@ -38,8 +41,8 @@ class StoragePlugin(plugins.Plugin): self._start_time = None def options(self, parser, env=os.environ): - env['NAILGUN_HOST'] = str(conf.nailgun.host) - env['NAILGUN_PORT'] = str(conf.nailgun.port) + env['NAILGUN_HOST'] = str(CONF.adapter.nailgun_host) + env['NAILGUN_PORT'] = str(CONF.adapter.nailgun_port) if self.cluster_id: env['CLUSTER_ID'] = str(self.cluster_id) diff --git a/fuel_plugin/ostf_adapter/server.py b/fuel_plugin/ostf_adapter/server.py new file mode 100644 index 00000000..1e0614b9 --- /dev/null +++ b/fuel_plugin/ostf_adapter/server.py @@ -0,0 +1,75 @@ +# Copyright 2014 Mirantis, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import os +import sys +import logging +import signal + +from oslo.config import cfg +from gevent import pywsgi + +from fuel_plugin.ostf_adapter import config as ostf_config +from fuel_plugin.ostf_adapter import nailgun_hooks +from fuel_plugin.ostf_adapter import logger +from fuel_plugin.ostf_adapter.wsgi import app +from fuel_plugin.ostf_adapter.nose_plugin import nose_discovery +from fuel_plugin.ostf_adapter.storage import engine +from fuel_plugin.ostf_adapter import mixins + + +CONF = cfg.CONF + + +def main(): + + ostf_config.init_config(sys.argv[1:]) + + logger.setup(log_file=CONF.adapter.log_file) + + log = logging.getLogger(__name__) + log.info('Start app configuration') + + root = app.setup_app({}) + + if CONF.after_initialization_environment_hook: + return nailgun_hooks.after_initialization_environment_hook() + + with engine.contexted_session(CONF.adapter.dbpath) as session: + # performing cleaning of expired data (if any) in db + mixins.clean_db(session) + log.info('Cleaned up database.') + # discover testsets and their tests + CORE_PATH = CONF.debug_tests or 'fuel_health' + + log.info('Performing nose discovery with {0}.'.format(CORE_PATH)) + + nose_discovery.discovery(path=CORE_PATH, session=session) + + # cache needed data from test repository + mixins.cache_test_repository(session) + + log.info('Discovery is completed') + host, port = CONF.adapter.server_host, CONF.adapter.server_port + srv = pywsgi.WSGIServer((host, port), root) + + log.info('Starting server in PID %s', os.getpid()) + log.info("serving on http://%s:%s", host, port) + + try: + signal.signal(signal.SIGCHLD, signal.SIG_IGN) + srv.serve_forever() + except KeyboardInterrupt: + pass diff --git a/fuel_plugin/ostf_adapter/storage/alembic_cli.py b/fuel_plugin/ostf_adapter/storage/alembic_cli.py index 2d4e52c7..6f15b7d5 100644 --- a/fuel_plugin/ostf_adapter/storage/alembic_cli.py +++ b/fuel_plugin/ostf_adapter/storage/alembic_cli.py @@ -15,8 +15,10 @@ import os import logging -from alembic import command, config -from pecan import conf +from oslo.config import cfg + +from alembic import command +from alembic import config log = logging.getLogger(__name__) @@ -28,7 +30,7 @@ def do_apply_migrations(): ) alembic_conf.set_main_option('script_location', 'fuel_plugin.ostf_adapter.storage:migrations') - alembic_conf.set_main_option('sqlalchemy.url', conf.dbpath) + alembic_conf.set_main_option('sqlalchemy.url', cfg.CONF.adapter.dbpath) # apply initial migration command.upgrade(alembic_conf, 'head') diff --git a/fuel_plugin/ostf_adapter/storage/engine.py b/fuel_plugin/ostf_adapter/storage/engine.py index 80cd9cc0..92f10d26 100644 --- a/fuel_plugin/ostf_adapter/storage/engine.py +++ b/fuel_plugin/ostf_adapter/storage/engine.py @@ -12,21 +12,28 @@ # License for the specific language governing permissions and limitations # under the License. +import logging + from contextlib import contextmanager from sqlalchemy import create_engine, orm +LOG = logging.getLogger(__name__) + + @contextmanager def contexted_session(dbpath): '''Allows to handle session via context manager ''' + LOG.debug('Starting session with dbpath={0}'.format(dbpath)) engine = create_engine(dbpath) session = orm.Session(bind=engine) - try: + LOG.debug('Before yielding session.') yield session session.commit() except Exception: + LOG.exception('Raised error in contexted session.') session.rollback() raise finally: diff --git a/fuel_plugin/ostf_adapter/wsgi/app.py b/fuel_plugin/ostf_adapter/wsgi/app.py index 791fd102..24365613 100644 --- a/fuel_plugin/ostf_adapter/wsgi/app.py +++ b/fuel_plugin/ostf_adapter/wsgi/app.py @@ -12,27 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg import pecan + from fuel_plugin.ostf_adapter.wsgi import hooks - -PECAN_DEFAULT = { - 'server': { - 'host': '0.0.0.0', - 'port': 8989 - }, - 'app': { - 'root': 'fuel_plugin.ostf_adapter.wsgi.root.RootController', - 'modules': ['fuel_plugin.ostf_adapter.wsgi'] - }, - 'nailgun': { - 'host': '127.0.0.1', - 'port': 8000 - }, - 'dbpath': 'postgresql+psycopg2://ostf:ostf@localhost/ostf', - 'debug': False, - 'debug_tests': 'fuel_plugin/tests/functional/dummy_tests' -} +CONF = cfg.CONF def setup_config(custom_pecan_config): @@ -41,7 +26,24 @@ def setup_config(custom_pecan_config): by those supplied via command line arguments when ostf-server is started ''' - config_to_use = PECAN_DEFAULT + config_to_use = { + 'server': { + 'host': CONF.adapter.server_host, + 'port': CONF.adapter.server_port + }, + 'dbpath': CONF.adapter.dbpath, + 'debug': CONF.debug, + 'debug_tests': CONF.debug_tests, + 'lock_dir': CONF.adapter.lock_dir, + 'nailgun': { + 'host': CONF.adapter.nailgun_host, + 'port': CONF.adapter.nailgun_port + }, + 'app': { + 'root': 'fuel_plugin.ostf_adapter.wsgi.root.RootController', + 'modules': ['fuel_plugin.ostf_adapter.wsgi'] + }, + } config_to_use.update(custom_pecan_config) pecan.conf.update(config_to_use) diff --git a/fuel_plugin/ostf_adapter/wsgi/controllers.py b/fuel_plugin/ostf_adapter/wsgi/controllers.py index 9dbe51c8..44d6e960 100644 --- a/fuel_plugin/ostf_adapter/wsgi/controllers.py +++ b/fuel_plugin/ostf_adapter/wsgi/controllers.py @@ -17,7 +17,9 @@ import logging from sqlalchemy import func from sqlalchemy.orm import joinedload -from pecan import conf, rest, expose, request +from pecan import rest, expose, request + +from oslo.config import cfg from fuel_plugin.ostf_adapter import mixins from fuel_plugin.ostf_adapter.storage import models @@ -140,7 +142,7 @@ class TestrunsController(BaseRestController): test_set, metadata, tests, - conf.dbpath + cfg.CONF.adapter.dbpath ) res.append(test_run) @@ -164,6 +166,6 @@ class TestrunsController(BaseRestController): data.append(test_run.stop(request.session)) elif status == 'restarted': data.append(test_run.restart(request.session, - conf.dbpath, + cfg.CONF.adapter.dbpath, tests=tests)) return data diff --git a/fuel_plugin/testing/tests/__init__.py b/fuel_plugin/testing/tests/__init__.py index 4dddf018..6520e426 100644 --- a/fuel_plugin/testing/tests/__init__.py +++ b/fuel_plugin/testing/tests/__init__.py @@ -37,7 +37,6 @@ def setup(): [ 'ostf-server', '--debug', - '--nailgun-port=8888', ('--debug_tests=fuel_plugin/testing/' 'fixture/dummy_tests') ], diff --git a/fuel_plugin/testing/tests/etc/.gitignore b/fuel_plugin/testing/tests/etc/.gitignore deleted file mode 100644 index 51f05cf0..00000000 --- a/fuel_plugin/testing/tests/etc/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Do not ignore .gitignore itself -!.gitignore diff --git a/fuel_plugin/testing/tests/unit/base.py b/fuel_plugin/testing/tests/unit/base.py index cd25c3f1..4eae2e74 100644 --- a/fuel_plugin/testing/tests/unit/base.py +++ b/fuel_plugin/testing/tests/unit/base.py @@ -18,6 +18,7 @@ from mock import patch, MagicMock from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker +from fuel_plugin.ostf_adapter import config from fuel_plugin.ostf_adapter.nose_plugin.nose_discovery import discovery from fuel_plugin.ostf_adapter.storage import models from fuel_plugin.ostf_adapter import mixins @@ -61,6 +62,7 @@ class BaseWSGITest(unittest2.TestCase): def setUp(self): # orm session wrapping + config.init_config([]) self.connection = self.engine.connect() self.trans = self.connection.begin() @@ -87,25 +89,6 @@ class BaseWSGITest(unittest2.TestCase): ) self.request_patcher.start() - # pecan conf mocking - self.pecan_conf_mock = MagicMock() - self.pecan_conf_mock.nailgun.host = '127.0.0.1' - self.pecan_conf_mock.nailgun.port = 8888 - - self.pecan_conf_patcher = patch( - 'fuel_plugin.ostf_adapter.mixins.conf', - self.pecan_conf_mock - ) - self.pecan_conf_patcher.start() - - # pecan conf mocking in wsgi.controllers - self.wsgi_controllers_pecan_conf_mock = MagicMock() - self.controllers_pecan_conf_patcher = patch( - 'fuel_plugin.ostf_adapter.wsgi.controllers.conf', - self.wsgi_controllers_pecan_conf_mock - ) - self.controllers_pecan_conf_patcher.start() - # engine.get_session mocking self.request_mock.session = self.session @@ -118,8 +101,6 @@ class BaseWSGITest(unittest2.TestCase): # end of test_case patching self.request_patcher.stop() - self.pecan_conf_patcher.stop() - self.controllers_pecan_conf_patcher.stop() mixins.TEST_REPOSITORY = [] diff --git a/fuel_plugin/testing/tests/unit/test_support_utilities.py b/fuel_plugin/testing/tests/unit/test_support_utilities.py index e0a9a626..8f94030b 100644 --- a/fuel_plugin/testing/tests/unit/test_support_utilities.py +++ b/fuel_plugin/testing/tests/unit/test_support_utilities.py @@ -13,7 +13,6 @@ # under the License. import unittest -import mock from fuel_plugin.ostf_adapter import mixins @@ -29,15 +28,6 @@ class TestDeplTagsGetter(unittest.TestCase): ) } - mocked_pecan_conf = mock.Mock() - mocked_pecan_conf.nailgun.host = '127.0.0.1' - mocked_pecan_conf.nailgun.port = 8888 - - with mock.patch( - 'fuel_plugin.ostf_adapter.mixins.conf', - mocked_pecan_conf - ): - res = mixins._get_cluster_depl_tags(expected['cluster_id']) - print res + res = mixins._get_cluster_depl_tags(expected['cluster_id']) self.assertEqual(res, expected['depl_tags']) diff --git a/fuel_plugin/testing/tests/unit/tests_wsgi_interface.py b/fuel_plugin/testing/tests/unit/tests_wsgi_interface.py index e9ace61d..a63d5e0f 100644 --- a/fuel_plugin/testing/tests/unit/tests_wsgi_interface.py +++ b/fuel_plugin/testing/tests/unit/tests_wsgi_interface.py @@ -17,7 +17,6 @@ from mock import patch, MagicMock from webtest import TestApp from fuel_plugin.ostf_adapter.wsgi import app -from fuel_plugin.ostf_adapter.wsgi.app import PECAN_DEFAULT from fuel_plugin.testing.tests.unit import base @@ -30,14 +29,7 @@ class WsgiInterfaceTests(base.BaseWSGITest): def setUp(self): super(WsgiInterfaceTests, self).setUp() - test_custom_config = PECAN_DEFAULT - test_custom_config['nailgun']['port'] = 8888 - - with patch( - 'fuel_plugin.ostf_adapter.wsgi.app.PECAN_DEFAULT', - test_custom_config - ): - self.app = TestApp(app.setup_app()) + self.app = TestApp(app.setup_app()) self.fixture = { 'cluster_id': 1 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..82e75505 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,19 @@ +oslo.config>=1.1.1 +python-cinderclient>=1.0.7 +python-ceilometerclient>=1.0.9 +python-keystoneclient>=0.4.2 +python-novaclient>=2.17.0 +python-heatclient>=0.2.9 +python-saharaclient>=0.6.0 +paramiko>=1.10.1,<1.13 +requests>=1.2.3 +unittest2>=0.5.1 +pyyaml>=3.10 +testresources>=0.2.7 +nose>=1.3.0 +SQLAlchemy>=0.7.8,<=0.9.99 +alembic>=0.5.0 +gevent==0.13.8 +pecan>=0.3.0 +psycopg2>=2.5.1 +stevedore>=0.10 \ No newline at end of file diff --git a/setup.py b/setup.py index f255e5f6..6f1fb0e6 100644 --- a/setup.py +++ b/setup.py @@ -12,45 +12,16 @@ # License for the specific language governing permissions and limitations # under the License. +import os import setuptools -fuel_health_reqs = [ - 'oslo.config>=1.1.1', - 'python-cinderclient>=1.0.7', - 'python-ceilometerclient>=1.0.9', - 'python-keystoneclient>=0.4.2', - 'python-novaclient>=2.17.0', - 'python-heatclient>=0.2.9', - 'python-muranoclient>=0.4.1', - 'python-saharaclient>=0.6.0', - 'paramiko>=1.10.1', - 'requests>=1.2.3', - 'unittest2>=0.5.1', - 'pyyaml>=3.10', - 'testresources>=0.2.7' -] - -fuel_ostf_reqs = [ - 'nose>=1.3.0', - 'SQLAlchemy>=0.7.8,<=0.9.99', - 'alembic>=0.5.0', - 'gevent==0.13.8', - 'pecan>=0.3.0', - 'psycopg2>=2.5.1', - 'stevedore>=0.10' -] - -test_requires = [ - 'mock>=1.0.1', - 'pep8>=1.4.6', - 'py>=1.4.15', - 'six>=1.5.2', - 'tox>=1.5.0', - 'unittest2', - 'nose', - 'requests' -] +def requirements(): + dir_path = os.path.dirname(os.path.realpath(__file__)) + requirements = [] + with open('{0}/requirements.txt'.format(dir_path), 'r') as reqs: + requirements = reqs.readlines() + return requirements setuptools.setup( @@ -80,7 +51,7 @@ setuptools.setup( packages=setuptools.find_packages(), - install_requires=fuel_health_reqs+fuel_ostf_reqs, + install_requires=requirements(), entry_points={ 'plugins': [ @@ -88,7 +59,7 @@ setuptools.setup( 'nose_plugin.nose_adapter:NoseDriver') ], 'console_scripts': [ - 'ostf-server = fuel_plugin.bin.adapter_api:main', + 'ostf-server = fuel_plugin.ostf_adapter.server:main', ('update-commands = fuel_plugin.tests.' 'test_utils.update_commands:main'), 'ostfctl = adapter_utils.bin.ostf_utils:main' diff --git a/test-requires b/test-requirements.txt similarity index 59% rename from test-requires rename to test-requirements.txt index 8c95211b..80186f95 100644 --- a/test-requires +++ b/test-requirements.txt @@ -1,6 +1,7 @@ +-r requirements.txt mock==1.0.1 pep8==1.4.6 -py==1.4.15 -six<=1.3.0 tox==1.5.0 coverage==3.6 +fabric +bottle \ No newline at end of file diff --git a/tox.ini b/tox.ini index cd11c537..b70d8334 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,10 @@ skipsdist = True show-source = True exclude = .tox +[testenv] +commands = nosetests fuel_plugin/testing/tests/unit fuel_plugin/testing/tests/functional/tests.py:AdapterTests +deps = -r{toxinidir}/test-requirements.txt + [testenv:flake8] deps = flake8 commands = flake8