From a3771ed1218748e5ba902e174505cc53cab2756b Mon Sep 17 00:00:00 2001 From: Ivan Kolodyazhny Date: Sat, 22 Dec 2018 00:23:19 +0200 Subject: [PATCH] Use Tempest config Tempest plugins should use tempest config only. This patch changes code to read params from tempest config instead of vitrage. OpenStack clients related code will be fixed in separate patch in scope of task #27631. Change-Id: Iaf91a84cbf7667e443ef21f7ed5ee0036afdba57 Story: #2004053 Task: #28634 --- devstack/post_test_hook.sh | 15 ++++++++++ vitrage_tempest_plugin/config.py | 29 +++++++++---------- vitrage_tempest_plugin/plugin.py | 15 ++++++---- .../test_3rd_degree_scenarios.py | 11 ++++--- 4 files changed, 45 insertions(+), 25 deletions(-) diff --git a/devstack/post_test_hook.sh b/devstack/post_test_hook.sh index 37ec742..0dee14f 100644 --- a/devstack/post_test_hook.sh +++ b/devstack/post_test_hook.sh @@ -13,7 +13,22 @@ # License for the specific language governing permissions and limitations # under the License. +source $BASE/new/devstack/functions +sudo chown -R $USER:stack $BASE/new/tempest + DEVSTACK_PATH="$BASE/new" +TEMPEST_CONFIG=$BASE/new/tempest/etc/tempest.conf + +iniset $TEMPEST_CONFIG service_available vitrage true + +if [ "$1" = "mock" ]; then + iniset $TEMPEST_CONFIG root_cause_analysis_service instances_per_host 50 + iniset $TEMPEST_CONFIG root_cause_analysis_service snapshots_interval 60 +else + iniset $TEMPEST_CONFIG root_cause_analysis_service instances_per_host 2 + iniset $TEMPEST_CONFIG root_cause_analysis_service snapshots_interval 120 +fi + #Argument is received from Zuul if [ "$1" = "api" ]; then diff --git a/vitrage_tempest_plugin/config.py b/vitrage_tempest_plugin/config.py index c9e16e3..4eb4bc0 100644 --- a/vitrage_tempest_plugin/config.py +++ b/vitrage_tempest_plugin/config.py @@ -15,25 +15,24 @@ from oslo_config import cfg -service_option = cfg.BoolOpt("vitrage", - default=True, - help="Whether or not vitrage is expected to be " - "available") +service_available_group = cfg.OptGroup(name="service_available", + title="Available OpenStack Services") + +ServiceAvailableGroup = [cfg.BoolOpt("vitrage", + default=True, + help="Whether or not vitrage is expected " + "to be available")] rca_service_group = cfg.OptGroup(name="root_cause_analysis_service", title="Root Cause Analysis Service Options") RcaServiceGroup = [ # RCA Service tempest configuration - cfg.StrOpt("region", - default="", - help="The application_catalog region name to use. If empty, " - "the value of identity.region is used instead. " - "If no such region is found in the service catalog, " - "the first found one is used."), - - cfg.StrOpt("identity_version", - default="v2", - help="Default identity version for " - "REST client authentication.") + cfg.IntOpt('instances_per_host', + default=2, + help="Number of instances per host in mock graph datasource"), + cfg.IntOpt('snapshots_interval', + default=120, + min=10, + help='Time to wait between subsequent datasource snapshots'), ] diff --git a/vitrage_tempest_plugin/plugin.py b/vitrage_tempest_plugin/plugin.py index 7fa345a..437d314 100644 --- a/vitrage_tempest_plugin/plugin.py +++ b/vitrage_tempest_plugin/plugin.py @@ -17,6 +17,7 @@ import os # noinspection PyPackageRequirements +from tempest import config from tempest.test_discover import plugins from vitrage_tempest_plugin import config as config_rca_service @@ -31,13 +32,15 @@ class VitrageTempestPlugin(plugins.TempestPlugin): return full_test_dir, base_path def register_opts(self, conf): - conf.register_opt(config_rca_service.service_option, - group='service_available') - conf.register_group(config_rca_service.rca_service_group) - conf.register_opts(config_rca_service.RcaServiceGroup, - group='root_cause_analysis_service') + config.register_opt_group(conf, + config_rca_service.service_available_group, + config_rca_service.ServiceAvailableGroup) + config.register_opt_group(conf, + config_rca_service.rca_service_group, + config_rca_service.RcaServiceGroup) def get_opt_lists(self): return [(config_rca_service.rca_service_group.name, config_rca_service.RcaServiceGroup), - ('service_available', [config_rca_service.service_option])] + (config_rca_service.service_available_group.name, + [config_rca_service.ServiceAvailableGroup])] diff --git a/vitrage_tempest_plugin/tests/resources/mock_datasource/test_3rd_degree_scenarios.py b/vitrage_tempest_plugin/tests/resources/mock_datasource/test_3rd_degree_scenarios.py index 3764f20..74ff2de 100644 --- a/vitrage_tempest_plugin/tests/resources/mock_datasource/test_3rd_degree_scenarios.py +++ b/vitrage_tempest_plugin/tests/resources/mock_datasource/test_3rd_degree_scenarios.py @@ -16,6 +16,8 @@ from threading import Thread import time from oslo_log import log as logging +from tempest import config + from vitrage_tempest_plugin.tests.common.constants import VertexProperties from vitrage_tempest_plugin.tests.common import general_utils as g_utils @@ -24,6 +26,7 @@ from vitrage_tempest_plugin.tests.common import vitrage_utils as v_utils from vitrage_tempest_plugin.tests.e2e.test_actions_base import TestActionsBase from vitrage_tempest_plugin.tests import utils +CONF = config.CONF LOG = logging.getLogger(__name__) DEDUCED_1 = 'mock_datasource.3rd_degree_scenarios.deduced.alarm1' @@ -68,7 +71,7 @@ class TestLongProcessing(TestActionsBase): v_utils.delete_template(name=TEMPLATE_NAME) # sleep to allow get_all to start and finish at least once: - time.sleep(4 * self.conf.datasources.snapshots_interval) + time.sleep(4 * CONF.root_cause_analysis_service.snapshots_interval) v_utils.restart_graph() self.keep_sending_events = False @@ -111,7 +114,7 @@ class TestLongProcessing(TestActionsBase): topo2 = TempestClients.vitrage().topology.get(all_tenants=True) self.assert_graph_equal( topo1, topo2, 'comparing graph items iteration ' + str(i)) - time.sleep(self.conf.datasources.snapshots_interval) + time.sleep(CONF.root_cause_analysis_service.snapshots_interval) v_utils.delete_template(name=TEMPLATE_NAME) time.sleep(SLEEP) @@ -130,11 +133,11 @@ class TestLongProcessing(TestActionsBase): alarm_count = TempestClients.vitrage().alarm.count( all_tenants=True) self.assertEqual( - self.conf.mock_graph_datasource.instances_per_host, + CONF.root_cause_analysis_service.instances_per_host, alarm_count['SEVERE'], 'Each instance should have one SEVERE deduced alarm') self.assertEqual( - self.conf.mock_graph_datasource.instances_per_host, + CONF.root_cause_analysis_service.instances_per_host, alarm_count['CRITICAL'], 'Each instance should have one CRITICAL deduced alarm')