diff -Nru cloud-init-20.1-10-g71af48df/debian/changelog cloud-init-20.1-10-g71af48df/debian/changelog --- cloud-init-20.1-10-g71af48df/debian/changelog 2020-04-03 19:57:52.000000000 +0000 +++ cloud-init-20.1-10-g71af48df/debian/changelog 2020-04-16 15:23:08.000000000 +0000 @@ -1,3 +1,17 @@ +cloud-init (20.1-10-g71af48df-0ubuntu5) focal; urgency=medium + + * cherry-pick 0c5c7367: test_mounts: expand happy path test for both + happy paths + + -- Daniel Watkins Thu, 16 Apr 2020 11:23:08 -0400 + +cloud-init (20.1-10-g71af48df-0ubuntu4) focal; urgency=medium + + * cherry-pick 9d7b35ce: cc_mounts: fix incorrect format specifiers + (#316) (LP: #1872836) + + -- Chad Smith Wed, 15 Apr 2020 15:09:04 -0600 + cloud-init (20.1-10-g71af48df-0ubuntu3) focal; urgency=medium * d/patches: redact openbsd netbsd from tests until new-upstream-snapshot diff -Nru cloud-init-20.1-10-g71af48df/debian/patches/cpick-0c5c7367-test_mounts-expand-happy-path-test-for-both-happy-paths cloud-init-20.1-10-g71af48df/debian/patches/cpick-0c5c7367-test_mounts-expand-happy-path-test-for-both-happy-paths --- cloud-init-20.1-10-g71af48df/debian/patches/cpick-0c5c7367-test_mounts-expand-happy-path-test-for-both-happy-paths 1970-01-01 00:00:00.000000000 +0000 +++ cloud-init-20.1-10-g71af48df/debian/patches/cpick-0c5c7367-test_mounts-expand-happy-path-test-for-both-happy-paths 2020-04-16 15:23:08.000000000 +0000 @@ -0,0 +1,41 @@ +From 0c5c736727d0f8e363678fe970d70bb889e3893c Mon Sep 17 00:00:00 2001 +From: Daniel Watkins +Date: Thu, 16 Apr 2020 11:18:36 -0400 +Subject: [PATCH] test_mounts: expand happy path test for both happy paths + (#319) + +--- + cloudinit/config/tests/test_mounts.py | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/cloudinit/config/tests/test_mounts.py ++++ b/cloudinit/config/tests/test_mounts.py +@@ -1,6 +1,8 @@ + # This file is part of cloud-init. See LICENSE file for license information. + from unittest import mock + ++import pytest ++ + from cloudinit.config.cc_mounts import create_swapfile + + +@@ -9,8 +11,10 @@ M_PATH = 'cloudinit.config.cc_mounts.' + + class TestCreateSwapfile: + ++ @pytest.mark.parametrize('fstype', ('xfs', 'btrfs', 'ext4', 'other')) ++ @mock.patch(M_PATH + 'util.get_mount_info') + @mock.patch(M_PATH + 'util.subp') +- def test_happy_path(self, m_subp, tmpdir): ++ def test_happy_path(self, m_subp, m_get_mount_info, fstype, tmpdir): + swap_file = tmpdir.join("swap-file") + fname = str(swap_file) + +@@ -18,5 +22,7 @@ class TestCreateSwapfile: + # roughly approximates that + m_subp.side_effect = lambda *args, **kwargs: swap_file.write('') + ++ m_get_mount_info.return_value = (mock.ANY, fstype) ++ + create_swapfile(fname, '') + assert mock.call(['mkswap', fname]) in m_subp.call_args_list diff -Nru cloud-init-20.1-10-g71af48df/debian/patches/cpick-9d7b35ce-cc_mounts-fix-incorrect-format-specifiers-316 cloud-init-20.1-10-g71af48df/debian/patches/cpick-9d7b35ce-cc_mounts-fix-incorrect-format-specifiers-316 --- cloud-init-20.1-10-g71af48df/debian/patches/cpick-9d7b35ce-cc_mounts-fix-incorrect-format-specifiers-316 1970-01-01 00:00:00.000000000 +0000 +++ cloud-init-20.1-10-g71af48df/debian/patches/cpick-9d7b35ce-cc_mounts-fix-incorrect-format-specifiers-316 2020-04-16 15:23:08.000000000 +0000 @@ -0,0 +1,64 @@ +From 9d7b35ce23aaf8741dd49b16e359c96591be3c76 Mon Sep 17 00:00:00 2001 +From: Daniel Watkins +Date: Wed, 15 Apr 2020 16:53:08 -0400 +Subject: [PATCH] cc_mounts: fix incorrect format specifiers (#316) + +LP: #1872836 +--- + cloudinit/config/cc_mounts.py | 8 ++++---- + cloudinit/config/tests/test_mounts.py | 22 ++++++++++++++++++++++ + 2 files changed, 26 insertions(+), 4 deletions(-) + create mode 100644 cloudinit/config/tests/test_mounts.py + +--- a/cloudinit/config/cc_mounts.py ++++ b/cloudinit/config/cc_mounts.py +@@ -223,20 +223,20 @@ def suggested_swapsize(memsize=None, max + return size + + +-def create_swapfile(fname, size): ++def create_swapfile(fname: str, size: str) -> None: + """Size is in MiB.""" + +- errmsg = "Failed to create swapfile '%s' of size %dMB via %s: %s" ++ errmsg = "Failed to create swapfile '%s' of size %sMB via %s: %s" + + def create_swap(fname, size, method): + LOG.debug("Creating swapfile in '%s' on fstype '%s' using '%s'", + fname, fstype, method) + + if method == "fallocate": +- cmd = ['fallocate', '-l', '%dM' % size, fname] ++ cmd = ['fallocate', '-l', '%sM' % size, fname] + elif method == "dd": + cmd = ['dd', 'if=/dev/zero', 'of=%s' % fname, 'bs=1M', +- 'count=%d' % size] ++ 'count=%s' % size] + + try: + util.subp(cmd, capture=True) +--- /dev/null ++++ b/cloudinit/config/tests/test_mounts.py +@@ -0,0 +1,22 @@ ++# This file is part of cloud-init. See LICENSE file for license information. ++from unittest import mock ++ ++from cloudinit.config.cc_mounts import create_swapfile ++ ++ ++M_PATH = 'cloudinit.config.cc_mounts.' ++ ++ ++class TestCreateSwapfile: ++ ++ @mock.patch(M_PATH + 'util.subp') ++ def test_happy_path(self, m_subp, tmpdir): ++ swap_file = tmpdir.join("swap-file") ++ fname = str(swap_file) ++ ++ # Some of the calls to util.subp should create the swap file; this ++ # roughly approximates that ++ m_subp.side_effect = lambda *args, **kwargs: swap_file.write('') ++ ++ create_swapfile(fname, '') ++ assert mock.call(['mkswap', fname]) in m_subp.call_args_list diff -Nru cloud-init-20.1-10-g71af48df/debian/patches/series cloud-init-20.1-10-g71af48df/debian/patches/series --- cloud-init-20.1-10-g71af48df/debian/patches/series 2020-04-03 19:57:52.000000000 +0000 +++ cloud-init-20.1-10-g71af48df/debian/patches/series 2020-04-16 15:23:08.000000000 +0000 @@ -9,3 +9,5 @@ cpick-1bbc4908-distros-drop-leading-trailing-hyphens-from-mirror-URL cpick-09fea85f-net-ignore-renderer-key-in-netplan-config-306 fix-cpick-4fb6fd8a-net-ubuntu-focal-prioritize-netplan-over-eni.patch +cpick-9d7b35ce-cc_mounts-fix-incorrect-format-specifiers-316 +cpick-0c5c7367-test_mounts-expand-happy-path-test-for-both-happy-paths