add alarms & change tempest folder hierarchy
Change-Id: I9b668f748d96d4527ff2c27b8a644b46f6f754ab
This commit is contained in:
parent
fc4225fc99
commit
a56f09aa54
@ -15,15 +15,6 @@
|
||||
from oslo_config import cfg
|
||||
|
||||
OPTS = [
|
||||
cfg.StrOpt('admin_user',
|
||||
default='admin',
|
||||
help='admin_user'),
|
||||
cfg.StrOpt('admin_password',
|
||||
default='password',
|
||||
help='admin_password'),
|
||||
cfg.StrOpt('admin_tenant_name',
|
||||
default='admin',
|
||||
help='admin_tenant_name'),
|
||||
cfg.StrOpt('identity_uri',
|
||||
help='identity_uri'),
|
||||
cfg.StrOpt('auth_url',
|
||||
help='auth_url'),
|
||||
]
|
||||
|
75
vitrage_tempest_tests/tests/api/alarms_test.py
Normal file
75
vitrage_tempest_tests/tests/api/alarms_test.py
Normal file
@ -0,0 +1,75 @@
|
||||
# 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_log import log as logging
|
||||
|
||||
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 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()
|
||||
|
||||
if self.alarms_client.compare_alarms_lists(
|
||||
api_alarms, cli_alarms) is False:
|
||||
LOG.error('The alarms list is not correct')
|
||||
else:
|
||||
LOG.info('The alarms list is correct')
|
||||
|
||||
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")
|
||||
|
||||
if self.alarms_client.validate_alarms_correctness(
|
||||
nova_alarms, "nova") is False:
|
||||
LOG.error('The nova alarms are not correct')
|
||||
else:
|
||||
LOG.info('The nova alarms are correct')
|
||||
|
||||
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")
|
||||
|
||||
if self.alarms_client.validate_alarms_correctness(
|
||||
nagios_alarms, "nagios") is False:
|
||||
LOG.error('The nagios alarms are not correct')
|
||||
else:
|
||||
LOG.info('The nagios alarms are correct')
|
||||
|
||||
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")
|
||||
|
||||
if self.alarms_client.validate_alarms_correctness(
|
||||
aodh_alarms, "aodh") is False:
|
||||
LOG.error('The aodh alarms are not correct')
|
||||
else:
|
||||
LOG.info('The aodh alarms are correct')
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from oslo_log import log as logging
|
||||
from vitrage.tests.base import BaseTest
|
||||
from oslotest import base
|
||||
from vitrage_tempest_tests.tests.base_mock import BaseMock
|
||||
|
||||
import vitrage_tempest_tests.tests.utils as utils
|
||||
@ -20,15 +20,16 @@ import vitrage_tempest_tests.tests.utils as utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BaseVitrageTest(BaseTest, BaseMock):
|
||||
class BaseVitrageTest(base.BaseTestCase):
|
||||
"""Base test class for Vitrage API tests."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BaseVitrageTest, self).__init__(*args, **kwargs)
|
||||
def __init__(self, *args, **kwds):
|
||||
super(BaseVitrageTest, self).__init__(*args, **kwds)
|
||||
self.mock_client = BaseMock()
|
||||
|
||||
def _create_graph_by_mock(self):
|
||||
"""Create MOCK Graph and copied to the string """
|
||||
processor = self.create_processor_with_graph()
|
||||
processor = self.mock_client.create_processor_with_graph()
|
||||
entity_graph = processor.entity_graph
|
||||
mock_graph_output = entity_graph.output_graph()
|
||||
LOG.info("The mock graph is : " + mock_graph_output)
|
||||
|
1
vitrage_tempest_tests/tests/api/rca_test.py
Normal file
1
vitrage_tempest_tests/tests/api/rca_test.py
Normal file
@ -0,0 +1 @@
|
||||
__author__ = 'stack'
|
@ -12,8 +12,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage_tempest_tests.tests.api.base import BaseVitrageTest
|
||||
from vitrage_tempest_tests.tests.api.topology.topology_helper \
|
||||
from vitrage_tempest_tests.tests.api.utils.topology \
|
||||
import TopologyHelper
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -22,8 +23,8 @@ LOG = logging.getLogger(__name__)
|
||||
class BaseTopologyTest(BaseVitrageTest):
|
||||
"""Topology test class for Vitrage API tests."""
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
super(BaseTopologyTest, self).__init__(*args, **kwds)
|
||||
def __init__(self):
|
||||
super(BaseTopologyTest, self).__init__()
|
||||
self.name = 'tempest_graph'
|
||||
self.topology_client = TopologyHelper()
|
||||
|
||||
@ -42,7 +43,8 @@ class BaseTopologyTest(BaseVitrageTest):
|
||||
resources = self.topology_client.create_machines(4)
|
||||
cli_graph = self.topology_client.show_cli_topology()
|
||||
|
||||
if self.validate_graph_correctness(cli_graph, resources) is False:
|
||||
if self.topology_client.validate_graph_correctness(
|
||||
cli_graph, resources) is False:
|
||||
LOG.error('The graph ' + self.name + ' is not correct')
|
||||
else:
|
||||
LOG.info('The graph ' + self.name + ' is correct')
|
||||
@ -52,7 +54,8 @@ class BaseTopologyTest(BaseVitrageTest):
|
||||
resources = self.topology_client.create_volume()
|
||||
cli_graph = self.topology_client.show_cli_topology()
|
||||
|
||||
if self.validate_graph_correctness(cli_graph, resources) is False:
|
||||
if self.topology_client.validate_graph_correctness(
|
||||
cli_graph, resources) is False:
|
||||
LOG.error('The graph ' + self.name + ' is not correct')
|
||||
else:
|
||||
LOG.info('The graph ' + self.name + ' is correct')
|
125
vitrage_tempest_tests/tests/api/utils/alarms.py
Normal file
125
vitrage_tempest_tests/tests/api/utils/alarms.py
Normal file
@ -0,0 +1,125 @@
|
||||
# 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.
|
||||
# import json
|
||||
import vitrage_tempest_tests.tests.utils as utils
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage.api.controllers.v1.alarms import AlarmsController
|
||||
# from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage_tempest_tests.tests.api.base import BaseVitrageTest
|
||||
|
||||
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()
|
||||
|
||||
@staticmethod
|
||||
def get_api_alarms():
|
||||
"""Get Alarms returned by the v1 client """
|
||||
try:
|
||||
alarms = AlarmsController().get_alarms()
|
||||
except Exception as e:
|
||||
LOG.exception("Failed to get alarms %s ", e)
|
||||
return None
|
||||
return alarms
|
||||
|
||||
@staticmethod
|
||||
def get_all_alarms():
|
||||
"""Get Alarms returned by the cli """
|
||||
return utils.run_vitrage_command('vitrage alarms list')
|
||||
|
||||
@staticmethod
|
||||
def filter_alarms(alarms_list, component):
|
||||
"""Filter alarms by component """
|
||||
filtered_alarms_list = []
|
||||
LOG.debug("The component is " + component)
|
||||
for alarm in alarms_list:
|
||||
if component in alarm["id"]:
|
||||
filtered_alarms_list.add(alarm)
|
||||
return filtered_alarms_list
|
||||
|
||||
""" CREATE ALARMS PER COMPONENT """
|
||||
def create_alarms_per_component(self, component):
|
||||
"""Break something to create alarm for each component """
|
||||
|
||||
LOG.debug("The component is " + component)
|
||||
switcher = {
|
||||
"nova": self._nova_alarms(),
|
||||
"nagios": self._nagios_alarms(),
|
||||
"ceilometer": self._ceilometer_alarm(),
|
||||
}
|
||||
|
||||
""" Get the function from switcher dictionary """
|
||||
func = switcher.get(component, lambda: "nothing")
|
||||
""" Execute the function """
|
||||
return func()
|
||||
|
||||
def _nova_alarms(self):
|
||||
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)
|
||||
|
||||
@staticmethod
|
||||
def _nagios_alarm():
|
||||
return "Not supported yet"
|
||||
|
||||
@staticmethod
|
||||
def _ceilometer_alarm():
|
||||
return "Not supported yet"
|
||||
|
||||
@staticmethod
|
||||
def compare_alarms_lists(api_alarms, cli_alarms):
|
||||
"""Validate alarm existence """
|
||||
if not api_alarms:
|
||||
LOG.error("The alarms list taken from api is empty")
|
||||
return False
|
||||
if not cli_alarms:
|
||||
LOG.error("The alarms list taken from cli is empty")
|
||||
return False
|
||||
|
||||
# parsed_alarms = json.loads(cli_alarms)
|
||||
# LOG.debug("The alarms list taken from cli is : " +
|
||||
# json.dumps(parsed_alarms))
|
||||
# LOG.debug("The alarms list taken by api is : %s",
|
||||
# json.dumps(api_alarms))
|
||||
#
|
||||
# cli_items = sorted(parsed_topology.items())
|
||||
# api_items = sorted(api_alarms.items())
|
||||
#
|
||||
# for item in cli_items[4][1]:
|
||||
# item.pop(VProps.UPDATE_TIMESTAMP, None)
|
||||
#
|
||||
# for item in api_items[4][1]:
|
||||
# item.pop(VProps.UPDATE_TIMESTAMP, None)
|
||||
#
|
||||
# return cli_items == api_items
|
||||
|
||||
@staticmethod
|
||||
def validate_alarms_correctness(alarms, component):
|
||||
"""Validate alarm existence """
|
||||
if not alarms:
|
||||
LOG.error("The alarms list is empty")
|
||||
return False
|
||||
LOG.debug("The component is " + component)
|
@ -26,8 +26,8 @@ LOG = logging.getLogger(__name__)
|
||||
class TopologyHelper(BaseVitrageTest):
|
||||
"""Topology test class for Vitrage API tests."""
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
super(TopologyHelper, self).__init__(*args, **kwds)
|
||||
def __init__(self):
|
||||
super(TopologyHelper, self).__init__()
|
||||
self.depth = ''
|
||||
self.query = ''
|
||||
self.root = ''
|
||||
@ -43,7 +43,7 @@ class TopologyHelper(BaseVitrageTest):
|
||||
root=self.root)
|
||||
except Exception as e:
|
||||
LOG.exception("Failed to get topology (graph_type = " +
|
||||
self.graph_type + ") %s ", e)
|
||||
graph_type + ") %s ", e)
|
||||
return None
|
||||
|
||||
return api_graph
|
@ -13,8 +13,8 @@
|
||||
# under the License.
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslotest import base
|
||||
|
||||
import testtools
|
||||
import vitrage_tempest_tests.tests.utils as utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -24,12 +24,11 @@ logging.setup(CONF, "vitrage")
|
||||
logging.set_defaults(default_log_levels=utils.extra_log_level_defaults)
|
||||
|
||||
|
||||
class RunVitrageEnv(testtools.TestCase):
|
||||
class RunVitrageEnv(base.BaseTestCase):
|
||||
"""RunVitrageEnv class. Run Vitrage env."""
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
super(RunVitrageEnv, self).__init__(*args, **kwds)
|
||||
self.filename = '/opt/stack/vitrage/etc/vitrage/vitrage.conf'
|
||||
|
||||
def test_run_env(self):
|
||||
if self._show_vitrage_processes() is True:
|
||||
@ -39,14 +38,9 @@ class RunVitrageEnv(testtools.TestCase):
|
||||
self._get_env_params()
|
||||
|
||||
utils.change_terminal_dir('/home/stack/devstack')
|
||||
# utils.run_from_terminal("chmod +x openrc")
|
||||
utils.get_from_terminal_enabled_bash(". openrc " + self.user + " " +
|
||||
utils.run_vitrage_command(". openrc " + self.user + " " +
|
||||
self.user)
|
||||
utils.run_from_terminal("openstack service create rca" +
|
||||
# " --os-username " + self.user +
|
||||
# " --os-password " + self.password +
|
||||
# " --os-auth-url " + self.url +
|
||||
# " --os-project-name admin" +
|
||||
" --name vitrage")
|
||||
utils.run_from_terminal("openstack endpoint create rca" +
|
||||
# " --os-username " + self.user +
|
||||
|
@ -14,9 +14,8 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslotest import base
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import testtools
|
||||
import vitrage_tempest_tests.tests.utils as utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -26,7 +25,7 @@ logging.setup(CONF, "vitrage")
|
||||
logging.set_defaults(default_log_levels=utils.extra_log_level_defaults)
|
||||
|
||||
|
||||
class StopVitrageEnv(testtools.TestCase):
|
||||
class StopVitrageEnv(base.BaseTestCase):
|
||||
"""StopVitrageEnv class. Stop Vitrage env."""
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
|
Loading…
x
Reference in New Issue
Block a user