From 1a2bf7168e42118522d4c2023f3f8b0171a80d98 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 17 Jun 2015 12:01:24 -0500 Subject: [PATCH] VMTasks: Make waiting for ping timing configurable Poll interval and timeout can now be set in rally.conf Closes-Bug: #1443035 Change-Id: Ia6d297f2fb8202ac7c00917b05a8db3480dcc5b6 --- etc/rally/rally.conf.sample | 6 ++++++ rally/plugins/openstack/scenarios/vm/utils.py | 18 +++++++++++++++--- .../openstack/scenarios/vm/test_utils.py | 5 ++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/etc/rally/rally.conf.sample b/etc/rally/rally.conf.sample index 7a8742f8..73ce3dfe 100644 --- a/etc/rally/rally.conf.sample +++ b/etc/rally/rally.conf.sample @@ -479,6 +479,12 @@ # Server boot poll interval (floating point value) #ec2_server_boot_poll_interval = 1.0 +# Interval between checks when waiting for a VM to become pingable +#vm_ping_poll_interval = 1.0 + +# Time to wait for a VM to become pingable +#vm_ping_timeout = 120.0 + [database] diff --git a/rally/plugins/openstack/scenarios/vm/utils.py b/rally/plugins/openstack/scenarios/vm/utils.py index 3a9a6654..e8b0c16e 100644 --- a/rally/plugins/openstack/scenarios/vm/utils.py +++ b/rally/plugins/openstack/scenarios/vm/utils.py @@ -17,6 +17,7 @@ import subprocess import sys import netaddr +from oslo_config import cfg import six from rally.common.i18n import _ @@ -32,6 +33,17 @@ LOG = logging.getLogger(__name__) ICMP_UP_STATUS = "ICMP UP" ICMP_DOWN_STATUS = "ICMP DOWN" +VM_BENCHMARK_OPTS = [ + cfg.FloatOpt("vm_ping_poll_interval", default=1.0, + help="Interval between checks when waiting for a VM to " + "become pingable"), + cfg.FloatOpt("vm_ping_timeout", default=120.0, + help="Time to wait for a VM to become pingable")] + +CONF = cfg.CONF +benchmark_group = cfg.OptGroup(name="benchmark", title="benchmark options") +CONF.register_opts(VM_BENCHMARK_OPTS, group=benchmark_group) + class VMScenario(base.Scenario): """Base class for VM scenarios with basic atomic actions. @@ -131,9 +143,9 @@ class VMScenario(base.Scenario): server_ip = netaddr.IPAddress(server_ip) utils.wait_for( server_ip, - is_ready=utils.resource_is(ICMP_UP_STATUS, - self._ping_ip_address), - timeout=120 + is_ready=utils.resource_is(ICMP_UP_STATUS, self._ping_ip_address), + timeout=CONF.benchmark.vm_ping_timeout, + check_interval=CONF.benchmark.vm_ping_poll_interval ) def _run_command(self, server_ip, port, username, password, command, diff --git a/tests/unit/plugins/openstack/scenarios/vm/test_utils.py b/tests/unit/plugins/openstack/scenarios/vm/test_utils.py index 7aad55ef..d933154c 100644 --- a/tests/unit/plugins/openstack/scenarios/vm/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/vm/test_utils.py @@ -18,11 +18,13 @@ import subprocess import mock import netaddr +from oslo_config import cfg from rally.plugins.openstack.scenarios.vm import utils from tests.unit import test VMTASKS_UTILS = "rally.plugins.openstack.scenarios.vm.utils" +CONF = cfg.CONF class VMScenarioTestCase(test.ScenarioTestCase): @@ -92,7 +94,8 @@ class VMScenarioTestCase(test.ScenarioTestCase): self.mock_wait_for.mock.assert_called_once_with( netaddr.IPAddress("1.2.3.4"), is_ready=self.mock_resource_is.mock.return_value, - timeout=120) + timeout=CONF.benchmark.vm_ping_timeout, + check_interval=CONF.benchmark.vm_ping_poll_interval) self.mock_resource_is.mock.assert_called_once_with( "ICMP UP", vm_scenario._ping_ip_address)