From 212f72d155e47ab2988eee9a17a89d18025d1724 Mon Sep 17 00:00:00 2001 From: Vitalii Yerys Date: Mon, 8 Aug 2016 18:21:15 +0300 Subject: [PATCH] Created test case to verify default values for plugin setup. Updated test docs accordingly. Change-Id: I68f3c8449ea488df4da42ed750dfef6873a713e7 --- doc/testing/master_test_plan.rst | 1 + doc/testing/test_gcs_gui.rst | 37 ++++++++++++++++++++++++ plugin_test/helpers/gcs_base.py | 31 ++++++++++++++++++++ plugin_test/helpers/gcs_settings.py | 27 ++++++++++++++++++ plugin_test/run_tests.py | 1 + plugin_test/tests/test_gcs_gui.py | 44 +++++++++++++++++++++++++++++ 6 files changed, 141 insertions(+) create mode 100644 doc/testing/test_gcs_gui.rst create mode 100644 plugin_test/tests/test_gcs_gui.py diff --git a/doc/testing/master_test_plan.rst b/doc/testing/master_test_plan.rst index 3110dde..fb5d99e 100644 --- a/doc/testing/master_test_plan.rst +++ b/doc/testing/master_test_plan.rst @@ -220,3 +220,4 @@ An ordinary test cycle for each iteration consists of the following steps: ------------- .. include:: test_suite_somke_bvt.rst +.. include:: test_gcs_gui.rst diff --git a/doc/testing/test_gcs_gui.rst b/doc/testing/test_gcs_gui.rst new file mode 100644 index 0000000..9035b83 --- /dev/null +++ b/doc/testing/test_gcs_gui.rst @@ -0,0 +1,37 @@ +=================== +GUI verify defaults +=================== + + +UI test +------- + + +ID +## + +gcs_gui_defaults + +Description +########### + +Test case designed to verify if plugin is being deployed with correct default +values set. + +Complexity +########## + +core + +Steps +##### + + 1. Create cluster + 2. Upload plugin to the master node + 3. Install plugin + 4. Verify default values + +Expected results +################ + +All steps must be completed successfully, without any errors. diff --git a/plugin_test/helpers/gcs_base.py b/plugin_test/helpers/gcs_base.py index 3f9607e..78e4c94 100644 --- a/plugin_test/helpers/gcs_base.py +++ b/plugin_test/helpers/gcs_base.py @@ -16,9 +16,13 @@ import os +from proboscis.asserts import assert_equal +from proboscis.asserts import assert_false + from fuelweb_test.tests.base_test_case import TestBasic from fuelweb_test import logger from fuelweb_test.helpers import utils +from helpers import gcs_settings class GcsTestBase(TestBasic): @@ -48,3 +52,30 @@ class GcsTestBase(TestBasic): '/var') utils.install_plugin_check_code( master_remote.host, os.path.basename(os.environ['GCS_PLUGIN_RPM'])) + + def verify_defaults(self, cluster_id): + """Method designed to verify plugin default values.""" + attr = self.fuel_web.client.get_cluster_attributes(cluster_id) + assert_false( + attr['editable'][gcs_settings.plugin_name]['metadata']['enabled'], + 'Plugin should be disabled by default.') + # attr value is being assigned twice in order to fit PEP8 restriction: + # lines in file can not be longer than 80 characters. + attr = attr['editable'][gcs_settings.plugin_name]['metadata'] + attr = attr['versions'][0] + error_list = [] + for key in gcs_settings.default_values.keys(): + next_key = 'value' + if key == 'metadata': + next_key = 'hot_pluggable' + msg = 'Default value is incorrect, got {} = {} instead of {}' + try: + assert_equal(gcs_settings.default_values[key], + attr[key][next_key], + msg.format(key, + attr[key][next_key], + gcs_settings.default_values[key])) + except AssertionError as e: + error_list.append(''.join(('\n', str(e)))) + error_msg = ''.join(error_list) + assert_equal(len(error_msg), 0, error_msg) diff --git a/plugin_test/helpers/gcs_settings.py b/plugin_test/helpers/gcs_settings.py index 9ec8d53..1afc64f 100644 --- a/plugin_test/helpers/gcs_settings.py +++ b/plugin_test/helpers/gcs_settings.py @@ -33,3 +33,30 @@ options = { 'gcs_client_email/value': os.environ['GCS_CLIENT_EMAIL'], 'gcs_client_id/value': os.environ['GCS_CLIENT_ID'] } + +default_values = { + 'backup_gcs_advanced_settings': False, + 'backup_gcs_enable_progress_timer': True, + 'backup_gcs_retry_error_codes': '429', + 'backup_gcs_writer_chunk_size': '2097152', + 'backup_gcs_bucket_location': 'US', + 'backup_gcs_bucket': '', + 'backup_gcs_project_id': '', + 'backup_gcs_block_size': '32768', + 'backup_gcs_object_size': '52428800', + 'backup_gcs_storage_class': 'NEARLINE', + 'backup_gcs_user_agent': 'gcscinder', + 'backup_gcs_reader_chunk_size': '2097152', + 'backup_gcs_num_retries': '3', + 'metadata': True, + 'gcs_private_key': '', + 'gcs_private_key_id': '', + 'gcs_token_uri': 'https://accounts.google.com/o/oauth2/token', + 'gcs_client_x509_cert_url': '', + 'gcs_auth_provider_x509_cert_url': 'https://www.googleapis.com/' + 'oauth2/v1/certs', + 'gcs_client_email': '', + 'gcs_auth_uri': 'https://accounts.google.com/o/oauth2/auth', + 'gcs_client_id': '', + 'gcs_account_type': 'service_account' +} diff --git a/plugin_test/run_tests.py b/plugin_test/run_tests.py index eec2602..72ea99b 100644 --- a/plugin_test/run_tests.py +++ b/plugin_test/run_tests.py @@ -48,6 +48,7 @@ class CloseSSHConnectionsPlugin(Plugin): def import_tests(): """Import test suite of project.""" from tests import test_gcs_smoke_bvt + from tests import test_gcs_gui def run_tests(): diff --git a/plugin_test/tests/test_gcs_gui.py b/plugin_test/tests/test_gcs_gui.py new file mode 100644 index 0000000..159cf52 --- /dev/null +++ b/plugin_test/tests/test_gcs_gui.py @@ -0,0 +1,44 @@ +# Copyright 2016 Mirantis, Inc. + +# 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. + +"""Module with ui defaults verification test.""" + +from proboscis import test + +from fuelweb_test.helpers.decorators import log_snapshot_after_test +from fuelweb_test.tests.base_test_case import SetupEnvironment +from helpers.gcs_base import GcsTestBase + + +@test(groups=["test_gcs_all"]) +class TestGCSPlugin(GcsTestBase): + """TestGCSPlugin.""" # TODO(unknown) documentation + + @test(depends_on=[SetupEnvironment.prepare_slaves_3], + groups=["gcs_gui_defaults"]) + @log_snapshot_after_test + def gcs_gui_defaults(self): + """Create non HA cluster with GCS plugin installed. + + Scenario: + 1. Create cluster + 2. Install GCS plugin + 3. Verify default values + """ + self.env.revert_snapshot("ready_with_3_slaves") + cluster_id = self.fuel_web.get_last_created_cluster() + + self.install_plugin() + self.verify_defaults(cluster_id) + self.env.make_snapshot("gcs_gui_defaults")