Fix Tox test of dex and oidc client

The dbapi.address_get_by_name function is returning a list now.  Zuul
log says "AttributeError: 'list' object has no attribute 'address'"

Add some debug and a length assertion, but use the first address in the
list.

Test Plan:
PASS  Zuul's tox execution passes with new logs

Closes-Bug: 2083724

Change-Id: I9cc6ffdd63de05465c54fcb5798bcad047ae5ac6
Signed-off-by: Michel Thebeau <Michel.Thebeau@windriver.com>
This commit is contained in:
Michel Thebeau 2024-09-20 13:42:23 +00:00
parent 17bda2e4d9
commit 495a7257a4
2 changed files with 34 additions and 2 deletions

View File

@ -33,12 +33,29 @@ class DexTestCase(test_plugins.K8SAppOidcAppMixin,
oam_addr_name = utils.format_address_name(constants.CONTROLLER_HOSTNAME,
constants.NETWORK_TYPE_OAM)
oam_address = self.dbapi.address_get_by_name(oam_addr_name)
config_issuer = "https://%s:30556/dex" % (utils.format_url_address(oam_address.address))
# add some debug printing
print("Number of addresses (%s): %s" %
(type(oam_address), len(oam_address)))
i = 0
while i < len(oam_address):
print("Address[%s]: %s" % (i, str(oam_address[i].address)))
i += 1
# There should be one address
oam_url = utils.format_url_address(oam_address[0].address)
print("Url Address: %s" % oam_url)
config_issuer = "https://%s:30556/dex" % oam_url
self.assertOverridesParameters(overrides, {
# issuer is set properly
'config': {'issuer': config_issuer}
})
# Complain if there is more than one address.
# It already failed if the list was empty
if len(oam_address) > 1:
raise ValueError("Too many addresses in returned list")
class DexIPv4ControllerHostTestCase(DexTestCase,
dbbase.ProvisionedControllerHostTestCase):

View File

@ -31,7 +31,17 @@ class OidcClientTestCase(test_plugins.K8SAppOidcAppMixin,
oam_addr_name = utils.format_address_name(constants.CONTROLLER_HOSTNAME,
constants.NETWORK_TYPE_OAM)
address = self.dbapi.address_get_by_name(oam_addr_name)
oam_url = utils.format_url_address(address.address)
# add some debug printing
print("Number of addresses (%s): %s" % (type(address), len(address)))
i = 0
while i < len(address):
print("Address[%s]: %s" % (i, str(address[i].address)))
i += 1
# There should be one address
oam_url = utils.format_url_address(address[0].address)
print("Url Address: %s" % oam_url)
parameters = {
'config': {
'issuer': 'https://%s:30556/dex' % oam_url,
@ -40,6 +50,11 @@ class OidcClientTestCase(test_plugins.K8SAppOidcAppMixin,
}
self.assertOverridesParameters(overrides, parameters)
# Complain if there is more than one address.
# It already failed if the list was empty
if len(address) > 1:
raise ValueError("Too many addresses in returned list")
class OidcClientIPv4ControllerHostTestCase(OidcClientTestCase,
dbbase.ProvisionedControllerHostTestCase):