Merge lp:~sil2100/ubuntu-release-upgrader/snap-core18-from-stable into lp:ubuntu-release-upgrader

Proposed by Łukasz Zemczak
Status: Merged
Merged at revision: 3281
Proposed branch: lp:~sil2100/ubuntu-release-upgrader/snap-core18-from-stable
Merge into: lp:ubuntu-release-upgrader
Prerequisite: lp:~sil2100/ubuntu-release-upgrader/snap-size-estimation
Diff against target: 195 lines (+78/-34)
2 files modified
DistUpgrade/DistUpgradeQuirks.py (+15/-8)
tests/test_quirks.py (+63/-26)
To merge this branch: bzr merge lp:~sil2100/ubuntu-release-upgrader/snap-core18-from-stable
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+372082@code.launchpad.net

Commit message

Make sure snaps like core18 are not refreshed/installed from the stable/ubuntu-VERSION branch but instead use stable on upgrades.

Description of the change

Make sure snaps like core18 are not refreshed/installed from the stable/ubuntu-VERSION branch but instead use stable on upgrades.

This branch depends on lp:~sil2100/ubuntu-release-upgrader/snap-size-estimation (and changes are included on top of it).

To post a comment you must log in.
3283. By Łukasz Zemczak

When checking for installed snaps, also use the right channel/branch.

Revision history for this message
Brian Murray (brian-murray) wrote :

This looks good other than changing a couple of variable names to make things consistent. Thanks for taking this on!

review: Approve
3284. By Łukasz Zemczak

Change variable naming.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DistUpgrade/DistUpgradeQuirks.py'
2--- DistUpgrade/DistUpgradeQuirks.py 2019-09-03 13:44:01 +0000
3+++ DistUpgrade/DistUpgradeQuirks.py 2019-09-03 13:44:01 +0000
4@@ -467,7 +467,7 @@
5 "instance-key": "upgrade-size-check",
6 "action": "download",
7 "snap-id": snap_object['snap-id'],
8- "channel": "stable/ubuntu-%s" % self._to_version,
9+ "channel": snap_object['channel'],
10 }
11 data = {
12 "context": [],
13@@ -496,6 +496,7 @@
14 # _calculateSnapSizeRequirements call.
15 for snap, snap_object in self._snap_list.items():
16 command = snap_object['command']
17+ channel = snap_object['channel']
18 if command == 'refresh':
19 self._view.updateStatus(_("refreshing snap %s" % snap))
20 else:
21@@ -503,8 +504,7 @@
22 try:
23 self._view.processEvents()
24 proc = subprocess.run(
25- ["snap", command, "--channel",
26- "stable/ubuntu-%s" % self._to_version, snap],
27+ ["snap", command, "--channel", channel, snap],
28 stdout=subprocess.PIPE,
29 check=True)
30 self._view.processEvents()
31@@ -814,11 +814,17 @@
32 self.controller.toDist).split()[0]
33 self._snap_list = {}
34 # gtk-common-themes isn't a package name but is this risky?
35- snaps = ['core18', 'gnome-3-28-1804', 'gtk-common-themes',
36- 'gnome-calculator', 'gnome-characters', 'gnome-logs',
37- 'gnome-system-monitor']
38+ from_channel = "stable/ubuntu-%s" % self._from_version
39+ to_channel = "stable/ubuntu-%s" % self._to_version
40+ snaps = {'core18': ('stable', 'stable'),
41+ 'gnome-3-28-1804': (from_channel, to_channel),
42+ 'gtk-common-themes': (from_channel, to_channel),
43+ 'gnome-calculator': (from_channel, to_channel),
44+ 'gnome-characters': (from_channel, to_channel),
45+ 'gnome-logs': (from_channel, to_channel),
46+ 'gnome-system-monitor': (from_channel, to_channel)}
47 self._view.updateStatus(_("Checking for installed snaps"))
48- for snap in snaps:
49+ for snap, (from_channel, to_channel) in snaps.items():
50 snap_object = {}
51 # check to see if the snap is already installed
52 snap_info = subprocess.Popen(["snap", "info", snap],
53@@ -828,7 +834,7 @@
54 if re.search("^installed: ", snap_info[0], re.MULTILINE):
55 logging.debug("Snap %s is installed" % snap)
56 # its not tracking the release channel so don't refresh
57- if not re.search("^tracking:.*ubuntu-%s" % self._from_version,
58+ if not re.search("^tracking:.*%s" % from_channel,
59 snap_info[0], re.MULTILINE):
60 logging.debug("Snap %s is not tracking the release channel"
61 % snap)
62@@ -842,5 +848,6 @@
63 continue
64 snap_object['command'] = 'install'
65 snap_object['snap-id'] = match[1]
66+ snap_object['channel'] = to_channel
67 self._snap_list[snap] = snap_object
68 return self._snap_list
69
70=== modified file 'tests/test_quirks.py'
71--- tests/test_quirks.py 2019-09-03 13:44:01 +0000
72+++ tests/test_quirks.py 2019-09-03 13:44:01 +0000
73@@ -346,13 +346,34 @@
74 # needing refresh and which ones need installation
75 self.assertDictEqual(
76 q._snap_list,
77- {'core18': {'command': 'install', 'snap-id': '1234'},
78- 'gnome-3-28-1804': {'command': 'install', 'snap-id': '1234'},
79- 'gtk-common-themes': {'command': 'install', 'snap-id': '1234'},
80- 'gnome-calculator': {'command': 'install', 'snap-id': '1234'},
81- 'gnome-characters': {'command': 'install', 'snap-id': '1234'},
82- 'gnome-logs': {'command': 'refresh'},
83- 'gnome-system-monitor': {'command': 'refresh'}})
84+ {'core18': {
85+ 'command': 'install', 'snap-id': '1234',
86+ 'channel': 'stable'
87+ },
88+ 'gnome-3-28-1804': {
89+ 'command': 'install', 'snap-id': '1234',
90+ 'channel': 'stable/ubuntu-19.10'
91+ },
92+ 'gtk-common-themes': {
93+ 'command': 'install', 'snap-id': '1234',
94+ 'channel': 'stable/ubuntu-19.10'
95+ },
96+ 'gnome-calculator': {
97+ 'command': 'install', 'snap-id': '1234',
98+ 'channel': 'stable/ubuntu-19.10'
99+ },
100+ 'gnome-characters': {
101+ 'command': 'install', 'snap-id': '1234',
102+ 'channel': 'stable/ubuntu-19.10'
103+ },
104+ 'gnome-logs': {
105+ 'command': 'refresh',
106+ 'channel': 'stable/ubuntu-19.10'
107+ },
108+ 'gnome-system-monitor': {
109+ 'command': 'refresh',
110+ 'channel': 'stable/ubuntu-19.10'
111+ }})
112
113 @mock.patch("DistUpgrade.DistUpgradeQuirks.get_arch")
114 @mock.patch("urllib.request.urlopen")
115@@ -366,9 +387,12 @@
116 # separately.
117 q._prepare_snap_replacement_data = mock.Mock()
118 q._snap_list = {
119- 'test-snap': {'command': 'install', 'snap-id': '2'},
120- 'gnome-calculator': {'command': 'install', 'snap-id': '1'},
121- 'gnome-system-monitor': {'command': 'refresh'}
122+ 'test-snap': {'command': 'install', 'snap-id': '2',
123+ 'channel': 'stable/ubuntu-19.10'},
124+ 'gnome-calculator': {'command': 'install', 'snap-id': '1',
125+ 'channel': 'stable/ubuntu-19.10'},
126+ 'gnome-system-monitor': {'command': 'refresh',
127+ 'channel': 'stable/ubuntu-19.10'}
128 }
129 q._to_version = "19.10"
130 # Mock out urlopen in such a way that we get a mocked response based
131@@ -397,35 +421,48 @@
132 config = mock.Mock()
133 q = DistUpgradeQuirks(controller, config)
134 q._snap_list = {
135- 'core18': {'command': 'install', 'snap-id': '1234'},
136- 'gnome-3-28-1804': {'command': 'install', 'snap-id': '1234'},
137- 'gtk-common-themes': {'command': 'install', 'snap-id': '1234'},
138- 'gnome-calculator': {'command': 'install', 'snap-id': '1234'},
139- 'gnome-characters': {'command': 'install', 'snap-id': '1234'},
140- 'gnome-logs': {'command': 'refresh'},
141- 'gnome-system-monitor': {'command': 'refresh'}
142+ 'core18': {'command': 'install', 'snap-id': '1234',
143+ 'channel': 'stable'},
144+ 'gnome-3-28-1804': {'command': 'install', 'snap-id': '1234',
145+ 'channel': 'stable/ubuntu-19.10'},
146+ 'gtk-common-themes': {'command': 'install', 'snap-id': '1234',
147+ 'channel': 'stable/ubuntu-19.10'},
148+ 'gnome-calculator': {'command': 'install', 'snap-id': '1234',
149+ 'channel': 'stable/ubuntu-19.10'},
150+ 'gnome-characters': {'command': 'install', 'snap-id': '1234',
151+ 'channel': 'stable/ubuntu-19.10'},
152+ 'gnome-logs': {'command': 'refresh',
153+ 'channel': 'stable/ubuntu-19.10'},
154+ 'gnome-system-monitor': {'command': 'refresh',
155+ 'channel': 'stable/ubuntu-19.10'}
156 }
157 q._to_version = "19.10"
158 q._replaceDebsWithSnaps()
159 # Make sure all snaps have been handled
160 self.assertEqual(run_mock.call_count, 7)
161- snaps_refreshed = set()
162- snaps_installed = set()
163+ snaps_refreshed = {}
164+ snaps_installed = {}
165 # Check if all the snaps that needed to be installed were installed
166 # and those that needed a refresh - refreshed
167+ # At the same time, let's check that all the snaps were acted upon
168+ # while using the correct channel and branch
169 for call in run_mock.call_args_list:
170 args = call[0][0]
171 if args[1] == 'install':
172- snaps_installed.add(args[4])
173+ snaps_installed[args[4]] = args[3]
174 else:
175- snaps_refreshed.add(args[4])
176- self.assertSetEqual(
177+ snaps_refreshed[args[4]] = args[3]
178+ self.assertDictEqual(
179 snaps_refreshed,
180- {'gnome-logs', 'gnome-system-monitor'})
181- self.assertSetEqual(
182+ {'gnome-logs': 'stable/ubuntu-19.10',
183+ 'gnome-system-monitor': 'stable/ubuntu-19.10'})
184+ self.assertDictEqual(
185 snaps_installed,
186- {'core18', 'gnome-3-28-1804', 'gtk-common-themes',
187- 'gnome-calculator', 'gnome-characters'})
188+ {'core18': 'stable',
189+ 'gnome-3-28-1804': 'stable/ubuntu-19.10',
190+ 'gtk-common-themes': 'stable/ubuntu-19.10',
191+ 'gnome-calculator': 'stable/ubuntu-19.10',
192+ 'gnome-characters': 'stable/ubuntu-19.10'})
193 # Make sure we marked the replaced ones for removal
194 # Here we only check if the right number of 'packages' has been
195 # added to the forced_obsoletes list - not all of those packages are

Subscribers

People subscribed via source and target branches