Skip to content

Commit

Permalink
Adjust scenario tests for NotImplemented skip
Browse files Browse the repository at this point in the history
This is a patch to restructrue the scenario tests to use the
new skip_if_not_implemented capability.

Change-Id: I49a7fb6650030f2a1115c6d42442062bd33415fd
  • Loading branch information
johnsom committed Sep 4, 2020
1 parent c611b45 commit 89bdbcd
Show file tree
Hide file tree
Showing 16 changed files with 2,274 additions and 655 deletions.
1 change: 1 addition & 0 deletions octavia_tempest_plugin/common/constants.py
Expand Up @@ -124,6 +124,7 @@
# Protocols
HTTP = 'HTTP'
HTTPS = 'HTTPS'
PROXY = 'PROXY'
TCP = 'TCP'
TERMINATED_HTTPS = 'TERMINATED_HTTPS'
UDP = 'UDP'
Expand Down
32 changes: 32 additions & 0 deletions octavia_tempest_plugin/common/requests_adapters.py
@@ -0,0 +1,32 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import socket

from requests.adapters import HTTPAdapter
from requests.packages.urllib3.connection import HTTPConnection
from requests.packages.urllib3.poolmanager import PoolManager


class SourcePortAdapter(HTTPAdapter):
""""Transport adapter" that allows us to set the source port."""
def __init__(self, port, *args, **kwargs):
self._source_port = port
super(SourcePortAdapter, self).__init__(*args, **kwargs)

def init_poolmanager(self, connections, maxsize, block=False):
# Make sure TIMED_WAIT doesn't stop us from reusing the socket
sock_options = HTTPConnection.default_socket_options + [
(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1), ]
self.poolmanager = PoolManager(
num_pools=connections, maxsize=maxsize,
block=block, source_address=('', self._source_port),
socket_options=sock_options)
Expand Up @@ -41,11 +41,6 @@ class TLSWithBarbicanTest(test_base.LoadBalancerBaseTestWithCompute):
@classmethod
def skip_checks(cls):
super(TLSWithBarbicanTest, cls).skip_checks()
if not CONF.loadbalancer_feature_enabled.l7_protocol_enabled:
raise cls.skipException(
'[loadbalancer_feature_enabled] "l7_protocol_enabled" is '
'False in the tempest configuration. TLS tests will be '
'skipped.')
if not CONF.loadbalancer_feature_enabled.terminated_tls_enabled:
raise cls.skipException(
'[loadbalancer-feature-enabled] "terminated_tls_enabled" is '
Expand Down Expand Up @@ -308,8 +303,8 @@ def test_basic_tls_traffic(self):

# Test HTTPS listener load balancing.
# Note: certificate validation tests will follow this test
self.check_members_balanced(self.lb_vip_address, protocol='https',
verify=False, protocol_port=443)
self.check_members_balanced(self.lb_vip_address, protocol=const.HTTPS,
HTTPS_verify=False, protocol_port=443)

def _verify_cb(connection, x509, errno, errdepth, retcode):
"""Callback for certificate validation."""
Expand Down Expand Up @@ -394,8 +389,8 @@ def test_mixed_http_https_traffic(self):

# Test HTTPS listener load balancing.
# Note: certificate validation tests will follow this test
self.check_members_balanced(self.lb_vip_address, protocol='https',
verify=False, protocol_port=443)
self.check_members_balanced(self.lb_vip_address, protocol=const.HTTPS,
HTTPS_verify=False, protocol_port=443)

# Test HTTP listener load balancing.
self.check_members_balanced(self.lb_vip_address)
Expand Down Expand Up @@ -429,8 +424,8 @@ def test_basic_tls_SNI_traffic(self):

# Test HTTPS listener load balancing.
# Note: certificate validation tests will follow this test
self.check_members_balanced(self.lb_vip_address, protocol='https',
verify=False, protocol_port=443)
self.check_members_balanced(self.lb_vip_address, protocol=const.HTTPS,
HTTPS_verify=False, protocol_port=443)

def _verify_server_cb(connection, x509, errno, errdepth, retcode):
return _verify_cb(connection, x509, errno, errdepth, retcode,
Expand Down Expand Up @@ -562,8 +557,8 @@ def test_basic_tls_SNI_multi_listener_traffic(self):

# Test HTTPS listener load balancing.
# Note: certificate validation tests will follow this test
self.check_members_balanced(self.lb_vip_address, protocol='https',
verify=False, protocol_port=443)
self.check_members_balanced(self.lb_vip_address, protocol=const.HTTPS,
HTTPS_verify=False, protocol_port=443)

listener2_name = data_utils.rand_name("lb_member_listener2-tls-sni")
listener2_kwargs = {
Expand All @@ -590,8 +585,8 @@ def test_basic_tls_SNI_multi_listener_traffic(self):

# Test HTTPS listener load balancing.
# Note: certificate validation tests will follow this test
self.check_members_balanced(self.lb_vip_address, protocol='https',
verify=False, protocol_port=8443)
self.check_members_balanced(self.lb_vip_address, protocol=const.HTTPS,
HTTPS_verify=False, protocol_port=8443)

def _verify_server_cb(connection, x509, errno, errdepth, retcode):
return _verify_cb(connection, x509, errno, errdepth, retcode,
Expand Down

0 comments on commit 89bdbcd

Please sign in to comment.