summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/benchmark/contexts/test_model.py48
-rw-r--r--yardstick/benchmark/contexts/model.py11
-rw-r--r--yardstick/orchestrator/heat.py11
3 files changed, 48 insertions, 22 deletions
diff --git a/tests/unit/benchmark/contexts/test_model.py b/tests/unit/benchmark/contexts/test_model.py
index 3e94168b5..53b035b82 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')
def test_override_ip(self):
network_ports = {
@@ -471,7 +474,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):
@@ -511,7 +537,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):
@@ -523,7 +550,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'
@@ -533,7 +560,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,
@@ -559,5 +585,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)
diff --git a/yardstick/benchmark/contexts/model.py b/yardstick/benchmark/contexts/model.py
index 97560c9f6..ae56066ee 100644
--- a/yardstick/benchmark/contexts/model.py
+++ b/yardstick/benchmark/contexts/model.py
@@ -239,6 +239,7 @@ class Server(Object): # pragma: no cover
self._flavor = attrs["flavor"]
self.user_data = attrs.get('user_data', '')
+ self.availability_zone = attrs.get('availability_zone')
Server.list.append(self)
@@ -355,12 +356,10 @@ class Server(Object): # pragma: no cover
mountpoint=self.volume_mountpoint)
template.add_server(server_name, self.image, flavor=self.flavor_name,
- flavors=self.context.flavors,
- ports=port_name_list,
- user=self.user,
- key_name=self.keypair_name,
- user_data=self.user_data,
- scheduler_hints=scheduler_hints)
+ flavors=self.context.flavors, ports=port_name_list,
+ scheduler_hints=scheduler_hints, user=self.user,
+ key_name=self.keypair_name, user_data=self.user_data,
+ availability_zone=self.availability_zone)
def add_to_template(self, template, networks, scheduler_hints=None):
"""adds to the template one or more servers (instances)"""
diff --git a/yardstick/orchestrator/heat.py b/yardstick/orchestrator/heat.py
index 455ddc34e..89785ee0e 100644
--- a/yardstick/orchestrator/heat.py
+++ b/yardstick/orchestrator/heat.py
@@ -518,11 +518,10 @@ name (i.e. %s).\
'value': {'get_resource': name}
}
- def add_server(self, name, image, flavor, flavors, ports=None,
- networks=None, scheduler_hints=None, user=None,
- key_name=None, user_data=None, metadata=None,
- additional_properties=None):
- """add to the template a Nova Server"""
+ def add_server(self, name, image, flavor, flavors, ports=None, networks=None,
+ scheduler_hints=None, user=None, key_name=None, user_data=None, metadata=None,
+ additional_properties=None, availability_zone=None):
+ """add to the template a Nova Server """
log.debug("adding Nova::Server '%s', image '%s', flavor '%s', "
"ports %s", name, image, flavor, ports)
@@ -537,6 +536,8 @@ name (i.e. %s).\
'flavor': {},
'networks': [] # list of dictionaries
}
+ if availability_zone:
+ server_properties["availability_zone"] = availability_zone
if flavor in flavors:
self.resources[name]['depends_on'].append(flavor)