diff --git a/test-requirements.txt b/test-requirements.txt index b39f3082e..62da7ffec 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.1.0,<1.2.0 # Apache-2.0 +hacking>=1.1.0 # Apache-2.0 coverage>=4.5.1 # Apache-2.0 python-subunit>=1.2.0 # Apache-2.0/BSD oslotest>=3.3.0 # Apache-2.0 diff --git a/tools/load_generator/load_generator.py b/tools/load_generator/load_generator.py index 8c8de6484..e22fcd4d4 100644 --- a/tools/load_generator/load_generator.py +++ b/tools/load_generator/load_generator.py @@ -21,7 +21,10 @@ from futurist import ThreadPoolExecutor from oslo_config import cfg from oslo_log import log import oslo_messaging -from tools.load_generator.notification_info import * # noqa +from tools.load_generator.notification_info import COMPUTE_INSTANCE_CREATE_END +from tools.load_generator.notification_info import PORT_CREATE_END +from tools.load_generator.notification_info import VOLUME_ATTACH_END +from tools.load_generator.notification_info import VOLUME_CREATE_END from vitrage.common import config from vitrage.messaging import get_transport diff --git a/tox.ini b/tox.ini index 5297a4092..bc6a20532 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ whitelist_externals = find setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt commands = stestr run --serial {posargs} stestr slowest @@ -20,10 +21,6 @@ commands = passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY [testenv:pep8] -deps = -r{toxinidir}/doc/requirements.txt - -c{toxinidir}/lower-constraints.txt - -r{toxinidir}/test-requirements.txt - -r{toxinidir}/requirements.txt commands = flake8 [testenv:genconfig] @@ -61,7 +58,7 @@ commands = oslo_debug_helper {posargs} # H203: Use assertIs(Not)None to check for None show-source = True -ignore = E123,E125 +ignore = E123,E125,E402,W503,W504,E731 enable-extensions=H104,H106,H203 builtins = _ filename = *.py,app.wsgi diff --git a/vitrage/datasources/alarm_transformer_base.py b/vitrage/datasources/alarm_transformer_base.py index fa55eae8b..3cbc8e622 100644 --- a/vitrage/datasources/alarm_transformer_base.py +++ b/vitrage/datasources/alarm_transformer_base.py @@ -35,10 +35,11 @@ class AlarmTransformerBase(tbase.TransformerBase): if datasource_action in \ (DatasourceAction.UPDATE, DatasourceAction.SNAPSHOT): - return GraphAction.DELETE_ENTITY if self._ok_status(entity_event) else \ + return GraphAction.DELETE_ENTITY \ + if self._ok_status(entity_event) else \ self.GRAPH_ACTION_MAPPING.get( - entity_event.get(DSProps.EVENT_TYPE, None), - GraphAction.UPDATE_ENTITY) + entity_event.get(DSProps.EVENT_TYPE, None), + GraphAction.UPDATE_ENTITY) if DatasourceAction.INIT_SNAPSHOT == datasource_action: return GraphAction.CREATE_ENTITY diff --git a/vitrage/datasources/heat/stack/driver.py b/vitrage/datasources/heat/stack/driver.py index e6f0585bf..f41eb2f28 100644 --- a/vitrage/datasources/heat/stack/driver.py +++ b/vitrage/datasources/heat/stack/driver.py @@ -114,7 +114,7 @@ class HeatStackDriver(DriverBase): return ['manager', '_info'] def _retrieve_stack_resources(self, stack, stack_id): - # guess 10 is enough + # guess 10 is enough resources = self.client.resources.list(stack_id, nested_depth=10) stack['resources'] = [resource.to_dict() for resource in resources if resource.to_dict()['resource_type'] in diff --git a/vitrage/datasources/kapacitor/auxiliary/kapacitor_vitrage.py b/vitrage/datasources/kapacitor/auxiliary/kapacitor_vitrage.py index 01000cb4e..8ab308d66 100644 --- a/vitrage/datasources/kapacitor/auxiliary/kapacitor_vitrage.py +++ b/vitrage/datasources/kapacitor/auxiliary/kapacitor_vitrage.py @@ -44,8 +44,8 @@ Alarm: LOG_FILE = '/var/log/kapacitor/kapacitor_vitrage.log' LOG_MAX_SIZE = 10000000 -LOG_FORMAT = '%(asctime)s.%(msecs).03d %(name)s[%(process)d] %(threadName)s %' \ - '(levelname)s - %(message)s' +LOG_FORMAT = '%(asctime)s.%(msecs).03d %(name)s[%(process)d] ' \ + '%(threadName)s %(levelname)s - %(message)s' LOG_DATE_FMT = '%Y.%m.%d %H:%M:%S' KAPACITOR_EVENT_TYPE = 'kapacitor.alarm' diff --git a/vitrage/datasources/kapacitor/config.py b/vitrage/datasources/kapacitor/config.py index c655e71ee..3ac63eb25 100644 --- a/vitrage/datasources/kapacitor/config.py +++ b/vitrage/datasources/kapacitor/config.py @@ -85,8 +85,8 @@ class KapacitorHostMapping(object): """ if kapacitor_host and self.kapacitor_host_regexp.match(kapacitor_host): - resource_name = \ - kapacitor_host if self.resource_name == self.KAPACITOR_HOST_NAME \ + resource_name = kapacitor_host\ + if self.resource_name == self.KAPACITOR_HOST_NAME \ else self.resource_name return self.resource_type, resource_name else: diff --git a/vitrage/datasources/zabbix/auxiliary/zabbix_vitrage.py b/vitrage/datasources/zabbix/auxiliary/zabbix_vitrage.py index 90b062dbf..00f193aee 100644 --- a/vitrage/datasources/zabbix/auxiliary/zabbix_vitrage.py +++ b/vitrage/datasources/zabbix/auxiliary/zabbix_vitrage.py @@ -48,8 +48,8 @@ Message: LOG_FILE = '/var/log/zabbix/zabbix_vitrage.log' LOG_MAX_SIZE = 10000000 -LOG_FORMAT = '%(asctime)s.%(msecs).03d %(name)s[%(process)d] %(threadName)s %' \ - '(levelname)s - %(message)s' +LOG_FORMAT = '%(asctime)s.%(msecs).03d %(name)s[%(process)d]' \ + ' %(threadName)s %(levelname)s - %(message)s' LOG_DATE_FMT = '%Y.%m.%d %H:%M:%S' ZABBIX_EVENT_TYPE = 'zabbix.alarm' diff --git a/vitrage/entity_graph/mappings/datasource_info_mapper.py b/vitrage/entity_graph/mappings/datasource_info_mapper.py index 2e8cb897f..df6b18c00 100644 --- a/vitrage/entity_graph/mappings/datasource_info_mapper.py +++ b/vitrage/entity_graph/mappings/datasource_info_mapper.py @@ -66,7 +66,7 @@ class DatasourceInfoMapper(object): vitrage_type not in CONF.datasources.types: value_properties = \ self.category_normalizer[vitrage_category].value_properties() - vitrage_operational_value, vitrage_aggregated_value, value_priority = \ + vitrage_oper_value, vitrage_aggregated_value, value_priority = \ self._find_operational_value_and_priority(new_vertex, graph_vertex, value_properties[0], @@ -80,14 +80,14 @@ class DatasourceInfoMapper(object): property_, vitrage_type) if t_value_priority > value_priority: - vitrage_operational_value = t_operational_value + vitrage_oper_value = t_operational_value vitrage_aggregated_value = t_aggregated_value value_priority = t_value_priority self.category_normalizer[vitrage_category].set_aggregated_value( new_vertex, vitrage_aggregated_value) self.category_normalizer[vitrage_category].set_operational_value( - new_vertex, vitrage_operational_value) + new_vertex, vitrage_oper_value) else: self.category_normalizer[vitrage_category].set_aggregated_value( new_vertex, self.UNDEFINED_DATASOURCE) diff --git a/vitrage/storage/sqlalchemy/migration/alembic_migrations/env.py b/vitrage/storage/sqlalchemy/migration/alembic_migrations/env.py index a419b886a..47e2aba00 100644 --- a/vitrage/storage/sqlalchemy/migration/alembic_migrations/env.py +++ b/vitrage/storage/sqlalchemy/migration/alembic_migrations/env.py @@ -70,6 +70,7 @@ def run_migrations_online(): with context.begin_transaction(): context.run_migrations() + if context.is_offline_mode(): run_migrations_offline() else: diff --git a/vitrage/tests/unit/evaluator/template_validation/content/v1/test_mark_down_validator.py b/vitrage/tests/unit/evaluator/template_validation/content/v1/test_mark_down_validator.py index d8bf30030..a05439063 100644 --- a/vitrage/tests/unit/evaluator/template_validation/content/v1/test_mark_down_validator.py +++ b/vitrage/tests/unit/evaluator/template_validation/content/v1/test_mark_down_validator.py @@ -14,8 +14,8 @@ from vitrage.evaluator.actions.base import ActionType from vitrage.evaluator.template_fields import TemplateFields -from vitrage.evaluator.template_validation.content.v1.mark_down_validator import \ - MarkDownValidator +from vitrage.evaluator.template_validation.content.v1.mark_down_validator \ + import MarkDownValidator from vitrage.tests.unit.evaluator.template_validation.content.base import \ ActionValidatorTest diff --git a/vitrage/tests/unit/graph/test_graph.py b/vitrage/tests/unit/graph/test_graph.py index 355f53405..11c61e403 100644 --- a/vitrage/tests/unit/graph/test_graph.py +++ b/vitrage/tests/unit/graph/test_graph.py @@ -18,14 +18,34 @@ test_vitrage graph Tests for `vitrage` graph driver """ + +from oslo_log import log as logging + from testtools import matchers from vitrage.common.constants import EdgeProperties as EProps +from vitrage.common.constants import EntityCategory +from vitrage.common.constants import VertexProperties as VProps +from vitrage.datasources import NOVA_HOST_DATASOURCE +from vitrage.datasources import NOVA_INSTANCE_DATASOURCE +from vitrage.datasources import OPENSTACK_CLUSTER from vitrage.graph import Direction from vitrage.graph.filter import check_filter from vitrage.graph import utils + +from vitrage.tests import base from vitrage.tests.base import IsEmpty -from vitrage.tests.unit.graph.base import * # noqa +from vitrage.tests.unit.graph.base import ALARM +from vitrage.tests.unit.graph.base import ALARM_ON_HOST +from vitrage.tests.unit.graph.base import ALARM_ON_VM +from vitrage.tests.unit.graph.base import e_node_to_host +from vitrage.tests.unit.graph.base import GraphTestBase +from vitrage.tests.unit.graph.base import NXGraph +from vitrage.tests.unit.graph.base import RESOURCE +from vitrage.tests.unit.graph.base import v_alarm +from vitrage.tests.unit.graph.base import v_host +from vitrage.tests.unit.graph.base import v_instance +from vitrage.tests.unit.graph.base import v_node LOG = logging.getLogger(__name__) diff --git a/vitrage/tests/unit/graph/test_graph_algo.py b/vitrage/tests/unit/graph/test_graph_algo.py index 59c0fc497..8c5b7e1a3 100644 --- a/vitrage/tests/unit/graph/test_graph_algo.py +++ b/vitrage/tests/unit/graph/test_graph_algo.py @@ -22,16 +22,37 @@ from testtools import matchers from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EdgeProperties as EProps +from vitrage.common.constants import EntityCategory +from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.heat.stack import HEAT_STACK_DATASOURCE from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE +from vitrage.datasources import NOVA_HOST_DATASOURCE +from vitrage.datasources import NOVA_INSTANCE_DATASOURCE +from vitrage.datasources import OPENSTACK_CLUSTER +from vitrage.datasources.transformer_base import CLUSTER_ID from vitrage.graph.algo_driver.algorithm import Mapping from vitrage.graph.algo_driver.sub_graph_matching import \ NEG_CONDITION from vitrage.graph.algo_driver.sub_graph_matching import subgraph_matching from vitrage.graph.driver.elements import Edge from vitrage.graph.driver.graph import Direction +from vitrage.graph.driver.networkx_graph import NXGraph +from vitrage.graph import utils as graph_utils from vitrage.tests.base import IsEmpty -from vitrage.tests.unit.graph.base import * # noqa +from vitrage.tests.unit.graph.base import ALARM +from vitrage.tests.unit.graph.base import ALARM_ON_HOST +from vitrage.tests.unit.graph.base import ALARM_ON_VM +from vitrage.tests.unit.graph.base import e_node_to_switch +from vitrage.tests.unit.graph.base import ELabel +from vitrage.tests.unit.graph.base import ENTITY_GRAPH_ALARMS_PER_HOST +from vitrage.tests.unit.graph.base import ENTITY_GRAPH_ALARMS_PER_VM +from vitrage.tests.unit.graph.base import ENTITY_GRAPH_HOSTS_PER_CLUSTER +from vitrage.tests.unit.graph.base import ENTITY_GRAPH_TESTS_PER_HOST +from vitrage.tests.unit.graph.base import ENTITY_GRAPH_VMS_PER_HOST +from vitrage.tests.unit.graph.base import GraphTestBase +from vitrage.tests.unit.graph.base import RESOURCE +from vitrage.tests.unit.graph.base import v_node +from vitrage.tests.unit.graph.base import v_switch ROOT_ID = EntityCategory.RESOURCE + ':' + OPENSTACK_CLUSTER + ':' + CLUSTER_ID