Fixing httpx requests with http2

It seems that passing http2=True is not longer enough to send an http2
request with httpx, http1=False needs to be passed as well

Change-Id: Ia748f8728a494799d34d7130df727b2055d04090
This commit is contained in:
Tom Weininger 2024-12-09 14:43:26 +01:00 committed by Gregory Thiemonge
parent 035e8b12d4
commit c32430072e
2 changed files with 15 additions and 23 deletions

View File

@ -1256,24 +1256,18 @@ class TLSWithBarbicanTest(test_base.LoadBalancerBaseTestWithCompute):
const.ACTIVE,
CONF.load_balancer.build_interval,
CONF.load_balancer.build_timeout)
# TODO(johnsom) - Remove this once eventlet is removed from OpenStack
# NOTE(pas-ha): depending on what other tempest plugins are installed
# the eventlet might've been imported by that time, and, since
# dnspython 2.2.0, importing eventlet or any part of it effectively
# instantiates a dummy httpx.Client instance, thus pinning the ssl
# implementation in httpx to the eventlet's one.
# This leads to error in the Client() call below, as the ssl lib in
# this module is different from ssl lib in httpx._config,
# which fails isinstance check for ssl.SSLContext.
# Use the ssl module that is actually used by httpx to instantiate
# the SSL context to be used with httpx.
ssl = httpx._config.ssl
context = ssl.create_default_context(cadata=self.ca_cert.public_bytes(
serialization.Encoding.PEM).decode('utf-8'))
context.check_hostname = False
url = 'https://%s:%s' % (self.lb_vip_address, 443)
client = httpx.Client(http2=(http_version == 'HTTP/2'), verify=context)
client_kwargs = {
'verify': context
}
if http_version == 'HTTP/2':
client_kwargs['http1'] = False
client_kwargs['http2'] = True
client = httpx.Client(**client_kwargs)
r = client.get(url)
self.assertEqual(http_version, r.http_version)
if hsts:

View File

@ -21,11 +21,10 @@
- octavia-v2-dsvm-scenario-non-traffic-ops-stable-2024-1
- octavia-v2-dsvm-scenario-traffic-ops-stable-2023-2
- octavia-v2-dsvm-scenario-non-traffic-ops-stable-2023-2
# TODO(gthiemonge) Re-enable this later, httpx workaround is broken
#- octavia-v2-dsvm-tls-barbican
#- octavia-v2-dsvm-tls-barbican-stable-2024-2
#- octavia-v2-dsvm-tls-barbican-stable-2024-1
#- octavia-v2-dsvm-tls-barbican-stable-2023-2
- octavia-v2-dsvm-tls-barbican
- octavia-v2-dsvm-tls-barbican-stable-2024-2
- octavia-v2-dsvm-tls-barbican-stable-2024-1
- octavia-v2-dsvm-tls-barbican-stable-2023-2
- octavia-v2-dsvm-scenario-ipv6-only:
voting: false
- octavia-v2-dsvm-scenario-centos-9-stream-traffic-ops:
@ -70,8 +69,7 @@
- octavia-v2-dsvm-scenario-non-traffic-ops-stable-2024-1
- octavia-v2-dsvm-scenario-traffic-ops-stable-2023-2
- octavia-v2-dsvm-scenario-non-traffic-ops-stable-2023-2
# TODO(gthiemonge) Re-enable this later, httpx workaround is broken
#- octavia-v2-dsvm-tls-barbican
#- octavia-v2-dsvm-tls-barbican-stable-2024-2
#- octavia-v2-dsvm-tls-barbican-stable-2024-1
#- octavia-v2-dsvm-tls-barbican-stable-2023-2
- octavia-v2-dsvm-tls-barbican
- octavia-v2-dsvm-tls-barbican-stable-2024-2
- octavia-v2-dsvm-tls-barbican-stable-2024-1
- octavia-v2-dsvm-tls-barbican-stable-2023-2