Adds API and scenario tests for STATS listeners.

This patch adds API and scenario tests for STATS listeners. This
includes scenario tests that connect to the new stats and metrics
endpoints.

Depends-On: https://review.opendev.org/c/openstack/octavia/+/812258
Change-Id: Ia46d8c0967bc5b0f7cd11b6e3ca3a4e03c0bc138
This commit is contained in:
Michael Johnson 2021-10-02 19:58:34 +00:00
parent ec23dbc276
commit 713ce63868
5 changed files with 199 additions and 0 deletions

View File

@ -130,6 +130,7 @@ SUPPORTED_LB_TOPOLOGIES = (SINGLE, ACTIVE_STANDBY)
HTTP = 'HTTP'
HTTPS = 'HTTPS'
PROXY = 'PROXY'
STATS = 'STATS'
TCP = 'TCP'
TERMINATED_HTTPS = 'TERMINATED_HTTPS'
UDP = 'UDP'

View File

@ -285,6 +285,12 @@ LBFeatureEnabledGroup = [
help="Whether the log offload tests will run. These require "
"the tempest instance have access to the log files "
"specified in the tempest configuration."),
cfg.BoolOpt('stats_listener_enabled', default=True,
help="Whether the STATS listener tests will run."),
cfg.BoolOpt('stats_listener_stats_enabled', default=True,
help="Whether the STATS listener stats page tests will run."),
cfg.BoolOpt('stats_listener_metrics_enabled', default=True,
help="Whether the STATS listener metrics tests will run."),
]
# Extending this enforce_scope group defined in tempest

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import testtools
import time
from uuid import UUID
@ -79,6 +80,17 @@ class ListenerAPITest(test_base.LoadBalancerBaseTest):
def test_tcp_listener_create(self):
self._test_listener_create(const.TCP, 8002)
@decorators.idempotent_id('1a6ba0d0-f309-4088-a686-dda0e9ab7e43')
@testtools.skipUnless(
CONF.loadbalancer_feature_enabled.stats_listener_enabled,
'STATS listener tests are disabled in the tempest configuration.')
def test_stats_listener_create(self):
if not self.mem_listener_client.is_version_supported(
self.api_version, '2.25'):
raise self.skipException('STATS listeners are only available on '
'Octavia API version 2.25 or newer.')
self._test_listener_create(const.STATS, 8090)
@decorators.idempotent_id('7b53f336-47bc-45ae-bbd7-4342ef0673fc')
# Skipping due to a status update bug in the amphora driver.
@decorators.skip_because(
@ -369,6 +381,17 @@ class ListenerAPITest(test_base.LoadBalancerBaseTest):
def test_https_listener_list(self):
self._test_listener_list(const.HTTPS, 8030)
@decorators.idempotent_id('5473e071-8277-4ac5-9277-01ecaf46e274')
@testtools.skipUnless(
CONF.loadbalancer_feature_enabled.stats_listener_enabled,
'STATS listener tests are disabled in the tempest configuration.')
def test_stats_listener_list(self):
if not self.mem_listener_client.is_version_supported(
self.api_version, '2.25'):
raise self.skipException('STATS listeners are only available on '
'Octavia API version 2.25 or newer.')
self._test_listener_list(const.STATS, 8091)
@decorators.idempotent_id('1cd476e2-7788-415e-bcaf-c377acfc9794')
def test_tcp_listener_list(self):
self._test_listener_list(const.TCP, 8030)
@ -730,6 +753,17 @@ class ListenerAPITest(test_base.LoadBalancerBaseTest):
def test_https_listener_show(self):
self._test_listener_show(const.HTTPS, 8051)
@decorators.idempotent_id('b851b754-4333-4115-9063-a9fce44c2e46')
@testtools.skipUnless(
CONF.loadbalancer_feature_enabled.stats_listener_enabled,
'STATS listener tests are disabled in the tempest configuration.')
def test_stats_listener_show(self):
if not self.mem_listener_client.is_version_supported(
self.api_version, '2.25'):
raise self.skipException('STATS listeners are only available on '
'Octavia API version 2.25 or newer.')
self._test_listener_show(const.STATS, 8092)
@decorators.idempotent_id('1fcbbee2-b697-4890-b6bf-d308ac1c94cd')
def test_tcp_listener_show(self):
self._test_listener_show(const.TCP, 8052)
@ -883,6 +917,17 @@ class ListenerAPITest(test_base.LoadBalancerBaseTest):
def test_https_listener_update(self):
self._test_listener_update(const.HTTPS, 8061)
@decorators.idempotent_id('cbba6bf8-9184-4da5-95e9-5efe1f89ddf0')
@testtools.skipUnless(
CONF.loadbalancer_feature_enabled.stats_listener_enabled,
'STATS listener tests are disabled in the tempest configuration.')
def test_stats_listener_update(self):
if not self.mem_listener_client.is_version_supported(
self.api_version, '2.25'):
raise self.skipException('STATS listeners are only available on '
'Octavia API version 2.25 or newer.')
self._test_listener_update(const.STATS, 8093)
@decorators.idempotent_id('8d933121-db03-4ccc-8b77-4e879064a9ba')
def test_tcp_listener_update(self):
self._test_listener_update(const.TCP, 8062)
@ -1145,6 +1190,17 @@ class ListenerAPITest(test_base.LoadBalancerBaseTest):
def test_https_listener_delete(self):
self._test_listener_delete(const.HTTPS, 8071)
@decorators.idempotent_id('322a6372-6b56-4a3c-87e3-dd82074bc83e')
@testtools.skipUnless(
CONF.loadbalancer_feature_enabled.stats_listener_enabled,
'STATS listener tests are disabled in the tempest configuration.')
def test_stats_listener_delete(self):
if not self.mem_listener_client.is_version_supported(
self.api_version, '2.25'):
raise self.skipException('STATS listeners are only available on '
'Octavia API version 2.25 or newer.')
self._test_listener_delete(const.STATS, 8094)
@decorators.idempotent_id('f5ca019d-2b33-48f9-9c2d-2ec169b423ca')
def test_tcp_listener_delete(self):
self._test_listener_delete(const.TCP, 8072)

View File

@ -1402,3 +1402,135 @@ class TrafficOperationsScenarioTest(test_base.LoadBalancerBaseTestWithCompute):
self._test_basic_traffic(const.UDP, common_vip_port, pool_id_udp)
self._test_basic_traffic(const.TCP, common_vip_port, pool_id_tcp,
persistent=False)
@decorators.idempotent_id('9bbd9f2a-f71e-47aa-ba61-33c6c09dc88a')
@testtools.skipUnless(
CONF.loadbalancer_feature_enabled.stats_listener_enabled,
'STATS listener tests are disabled in the tempest configuration.')
@testtools.skipUnless(
CONF.loadbalancer_feature_enabled.stats_listener_stats_enabled,
'STATS listener stats page tests are disabled in the tempest '
'configuration.')
def test_stats_listener_stats_page(self):
"""Tests stats listener create and stats web page available
* Create STATS listener.
* Query the stats web page on the load balancer.
"""
if not self.mem_listener_client.is_version_supported(
self.api_version, '2.25'):
raise self.skipException('STATS listeners are only available on '
'Octavia API version 2.25 or newer.')
# Listener create
listener_name = data_utils.rand_name("lb_member_stats_listener-stats")
listener_description = data_utils.arbitrary_string(size=255)
listener_kwargs = {
const.NAME: listener_name,
const.DESCRIPTION: listener_description,
const.ADMIN_STATE_UP: True,
const.PROTOCOL: const.STATS,
const.PROTOCOL_PORT: 8080,
const.LOADBALANCER_ID: self.lb_id,
const.CONNECTION_LIMIT: 200,
}
if self.mem_listener_client.is_version_supported(
self.api_version, '2.1'):
listener_kwargs.update({
const.TIMEOUT_CLIENT_DATA: 1000,
const.TIMEOUT_MEMBER_CONNECT: 1000,
const.TIMEOUT_MEMBER_DATA: 1000,
const.TIMEOUT_TCP_INSPECT: 50,
})
if self.mem_listener_client.is_version_supported(
self.api_version, '2.12'):
listener_kwargs.update({const.ALLOWED_CIDRS: ['0.0.0.0/0']})
listener = self.mem_listener_client.create_listener(**listener_kwargs)
self.addCleanup(
self.mem_listener_client.cleanup_listener,
listener[const.ID],
lb_client=self.mem_lb_client, lb_id=self.lb_id)
waiters.wait_for_status(
self.mem_lb_client.show_loadbalancer, self.lb_id,
const.PROVISIONING_STATUS, const.ACTIVE,
CONF.load_balancer.build_interval,
CONF.load_balancer.build_timeout)
listener = waiters.wait_for_status(
self.mem_listener_client.show_listener,
listener[const.ID], const.PROVISIONING_STATUS,
const.ACTIVE,
CONF.load_balancer.build_interval,
CONF.load_balancer.build_timeout)
# Make a request to the stats page
URL = 'http://{0}:{1}/stats'.format(self.lb_vip_address, '8080')
self.validate_URL_response(URL, expected_status_code=200)
@decorators.idempotent_id('05e99fb3-2b37-478e-889b-77f1c731a471')
@testtools.skipUnless(
CONF.loadbalancer_feature_enabled.stats_listener_enabled,
'STATS listener tests are disabled in the tempest configuration.')
@testtools.skipUnless(
CONF.loadbalancer_feature_enabled.stats_listener_metrics_enabled,
'STATS listener metrics endpoint tests are disabled in the tempest '
'configuration.')
def test_stats_listener_metrics_page(self):
"""Tests stats listener create and metrics endpoint is available
* Create STATS listener.
* Query the metrics endpoint on the load balancer.
"""
if not self.mem_listener_client.is_version_supported(
self.api_version, '2.25'):
raise self.skipException('STATS listeners are only available on '
'Octavia API version 2.25 or newer.')
# Listener create
listener_name = data_utils.rand_name("lb_member_stats_listener-stats")
listener_description = data_utils.arbitrary_string(size=255)
listener_kwargs = {
const.NAME: listener_name,
const.DESCRIPTION: listener_description,
const.ADMIN_STATE_UP: True,
const.PROTOCOL: const.STATS,
const.PROTOCOL_PORT: 8080,
const.LOADBALANCER_ID: self.lb_id,
const.CONNECTION_LIMIT: 200,
}
if self.mem_listener_client.is_version_supported(
self.api_version, '2.1'):
listener_kwargs.update({
const.TIMEOUT_CLIENT_DATA: 1000,
const.TIMEOUT_MEMBER_CONNECT: 1000,
const.TIMEOUT_MEMBER_DATA: 1000,
const.TIMEOUT_TCP_INSPECT: 50,
})
if self.mem_listener_client.is_version_supported(
self.api_version, '2.12'):
listener_kwargs.update({const.ALLOWED_CIDRS: ['0.0.0.0/0']})
listener = self.mem_listener_client.create_listener(**listener_kwargs)
self.addCleanup(
self.mem_listener_client.cleanup_listener,
listener[const.ID],
lb_client=self.mem_lb_client, lb_id=self.lb_id)
waiters.wait_for_status(
self.mem_lb_client.show_loadbalancer, self.lb_id,
const.PROVISIONING_STATUS, const.ACTIVE,
CONF.load_balancer.build_interval,
CONF.load_balancer.build_timeout)
listener = waiters.wait_for_status(
self.mem_listener_client.show_listener,
listener[const.ID], const.PROVISIONING_STATUS,
const.ACTIVE,
CONF.load_balancer.build_interval,
CONF.load_balancer.build_timeout)
# Make a request to the stats page
URL = 'http://{0}:{1}/metrics'.format(self.lb_vip_address, '8080')
self.validate_URL_response(URL, expected_status_code=200)

View File

@ -0,0 +1,4 @@
---
features:
- |
Added API and scenario tests for STATS listeners.