Merge lp:~paelzer/cloud-init/test-apt-source into lp:~cloud-init-dev/cloud-init/trunk
| Status: | Merged |
|---|---|
| Merged at revision: | 1224 |
| Proposed branch: | lp:~paelzer/cloud-init/test-apt-source |
| Merge into: | lp:~cloud-init-dev/cloud-init/trunk |
| Diff against target: |
1134 lines (+945/-56) 6 files modified
cloudinit/config/cc_apt_configure.py (+82/-32) cloudinit/templater.py (+5/-0) cloudinit/util.py (+10/-0) doc/examples/cloud-config.txt (+131/-24) tests/unittests/test_handler/test_handler_apt_configure_sources_list.py (+166/-0) tests/unittests/test_handler/test_handler_apt_source.py (+551/-0) |
| To merge this branch: | bzr merge lp:~paelzer/cloud-init/test-apt-source |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Scott Moser | 2016-05-12 | Needs Fixing on 2016-05-24 | |
|
Review via email:
|
|||
Commit Message
Apt sources configuration improvements
- keyid-only (no source statement)
- key only (no source statement)
- custom source.list template
- support long gpg key fingerprints with spaces
- fix issue with key's that were already in the local gpg keyring
- allowing a new format to specify apt_sources in a dictionary instead of a list to allow merging of configurations
Along the way to ensure things are working this series also added several tests. Related to the new format and the realization of corner cases related to "no" or "multiple" specified filenames further unittests were added.
Testing various combinations of the execution as it was so far:
- test_apt_
- test_apt_
- test_apt_
- test_apt_source_key Test specification of a source + key
- test_apt_
- test_apt_
- test_apt_source_ppa Test specification of a ppa
- test_apt_
- test_apt_
- test_apt_
- test_apt_
- test_apt_
- test_apt_
- test_apt_
Testing variations of above cases but without filename being specified
- test_apt_
- test_apt_
- test_apt_
- test_apt_
Testing variations of above cases with multiple specifications in one call:
test_apt_
test_apt_
test_apt_
test_apt_
Testing the new format:
test_apt_
test_apt_
test_apt_
test_convert_
Description of the Change
As discussed, the cloud-init portion of key-only (no source) and alternative source.list template.
I refused to do all the major changes you indicated as "might" in your mail.
Especially since IIRC the thought is to SRU it back.
The impact on backward compatibility could be too big.
Instead I tried to take a safe approach.
For none of the already existing features that touched existed unit tests.
So I wrote these, then added functionality and verified at least nothing on the old tests broke.
Finally I added tests for the new functions and also documentations in the example files.
| Scott Moser (smoser) wrote : | # |
| Scott Moser (smoser) wrote : | # |
I *do* want the dictionary format supported though.
dictionaries just merge so much more easily.
so this MP doesn't have to have it, but we want dictionary 'apt_sources' to support being a dictionary to fix that bug, and want that in curtin.
- 1246. By ChristianEhrhardt on 2016-05-12
-
remove no more applicable "not supported" statements
- 1247. By ChristianEhrhardt on 2016-05-12
-
move errorlist.append out of add_key
- 1248. By ChristianEhrhardt on 2016-05-12
-
remove Unnecessary parens in add_key
- 1249. By ChristianEhrhardt on 2016-05-12
-
fix EXPORT_GPG_KEYID for long key fingerprints
- 1250. By ChristianEhrhardt on 2016-05-12
-
split add_key and add_key_raw fior better testability
- 1251. By ChristianEhrhardt on 2016-05-12
-
Adding test_apt_
source_ keyid_real and test_apt_ source_ longkeyid_ real This now ensures that the stack of fetching IDs from keyservers and adding them
really works by comparing against known good keys that are expected. - 1252. By ChristianEhrhardt on 2016-05-12
-
remove superfluous import
- 1253. By ChristianEhrhardt on 2016-05-12
-
alphabetical import order
- 1254. By ChristianEhrhardt on 2016-05-12
-
alphabetical order on imports
- 1255. By ChristianEhrhardt on 2016-05-12
-
fix old typo in example
- 1256. By ChristianEhrhardt on 2016-05-12
-
improve spacing in apt_source_list test
- 1257. By ChristianEhrhardt on 2016-05-12
-
streamline code and sanitize expected result string definition
- 1258. By ChristianEhrhardt on 2016-05-12
-
make pep8 happy with a few spaces
- 1259. By ChristianEhrhardt on 2016-05-23
-
generalize test_apt_
source_ basic to be reusable across more testcases - 1260. By ChristianEhrhardt on 2016-05-23
-
test_apt_
source_ basic_nofn check for non-specified filename Cloud-inint uses a default fallback, we want to ensure no code change modfies
this behaviour. - 1261. By ChristianEhrhardt on 2016-05-23
-
drop unused mockappsubp
- 1262. By ChristianEhrhardt on 2016-05-23
-
extend test_apt_
source_ replace by a no-filename case - 1263. By ChristianEhrhardt on 2016-05-23
-
extend test_apt_
source_ keyid by no filename case - 1264. By ChristianEhrhardt on 2016-05-23
-
put fallbackfn to init
This was now used by multiple methods, no need to duplicate code.
- 1265. By ChristianEhrhardt on 2016-05-23
-
extend test_apt_source_key by nofn case
- 1266. By ChristianEhrhardt on 2016-05-23
-
support apt_sources to be a dictionary
key is the filename, and "old" input shall be handled as it was all the time.
For compatibility this will (continue to) overwrite the file of multiple
options that did not specify an output file (they all get the same default).
Yet it will process them all - as it always did - e.g. to add the keys of all
of them.Any users of the new format won't have these issues, as they will always have
a key. - 1267. By ChristianEhrhardt on 2016-05-23
-
warn about multiple colliding apt_source without filenames
- 1268. By ChristianEhrhardt on 2016-05-23
-
fix function names in inline doc
- 1269. By ChristianEhrhardt on 2016-05-23
-
testcases with multiple source list entries
- 1270. By ChristianEhrhardt on 2016-05-23
-
add triple case for test_apt_
source_ keyid_triple incl triple key check - 1271. By ChristianEhrhardt on 2016-05-23
-
make checkers happy about unused loop index
- 1272. By ChristianEhrhardt on 2016-05-23
-
add triple test for ppa adding
- 1273. By ChristianEhrhardt on 2016-05-23
-
fix issue with dictionary style apt_sources handling filenames
- 1274. By ChristianEhrhardt on 2016-05-23
-
add test_apt_
source_ basic_dict This is the basic testcase but in the new dictionary format
- 1275. By ChristianEhrhardt on 2016-05-23
-
unify basic triple check and add test_apt_
src_basic_ dict_triple based on it - 1276. By ChristianEhrhardt on 2016-05-23
-
make sure we only handle list or dict apt_sources and bail out for others
- 1277. By ChristianEhrhardt on 2016-05-23
-
shorten method names to follow python rules
- 1278. By ChristianEhrhardt on 2016-05-23
-
add test_apt_
src_replace_ dict_tri This includes a test for the weird but valid case in the new dictionary syntax
that one sets a key (which is the filename) but overwrites the filename value
inside of it. - 1279. By ChristianEhrhardt on 2016-05-23
-
modify cloud-config examples to match the new apt_source format
- 1280. By ChristianEhrhardt on 2016-05-23
-
final pep8 check fixups
| ChristianEhrhardt (paelzer) wrote : | # |
Following the discussion with smoser I added the requested new dictionary based format to apt_sources. This goes along with a collection of extra testcases to ensure the behavior of new (and old) configuration works.
| Scott Moser (smoser) wrote : | # |
so, some comments inline . that might seem like a lot, and that i'm nit picking. Sorry if it seems like that.
- 1281. By ChristianEhrhardt on 2016-05-24
-
fix typo in examples doc
- 1282. By ChristianEhrhardt on 2016-05-24
-
improve examples of ap_source
| ChristianEhrhardt (paelzer) wrote : | # |
> so, some comments inline . that might seem like a lot, and that i'm nit
> picking. Sorry if it seems like that.
You are not, I'm happy about a good review and that it is!
If the file would be free of warnings in general it would be easier to see the new ones :-)
I usually found a lot of missing docstrings and invalid constant/variable name issues of pylint littering my view of checker warnings probably too much.
Anyway - most of the (not nit) picks are stuff I copied or moved and now you just look at it again - so I don't feel offended but assisted to make the code better.
I found even more minor things on my own in the meantime that I can merge in given that changes of a respin.
| ChristianEhrhardt (paelzer) wrote : | # |
On Tue, May 24, 2016 at 4:01 PM, Scott Moser <email address hidden> wrote:
> so, some comments inline . that might seem like a lot, and that i'm nit
> picking. Sorry if it seems like that.
>
Having worked on the list of feedback I really found that they are mostly
picks on older code I moved - so I feel good :-)
And for my English sometimes I think I just shouldn't try to race to a new
MP at the end of a day :-)
> > + """
> > + if 'keyid' in ent and 'key' not in ent:
> > + keyserver = "keyserver.
> > + if 'keyserver' in ent:
> > + keyserver = ent['keyserver']
> > + try:
> > + ent['key'] = getkeybyid(
> > + except:
> > + raise Exception('failed to get key from %s' % keyserver)
>
> KeyError ? or LookupError maybe? might seem reasonable.
> catch the subp.ProcessExe
> through would be better than swallowing it with a more generic error.
>
>
Yeah, given a second thought I like not catching it at that level the most.
> >
> > errorlist = []
> > - for ent in srclist:
> > + # convert old list format to new dict based format
>
> converting the array to a dictionary seems like a method itself that would
> be stand alone be easily unit tested.
>
I first thought to refuse that since so many older tests are testing that
implicitly but ten decided to add it (refusing to go home to the family -
remote this week for better internet access).
Uploading updated MP now ...
- 1283. By ChristianEhrhardt on 2016-05-24
-
rebased with upstream and reolved merge conflicts
- 1284. By ChristianEhrhardt on 2016-05-24
-
integrate further smaller review feedback
- 1285. By ChristianEhrhardt on 2016-05-24
-
pacify pep8 regarding the new changes
- 1286. By ChristianEhrhardt on 2016-05-24
-
add test for the now isolated convert_
to_new_ format function
| ChristianEhrhardt (paelzer) wrote : | # |
Review feedback integrated and new test test_convert_
Ready for another review or merging.
- 1287. By ChristianEhrhardt on 2016-05-25
-
make test_apt_
srcl_custom independent to where it is executed
| ChristianEhrhardt (paelzer) wrote : | # |
by ongoing testing I found that one of the unittests depended on the system being xenial, this last commit fixes that dependency
- 1288. By ChristianEhrhardt on 2016-05-25
-
fix inline doc of test_apt_
src_longkeyid_ real
| Scott Moser (smoser) wrote : | # |
one more, but i think we're there.
- 1289. By ChristianEhrhardt on 2016-05-30
-
drop errorlist from convert_
to_new_ format - 1290. By ChristianEhrhardt on 2016-05-30
-
add test for wrong apt_source format
- 1291. By ChristianEhrhardt on 2016-05-30
-
improve wording in the examples
- 1292. By ChristianEhrhardt on 2016-05-30
-
fix EXPORT_GPG_KEYID for existing keys
This was broken for keys already existing in the local keyring.
There instead of the keycontent it reported the header like:
pub 1024R/03683F77 2009-10-27
uid Launchpad PPA for Scott Moser - 1293. By ChristianEhrhardt on 2016-05-30
-
merge with last upstream to avoid merging conflicts on MP
| ChristianEhrhardt (paelzer) wrote : | # |
Thanks for the repeated great review, due to that I changed:
- warning/errors in convert_
- improved example wording
Further on I:
- extended test_convert_
- fixed an issue identified the key* tests depending if it was already imported in gpg (that turned out to be a real issue with the implementation)
- rebased again to avoid merge conflicts
Will update commit message now ...


looks really good. a couple things to tweak.