-
-
Save igalic/7c6648aebe4b384e0138060b1f2c5d2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cloudinit/stages.py b/cloudinit/stages.py | |
index 765f4aab..24798705 100644 | |
--- a/cloudinit/stages.py | |
+++ b/cloudinit/stages.py | |
@@ -663,7 +663,7 @@ class Init(object): | |
return (None, cfg_source) | |
if ncfg: | |
return (ncfg, cfg_source) | |
- return (self.distro.generate_fallback_config(), | |
+ return (self.distro.networking.generate_fallback_config(), | |
NetworkConfigSource.fallback) | |
def _apply_netcfg_names(self, netcfg): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
◆ cloud-init git:(refactor-generate-fallback) ✗ ❯❯❯ tox -e py3 cloudinit/tests/test_stages.py::TestInit | |
GLOB sdist-make: /home/meena/src/cloud/cloud-init/setup.py | |
py3 inst-nodeps: /home/meena/src/cloud/cloud-init/.tox/.tmp/package/1/cloud-init-20.3.zip | |
py3 installed: attrs==20.2.0,certifi==2020.6.20,chardet==3.0.4,cloud-init @ file:///home/meena/src/cloud/cloud-init/.tox/.tmp/package/1/cloud-init-20.3.zip,configobj==5.0.6,coverage==5.3,httpretty==1.0.2,idna==2.10,iniconfig==1.0.1,Jinja2==2.11.2,jsonpatch==1.26,jsonpointer==2.0,jsonschema==3.2.0,MarkupSafe==1.1.1,oauthlib==3.1.0,packaging==20.4,pluggy==0.13.1,py==1.9.0,pyparsing==2.4.7,pyrsistent==0.17.3,pytest==6.1.1,pytest-cov==2.10.1,PyYAML==5.3.1,requests==2.24.0,six==1.15.0,toml==0.10.1,urllib3==1.25.10 | |
py3 run-test-pre: PYTHONHASHSEED='741989127' | |
py3 run-test: commands[0] | /home/meena/src/cloud/cloud-init/.tox/py3/bin/python -m pytest --durations 10 cloudinit/tests/test_stages.py::TestInit | |
========================================================= test session starts ========================================================== | |
platform linux -- Python 3.8.3, pytest-6.1.1, py-1.9.0, pluggy-0.13.1 | |
cachedir: .tox/py3/.pytest_cache | |
rootdir: /home/meena/src/cloud/cloud-init, configfile: tox.ini | |
plugins: cov-2.10.1 | |
collected 17 items | |
cloudinit/tests/test_stages.py .............F... [100%] | |
=============================================================== FAILURES =============================================================== | |
______________________________________ TestInit.test_wb__find_networking_config_returns_fallback _______________________________________ | |
self = <cloudinit.tests.test_stages.TestInit testMethod=test_wb__find_networking_config_returns_fallback> | |
m_cmdline = <MagicMock name='read_kernel_cmdline_config' id='140252780136096'> | |
m_initramfs = <MagicMock name='read_initramfs_config' id='140252780100864'> | |
@mock.patch('cloudinit.stages.cmdline.read_initramfs_config') | |
@mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config') | |
def test_wb__find_networking_config_returns_fallback( | |
self, m_cmdline, m_initramfs): | |
"""find_networking_config returns fallback config if not defined.""" | |
m_cmdline.return_value = {} # Kernel doesn't disable networking | |
m_initramfs.return_value = {} # no initramfs network config | |
# Neither datasource nor system_info disable or provide network | |
fake_cfg = {'config': [{'type': 'physical', 'name': 'eth9'}], | |
'version': 1} | |
def fake_generate_fallback(): | |
return fake_cfg | |
# Monkey patch distro which gets cached on self.init | |
distro = self.init.distro | |
distro.generate_fallback_config = fake_generate_fallback | |
self.assertEqual( | |
(fake_cfg, NetworkConfigSource.fallback), | |
> self.init._find_networking_config()) | |
cloudinit/tests/test_stages.py:258: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cloudinit/stages.py:666: in _find_networking_config | |
return (self.distro.networking.generate_fallback_config(), | |
cloudinit/distros/networking.py:216: in generate_fallback_config | |
target_name = self.find_fallback_nic( | |
cloudinit/distros/networking.py:44: in find_fallback_nic | |
return net.find_fallback_nic(blacklist_drivers=blacklist_drivers) | |
cloudinit/net/__init__.py:315: in find_fallback_nic | |
return find_fallback_nic_on_linux(blacklist_drivers) | |
cloudinit/net/__init__.py:352: in find_fallback_nic_on_linux | |
if 'net.ifnames=0' in util.get_cmdline(): | |
cloudinit/util.py:1346: in get_cmdline | |
return _get_cmdline() | |
cloudinit/util.py:1325: in _get_cmdline | |
if is_container(): | |
cloudinit/util.py:1956: in is_container | |
subp.subp(helper) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <cloudinit.tests.test_stages.TestInit testMethod=test_wb__find_networking_config_returns_fallback> | |
args = (['systemd-detect-virt', '--quiet', '--container'],), kwargs = {}, cmd = 'systemd-detect-virt', pass_through = False | |
def _fake_subp(self, *args, **kwargs): | |
if 'args' in kwargs: | |
cmd = kwargs['args'] | |
else: | |
if not args: | |
raise TypeError( | |
"subp() missing 1 required positional argument: 'args'") | |
cmd = args[0] | |
if not isinstance(cmd, str): | |
cmd = cmd[0] | |
pass_through = False | |
if not isinstance(self.allowed_subp, (list, bool)): | |
raise TypeError("self.allowed_subp supports list or bool.") | |
if isinstance(self.allowed_subp, bool): | |
pass_through = self.allowed_subp | |
else: | |
pass_through = ( | |
(cmd in self.allowed_subp) or | |
(self.SUBP_SHELL_TRUE in self.allowed_subp and | |
kwargs.get('shell'))) | |
if pass_through: | |
return _real_subp(*args, **kwargs) | |
> raise Exception( | |
"called subp. set self.allowed_subp=True to allow\n subp(%s)" % | |
', '.join([str(repr(a)) for a in args] + | |
["%s=%s" % (k, repr(v)) for k, v in kwargs.items()])) | |
E Exception: called subp. set self.allowed_subp=True to allow | |
E subp(['systemd-detect-virt', '--quiet', '--container']) | |
cloudinit/tests/helpers.py:165: Exception | |
========================================================= slowest 10 durations ========================================================= | |
0.05s call cloudinit/tests/test_stages.py::TestInit::test_apply_network_on_datasource_allowed_event | |
(9 durations < 0.005s hidden. Use -vv to show these durations.) | |
======================================================= short test summary info ======================================================== | |
FAILED cloudinit/tests/test_stages.py::TestInit::test_wb__find_networking_config_returns_fallback - Exception: called subp. set self.... | |
===================================================== 1 failed, 16 passed in 0.31s ===================================================== | |
ERROR: InvocationError for command /home/meena/src/cloud/cloud-init/.tox/py3/bin/python -m pytest --durations 10 cloudinit/tests/test_stages.py::TestInit (exited with code 1) | |
_______________________________________________________________ summary ________________________________________________________________ | |
ERROR: py3: commands failed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment