Patch DNS lookups in Unit tests

Currently the unit testing suite has a minimal set of IPs
hard-coded (in the subnet 10.0.0.0/8). The failing unit tests call
functions that will perform DNS reverse lookups on the hard-coded
IPs. In the event that a DNS server is unavailable, or misconfigured,
the DNS lookups will result in a Python Exception being thrown,
causing the unit tests to fail.

This solution patches DNS lookups to return None result.

Also add OS_* to tox passenv to resolve the http proxy issue in
retrieving the cirros image.

Change-Id: I7a519fbe7fba5f3aefd22c57b8d44e3b39c99582
Closes-Bug: #1841806
This commit is contained in:
Edin Sarajlic 2019-09-02 09:17:05 +10:00 committed by Ryan Beisner
parent 9802c2ff1b
commit a6461cbb9f
No known key found for this signature in database
GPG Key ID: 952BACDC1C1A05FB
2 changed files with 3 additions and 1 deletions

View File

@ -14,7 +14,7 @@ install_command =
pip install {opts} {packages}
commands = stestr run {posargs}
whitelist_externals = juju
passenv = HOME TERM AMULET_* CS_API_*
passenv = HOME TERM AMULET_* CS_API_* OS_*
[testenv:py35]
basepython = python3.5

View File

@ -30,6 +30,7 @@ TO_PATCH = [
'charmhelpers.contrib.network.ip.get_iface_for_address',
'charmhelpers.contrib.network.ip.get_netmask_for_address',
'charmhelpers.contrib.network.ip.get_relation_ip',
'charmhelpers.contrib.network.ip.ns_query',
'charmhelpers.contrib.openstack.ha.utils.generate_ha_relation_data',
'charmhelpers.contrib.openstack.ha.utils.update_dns_ha_resource_params',
'charmhelpers.contrib.openstack.neutron.network_manager',
@ -98,6 +99,7 @@ class NovaCCHooksTests(CharmTestCase):
self.config.side_effect = self.test_config.get
self.relation_get.side_effect = self.test_relation.get
self.charm_dir.return_value = '/var/lib/juju/charms/nova/charm'
self.ns_query.return_value = None
self.is_unit_paused_set.return_value = False
# disable hardening for unit tests
harden._DISABLE_HARDENING_FOR_UNIT_TEST = True