Make regex in extra dhcp opts test less strict

In order to make test_extra_dhcp_opts_disabled_enabled_dhcp4 stable
even when nova dhcp_domain is configured and not depend on
inconsistent dhclient behavior [1] this patch makes regex searching
for the domain less strict.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=637763

Change-Id: Ie9fd08417fa48cd7874572344af25c655bd5ade9
This commit is contained in:
Roman Safronov 2024-06-20 17:44:23 +03:00
parent 9c71eed490
commit c937f9c942

View File

@ -226,7 +226,7 @@ class ExtraDhcpOptionsTest(base.BaseTempestTestCase):
# ipv4.domain is not expected
vm_resolv_conf = vm_ssh_client.exec_command(
"sudo dhclient && cat /etc/resolv.conf")
self.assertIsNone(re.search(r'^search\s+{}$'.format(domain_value),
self.assertIsNone(re.search(r'^search\s+{}\s+'.format(domain_value),
vm_resolv_conf,
re.MULTILINE))
@ -241,7 +241,10 @@ class ExtraDhcpOptionsTest(base.BaseTempestTestCase):
# ipv4.domain is expected
vm_resolv_conf = vm_ssh_client.exec_command(
"sudo dhclient && cat /etc/resolv.conf")
self.assertIsNotNone(re.search(r'^search\s+{}$'.format(domain_value),
# (rsafrono) this regex will work reliably even in case dhcp_domain in
# nova.conf is defined, i.e. not an empty value. Helps to stabilize
# the test on podified environments.
self.assertIsNotNone(re.search(r'^search\s+{}\s+'.format(domain_value),
vm_resolv_conf,
re.MULTILINE))