Merge ~raharper/curtin:ubuntu/devel/newupstream-20181010 into curtin:ubuntu/devel

Proposed by Ryan Harper
Status: Merged
Merged at revision: e1ff13f28deee6446db8a7bef26ae3c32e63307d
Proposed branch: ~raharper/curtin:ubuntu/devel/newupstream-20181010
Merge into: curtin:ubuntu/devel
Diff against target: 168 lines (+95/-9)
5 files modified
curtin/distro.py (+3/-3)
debian/changelog (+10/-0)
tests/unittests/test_distro.py (+75/-4)
tests/vmtests/__init__.py (+1/-0)
tools/curtin-from-container (+6/-2)
Reviewer Review Type Date Requested Status
curtin developers Pending
Review via email: mp+356420@code.launchpad.net

Commit message

curtin (18.1-59-g0f993084-0ubuntu1) cosmic; urgency=medium

  * New upstream snapshot.
    - distro: fix system_upgrade command using string instead of function
      (LP: #1796968)
    - Capture stdout when using lxc file push
    - vmtest: boot ephemeral with 'ro' on the kernel command line.

 -- Ryan Harper <email address hidden> Wed, 10 Oct 2018 11:22:30 -0500

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/distro.py b/curtin/distro.py
2index f2a78ed..9714515 100644
3--- a/curtin/distro.py
4+++ b/curtin/distro.py
5@@ -337,10 +337,10 @@ def system_upgrade(opts=None, target=None, env=None, allow_daemons=False,
6 LOG.debug("Upgrading system in %s", target)
7
8 distro_cfg = {
9- DISTROS.debian: {'function': 'run_apt_command',
10+ DISTROS.debian: {'function': run_apt_command,
11 'subcommands': ('dist-upgrade', 'autoremove')},
12- DISTROS.redhat: {'function': 'run_yum_command',
13- 'subcommands': ('upgrade')},
14+ DISTROS.redhat: {'function': run_yum_command,
15+ 'subcommands': ('upgrade',)},
16 }
17 if osfamily not in distro_cfg:
18 raise ValueError('Distro "%s" does not have system_upgrade support',
19diff --git a/debian/changelog b/debian/changelog
20index 4f5237f..89bb20f 100644
21--- a/debian/changelog
22+++ b/debian/changelog
23@@ -1,3 +1,13 @@
24+curtin (18.1-59-g0f993084-0ubuntu1) cosmic; urgency=medium
25+
26+ * New upstream snapshot.
27+ - distro: fix system_upgrade command using string instead of function
28+ (LP: #1796968)
29+ - Capture stdout when using lxc file push
30+ - vmtest: boot ephemeral with 'ro' on the kernel command line.
31+
32+ -- Ryan Harper <ryan.harper@canonical.com> Wed, 10 Oct 2018 11:22:30 -0500
33+
34 curtin (18.1-56-g3aafe77d-0ubuntu1) cosmic; urgency=medium
35
36 * New upstream snapshot.
37diff --git a/tests/unittests/test_distro.py b/tests/unittests/test_distro.py
38index d4e5a1e..b079162 100644
39--- a/tests/unittests/test_distro.py
40+++ b/tests/unittests/test_distro.py
41@@ -235,21 +235,92 @@ class TestYumInstall(CiTestCase):
42 ]
43
44 # call yum_install directly
45+ self.assertFalse(m_subp.called)
46 distro.yum_install(mode, pkglist, target=target)
47 m_subp.assert_has_calls(expected_calls)
48
49- # call yum_install through run_yum_command
50- m_subp.reset()
51+ # call yum_install through run_yum_command; expect the same calls
52+ # so clear m_subp's call stack.
53+ m_subp.reset_mock()
54+ self.assertFalse(m_subp.called)
55 distro.run_yum_command('install', pkglist, target=target)
56 m_subp.assert_has_calls(expected_calls)
57
58- # call yum_install through install_packages
59- m_subp.reset()
60+ # call yum_install through install_packages; expect the same calls
61+ # so clear m_subp's call stack.
62+ m_subp.reset_mock()
63+ self.assertFalse(m_subp.called)
64 osfamily = distro.DISTROS.redhat
65 distro.install_packages(pkglist, osfamily=osfamily, target=target)
66 m_subp.assert_has_calls(expected_calls)
67
68
69+class TestSystemUpgrade(CiTestCase):
70+
71+ @mock.patch.object(util.ChrootableTarget, "__enter__", new=lambda a: a)
72+ @mock.patch('curtin.util.subp')
73+ def test_system_upgrade_redhat(self, m_subp):
74+ """system_upgrade osfamily=redhat calls run_yum_command mode=upgrade"""
75+ osfamily = distro.DISTROS.redhat
76+ target = 'mytarget'
77+ mode = 'upgrade'
78+ pkglist = []
79+ expected_calls = [
80+ mock.call(['yum', '--assumeyes', '--quiet', mode,
81+ '--downloadonly', '--setopt=keepcache=1'] + pkglist,
82+ env=None, retries=[1] * 10,
83+ target=paths.target_path(target)),
84+ mock.call(['yum', '--assumeyes', '--quiet', mode,
85+ '--cacheonly'] + pkglist, env=None,
86+ target=paths.target_path(target))
87+ ]
88+ # call system_upgrade via osfamily; note that we expect the same calls
89+ # call system_upgrade via osfamily; note that we expect the same calls
90+
91+ # call yum_install through run_yum_command
92+ distro.run_yum_command(mode, pkglist, target=target)
93+ m_subp.assert_has_calls(expected_calls)
94+
95+ # call system_upgrade via osfamily; note that we expect the same calls
96+ # but to prevent a false positive we clear m_subp's call stack.
97+ m_subp.reset_mock()
98+ self.assertFalse(m_subp.called)
99+ distro.system_upgrade(target=target, osfamily=osfamily)
100+ m_subp.assert_has_calls(expected_calls)
101+
102+ @mock.patch.object(util.ChrootableTarget, "__enter__", new=lambda a: a)
103+ @mock.patch('curtin.distro.os.environ')
104+ @mock.patch('curtin.distro.apt_update')
105+ @mock.patch('curtin.distro.which')
106+ @mock.patch('curtin.util.subp')
107+ def test_system_upgrade_debian(self, m_subp, m_which, m_apt_update, m_env):
108+ """system_upgrade osfamily=debian calls run_apt_command mode=upgrade"""
109+ osfamily = distro.DISTROS.debian
110+ target = 'mytarget'
111+ m_env.copy.return_value = {}
112+ m_which.return_value = None
113+ env = {'DEBIAN_FRONTEND': 'noninteractive'}
114+ pkglist = []
115+ apt_base = [
116+ 'apt-get', '--quiet', '--assume-yes',
117+ '--option=Dpkg::options::=--force-unsafe-io',
118+ '--option=Dpkg::Options::=--force-confold']
119+ apt_cmd = apt_base + ['dist-upgrade'] + pkglist
120+ auto_remove = apt_base + ['autoremove']
121+ expected_calls = [
122+ mock.call(apt_cmd, env=env, target=paths.target_path(target)),
123+ mock.call(auto_remove, env=env, target=paths.target_path(target)),
124+ ]
125+ which_calls = [mock.call('eatmydata', target=target)]
126+ apt_update_calls = [
127+ mock.call(target, env=env, comment=' '.join(apt_cmd))]
128+
129+ distro.system_upgrade(target=target, osfamily=osfamily)
130+ m_which.assert_has_calls(which_calls)
131+ m_apt_update.assert_has_calls(apt_update_calls)
132+ m_subp.assert_has_calls(expected_calls)
133+
134+
135 class TestHasPkgAvailable(CiTestCase):
136
137 def setUp(self):
138diff --git a/tests/vmtests/__init__.py b/tests/vmtests/__init__.py
139index af75599..3823e39 100644
140--- a/tests/vmtests/__init__.py
141+++ b/tests/vmtests/__init__.py
142@@ -887,6 +887,7 @@ class VMBaseClass(TestCase):
143 cmd.extend([
144 "--root-arg=root=%s" % root_url,
145 "--append=overlayroot=tmpfs",
146+ "--append=ro",
147 ])
148
149 # getting resolvconf configured is only fixed in bionic
150diff --git a/tools/curtin-from-container b/tools/curtin-from-container
151index ed7d1fc..7addd1a 100755
152--- a/tools/curtin-from-container
153+++ b/tools/curtin-from-container
154@@ -63,8 +63,12 @@ send() {
155 return
156 }
157
158- lxc file push "$fpath" "$name/$prefix/$afile" || {
159- rerror "failed: lxc file push '$fpath' '$name/$prefix/$afile'"
160+ # 'lxc file' command may write progress info to stdout which breaks
161+ # this program when called as 'curtin pack' as it needs to write the
162+ # payload to stdout. LXD issue #2683
163+ local out=""
164+ out=$(lxc file push "$fpath" "$name/$prefix/$afile" 2>&1) || {
165+ rerror "failed: lxc file push '$fpath' '$name/$prefix/$afile': $out"
166 return
167 }
168 _RET="$afile:$prefix/$afile"

Subscribers

People subscribed via source and target branches