summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-08-24 15:06:50 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-11-01 03:56:14 -0700
commit81b9d338268f47f3d8863f10ef3940f0ea79d618 (patch)
tree4fbbe511f9bcfd0503853ff8107d8bc8144e1523
parent8291c3d11227de42599be920605f3f884dfa755b (diff)
Heat: add availability_zone
Users would like to ensure placement of VMs on specific compute nodes so that the measurements are meaningful. Examples: Measure network performance in different scenarios (VMs in same host, in different hosts, across fabric, across tenants) Example: context: name: yardstick placement_groups: pgrp1: policy: "availability" servers: tg_0: floating_ip: true placement: "pgrp1" availability_zone: "zone2" vnf_0: floating_ip: true placement: "pgrp1" availability_zone: "zone1" Change-Id: I28a757c25ae3f5b3571ab3edd82d51ceba32c302 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
-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 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)
diff --git a/yardstick/benchmark/contexts/model.py b/yardstick/benchmark/contexts/model.py
index facfab892..d3c03e100 100644
--- a/yardstick/benchmark/contexts/model.py
+++ b/yardstick/benchmark/contexts/model.py
@@ -237,6 +237,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)
@@ -329,12 +330,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)