change hierarchy
Change-Id: Id6d675bbf19429cb67b8a11b7c7dc8ea3669ff38
This commit is contained in:
parent
3ee466c5d9
commit
2fc12864a4
@ -13,26 +13,24 @@
|
||||
# under the License.
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage_tempest_tests.tests.api.alarms.utils import AlarmsHelper
|
||||
from vitrage_tempest_tests.tests.api.base import BaseVitrageTest
|
||||
from vitrage_tempest_tests.tests.api.utils.alarms \
|
||||
import AlarmsHelper
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BaseAlarmsTest(BaseVitrageTest):
|
||||
"""Alarms test class for Vitrage API tests."""
|
||||
|
||||
def __init__(self):
|
||||
super(BaseAlarmsTest, self).__init__()
|
||||
self.alarms_client = AlarmsHelper()
|
||||
def setUp(self):
|
||||
super(BaseAlarmsTest, self).setUp()
|
||||
self.client = AlarmsHelper()
|
||||
|
||||
def test_compare_alarms(self):
|
||||
"""Wrapper that returns a test graph."""
|
||||
api_alarms = self.alarms_client.get_api_alarms()
|
||||
cli_alarms = self.alarms_client.get_all_alarms()
|
||||
api_alarms = self.client.get_api_alarms()
|
||||
cli_alarms = self.client.get_all_alarms()
|
||||
|
||||
if self.alarms_client.compare_alarms_lists(
|
||||
if self.client.compare_alarms_lists(
|
||||
api_alarms, cli_alarms) is False:
|
||||
LOG.error('The alarms list is not correct')
|
||||
else:
|
||||
@ -40,11 +38,11 @@ class BaseAlarmsTest(BaseVitrageTest):
|
||||
|
||||
def test_nova_alarms(self):
|
||||
"""Wrapper that returns test nova alarms."""
|
||||
self.alarms_client.create_alarms_per_component("nova")
|
||||
alarms = self.alarms_client.get_all_alarms()
|
||||
nova_alarms = self.alarms_client.filter_alarms(alarms, "nova")
|
||||
self.self.client.create_alarms_per_component('nova')
|
||||
alarms = self.client.get_all_alarms()
|
||||
nova_alarms = self.client.filter_alarms(alarms, "nova")
|
||||
|
||||
if self.alarms_client.validate_alarms_correctness(
|
||||
if self.client.validate_alarms_correctness(
|
||||
nova_alarms, "nova") is False:
|
||||
LOG.error('The nova alarms are not correct')
|
||||
else:
|
||||
@ -52,11 +50,11 @@ class BaseAlarmsTest(BaseVitrageTest):
|
||||
|
||||
def test_nagios_alarms(self):
|
||||
"""Wrapper that returns test nagios alarms."""
|
||||
self.alarms_client.create_alarms_per_component("nagios")
|
||||
alarms = self.alarms_client.get_all_alarms()
|
||||
nagios_alarms = self.alarms_client.filter_alarms(alarms, "nagios")
|
||||
self.client.create_alarms_per_component('nagios')
|
||||
alarms = self.client.get_all_alarms()
|
||||
nagios_alarms = self.client.filter_alarms(alarms, "nagios")
|
||||
|
||||
if self.alarms_client.validate_alarms_correctness(
|
||||
if self.client.validate_alarms_correctness(
|
||||
nagios_alarms, "nagios") is False:
|
||||
LOG.error('The nagios alarms are not correct')
|
||||
else:
|
||||
@ -64,11 +62,11 @@ class BaseAlarmsTest(BaseVitrageTest):
|
||||
|
||||
def test_aodh_alarms(self):
|
||||
"""Wrapper that returns test aodh alarms."""
|
||||
self.alarms_client.create_alarms_per_component("aodh")
|
||||
alarms = self.alarms_client.get_all_alarms()
|
||||
aodh_alarms = self.alarms_client.filter_alarms(alarms, "aodh")
|
||||
self.client.create_alarms_per_component('aodh')
|
||||
alarms = self.client.get_all_alarms()
|
||||
aodh_alarms = self.client.filter_alarms(alarms, "aodh")
|
||||
|
||||
if self.alarms_client.validate_alarms_correctness(
|
||||
if self.client.validate_alarms_correctness(
|
||||
aodh_alarms, "aodh") is False:
|
||||
LOG.error('The aodh alarms are not correct')
|
||||
else:
|
@ -26,13 +26,8 @@ LOG = logging.getLogger(__name__)
|
||||
class AlarmsHelper(BaseVitrageTest):
|
||||
"""Alarms test class for Vitrage API tests."""
|
||||
|
||||
def __init__(self):
|
||||
super(AlarmsHelper, self).__init__()
|
||||
self.depth = ''
|
||||
self.query = ''
|
||||
self.root = ''
|
||||
self._get_env_params()
|
||||
self.client = utils.get_client()
|
||||
def setUp(self):
|
||||
super(AlarmsHelper, self).setUp()
|
||||
|
||||
@staticmethod
|
||||
def get_api_alarms():
|
||||
@ -44,10 +39,10 @@ class AlarmsHelper(BaseVitrageTest):
|
||||
return None
|
||||
return alarms
|
||||
|
||||
@staticmethod
|
||||
def get_all_alarms():
|
||||
def get_all_alarms(self):
|
||||
"""Get Alarms returned by the cli """
|
||||
return utils.run_vitrage_command('vitrage alarms list')
|
||||
return utils.run_vitrage_command_with_user(
|
||||
'vitrage alarms list', self.conf.service_credentials.user)
|
||||
|
||||
@staticmethod
|
||||
def filter_alarms(alarms_list, component):
|
||||
@ -67,7 +62,7 @@ class AlarmsHelper(BaseVitrageTest):
|
||||
switcher = {
|
||||
"nova": self._nova_alarms(),
|
||||
"nagios": self._nagios_alarms(),
|
||||
"ceilometer": self._ceilometer_alarm(),
|
||||
"aodh": self._aodh_alarm(),
|
||||
}
|
||||
|
||||
""" Get the function from switcher dictionary """
|
||||
@ -76,8 +71,8 @@ class AlarmsHelper(BaseVitrageTest):
|
||||
return func()
|
||||
|
||||
def _nova_alarms(self):
|
||||
flavor_id = self._get_flavor_id_from_list()
|
||||
image_id = self._get_image_id_from_list()
|
||||
flavor_id = self.get_flavor_id_from_list()
|
||||
image_id = self.get_image_id_from_list()
|
||||
|
||||
self.create_vm_with_exist_image("alarm_vm", flavor_id, image_id)
|
||||
|
||||
@ -86,7 +81,7 @@ class AlarmsHelper(BaseVitrageTest):
|
||||
return "Not supported yet"
|
||||
|
||||
@staticmethod
|
||||
def _ceilometer_alarm():
|
||||
def _aodh_alarm():
|
||||
return "Not supported yet"
|
||||
|
||||
@staticmethod
|
@ -22,13 +22,13 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class BaseVitrageTest(base.BaseTestCase):
|
||||
"""Base test class for Vitrage API tests."""
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
super(BaseVitrageTest, self).__init__(*args, **kwds)
|
||||
self.mock_client = BaseMock()
|
||||
def setUp(self):
|
||||
super(BaseVitrageTest, self).setUp()
|
||||
self.conf = utils.get_conf()
|
||||
|
||||
def _create_graph_by_mock(self):
|
||||
"""Create MOCK Graph and copied to the string """
|
||||
self.mock_client = BaseMock()
|
||||
processor = self.mock_client.create_processor_with_graph()
|
||||
entity_graph = processor.entity_graph
|
||||
mock_graph_output = entity_graph.output_graph()
|
||||
|
15
vitrage_tempest_tests/tests/api/rca/__init__.py
Normal file
15
vitrage_tempest_tests/tests/api/rca/__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_tempest_tests/tests/api/topology/__init__.py
Normal file
15
vitrage_tempest_tests/tests/api/topology/__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'
|
@ -14,7 +14,7 @@
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage_tempest_tests.tests.api.base import BaseVitrageTest
|
||||
from vitrage_tempest_tests.tests.api.utils.topology \
|
||||
from vitrage_tempest_tests.tests.api.topology.utils \
|
||||
import TopologyHelper
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -23,9 +23,8 @@ LOG = logging.getLogger(__name__)
|
||||
class BaseTopologyTest(BaseVitrageTest):
|
||||
"""Topology test class for Vitrage API tests."""
|
||||
|
||||
def __init__(self):
|
||||
super(BaseTopologyTest, self).__init__()
|
||||
self.name = 'tempest_graph'
|
||||
def setUp(self):
|
||||
super(BaseTopologyTest, self).setUp()
|
||||
self.topology_client = TopologyHelper()
|
||||
|
||||
def test_compare_graphs(self):
|
||||
@ -34,9 +33,9 @@ class BaseTopologyTest(BaseVitrageTest):
|
||||
cli_graph = self.topology_client.show_cli_topology()
|
||||
|
||||
if self.topology_client.compare_graphs(api_graph, cli_graph) is False:
|
||||
LOG.error('The graph ' + self.name + ' is not correct')
|
||||
LOG.error('The graph tempest_graph is not correct')
|
||||
else:
|
||||
LOG.info('The graph ' + self.name + ' is correct')
|
||||
LOG.info('The graph tempest_graph is correct')
|
||||
|
||||
def test_get_tree_with_vms(self):
|
||||
"""Wrapper that returns a test tree with created vm's"""
|
@ -26,13 +26,12 @@ LOG = logging.getLogger(__name__)
|
||||
class TopologyHelper(BaseVitrageTest):
|
||||
"""Topology test class for Vitrage API tests."""
|
||||
|
||||
def __init__(self):
|
||||
super(TopologyHelper, self).__init__()
|
||||
def setUp(self):
|
||||
super(TopologyHelper, self).setUp()
|
||||
self.client = utils.get_client()
|
||||
self.depth = ''
|
||||
self.query = ''
|
||||
self.root = ''
|
||||
self._get_env_params()
|
||||
self.client = utils.get_client()
|
||||
|
||||
def get_api_topology(self, graph_type):
|
||||
"""Get Graph objects returned by the v1 client """
|
||||
@ -48,17 +47,12 @@ class TopologyHelper(BaseVitrageTest):
|
||||
|
||||
return api_graph
|
||||
|
||||
def _get_env_params(self):
|
||||
conf = utils.get_conf()
|
||||
self.user = conf.service_credentials.user
|
||||
|
||||
def show_cli_topology(self):
|
||||
"""Get Graph objects returned by cli """
|
||||
LOG.debug("The command is : vitrage topology show")
|
||||
return utils.run_vitrage_command(
|
||||
"cd /home/stack/devstack; . openrc " +
|
||||
self.user + " " + self.user +
|
||||
"; vitrage topology show")
|
||||
|
||||
return utils.run_vitrage_command_with_user(
|
||||
"vitrage topology show", self.conf.service_credentials.user)
|
||||
|
||||
def create_machines(self, machine_number):
|
||||
flavor_id = self.get_flavor_id_from_list()
|
@ -68,6 +68,13 @@ def run_vitrage_command(command):
|
||||
return None
|
||||
|
||||
|
||||
def run_vitrage_command_with_user(command, user):
|
||||
run_vitrage_command(
|
||||
"cd /home/stack/devstack; . openrc " +
|
||||
user + " " + user +
|
||||
"; " + command)
|
||||
|
||||
|
||||
def run_from_terminal(command):
|
||||
proc = os.popen(command)
|
||||
text_out = proc.read()
|
||||
|
Loading…
x
Reference in New Issue
Block a user