From c00ff2d45a5b0653ab8e516f3daaa09a753263c1 Mon Sep 17 00:00:00 2001 From: Sanjay Chari Date: Tue, 26 Jul 2022 18:11:58 +0530 Subject: [PATCH] Add nova_boot_in_batches_with_delay workload This patch adds a workload which adds a delay after booting a given number of servers. Change-Id: Icb92782d487a67f146c395c03a86034418ff9dc7 --- browbeat-config.yaml | 17 +++++++ rally/rally-plugins/nova/nova.py | 39 +++++++++++++++ .../nova/nova_boot_in_batches_with_delay.yml | 47 +++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 rally/rally-plugins/nova/nova_boot_in_batches_with_delay.yml diff --git a/browbeat-config.yaml b/browbeat-config.yaml index b9ba687c..bed6ec9d 100644 --- a/browbeat-config.yaml +++ b/browbeat-config.yaml @@ -404,6 +404,23 @@ workloads: - 8 times: 10 scenarios: + - name: nova-boot-in-batches-with-delay + enabled: true + image_name: cirro5 + flavor_name: m1.tiny-cirros + # Time to throttle VM boot in seconds + delay_time: 600 + # Number of iterations that can run before delay is introduced + # iterations_per_batch should always be greater than concurrency. + iterations_per_batch: 10 + # Number of iterations that should be delayed per batch. + # For example, if iterations_per_batch is 3000 and num_iterations_to_delay + # is 50, iterations 3000-3050, 6000-6050.... will be delayed. + # Setting this value to a small multiple(1x or 2x) of the concurrency is optimal. + # num_iterations_to_delay should always be lesser than iterations_per_batch. + num_iterations_to_delay: 8 + num_tenant_networks: 1 + file: rally/rally-plugins/nova/nova_boot_in_batches_with_delay.yml - name: netcreate-boot enabled: true enable_dhcp: true diff --git a/rally/rally-plugins/nova/nova.py b/rally/rally-plugins/nova/nova.py index 47ec9e96..b6b168e3 100644 --- a/rally/rally-plugins/nova/nova.py +++ b/rally/rally-plugins/nova/nova.py @@ -10,6 +10,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging +import time from rally_openstack.common import consts from rally_openstack.task.scenarios.cinder import utils as cinder_utils from rally_openstack.task.scenarios.nova import utils as nova_utils @@ -18,6 +20,7 @@ from rally.task import types from rally.task import validation +LOG = logging.getLogger(__name__) @types.convert(image={"type": "glance_image"}, flavor={"type": "nova_flavor"}) @validation.add("image_valid_on_flavor", flavor_param="flavor", image_param="image") @@ -102,3 +105,39 @@ def run(self, image, flavor, volume_size, boot_server_kwargs, external_net_name) volume = self.cinder.create_volume(volume_size) self._attach_volume(server, volume) self._attach_floating_ip(server, external_net_name) + +@types.convert(image={"type": "glance_image"}, flavor={"type": "nova_flavor"}) +@validation.add("image_valid_on_flavor", flavor_param="flavor", image_param="image") +@validation.add("required_services",services=[consts.Service.NOVA, consts.Service.NEUTRON]) +@validation.add("required_platform", platform="openstack", users=True) +@scenario.configure(context={"cleanup@openstack": ["neutron", "nova"]}, + name="BrowbeatNova.nova_boot_in_batches_with_delay", + platform="openstack") +class NovaBootInBatchesWithDelay(vm_utils.VMScenario): + + def run(self, image, flavor, delay_time, iterations_per_batch, + num_iterations_to_delay, num_tenant_networks, concurrency, **kwargs): + """Boot VMs in batches with delay in between. This scenario is useful for scaling VMs incrementally. + :param image: image of the VMs to be booted + :param flavor: flavor of the VMs to be booted + :param delay_time: int, time in seconds to delay VM boot in between batches + :param iterations_per_batch: int, number of iterations that can run before delay occurs + :param num_iterations_to_delay: int, number of iterations to delay + :param num_tenant_networks: int, number of tenant networks + :param concurrency: int, concurrency passed to rally runner + """ + if iterations_per_batch <= num_iterations_to_delay: + raise Exception("num_iterations_to_delay cannot be greater than iterations_per_batch.") + if iterations_per_batch <= concurrency: + raise Exception("concurrency cannot be greater than iterations_per_batch.") + if (self.context["iteration"] % iterations_per_batch <= num_iterations_to_delay and + self.context["iteration"] >= iterations_per_batch): + LOG.info("Iteration {} delaying VM boot for {} seconds".format( + self.context["iteration"], delay_time)) + time.sleep(delay_time) + tenant_network_id = self.context["tenant"]["networks"][((self.context["iteration"]-1) + % num_tenant_networks)]["id"] + LOG.info("Iteration {} using tenant network {}".format(self.context["iteration"], + tenant_network_id)) + kwargs["nics"] = [{"net-id": tenant_network_id}] + self._boot_server(image, flavor, **kwargs) diff --git a/rally/rally-plugins/nova/nova_boot_in_batches_with_delay.yml b/rally/rally-plugins/nova/nova_boot_in_batches_with_delay.yml new file mode 100644 index 00000000..92d2ee57 --- /dev/null +++ b/rally/rally-plugins/nova/nova_boot_in_batches_with_delay.yml @@ -0,0 +1,47 @@ +{% set image_name = image_name or 'cirro5' %} +{% set flavor_name = flavor_name or 'm1.tiny-cirros' %} +{% set delay_time = delay_time or 600 %} +{% set iterations_per_batch = iterations_per_batch or 5 %} +{% set num_iterations_to_delay = num_iterations_to_delay or 1 %} +{% set num_tenant_networks = num_tenant_networks or 1 %} +{% set sla_max_avg_duration = sla_max_avg_duration or 60 %} +{% set sla_max_failure = sla_max_failure or 0 %} +{% set sla_max_seconds = sla_max_seconds or 60 %} +--- +BrowbeatNova.nova_boot_in_batches_with_delay: + - + args: + flavor: + name: '{{flavor_name}}' + image: + name: '{{image_name}}' + delay_time: {{delay_time}} + iterations_per_batch: {{iterations_per_batch}} + num_iterations_to_delay: {{num_iterations_to_delay}} + num_tenant_networks: {{num_tenant_networks}} + concurrency: {{concurrency}} + runner: + concurrency: {{concurrency}} + times: {{times}} + type: 'constant' + context: + users: + tenants: 1 + users_per_tenant: 8 + network: + networks_per_tenant: {{num_tenant_networks}} + quotas: + neutron: + network: -1 + port: -1 + router: -1 + subnet: -1 + nova: + instances: -1 + cores: -1 + ram: -1 + sla: + max_avg_duration: {{sla_max_avg_duration}} + max_seconds_per_iteration: {{sla_max_seconds}} + failure_rate: + max: {{sla_max_failure}}