Revert "unit tests for "Implemention manual scaling""

It prints stacktraces with errors to the logs during the unit tests

This reverts commit fabec23298
This commit is contained in:
Sergey Lukjanov 2013-07-08 16:24:23 +00:00 committed by Gerrit Code Review
parent fabec23298
commit 1fb92de13c
8 changed files with 0 additions and 240 deletions

View File

@ -1,7 +1,6 @@
Alexander Ignatov <aignatov@mirantis.com>
Alexander Kuznetsov <akuznetsov@mirantis.com>
Dmitry Mescheryakov <dmescheryakov@mirantis.com>
Ilya Tyaptin <ityaptin@mirantis.com>
Jeremy Stanley <fungi@yuggoth.org>
Matthew Farrellee <matt@redhat.com>
Nadya Privalova <nprivalova@mirantis.com>

View File

@ -1,43 +0,0 @@
# 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 unittest2
from savanna.db import models as m
from savanna.plugins.vanilla import exceptions as ex
from savanna.plugins.vanilla import plugin as p
class VanillaPluginScalingTest(unittest2.TestCase):
def setUp(self):
self.pl = p.VanillaProvider()
self.cl = m.Cluster("cluster1", "tenant1", "vanilla", "1.1.2")
self.ng1 = m.NodeGroup("nn", "f1", ["namenode"], 1)
self.ng2 = m.NodeGroup("jt", "f1", ["jobtracker"], 1)
self.ng3 = m.NodeGroup("tt", "f1", ["tasktracker"], 10)
self.cl_configs = self.pl.get_configs("1.1.2")
def test_validate_scaling(self):
ng_names = {self.ng1.name: 1, self.ng2.name: 1, self.ng3.name: 10}
self.cl.node_groups.append(self.ng1)
self.cl.node_groups.append(self.ng2)
self.cl.node_groups.append(self.ng3)
with self.assertRaises(ex.NodeGroupCannotBeScaled):
self.pl.validate_scaling(self.cl, ng_names, [self.ng1])
del ng_names['jt']
del ng_names['nn']
ng_names['dn'] = 3
with self.assertRaises(ex.NodeGroupsDoNotExist):
self.pl.validate_scaling(self.cl, ng_names, [self.ng3])

View File

@ -1,109 +0,0 @@
# 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 mock
import savanna.db.models as m
from savanna.plugins import base
from savanna.plugins.vanilla import exceptions as ex
from savanna.plugins.vanilla import plugin
from savanna.service import api
from savanna.tests.unit import base as models_test_base
def patch_get_ng(test_ng):
temp_mock = mock.Mock()
temp_mock.to_object.return_value = test_ng
mock.patch("savanna.service.api.get_node_group_template",
return_value=temp_mock).start()
def patch(cluster, test_ng):
patch_get_ng(test_ng)
mock.patch("savanna.service.api.get_cluster",
return_value=cluster).start()
mock.patch("savanna.plugins.base.PluginManager.get_plugin",
return_value=plugin.VanillaProvider()).start()
class ClusterScalingApiTest(models_test_base.DbTestCase):
def init_cluster(self):
ng_master = m.NodeGroup('ng1', 'test_flavor',
['namenode', 'jobtracker'], 1)
ng_master.instances = [m.Instance("ng1", "i1", "i1")]
ng_datanode = m.NodeGroup('ng2', 'test_flavor',
['datanode'], 3)
ng_test_nodes = m.NodeGroup('ng3', 'test_flavor',
['datanode'], 3)
cluster = m.Cluster("cluster3", "test_tenant",
"vanilla", "1.1.2")
cluster.node_groups = [ng_master, ng_datanode]
base.setup_plugins()
return cluster, ng_test_nodes
def test_scale_cluster_with_adding_node_group(self):
cluster, ng_tasktracker = self.init_cluster()
patch(cluster, ng_tasktracker)
data = {'resize_node_groups': [],
'add_node_groups': [{'name': 'ng3', 'count': 4,
'node_group_template_id': '1'}]}
cluster = api.scale_cluster("1", data)
self.assertEqual(len(cluster.node_groups), 3)
def test_scale_cluster_with_adding_node_group_with_none_template_id(self):
cluster, ng_tasktracker = self.init_cluster()
patch(cluster, ng_tasktracker)
data = {'resize_node_groups': [],
'add_node_groups': [{'name': 'ng3', 'count': 4,
'node_group_template_id': None,
'flavor_id': '3',
'node_processes': ['tasktracker']}]}
cluster = api.scale_cluster("1", data)
self.assertEqual(len(cluster.node_groups), 3)
def test_scale_cluster_with_adding_invalid_node_group(self):
cluster, ng_tasktracker = self.init_cluster()
patch(cluster, ng_tasktracker)
data = {'resize_node_groups': [],
'add_node_groups': [{'name': 'ng3', 'count': 4,
'node_group_template_id': None,
'flavor_id': '3',
'node_processes': ['namenode']}]}
with self.assertRaises(ex.NodeGroupCannotBeScaled):
api.scale_cluster("1", data)
class ConstructNgsForScalingApiTest(models_test_base.DbTestCase):
def test_create_ngs_with_none_template_id(self):
additional_ng = [{'name': 'ng3', 'count': 4,
'node_group_template_id': None,
"flavor_id": "1",
"node_processes": ["namenode"]}]
result = api.construct_ngs_for_scaling(additional_ng)
self.assertEqual(len(result), 1)
ng = result.keys()[0]
self.assertEqual(ng.node_processes, ["namenode"])
self.assertEqual(result[ng], 4)
def test_create_ngs_with_template_id(self):
additional_ng = [{'name': 'ng3', 'count': 4,
'node_group_template_id': '1'}]
test_ng = m.NodeGroup("ng3", "f1", ["tasktracker"], 3)
patch_get_ng(test_ng)
result = api.construct_ngs_for_scaling(additional_ng)
self.assertEqual(len(result), 1)
ng = result.keys()[0]
self.assertEqual(result[ng], 4)

View File

@ -1,87 +0,0 @@
# 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 mock
import savanna.db.models as m
from savanna.service import instances
from savanna.tests.unit import base as models_test_base
import savanna.utils.crypto as c
def run_instance_side_effect(*args):
return _mock_instance(args[2])
class ClusterScalingTest(models_test_base.DbTestCase):
def test_cluster_scaling_add_new_nodes(self):
node_groups = [m.NodeGroup("ng1", "fid1", ["namenode"], 2),
m.NodeGroup("ng2", "fid1", ["namenode"], 3)]
node_groups[0]._username = 'root'
node_groups[1]._username = 'root'
cluster = m.Cluster("cluster1", "tenant1",
"vanilla", "1.2.2", "image1")
cluster.node_groups = node_groups
cluster.private_key = c.generate_private_key(1024)
cluster._user_kp = mock.Mock()
cluster._user_kp.public_key = "123"
cluster.status = 'Active'
with mock.patch("savanna.service.instances._run_instance") as m_m:
m_m._run_instance.side_effect = run_instance_side_effect
res = instances.scale_cluster(cluster, {"ng1": 4, 'ng2': 5})
self.assertEqual(len(res), 4)
self.assertEqual(cluster.status, "Active")
def test_cluster_scaling_not_add_new_nodes(self):
node_groups = [m.NodeGroup("ng1", "fid1", ["namenode"], 2)]
node_groups[0]._username = 'root'
cluster = m.Cluster("cluster1", "tenant1",
"vanilla", "1.2.2", "image1")
cluster.node_groups = node_groups
cluster.private_key = c.generate_private_key(1024)
cluster._user_kp = mock.Mock()
cluster._user_kp.public_key = "123"
with mock.patch("savanna.service.instances._run_instance") as m_m:
m_m._run_instance.side_effect = run_instance_side_effect
new_instances = instances.scale_cluster(cluster, {"ng1": 2})
self.assertEqual(len(new_instances), 0)
def test_cluster_scaling_with_not_exists_node_group(self):
node_groups = [m.NodeGroup("ng1", "fid1", ["namenode"], 2), ]
node_groups[0]._username = 'root'
cluster = m.Cluster("cluster1", "tenant1",
"vanilla", "1.2.2", "image1")
cluster.node_groups = node_groups
cluster.private_key = c.generate_private_key(1024)
cluster._user_kp = mock.Mock()
cluster._user_kp.public_key = "123"
cluster.status = 'Active'
with mock.patch("savanna.service.instances._run_instance") as m_m:
m_m._run_instance.side_effect = run_instance_side_effect
new_instances = instances.scale_cluster(cluster,
{"not_exists_ng": 2})
self.assertEqual(len(new_instances), 0)
self.assertEqual(cluster.status, 'Active')
def _mock_instance(instance_id):
instance1 = mock.Mock()
instance1.id = instance_id
return instance1
def _mock_instances(count):
return [_mock_instance(str(i)) for i in range(1, count + 1)]