data sources functional tests
Change-Id: Ifac5083436d1ad16af3871bfb974a0fd715e0259
This commit is contained in:
parent
83a5163e6e
commit
efbc219297
27
etc/vitrage/states_plugins/vitrage.yaml
Normal file
27
etc/vitrage/states_plugins/vitrage.yaml
Normal file
@ -0,0 +1,27 @@
|
||||
category: ALARM
|
||||
states:
|
||||
- normalized state:
|
||||
name: CRITICAL
|
||||
priority: 50
|
||||
original states:
|
||||
- name: CRITICAL
|
||||
- normalized state:
|
||||
name: SEVERE
|
||||
priority: 40
|
||||
original states:
|
||||
- name: SEVERE
|
||||
- normalized state:
|
||||
name: WARNING
|
||||
priority: 30
|
||||
original states:
|
||||
- name: WARNING
|
||||
- normalized state:
|
||||
name: UNKNOWN
|
||||
priority: 20
|
||||
original states:
|
||||
- name: UNKNOWN
|
||||
- normalized state:
|
||||
name: DISABLED
|
||||
priority: 10
|
||||
original states:
|
||||
- name: OK
|
@ -22,6 +22,7 @@ from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
|
||||
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN
|
||||
from vitrage.synchronizer.plugins.nova.zone import NOVA_ZONE_PLUGIN
|
||||
from vitrage.synchronizer.plugins.static_physical import STATIC_PHYSICAL_PLUGIN
|
||||
|
||||
OPENSTACK_NODE = 'openstack.node'
|
||||
|
||||
# Register options for the service
|
||||
|
@ -20,7 +20,7 @@ from vitrage.tests.mocks import mock_syncronizer as mock_sync
|
||||
from vitrage.tests.unit.entity_graph.base import TestEntityGraphUnitBase
|
||||
|
||||
|
||||
class TestEntityGraphFunctionalBase(TestEntityGraphUnitBase):
|
||||
class TestFunctionalBase(TestEntityGraphUnitBase):
|
||||
|
||||
def _create_processor_with_graph(self, conf, processor=None):
|
||||
events = self._create_mock_events()
|
15
vitrage/tests/functional/data_sources/__init__.py
Normal file
15
vitrage/tests/functional/data_sources/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
15
vitrage/tests/functional/data_sources/aodh/__init__.py
Normal file
15
vitrage/tests/functional/data_sources/aodh/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
15
vitrage/tests/functional/data_sources/aodh/test_aodh.py
Normal file
15
vitrage/tests/functional/data_sources/aodh/test_aodh.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
29
vitrage/tests/functional/data_sources/base.py
Normal file
29
vitrage/tests/functional/data_sources/base.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.tests.functional.base import TestFunctionalBase
|
||||
|
||||
|
||||
class TestDataSourcesBase(TestFunctionalBase):
|
||||
|
||||
def _find_entity_id_by_type(self, graph, type):
|
||||
entity_vertices = graph.get_vertices(vertex_attr_filter={
|
||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
||||
VProps.TYPE: type
|
||||
})
|
||||
self.assertTrue(len(entity_vertices) > 0)
|
||||
|
||||
return entity_vertices[0][VProps.ID]
|
15
vitrage/tests/functional/data_sources/cinder/__init__.py
Normal file
15
vitrage/tests/functional/data_sources/cinder/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
@ -0,0 +1,88 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.synchronizer.plugins import CINDER_VOLUME_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NAGIOS_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NOVA_HOST_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NOVA_INSTANCE_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NOVA_ZONE_PLUGIN
|
||||
from vitrage.tests.functional.data_sources.base import \
|
||||
TestDataSourcesBase
|
||||
from vitrage.tests.mocks import mock_syncronizer as mock_sync
|
||||
|
||||
|
||||
class TestCinderVolume(TestDataSourcesBase):
|
||||
|
||||
PLUGINS_OPTS = [
|
||||
cfg.ListOpt('plugin_type',
|
||||
default=[NAGIOS_PLUGIN,
|
||||
NOVA_HOST_PLUGIN,
|
||||
NOVA_INSTANCE_PLUGIN,
|
||||
NOVA_ZONE_PLUGIN,
|
||||
CINDER_VOLUME_PLUGIN],
|
||||
help='Names of supported driver data sources'),
|
||||
|
||||
cfg.ListOpt('plugin_path',
|
||||
default=['vitrage.synchronizer.plugins'],
|
||||
help='base path for data sources')
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestCinderVolume, cls).setUpClass()
|
||||
cls.conf = cfg.ConfigOpts()
|
||||
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
|
||||
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins')
|
||||
cls.load_plugins(cls.conf)
|
||||
|
||||
def test_cinder_volume_validity(self):
|
||||
# Setup
|
||||
processor = self._create_processor_with_graph(self.conf)
|
||||
self.assertEqual(self._num_total_expected_vertices(),
|
||||
len(processor.entity_graph))
|
||||
|
||||
spec_list = mock_sync.simple_volume_generators(
|
||||
volume_num=1,
|
||||
instance_num=1,
|
||||
snapshot_events=1)
|
||||
static_events = mock_sync.generate_random_events_list(spec_list)
|
||||
cinder_volume_event = static_events[0]
|
||||
cinder_volume_event['attachments'][0]['server_id'] = \
|
||||
self._find_entity_id_by_type(processor.entity_graph,
|
||||
NOVA_INSTANCE_PLUGIN)
|
||||
|
||||
# Action
|
||||
processor.process_event(cinder_volume_event)
|
||||
|
||||
# Test assertions
|
||||
self.assertEqual(self._num_total_expected_vertices() + 1,
|
||||
len(processor.entity_graph))
|
||||
|
||||
cinder_vertices = processor.entity_graph.get_vertices(
|
||||
vertex_attr_filter={
|
||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
||||
VProps.TYPE: CINDER_VOLUME_PLUGIN
|
||||
})
|
||||
self.assertEqual(1, len(cinder_vertices))
|
||||
|
||||
cinder_neighbors = processor.entity_graph.neighbors(
|
||||
cinder_vertices[0].vertex_id)
|
||||
self.assertEqual(1, len(cinder_neighbors))
|
||||
|
||||
self.assertEqual(NOVA_INSTANCE_PLUGIN,
|
||||
cinder_neighbors[0][VProps.TYPE])
|
15
vitrage/tests/functional/data_sources/nagios/__init__.py
Normal file
15
vitrage/tests/functional/data_sources/nagios/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
87
vitrage/tests/functional/data_sources/nagios/test_nagios.py
Normal file
87
vitrage/tests/functional/data_sources/nagios/test_nagios.py
Normal file
@ -0,0 +1,87 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.synchronizer.plugins import NAGIOS_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NOVA_HOST_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NOVA_INSTANCE_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NOVA_ZONE_PLUGIN
|
||||
from vitrage.tests.functional.data_sources.base import \
|
||||
TestDataSourcesBase
|
||||
from vitrage.tests.mocks import mock_syncronizer as mock_sync
|
||||
|
||||
|
||||
class TestNagios(TestDataSourcesBase):
|
||||
|
||||
PLUGINS_OPTS = [
|
||||
cfg.ListOpt('plugin_type',
|
||||
default=[NAGIOS_PLUGIN,
|
||||
NOVA_HOST_PLUGIN,
|
||||
NOVA_INSTANCE_PLUGIN,
|
||||
NOVA_ZONE_PLUGIN,
|
||||
NAGIOS_PLUGIN],
|
||||
help='Names of supported driver data sources'),
|
||||
|
||||
cfg.ListOpt('plugin_path',
|
||||
default=['vitrage.synchronizer.plugins'],
|
||||
help='base path for data sources')
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestNagios, cls).setUpClass()
|
||||
cls.conf = cfg.ConfigOpts()
|
||||
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
|
||||
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins')
|
||||
cls.load_plugins(cls.conf)
|
||||
|
||||
def test_nagios_validity(self):
|
||||
# Setup
|
||||
processor = self._create_processor_with_graph(self.conf)
|
||||
self.assertEqual(self._num_total_expected_vertices(),
|
||||
len(processor.entity_graph))
|
||||
|
||||
spec_list = mock_sync.simple_nagios_alarm_generators(
|
||||
host_num=1,
|
||||
events_num=1)
|
||||
static_events = mock_sync.generate_random_events_list(spec_list)
|
||||
nagios_event = static_events[0]
|
||||
nagios_event['resource_name'] = \
|
||||
self._find_entity_id_by_type(processor.entity_graph,
|
||||
NOVA_HOST_PLUGIN)
|
||||
nagios_event['status'] = 'critical'
|
||||
|
||||
# Action
|
||||
processor.process_event(nagios_event)
|
||||
|
||||
# Test assertions
|
||||
self.assertEqual(self._num_total_expected_vertices() + 1,
|
||||
len(processor.entity_graph))
|
||||
|
||||
nagios_vertices = processor.entity_graph.get_vertices(
|
||||
vertex_attr_filter={
|
||||
VProps.CATEGORY: EntityCategory.ALARM,
|
||||
VProps.TYPE: NAGIOS_PLUGIN
|
||||
})
|
||||
self.assertEqual(1, len(nagios_vertices))
|
||||
|
||||
nagios_neighbors = processor.entity_graph.neighbors(
|
||||
nagios_vertices[0].vertex_id)
|
||||
self.assertEqual(1, len(nagios_neighbors))
|
||||
|
||||
self.assertEqual(NOVA_HOST_PLUGIN,
|
||||
nagios_neighbors[0][VProps.TYPE])
|
15
vitrage/tests/functional/data_sources/neutron/__init__.py
Normal file
15
vitrage/tests/functional/data_sources/neutron/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
15
vitrage/tests/functional/data_sources/nova/__init__.py
Normal file
15
vitrage/tests/functional/data_sources/nova/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
@ -0,0 +1,45 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from vitrage.tests.functional.data_sources.base import \
|
||||
TestDataSourcesBase
|
||||
|
||||
|
||||
class TestNovaPlugins(TestDataSourcesBase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestNovaPlugins, cls).setUpClass()
|
||||
cls.conf = cfg.ConfigOpts()
|
||||
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
|
||||
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins')
|
||||
cls.load_plugins(cls.conf)
|
||||
|
||||
def test_nova_plugins(self):
|
||||
processor = self._create_processor_with_graph(self.conf)
|
||||
|
||||
self.assertEqual(self._num_total_expected_vertices(),
|
||||
processor.entity_graph.num_vertices())
|
||||
|
||||
self.assertEqual(self._num_total_expected_edges(),
|
||||
processor.entity_graph.num_edges())
|
||||
|
||||
# TODO(Alexey): add this check and to check also the number of edges
|
||||
# check all entities create a tree and no free floating vertices exists
|
||||
# it will be done only after we will have zone data source
|
||||
# vertex = graph.find_vertex_in_graph()
|
||||
# bfs_list = graph.algo.bfs(graph)
|
||||
# self.assertEqual(num_vertices, len(bfs_list))
|
@ -0,0 +1,15 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'stack'
|
@ -0,0 +1,93 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import SynchronizerProperties as SyncProps
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.synchronizer.plugins import NAGIOS_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NOVA_HOST_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NOVA_INSTANCE_PLUGIN
|
||||
from vitrage.synchronizer.plugins import NOVA_ZONE_PLUGIN
|
||||
from vitrage.synchronizer.plugins.static_physical import STATIC_PHYSICAL_PLUGIN
|
||||
from vitrage.synchronizer.plugins.static_physical import SWITCH
|
||||
from vitrage.tests.functional.data_sources.base import \
|
||||
TestDataSourcesBase
|
||||
from vitrage.tests.mocks import mock_syncronizer as mock_sync
|
||||
|
||||
|
||||
class TestStaticPhysical(TestDataSourcesBase):
|
||||
|
||||
PLUGINS_OPTS = [
|
||||
cfg.ListOpt('plugin_type',
|
||||
default=[NAGIOS_PLUGIN,
|
||||
NOVA_HOST_PLUGIN,
|
||||
NOVA_INSTANCE_PLUGIN,
|
||||
NOVA_ZONE_PLUGIN,
|
||||
STATIC_PHYSICAL_PLUGIN],
|
||||
help='Names of supported driver data sources'),
|
||||
|
||||
cfg.ListOpt('plugin_path',
|
||||
default=['vitrage.synchronizer.plugins'],
|
||||
help='base path for data sources')
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestStaticPhysical, cls).setUpClass()
|
||||
cls.conf = cfg.ConfigOpts()
|
||||
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
|
||||
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins')
|
||||
cls.load_plugins(cls.conf)
|
||||
|
||||
def test_static_physical_validity(self):
|
||||
# Setup
|
||||
processor = self._create_processor_with_graph(self.conf)
|
||||
processor.transformer_manager.transformers[SWITCH] = \
|
||||
processor.transformer_manager.transformers[STATIC_PHYSICAL_PLUGIN]
|
||||
self.assertEqual(self._num_total_expected_vertices(),
|
||||
len(processor.entity_graph))
|
||||
|
||||
spec_list = mock_sync.simple_switch_generators(
|
||||
switch_num=1,
|
||||
host_num=1,
|
||||
snapshot_events=1)
|
||||
static_events = mock_sync.generate_random_events_list(spec_list)
|
||||
static_physical_event = static_events[0]
|
||||
static_physical_event[SyncProps.SYNC_TYPE] = SWITCH
|
||||
static_physical_event['relationships'][0]['name'] = \
|
||||
self._find_entity_id_by_type(processor.entity_graph,
|
||||
NOVA_HOST_PLUGIN)
|
||||
|
||||
# Action
|
||||
processor.process_event(static_physical_event)
|
||||
|
||||
# Test assertions
|
||||
self.assertEqual(self._num_total_expected_vertices() + 1,
|
||||
len(processor.entity_graph))
|
||||
|
||||
static_physical_vertices = processor.entity_graph.get_vertices(
|
||||
vertex_attr_filter={
|
||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
||||
VProps.TYPE: SWITCH
|
||||
})
|
||||
self.assertEqual(1, len(static_physical_vertices))
|
||||
|
||||
static_physical_neighbors = processor.entity_graph.neighbors(
|
||||
static_physical_vertices[0].vertex_id)
|
||||
self.assertEqual(1, len(static_physical_neighbors))
|
||||
|
||||
self.assertEqual(NOVA_HOST_PLUGIN,
|
||||
static_physical_neighbors[0][VProps.TYPE])
|
@ -12,14 +12,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from datetime import timedelta
|
||||
import threading
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from datetime import timedelta
|
||||
from oslo_config import cfg
|
||||
from six.moves import queue
|
||||
|
||||
from six.moves import queue
|
||||
from vitrage.common.constants import EdgeLabels
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
@ -36,12 +36,12 @@ from vitrage.synchronizer.plugins.nagios import NAGIOS_PLUGIN
|
||||
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
|
||||
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN
|
||||
from vitrage.synchronizer.plugins.nova.zone import NOVA_ZONE_PLUGIN
|
||||
from vitrage.tests.functional.entity_graph.base import \
|
||||
TestEntityGraphFunctionalBase
|
||||
from vitrage.tests.functional.base import \
|
||||
TestFunctionalBase
|
||||
from vitrage.tests.mocks import utils
|
||||
|
||||
|
||||
class TestConsistencyFunctional(TestEntityGraphFunctionalBase):
|
||||
class TestConsistencyFunctional(TestFunctionalBase):
|
||||
|
||||
CONSISTENCY_OPTS = [
|
||||
cfg.IntOpt('min_time_to_delete',
|
||||
|
@ -14,19 +14,15 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from vitrage.tests.functional.entity_graph.base import \
|
||||
TestEntityGraphFunctionalBase
|
||||
from vitrage.tests.functional.base import \
|
||||
TestFunctionalBase
|
||||
|
||||
|
||||
class TestProcessorFunctional(TestEntityGraphFunctionalBase):
|
||||
class TestProcessorFunctional(TestFunctionalBase):
|
||||
|
||||
ZONE_SPEC = 'ZONE_SPEC'
|
||||
HOST_SPEC = 'HOST_SPEC'
|
||||
INSTANCE_SPEC = 'INSTANCE_SPEC'
|
||||
NUM_VERTICES_AFTER_CREATION = 2
|
||||
NUM_EDGES_AFTER_CREATION = 1
|
||||
NUM_VERTICES_AFTER_DELETION = 1
|
||||
NUM_EDGES_AFTER_DELETION = 0
|
||||
|
||||
# noinspection PyAttributeOutsideInit,PyPep8Naming
|
||||
@classmethod
|
||||
@ -40,9 +36,12 @@ class TestProcessorFunctional(TestEntityGraphFunctionalBase):
|
||||
def test_create_entity_graph(self):
|
||||
processor = self._create_processor_with_graph(self.conf)
|
||||
|
||||
# check number of entities
|
||||
num_vertices = len(processor.entity_graph)
|
||||
self.assertEqual(self._num_total_expected_vertices(), num_vertices)
|
||||
self.assertEqual(self._num_total_expected_vertices(),
|
||||
processor.entity_graph.num_vertices())
|
||||
|
||||
self.assertEqual(self._num_total_expected_edges(),
|
||||
processor.entity_graph.num_edges())
|
||||
|
||||
# TODO(Alexey): add this check and to check also the number of edges
|
||||
# check all entities create a tree and no free floating vertices exists
|
||||
# it will be done only after we will have zone plugin
|
||||
|
@ -23,11 +23,11 @@ from vitrage.entity_graph.states.normalized_resource_state import \
|
||||
NormalizedResourceState
|
||||
from vitrage.synchronizer.plugins.nova.instance.transformer import \
|
||||
InstanceTransformer
|
||||
from vitrage.tests.functional.entity_graph.base import \
|
||||
TestEntityGraphFunctionalBase
|
||||
from vitrage.tests.functional.base import \
|
||||
TestFunctionalBase
|
||||
|
||||
|
||||
class TestStateManagerFunctional(TestEntityGraphFunctionalBase):
|
||||
class TestStateManagerFunctional(TestFunctionalBase):
|
||||
|
||||
# noinspection PyAttributeOutsideInit,PyPep8Naming
|
||||
@classmethod
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from six.moves import queue
|
||||
|
||||
from six.moves import queue
|
||||
from vitrage.common.constants import EdgeLabels
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
@ -33,13 +33,13 @@ from vitrage.synchronizer.plugins.base.alarm.properties \
|
||||
import AlarmProperties as AlarmProps
|
||||
from vitrage.synchronizer.plugins.nagios import NAGIOS_PLUGIN
|
||||
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
|
||||
from vitrage.tests.functional.entity_graph.base import \
|
||||
TestEntityGraphFunctionalBase
|
||||
from vitrage.tests.functional.base import \
|
||||
TestFunctionalBase
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestActionExecutor(TestEntityGraphFunctionalBase):
|
||||
class TestActionExecutor(TestFunctionalBase):
|
||||
|
||||
# noinspection PyPep8Naming
|
||||
@classmethod
|
||||
|
@ -14,21 +14,20 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from six.moves import queue
|
||||
|
||||
from six.moves import queue
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
|
||||
from vitrage.evaluator.scenario_repository import ScenarioRepository
|
||||
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
|
||||
from vitrage.tests.functional.entity_graph.base import \
|
||||
TestEntityGraphFunctionalBase
|
||||
from vitrage.tests.functional.base import \
|
||||
TestFunctionalBase
|
||||
from vitrage.tests.mocks import utils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestScenarioEvaluator(TestEntityGraphFunctionalBase):
|
||||
class TestScenarioEvaluator(TestFunctionalBase):
|
||||
|
||||
EVALUATOR_OPTS = [
|
||||
cfg.StrOpt('templates_dir',
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"relationships": [
|
||||
{"type": "nova\\.host",
|
||||
"name": "host-[1-9]|switch-[1-9]",
|
||||
"name": "host-[1-9]",
|
||||
"id": "[1-9]{5}",
|
||||
"relation_type": "contains"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"attachments": [{"server_id": "54321"}],
|
||||
"attachments": [{"server_id": "vm-1"}],
|
||||
"display_name": "volume-0",
|
||||
"created_at": "2015-12-01T12:46:41Z",
|
||||
"status": "In-use",
|
||||
|
@ -145,3 +145,7 @@ class TestEntityGraphUnitBase(base.BaseTest):
|
||||
def _num_total_expected_vertices(self):
|
||||
return self.NUM_NODES + self.NUM_ZONES + self.NUM_HOSTS + \
|
||||
self.NUM_INSTANCES
|
||||
|
||||
def _num_total_expected_edges(self):
|
||||
return self.NUM_NODES + self.NUM_ZONES + self.NUM_HOSTS + \
|
||||
self.NUM_INSTANCES - 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user