From 4ed9f32b3c12ba45d097c8993e63551e6dfff273 Mon Sep 17 00:00:00 2001 From: Luigi Toscano Date: Wed, 26 Jun 2019 15:35:56 +0200 Subject: [PATCH] scenario tests: allow to use boot_from_volume on NGT The key boot_from_volume can now be configured when defining node group templates. Thi change works only when API v2 is enabled. Change-Id: I1b23c2e457ceb6cf396addd5daa6d7bd36989167 --- .../scenario-boot-from-volume-a87c680b03f560a0.yaml | 5 +++++ sahara_tests/scenario/base.py | 6 ++++++ sahara_tests/scenario/validation.py | 3 +++ sahara_tests/unit/scenario/test_base.py | 10 ++++++++++ 4 files changed, 24 insertions(+) create mode 100644 releasenotes/notes/scenario-boot-from-volume-a87c680b03f560a0.yaml diff --git a/releasenotes/notes/scenario-boot-from-volume-a87c680b03f560a0.yaml b/releasenotes/notes/scenario-boot-from-volume-a87c680b03f560a0.yaml new file mode 100644 index 00000000..bc135c88 --- /dev/null +++ b/releasenotes/notes/scenario-boot-from-volume-a87c680b03f560a0.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Allow to enable boot_from_volume on node group templates + when running scenario tests with APIv2. diff --git a/sahara_tests/scenario/base.py b/sahara_tests/scenario/base.py index 0832a165..1b331d9c 100644 --- a/sahara_tests/scenario/base.py +++ b/sahara_tests/scenario/base.py @@ -601,6 +601,12 @@ class BaseTestCase(base.BaseTestCase): self.neutron.add_security_group_rule_for_neutron( security_group) kwargs['security_groups'] = [security_group] + + # boot_from_volume requires APIv2 + if kwargs.get('boot_from_volume', False) and not self.use_api_v2: + raise Exception('boot_from_volume is set for %s but it ' + 'requires APIv2' % (kwargs['name'])) + ng_id = self.__create_node_group_template(**kwargs) ng_id_map[ng['name']] = ng_id return ng_id_map diff --git a/sahara_tests/scenario/validation.py b/sahara_tests/scenario/validation.py index 9beee192..a8dee751 100644 --- a/sahara_tests/scenario/validation.py +++ b/sahara_tests/scenario/validation.py @@ -206,6 +206,9 @@ SCHEMA = { "minLength": 1 } }, + "boot_from_volume": { + "type": "boolean" + }, "auto_security_group": { "type": "boolean" }, diff --git a/sahara_tests/unit/scenario/test_base.py b/sahara_tests/unit/scenario/test_base.py index a78ee43f..f4dcd5dd 100644 --- a/sahara_tests/unit/scenario/test_base.py +++ b/sahara_tests/unit/scenario/test_base.py @@ -218,6 +218,16 @@ class TestBase(testtools.TestCase): self.assertEqual({'worker': 'id_ng', 'master': 'id_ng'}, self.base_scenario._create_node_group_templates()) + @mock.patch('neutronclient.v2_0.client.Client.list_networks', + return_value={'networks': [{'id': '2314'}]}) + def test__create_node_group_template_bootfromvolume_apiv1(self, mock_del): + self.base_scenario._init_clients() + self.base_scenario.use_api_v2 = False + for ng in self.base_scenario.testcase['node_group_templates']: + ng['boot_from_volume'] = True + with self.assertRaisesRegex(Exception, "^boot_from_volume is.*"): + self.base_scenario._create_node_group_templates() + @mock.patch('saharaclient.api.node_group_templates.' 'NodeGroupTemplateManager.create', return_value=FakeResponse(set_id='id_ng'))