aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-11-10 15:05:51 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-11-10 15:05:51 +0000
commit9894640fb446b587c621804572eb580886bae7a1 (patch)
tree514963a23c47a00901ad28573aa835189ed82f41 /tests/unit
parentbf049c61b6c11ff0756220b44b73ebbdc101366a (diff)
parent81b9d338268f47f3d8863f10ef3940f0ea79d618 (diff)
Merge "Heat: add availability_zone"
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/benchmark/contexts/test_model.py48
1 files changed, 37 insertions, 11 deletions
diff --git a/tests/unit/benchmark/contexts/test_model.py b/tests/unit/benchmark/contexts/test_model.py
index 5444c2bc8..48ee01cf0 100644
--- a/tests/unit/benchmark/contexts/test_model.py
+++ b/tests/unit/benchmark/contexts/test_model.py
@@ -179,6 +179,7 @@ class NetworkTestCase(unittest.TestCase):
test_network = model.Network('foo', self.mock_context, attrs)
self.assertIsNone(test_network.gateway_ip)
+
class ServerTestCase(unittest.TestCase):
def setUp(self):
@@ -190,7 +191,6 @@ class ServerTestCase(unittest.TestCase):
netattrs = {'cidr': '10.0.0.0/24', 'provider': None, 'external_network': 'ext_net'}
self.mock_context.networks = [model.Network("some-network", self.mock_context, netattrs)]
-
def test_construct_defaults(self):
attrs = None
@@ -227,8 +227,9 @@ class ServerTestCase(unittest.TestCase):
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance(self, mock_template):
-
- attrs = {'image': 'some-image', 'flavor': 'some-flavor', 'floating_ip': '192.168.1.10', 'floating_ip_assoc': 'some-vm'}
+ attrs = {'image': 'some-image', 'flavor': 'some-flavor', 'floating_ip': '192.168.1.10',
+ 'floating_ip_assoc': 'some-vm',
+ 'availability_zone': 'zone'}
test_server = model.Server('foo', self.mock_context, attrs)
self.mock_context.flavors = ['flavor1', 'flavor2', 'some-flavor']
@@ -241,7 +242,8 @@ class ServerTestCase(unittest.TestCase):
mock_network.subnet_stack_name = 'some-network-stack-subnet'
mock_network.provider = 'sriov'
mock_network.external_network = 'ext_net'
- mock_network.router = model.Router('some-router', 'some-network', self.mock_context, 'ext_net')
+ mock_network.router = model.Router('some-router', 'some-network', self.mock_context,
+ 'ext_net')
test_server._add_instance(mock_template, 'some-server',
[mock_network], 'hints')
@@ -277,7 +279,8 @@ class ServerTestCase(unittest.TestCase):
user=self.mock_context.user,
key_name=self.mock_context.keypair_name,
user_data='',
- scheduler_hints='hints')
+ scheduler_hints='hints',
+ availability_zone='zone')
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance_with_user_data(self, mock_template):
@@ -299,7 +302,30 @@ class ServerTestCase(unittest.TestCase):
user=self.mock_context.user,
key_name=self.mock_context.keypair_name,
user_data=user_data,
- scheduler_hints='hints')
+ scheduler_hints='hints',
+ availability_zone=None)
+
+ @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
+ def test__add_instance_with_availablity_zone(self, mock_template):
+ attrs = {
+ 'image': 'some-image', 'flavor': 'some-flavor',
+ 'availability_zone': 'zone',
+ }
+ test_server = model.Server('foo', self.mock_context, attrs)
+
+ test_server._add_instance(mock_template, 'some-server',
+ [], 'hints')
+
+ mock_template.add_server.assert_called_with(
+ 'some-server', 'some-image',
+ flavor='some-flavor',
+ flavors=self.mock_context.flavors,
+ ports=[],
+ user=self.mock_context.user,
+ key_name=self.mock_context.keypair_name,
+ user_data='',
+ scheduler_hints='hints',
+ availability_zone='zone')
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance_plus_flavor(self, mock_template):
@@ -339,7 +365,8 @@ class ServerTestCase(unittest.TestCase):
user=self.mock_context.user,
key_name=self.mock_context.keypair_name,
user_data=user_data,
- scheduler_hints='hints')
+ scheduler_hints='hints',
+ availability_zone=None)
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance_misc(self, mock_template):
@@ -351,7 +378,7 @@ class ServerTestCase(unittest.TestCase):
}
test_server = model.Server('ServerFlavor-3', self.mock_context, attrs)
- self.mock_context.flavors = ['flavor2']
+ self.mock_context.flavors = ['flavor2']
self.mock_context.flavor = {'vcpus': 4}
mock_network = mock.Mock()
mock_network.name = 'some-network'
@@ -361,7 +388,6 @@ class ServerTestCase(unittest.TestCase):
test_server._add_instance(mock_template, 'ServerFlavor-3',
[mock_network], 'hints')
-
mock_template.add_port(
'ServerFlavor-3-some-network-port',
mock_network.stack_name,
@@ -387,5 +413,5 @@ class ServerTestCase(unittest.TestCase):
user=self.mock_context.user,
key_name=self.mock_context.keypair_name,
user_data=user_data,
- scheduler_hints='hints')
-
+ scheduler_hints='hints',
+ availability_zone=None)