Merge "Check LB "provisioning_status" and improving Netcat Cirros HTTP stub"
This commit is contained in:
commit
2eaffed230
@ -68,9 +68,15 @@ class OctaviaCirrosServerStackFixture(_cirros.CirrosServerStackFixture):
|
||||
# clients connect at the same time. For concurrency testing,
|
||||
# OctaviaCentosServerStackFixture is more suited to handle multiple
|
||||
# requests.
|
||||
return ("#!/bin/sh\n"
|
||||
"sudo nc -k -p 80 -e echo -e \"HTTP/1.0 200 OK\r\n"
|
||||
"\r\n$(hostname)\"\n")
|
||||
|
||||
return (
|
||||
"#!/bin/sh\n"
|
||||
"sudo nc -k -p 80 -e echo -e \"HTTP/1.1 200 OK\r\n"
|
||||
"Content-Length: $(hostname | head -c-1 | wc -c )\r\n"
|
||||
"Server: $(hostname)\r\n"
|
||||
"Content-type: text/html; charset=utf-8\r\n"
|
||||
"Connection: close\r\n\r\n"
|
||||
"$(hostname)\"\n")
|
||||
|
||||
|
||||
class OctaviaServerStackFixture(OctaviaCirrosServerStackFixture):
|
||||
|
@ -61,6 +61,9 @@ class OctaviaBasicTrafficScenarioTest(octavia_base.OctaviaTest):
|
||||
self.listener_stack,
|
||||
self.member2_stack, self.request)
|
||||
|
||||
# Wait for LB is provisioned and ACTIVE
|
||||
waiters.wait_for_loadbalancer_is_active(self.loadbalancer_stack)
|
||||
|
||||
# Check if load balancer is functional
|
||||
waiters.wait_for_loadbalancer_functional(self.loadbalancer_stack,
|
||||
self.client_stack,
|
||||
|
@ -53,6 +53,32 @@ def wait_lb_operating_status(lb_id, operating_status):
|
||||
lb_id)
|
||||
|
||||
|
||||
def wait_resource_provisioning_status(resource_type, provisioning_status,
|
||||
resource_get, *args):
|
||||
start = time.time()
|
||||
|
||||
while time.time() - start < CONF.tobiko.octavia.check_timeout:
|
||||
res = resource_get(*args)
|
||||
if res['provisioning_status'] == provisioning_status:
|
||||
return
|
||||
|
||||
time.sleep(CONF.tobiko.octavia.check_interval)
|
||||
|
||||
raise exceptions.TimeoutException(
|
||||
reason=("Cannot get provisioning_status '{}' from {} {} "
|
||||
"within the timeout period.".format(provisioning_status,
|
||||
resource_type, args)))
|
||||
|
||||
|
||||
def wait_lb_provisioning_status(lb_id, provisioning_status):
|
||||
LOG.debug("Wait for loadbalancer {} to have '{}' "
|
||||
"provisioning_status".format(lb_id, provisioning_status))
|
||||
wait_resource_provisioning_status("loadbalancer",
|
||||
provisioning_status,
|
||||
octavia.get_loadbalancer,
|
||||
lb_id)
|
||||
|
||||
|
||||
def wait_for_request_data(client_stack, server_ip_address,
|
||||
server_protocol, server_port, request_function):
|
||||
"""Wait until a request on a server succeeds
|
||||
@ -79,6 +105,11 @@ def wait_for_request_data(client_stack, server_ip_address,
|
||||
server_ip_address, server_port, server_protocol)))
|
||||
|
||||
|
||||
def wait_for_loadbalancer_is_active(loadbalancer_stack):
|
||||
loadbalancer_id = loadbalancer_stack.loadbalancer_id
|
||||
wait_lb_provisioning_status(loadbalancer_id, 'ACTIVE')
|
||||
|
||||
|
||||
def wait_for_loadbalancer_functional(loadbalancer_stack, client_stack,
|
||||
loadbalancer_vip, loadbalancer_protocol,
|
||||
loadbalancer_port, request_function):
|
||||
|
Loading…
Reference in New Issue
Block a user