ede2ea5f6a
With tox 1.7.2 hash randomization will be on by default, causing random failures of tests. How to reproduce: * Update tox * Remove "PYTHONHASHSEED=0" from tox.ini * Run something like: $ for i in {1..20}; do tox -epy27 || break; done Changes: * Made most of generated stuff predictable by adding sorting Not done: * Current API validation checks nothing relying on specific response for specific hash. I tried to test it based on regexp patterns but it looks like more discussion is needed. See https://review.openstack.org/#/c/112736/ for more details. This patch is a part that can be done without regexps. Change-Id: I92a714cf9c29547e875170547a6c0625ddaebc88 Partial-Bug: #1348818
90 lines
2.4 KiB
Python
90 lines
2.4 KiB
Python
# Copyright (c) 2013 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.
|
|
|
|
import testtools
|
|
|
|
from sahara import exceptions as ex
|
|
from sahara.plugins import provisioning as p
|
|
|
|
|
|
class ProvisioningPluginBaseTest(testtools.TestCase):
|
|
def test__map_to_user_inputs_success(self):
|
|
c1, c2, c3, plugin = _build_configs_and_plugin()
|
|
|
|
user_inputs = plugin._map_to_user_inputs(None, {
|
|
'at-1': {
|
|
'n-1': 'v-1',
|
|
'n-3': 'v-3',
|
|
},
|
|
'at-2': {
|
|
'n-2': 'v-2',
|
|
},
|
|
})
|
|
|
|
self.assertEqual([
|
|
p.UserInput(c1, 'v-1'),
|
|
p.UserInput(c2, 'v-2'),
|
|
p.UserInput(c3, 'v-3'),
|
|
], user_inputs)
|
|
|
|
def test__map_to_user_inputs_failure(self):
|
|
c1, c2, c3, plugin = _build_configs_and_plugin()
|
|
|
|
with testtools.ExpectedException(ex.ConfigurationError):
|
|
plugin._map_to_user_inputs(None, {
|
|
'at-X': {
|
|
'n-1': 'v-1',
|
|
},
|
|
})
|
|
|
|
with testtools.ExpectedException(ex.ConfigurationError):
|
|
plugin._map_to_user_inputs(None, {
|
|
'at-1': {
|
|
'n-X': 'v-1',
|
|
},
|
|
})
|
|
|
|
|
|
def _build_configs_and_plugin():
|
|
c1 = p.Config('n-1', 'at-1', 'cluster')
|
|
c2 = p.Config('n-2', 'at-2', 'cluster')
|
|
c3 = p.Config('n-3', 'at-1', 'node')
|
|
|
|
class TestPlugin(TestEmptyPlugin):
|
|
def get_configs(self, hadoop_version):
|
|
return [c1, c2, c3]
|
|
|
|
return c1, c2, c3, TestPlugin()
|
|
|
|
|
|
class TestEmptyPlugin(p.ProvisioningPluginBase):
|
|
def get_title(self):
|
|
pass
|
|
|
|
def get_versions(self):
|
|
pass
|
|
|
|
def get_configs(self, hadoop_version):
|
|
pass
|
|
|
|
def get_node_processes(self, hadoop_version):
|
|
pass
|
|
|
|
def configure_cluster(self, cluster):
|
|
pass
|
|
|
|
def start_cluster(self, cluster):
|
|
pass
|