summaryrefslogtreecommitdiff
path: root/tests/unittests/config/test_cc_puppet.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/config/test_cc_puppet.py')
-rw-r--r--tests/unittests/config/test_cc_puppet.py65
1 files changed, 31 insertions, 34 deletions
diff --git a/tests/unittests/config/test_cc_puppet.py b/tests/unittests/config/test_cc_puppet.py
index 23461c2b..9c55e9b5 100644
--- a/tests/unittests/config/test_cc_puppet.py
+++ b/tests/unittests/config/test_cc_puppet.py
@@ -1,5 +1,4 @@
# This file is part of cloud-init. See LICENSE file for license information.
-import logging
import textwrap
import pytest
@@ -16,8 +15,6 @@ from cloudinit.subp import ProcessExecutionError
from tests.unittests.helpers import CiTestCase, mock, skipUnlessJsonSchema
from tests.unittests.util import get_cloud
-LOG = logging.getLogger(__name__)
-
@pytest.fixture
def fake_tempdir(mocker, tmpdir):
@@ -36,7 +33,7 @@ class TestManagePuppetServices(CiTestCase):
self,
m_subp,
):
- cc_puppet._manage_puppet_services(LOG, self.cloud, "enable")
+ cc_puppet._manage_puppet_services(self.cloud, "enable")
expected_calls = [
mock.call(
["systemctl", "enable", "puppet-agent.service"],
@@ -49,7 +46,7 @@ class TestManagePuppetServices(CiTestCase):
self,
m_subp,
):
- cc_puppet._manage_puppet_services(LOG, self.cloud, "start")
+ cc_puppet._manage_puppet_services(self.cloud, "start")
expected_calls = [
mock.call(
["systemctl", "start", "puppet-agent.service"],
@@ -60,7 +57,7 @@ class TestManagePuppetServices(CiTestCase):
def test_enable_fallback_on_failure(self, m_subp):
m_subp.side_effect = (ProcessExecutionError, 0)
- cc_puppet._manage_puppet_services(LOG, self.cloud, "enable")
+ cc_puppet._manage_puppet_services(self.cloud, "enable")
expected_calls = [
mock.call(
["systemctl", "enable", "puppet-agent.service"],
@@ -90,7 +87,7 @@ class TestPuppetHandle(CiTestCase):
"""Cloud-config containing no 'puppet' key is skipped."""
cfg = {}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertIn("no 'puppet' configuration found", self.logs.getvalue())
self.assertEqual(0, m_man_puppet.call_count)
@@ -99,11 +96,11 @@ class TestPuppetHandle(CiTestCase):
"""Cloud-config 'puppet' configuration starts puppet."""
cfg = {"puppet": {"install": False}}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(2, m_man_puppet.call_count)
expected_calls = [
- mock.call(LOG, self.cloud, "enable"),
- mock.call(LOG, self.cloud, "start"),
+ mock.call(self.cloud, "enable"),
+ mock.call(self.cloud, "start"),
]
self.assertEqual(expected_calls, m_man_puppet.call_args_list)
@@ -113,7 +110,7 @@ class TestPuppetHandle(CiTestCase):
self.cloud.distro = mock.MagicMock()
cfg = {"puppet": {}}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(
[mock.call(("puppet-agent", None))],
self.cloud.distro.install_packages.call_args_list,
@@ -125,7 +122,7 @@ class TestPuppetHandle(CiTestCase):
self.cloud.distro = mock.MagicMock()
cfg = {"puppet": {"install": True}}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertIn(
[mock.call(("puppet-agent", None))],
self.cloud.distro.install_packages.call_args_list,
@@ -139,7 +136,7 @@ class TestPuppetHandle(CiTestCase):
distro = mock.MagicMock()
self.cloud.distro = distro
cfg = {"puppet": {"install": True, "install_type": "aio"}}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
m_aio.assert_called_with(
distro, cc_puppet.AIO_INSTALL_URL, None, None, True
)
@@ -160,7 +157,7 @@ class TestPuppetHandle(CiTestCase):
"install_type": "aio",
}
}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
m_aio.assert_called_with(
distro, cc_puppet.AIO_INSTALL_URL, "6.24.0", None, True
)
@@ -181,7 +178,7 @@ class TestPuppetHandle(CiTestCase):
"install_type": "aio",
}
}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
m_aio.assert_called_with(
distro, cc_puppet.AIO_INSTALL_URL, None, "puppet6", True
)
@@ -202,7 +199,7 @@ class TestPuppetHandle(CiTestCase):
"install_type": "aio",
}
}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
m_aio.assert_called_with(
distro, "http://test.url/path/to/script.sh", None, None, True
)
@@ -223,7 +220,7 @@ class TestPuppetHandle(CiTestCase):
"install_type": "aio",
}
}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
m_aio.assert_called_with(
distro, cc_puppet.AIO_INSTALL_URL, None, None, False
)
@@ -234,7 +231,7 @@ class TestPuppetHandle(CiTestCase):
self.cloud.distro = mock.MagicMock()
cfg = {"puppet": {"version": "3.8"}}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(
[mock.call(("puppet-agent", "3.8"))],
self.cloud.distro.install_packages.call_args_list,
@@ -259,7 +256,7 @@ class TestPuppetHandle(CiTestCase):
}
util.write_file(self.conf, "[agent]\nserver = origpuppet\nother = 3")
self.cloud.distro = mock.MagicMock()
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
content = util.load_file(self.conf)
expected = "[agent]\nserver = puppetserver.example.org\nother = 3\n\n"
self.assertEqual(expected, content)
@@ -296,7 +293,7 @@ class TestPuppetHandle(CiTestCase):
}
}
}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
content = util.load_file(self.csr_attributes_path)
expected = textwrap.dedent(
"""\
@@ -315,11 +312,11 @@ class TestPuppetHandle(CiTestCase):
"""Run puppet with default args if 'exec' is set to True."""
cfg = {"puppet": {"exec": True}}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(2, m_man_puppet.call_count)
expected_calls = [
- mock.call(LOG, self.cloud, "enable"),
- mock.call(LOG, self.cloud, "start"),
+ mock.call(self.cloud, "enable"),
+ mock.call(self.cloud, "start"),
]
self.assertEqual(expected_calls, m_man_puppet.call_args_list)
self.assertIn(
@@ -332,11 +329,11 @@ class TestPuppetHandle(CiTestCase):
"""Run puppet with default args if 'exec' is set to True."""
cfg = {"puppet": {}}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(2, m_man_puppet.call_count)
expected_calls = [
- mock.call(LOG, self.cloud, "enable"),
- mock.call(LOG, self.cloud, "start"),
+ mock.call(self.cloud, "enable"),
+ mock.call(self.cloud, "start"),
]
self.assertEqual(expected_calls, m_man_puppet.call_args_list)
@@ -345,7 +342,7 @@ class TestPuppetHandle(CiTestCase):
"""Run puppet with default args if 'exec' is set to True."""
cfg = {"puppet": {"start_service": False}}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(0, m_man_puppet.call_count)
self.assertNotIn(
[mock.call(["systemctl", "start", "puppet-agent"], capture=False)],
@@ -364,7 +361,7 @@ class TestPuppetHandle(CiTestCase):
"exec_args": ["--onetime", "--detailed-exitcodes"],
}
}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(2, m_man_puppet.call_count)
self.assertIn(
[
@@ -388,7 +385,7 @@ class TestPuppetHandle(CiTestCase):
"exec_args": "--onetime --detailed-exitcodes",
}
}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(2, m_man_puppet.call_count)
self.assertIn(
[
@@ -409,10 +406,10 @@ class TestPuppetHandle(CiTestCase):
# puppet-agent not installed, but puppet is
install_pkg.side_effect = (ProcessExecutionError, 0)
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
expected_calls = [
- mock.call(LOG, self.cloud, "enable"),
- mock.call(LOG, self.cloud, "start"),
+ mock.call(self.cloud, "enable"),
+ mock.call(self.cloud, "start"),
]
self.assertEqual(expected_calls, m_man_puppet.call_args_list)
@@ -425,7 +422,7 @@ class TestPuppetHandle(CiTestCase):
# puppet-agent not installed, but puppet is
install_pkg.side_effect = (ProcessExecutionError, 0)
with pytest.raises(ProcessExecutionError):
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(0, m_man_puppet.call_count)
self.assertNotIn(
[
@@ -439,7 +436,7 @@ class TestPuppetHandle(CiTestCase):
@mock.patch("cloudinit.config.cc_puppet.subp.subp", return_value=("", ""))
def test_puppet_with_conf_package_name_success(self, m_subp, m_man_puppet):
cfg = {"puppet": {"package_name": "puppet"}}
- cc_puppet.handle("notimportant", cfg, self.cloud, LOG, None)
+ cc_puppet.handle("notimportant", cfg, self.cloud, None)
self.assertEqual(2, m_man_puppet.call_count)