~ubuntu-branches/ubuntu/wily/system-image/wily-proposed

« back to all changes in this revision

Viewing changes to systemimage/tests/test_winner.py

  • Committer: Package Import Robot
  • Author(s): Barry Warsaw
  • Date: 2013-09-06 18:34:29 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20130906183429-mwrrv52ooot0n3ut
Tags: 1.5-0ubuntu1
* New upstream release.
  - `system-image-cli --info` prints additional information:
     + last update time (i.e. the mtime of `/etc/system-image/channel.ini`
       falling back to the mtime of `/etc/ubuntu-build`).
     + version details for ubuntu, the device, and any custom version, if the
       `/etc/system-image/channel.ini` file contains these details.
  - `system-image-cli --dry-run -c <bad-channel>` no longer produces a
     traceback.  You get "Already up-to-date", but use `-v` for more info.
  - D-Bus API method `UpdateAvailableStatus` field `last_update_date`
    has changes its format.  It's still ISO 8601, but with a space
    instead of a 'T' separating the date from the time.
  - LP: #1221841 - Support the new channels.json file format with
    backward compatibility (for now) with the old format.
  - LP: #1215959 - New D-Bus .Info() method returns data similar to
    `system-image-cli --info`

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from contextlib import ExitStack
27
27
from systemimage.candidates import get_candidates
28
28
from systemimage.config import config
29
 
from systemimage.download import get_files
30
29
from systemimage.gpg import SignatureError
31
30
from systemimage.helpers import temporary_directory
32
 
from systemimage.scores import WeightedScorer
33
31
from systemimage.state import ChecksumError, State
34
32
from systemimage.testing.helpers import (
35
 
    configuration, copy, get_index, make_http_server, makedirs, setup_index,
36
 
    setup_keyring_txz, setup_keyrings, sign)
 
33
    configuration, copy, make_http_server, setup_index, setup_keyring_txz,
 
34
    setup_keyrings, sign, touch_build)
37
35
 
38
36
 
39
37
class TestWinnerDownloads(unittest.TestCase):
100
98
        # Calculate the winning upgrade path.
101
99
        setup_keyrings()
102
100
        state = State()
103
 
        # Set the build number.
104
 
        with open(config.system.build_file, 'wt', encoding='utf-8') as fp:
105
 
            print(20120100, file=fp)
 
101
        touch_build(20120100)
106
102
        # Run the state machine 4 times to get the candidates and winner.
107
103
        # (blacklist -> channel -> index -> calculate)
108
104
        for i in range(4):
119
115
        # Check that all the winning path's files are downloaded.
120
116
        setup_keyrings()
121
117
        state = State()
122
 
        # Set the build number.
123
 
        with open(config.system.build_file, 'wt', encoding='utf-8') as fp:
124
 
            print(20120100, file=fp)
 
118
        touch_build(20120100)
125
119
        # Run the state machine until we download the files.
126
120
        state.run_thru('download_files')
127
121
        # The B path files contain their checksums.
161
155
        sign(os.path.join(self._serverdir, self._indexpath),
162
156
             'device-signing.gpg')
163
157
        setup_index('index_12.json', self._serverdir, 'device-signing.gpg')
164
 
        # Set the build number.
165
 
        with open(config.system.build_file, 'wt', encoding='utf-8') as fp:
166
 
            print(20120100, file=fp)
 
158
        touch_build(20120100)
167
159
        # Run the state machine until we download the files.
168
160
        state = State()
169
161
        state.run_thru('download_files')
203
195
             'device-signing.gpg')
204
196
        # All the downloadable files are now signed with the image signing key.
205
197
        setup_index('index_12.json', self._serverdir, 'image-signing.gpg')
206
 
        # Set the build number.
207
 
        with open(config.system.build_file, 'wt', encoding='utf-8') as fp:
208
 
            print(20120100, file=fp)
 
198
        touch_build(20120100)
209
199
        # Run the state machine until we download the files.
210
200
        state = State()
211
201
        state.run_thru('download_files')
236
226
        setup_index('index_10.json', self._serverdir, 'image-signing.gpg')
237
227
        setup_keyrings()
238
228
        state = State()
239
 
        # Set the build number.
240
 
        with open(config.system.build_file, 'wt', encoding='utf-8') as fp:
241
 
            print(20120100, file=fp)
 
229
        touch_build(20120100)
242
230
        # Run the state machine until we're prepped to download
243
231
        state.run_until('download_files')
244
232
        # Now try to download the files and get the error.
263
251
             'device-signing.gpg')
264
252
        # All the downloadable files are now signed with a bogus key.
265
253
        setup_index('index_12.json', self._serverdir, 'spare.gpg')
266
 
        # Set the build number.
267
 
        with open(config.system.build_file, 'wt', encoding='utf-8') as fp:
268
 
            print(20120100, file=fp)
 
254
        touch_build(20120100)
269
255
        # Run the state machine until just before we download the files.
270
256
        state = State()
271
257
        state.run_until('download_files')
283
269
        # files get downloaded and get_files() fails.
284
270
        setup_keyrings()
285
271
        state = State()
286
 
        # Set the build number.
287
 
        with open(config.system.build_file, 'wt', encoding='utf-8') as fp:
288
 
            print(20120100, file=fp)
 
272
        touch_build(20120100)
289
273
        # Remove a signature.
290
274
        os.remove(os.path.join(self._serverdir, '6/7/8.txt.asc'))
291
275
        # Run the state machine to calculate the winning path.
304
288
        # files get downloaded and get_files() fails.
305
289
        setup_keyrings()
306
290
        state = State()
307
 
        # Set the build number.
308
 
        with open(config.system.build_file, 'wt', encoding='utf-8') as fp:
309
 
            print(20120100, file=fp)
 
291
        touch_build(20120100)
310
292
        # Break a signature
311
293
        sign(os.path.join(self._serverdir, '6', '7', '8.txt'), 'spare.gpg')
312
294
        # Run the state machine to calculate the winning path.