Fix traffic test - add curl timeout error

This patch fixes the timeout error we get at the traffic test, which
happens when we send the traffic to the loadbalancer when it is not
ready/stable.

Change-Id: Ia3eaa4f9dfddf29828a40f19b46127fd7e7a8e05
This commit is contained in:
Omer 2021-11-19 18:22:06 +01:00
parent e8a56bb2dc
commit eafd39720a
4 changed files with 20 additions and 7 deletions

View File

@ -45,6 +45,7 @@ RequestException = _exceptions.RequestException
TimeoutException = _exceptions.TimeoutException
OctaviaClientException = _exceptions.OctaviaClientException
RoundRobinException = _exceptions.RoundRobinException
TrafficTimeoutError = _exceptions.TrafficTimeoutError
# Constants
PROVISIONING_STATUS = _constants.PROVISIONING_STATUS

View File

@ -33,3 +33,7 @@ OctaviaClientException = exceptions.OctaviaClientException
class RoundRobinException(tobiko.TobikoException):
message = "Round robin exception: {reason}"
class TrafficTimeoutError(tobiko.TobikoException):
message = "Traffic timeout error: {reason}"

View File

@ -23,6 +23,7 @@ import tobiko
from tobiko.openstack import octavia
from tobiko.shell import curl
from tobiko.shell import ssh
from tobiko.shell import sh
LOG = log.getLogger(__name__)
@ -57,12 +58,18 @@ def check_members_balanced(ip_address: str,
replies: typing.Dict[str, int] = collections.defaultdict(lambda: 0)
for attempt in tobiko.retry(count=members_count * requests_count,
interval=interval):
content = curl.execute_curl(hostname=ip_address,
scheme=protocol,
port=port,
path='id',
connect_timeout=connect_timeout,
ssh_client=ssh_client).strip()
try:
content = curl.execute_curl(hostname=ip_address,
scheme=protocol,
port=port,
path='id',
connect_timeout=connect_timeout,
ssh_client=ssh_client).strip()
except sh.ShellCommandFailed as ex:
if ex.exit_status == 28:
raise octavia.TrafficTimeoutError(
reason=str(ex.stderr)) from ex
replies[content] += 1
if last_content is not None and lb_algorithm == 'ROUND_ROBIN':

View File

@ -86,7 +86,8 @@ class OctaviaBasicTrafficScenarioTest(testtools.TestCase):
break
except octavia.RoundRobinException as e:
except (octavia.RoundRobinException,
octavia.TrafficTimeoutError) as e:
if attempt.is_last:
raise e