Fix tox and update hacking

Change-Id: I2b181ddaa31862b8850996489149b6c491d9443f
This commit is contained in:
Eyal 2020-01-02 15:39:27 +02:00
parent 19ebcd43f6
commit 6e59549eaf
13 changed files with 67 additions and 24 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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:

View File

@ -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'

View File

@ -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)

View File

@ -70,6 +70,7 @@ def run_migrations_online():
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:

View File

@ -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

View File

@ -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__)

View File

@ -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