Use ubuntu servers as LB members
Change-Id: I0edc58b64cfdb3ed3ec6c5397afb1dc11b7406c4
This commit is contained in:
parent
35058b22d3
commit
af3ae474b7
|
@ -36,7 +36,7 @@ def check_members_balanced(ip_address: str,
|
||||||
members_count: int = None,
|
members_count: int = None,
|
||||||
lb_algorithm: str = None,
|
lb_algorithm: str = None,
|
||||||
requests_count: int = 10,
|
requests_count: int = 10,
|
||||||
connect_timeout: tobiko.Seconds = 2.,
|
connect_timeout: tobiko.Seconds = 10.,
|
||||||
interval: tobiko.Seconds = 1,
|
interval: tobiko.Seconds = 1,
|
||||||
ssh_client: ssh.SSHClientFixture = None) -> (
|
ssh_client: ssh.SSHClientFixture = None) -> (
|
||||||
typing.Dict[str, int]):
|
typing.Dict[str, int]):
|
||||||
|
|
|
@ -85,7 +85,6 @@ OctaviaLoadbalancerStackFixture = _octavia.OctaviaLoadbalancerStackFixture
|
||||||
OctaviaListenerStackFixture = _octavia.OctaviaListenerStackFixture
|
OctaviaListenerStackFixture = _octavia.OctaviaListenerStackFixture
|
||||||
OctaviaPoolStackFixture = _octavia.OctaviaPoolStackFixture
|
OctaviaPoolStackFixture = _octavia.OctaviaPoolStackFixture
|
||||||
OctaviaMemberServerStackFixture = _octavia.OctaviaMemberServerStackFixture
|
OctaviaMemberServerStackFixture = _octavia.OctaviaMemberServerStackFixture
|
||||||
OctaviaServerStackFixture = _octavia.OctaviaServerStackFixture
|
|
||||||
OctaviaOtherServerStackFixture = _octavia.OctaviaOtherServerStackFixture
|
OctaviaOtherServerStackFixture = _octavia.OctaviaOtherServerStackFixture
|
||||||
OctaviaOtherMemberServerStackFixture = (
|
OctaviaOtherMemberServerStackFixture = (
|
||||||
_octavia.OctaviaOtherMemberServerStackFixture)
|
_octavia.OctaviaOtherMemberServerStackFixture)
|
||||||
|
@ -100,7 +99,6 @@ OctaviaOvnProviderMemberServerStackFixture = (
|
||||||
_octavia.OctaviaOvnProviderMemberServerStackFixture)
|
_octavia.OctaviaOvnProviderMemberServerStackFixture)
|
||||||
OctaviaOvnProviderOtherMemberServerStackFixture = (
|
OctaviaOvnProviderOtherMemberServerStackFixture = (
|
||||||
_octavia.OctaviaOvnProviderOtherMemberServerStackFixture)
|
_octavia.OctaviaOvnProviderOtherMemberServerStackFixture)
|
||||||
OctaviaVipNetworkStackFixture = _octavia.OctaviaVipNetworkStackFixture
|
|
||||||
|
|
||||||
QosNetworkStackFixture = _qos.QosNetworkStackFixture
|
QosNetworkStackFixture = _qos.QosNetworkStackFixture
|
||||||
QosPolicyStackFixture = _qos.QosPolicyStackFixture
|
QosPolicyStackFixture = _qos.QosPolicyStackFixture
|
||||||
|
|
|
@ -19,67 +19,17 @@ import tobiko
|
||||||
from tobiko import config
|
from tobiko import config
|
||||||
from tobiko.openstack import heat
|
from tobiko.openstack import heat
|
||||||
from tobiko.openstack import octavia
|
from tobiko.openstack import octavia
|
||||||
from tobiko.openstack.stacks import _centos
|
|
||||||
from tobiko.openstack.stacks import _cirros
|
|
||||||
from tobiko.openstack.stacks import _hot
|
from tobiko.openstack.stacks import _hot
|
||||||
from tobiko.openstack.stacks import _neutron
|
from tobiko.openstack.stacks import _neutron
|
||||||
|
from tobiko.openstack.stacks import _ubuntu
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
|
|
||||||
|
|
||||||
class OctaviaVipNetworkStackFixture(_neutron.NetworkStackFixture):
|
|
||||||
# Load Balancer VIP network must use port security (required by neutron to
|
|
||||||
# support allowed address pairs on ports)
|
|
||||||
port_security_enabled = True
|
|
||||||
|
|
||||||
|
|
||||||
class OctaviaCentosServerStackFixture(_centos.CentosServerStackFixture):
|
|
||||||
network_stack = tobiko.required_setup_fixture(
|
|
||||||
OctaviaVipNetworkStackFixture)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def user_data(self):
|
|
||||||
# Launch a webserver on port 80 that replies the server name to the
|
|
||||||
# client
|
|
||||||
return ("#cloud-config\n"
|
|
||||||
"packages:\n"
|
|
||||||
"- httpd\n"
|
|
||||||
"runcmd:\n"
|
|
||||||
"- [ sh, -c, \"hostname > /var/www/html/id\" ]\n"
|
|
||||||
"- [ systemctl, enable, --now, httpd ]\n")
|
|
||||||
|
|
||||||
|
|
||||||
class OctaviaCirrosServerStackFixture(_cirros.CirrosServerStackFixture):
|
|
||||||
network_stack = tobiko.required_setup_fixture(
|
|
||||||
OctaviaVipNetworkStackFixture)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def user_data(self):
|
|
||||||
# Launch a webserver on port 80 that replies the server name to the
|
|
||||||
# client
|
|
||||||
# This webserver relies on the nc command which may fail if multiple
|
|
||||||
# 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.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):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class OctaviaLoadbalancerStackFixture(heat.HeatStackFixture):
|
class OctaviaLoadbalancerStackFixture(heat.HeatStackFixture):
|
||||||
template = _hot.heat_template_file('octavia/load_balancer.yaml')
|
template = _hot.heat_template_file('octavia/load_balancer.yaml')
|
||||||
|
|
||||||
vip_network = tobiko.required_setup_fixture(OctaviaVipNetworkStackFixture)
|
vip_network = tobiko.required_setup_fixture(_neutron.NetworkStackFixture)
|
||||||
|
|
||||||
#: Floating IP network where the Neutron floating IP are created
|
#: Floating IP network where the Neutron floating IP are created
|
||||||
@property
|
@property
|
||||||
|
@ -187,9 +137,9 @@ class OctaviaPoolStackFixture(heat.HeatStackFixture):
|
||||||
class OctaviaMemberServerStackFixture(heat.HeatStackFixture):
|
class OctaviaMemberServerStackFixture(heat.HeatStackFixture):
|
||||||
template = _hot.heat_template_file('octavia/member.yaml')
|
template = _hot.heat_template_file('octavia/member.yaml')
|
||||||
|
|
||||||
pool = tobiko.required_setup_fixture(OctaviaPoolStackFixture)
|
pool = tobiko.required_fixture(OctaviaPoolStackFixture)
|
||||||
|
|
||||||
server_stack = tobiko.required_setup_fixture(OctaviaServerStackFixture)
|
server_stack = tobiko.required_fixture(_ubuntu.UbuntuServerStackFixture)
|
||||||
|
|
||||||
application_port = 80
|
application_port = 80
|
||||||
|
|
||||||
|
@ -207,19 +157,11 @@ class OctaviaMemberServerStackFixture(heat.HeatStackFixture):
|
||||||
return self.server_stack.network_stack.ipv6_subnet_id
|
return self.server_stack.network_stack.ipv6_subnet_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def member_address(self):
|
def member_address(self) -> str:
|
||||||
return [
|
return str(self.server_stack.find_fixed_ip(ip_version=self.ip_version))
|
||||||
fixed_ip['ip_address']
|
|
||||||
for fixed_ip in self.server_stack.fixed_ips
|
|
||||||
if ((self.ip_version == 4 and
|
|
||||||
':' not in fixed_ip['ip_address']) or
|
|
||||||
(self.ip_version == 6 and
|
|
||||||
':' in fixed_ip['ip_address']))
|
|
||||||
][0]
|
|
||||||
|
|
||||||
|
|
||||||
class OctaviaOtherServerStackFixture(
|
class OctaviaOtherServerStackFixture(_ubuntu.UbuntuServerStackFixture):
|
||||||
OctaviaServerStackFixture):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import collections
|
||||||
import json
|
import json
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
import pytest
|
|
||||||
import testtools
|
import testtools
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
|
@ -75,12 +74,10 @@ class OctaviaBasicTrafficScenarioTest(testtools.TestCase):
|
||||||
lb_port=self.listener_stack.lb_port
|
lb_port=self.listener_stack.lb_port
|
||||||
)
|
)
|
||||||
|
|
||||||
@pytest.mark.flaky(reruns=3)
|
|
||||||
def test_round_robin_traffic(self):
|
def test_round_robin_traffic(self):
|
||||||
|
# For 5 minutes seconds we ignore specific exceptions as we know
|
||||||
# For 30 seconds we ignore specific exceptions as we know that Octavia
|
# that Octavia resources are being provisioned
|
||||||
# resources are being provisioned
|
for attempt in tobiko.retry(timeout=300.):
|
||||||
for attempt in tobiko.retry(timeout=30.):
|
|
||||||
try:
|
try:
|
||||||
octavia.check_members_balanced(
|
octavia.check_members_balanced(
|
||||||
pool_id=self.pool_stack.pool_id,
|
pool_id=self.pool_stack.pool_id,
|
||||||
|
@ -88,14 +85,13 @@ class OctaviaBasicTrafficScenarioTest(testtools.TestCase):
|
||||||
lb_algorithm=self.pool_stack.lb_algorithm,
|
lb_algorithm=self.pool_stack.lb_algorithm,
|
||||||
protocol=self.listener_stack.lb_protocol,
|
protocol=self.listener_stack.lb_protocol,
|
||||||
port=self.listener_stack.lb_port)
|
port=self.listener_stack.lb_port)
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
except (octavia.RoundRobinException,
|
except (octavia.RoundRobinException,
|
||||||
octavia.TrafficTimeoutError,
|
octavia.TrafficTimeoutError,
|
||||||
sh.ShellCommandFailed) as e:
|
sh.ShellCommandFailed) as e:
|
||||||
LOG.debug(f"Traffic couldn't reach for the #{attempt.count} "
|
LOG.exception(f"Traffic didn't reach all members after "
|
||||||
f"time, because of the next exception: {e}")
|
f"#{attempt.number} attempts and "
|
||||||
|
f"{attempt.elapsed_time} seconds")
|
||||||
if attempt.is_last:
|
if attempt.is_last:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue