Merge lp://staging/~ursinha/ubuntu-ci-services-itself/bug-1290174-and-1287686 into lp://staging/ubuntu-ci-services-itself

Proposed by Ursula Junque
Status: Merged
Approved by: Ursula Junque
Approved revision: 369
Merged at revision: 347
Proposed branch: lp://staging/~ursinha/ubuntu-ci-services-itself/bug-1290174-and-1287686
Merge into: lp://staging/ubuntu-ci-services-itself
Diff against target: 964 lines (+397/-191)
15 files modified
cli/ci_libs/file_handler.py (+11/-4)
cli/setup.py (+1/-0)
cli/tests/__init__.py (+44/-3)
cli/tests/data/barfoo_0.1-1.dsc (+16/-3)
cli/tests/data/barfoo_0.1-1_source.changes (+22/-9)
cli/tests/data/foobar_0.1-1.dsc (+20/-7)
cli/tests/data/foobar_0.1-1_source.changes (+29/-16)
cli/tests/data/foobar_0.1-1_unreleased.changes (+28/-15)
cli/tests/data/foobar_0.1-1_unsigned.changes (+28/-0)
cli/tests/test_cli.py (+174/-112)
cli/tests/test_file_handler.py (+8/-9)
cli/tests/test_get_ticket_status.py (+5/-4)
cli/tests/test_ticket.py (+5/-5)
cli/tests/test_utils.py (+2/-2)
cli/ubuntu-ci (+4/-2)
To merge this branch: bzr merge lp://staging/~ursinha/ubuntu-ci-services-itself/bug-1290174-and-1287686
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Vincent Ladeuil (community) Approve
Review via email: mp+210133@code.staging.launchpad.net

Commit message

Enables .changes signature validation during ticket creation and solves isolation test problems on test_cli.py

Description of the change

This branch enables .changes signature validation in the cli, unallowing unsigned packages to pass and fail later on branch source builder stage (as seen on bug 1283186).

It also fixes bug 1287686 (test_cli isolation problem requiring system to have an .ubuntu-ci file), by adding calls to mock_load_config -- I was modifying the tests here and decided to add these right away. I'm probably going to hell for fixing more than one bug with one branch, but this fix is really simple.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:351
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/353/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/353/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ursula Junque (ursinha) wrote :

Tests didn't like the validation (there were no errors when I tested locally in an isolated env). I'm investigating the issue.

366. By Ursula Junque

Oops, these should have been removed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:366
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/356/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/356/rebuild

review: Approve (continuous-integration)
Revision history for this message
Vincent Ladeuil (vila) wrote :

Excellent !

td;lr: nothing critical to fix but the env var leak... breaks isolation and those kind of issue are a pain to debug. Not sure it matters here as I don't clearly see the impact on other tests.

Voting approve so you can sort out what you want to fix before landing.

46 + 'python-gnupg',

Set a version if only to make sure we don't grab a newer one without noticing.

71 +KEY_DATA = """
72 +-----BEGIN PGP PUBLIC KEY BLOCK-----
73 +Version: GnuPG v1

It would be nice to have the test infra to validate this on the fly, not a blocker but something to think about post phase-0.

117 + def _set_gnupg_home(self):
118 + os.environ["GNUPGHOME"] = self.gnupg_home

You're leaking the env var, other tests may fail, you want:

  from ucitests import fixtures

  fixtures.override_env(self, 'GNUPGHOME', self.gnupg_home)

which will take care of the cleanup for you.

120 + def _unset_gnupg_home(self):
121 + os.environ.pop("GNUPGHOME")

so this can be deleted.

Likewise, using the following in setUp():

  fixtures.set_uniq_cwd(self)
  self.gnupg_home = '.'

will take care of:

123 + def _destroy_gnupg_env(self):
124 + self._unset_gnupg_home()
125 + shutil.rmtree(self.gnupg_home)

<lots of fallouts in existing tests related to the gpg key change>

I trust you got that by using that command locally, in the same vein of the remark about automating gpg key creation, all this data can be generated wit that local command and remove test code making it more readable and easier to reuse. Again, nothing to fix for now.

Nit:

527 + self.assertEqual(mock_process.call_count, 2)
528 + self.assertEqual(mock_post.call_count, 1)
529 + self.assertEqual(mock_patch.call_count, 1)

pick one of expected, actual or actual, expected but stick to it ;) You know my preference ;)

Nit:

860 + self.assertRaises(ChangesValidationError, processor.validate)

this is valid but more and more I prefer:

   with self.assertRaises(ChangesValidationError) as cm:
     processor.validate()

as it's easier to read and gives greater control to the test writer to add assertions on the exception details (if/when needed).

review: Approve
367. By Ursula Junque

Pinning python-gnupg version

368. By Ursula Junque

Using fixtures to set env variable

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:368
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/357/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/357/rebuild

review: Approve (continuous-integration)
369. By Ursula Junque

Fixing assertEquals order

Revision history for this message
Ursula Junque (ursinha) wrote :

> Excellent !
>
> td;lr: nothing critical to fix but the env var leak... breaks isolation and
> those kind of issue are a pain to debug. Not sure it matters here as I don't
> clearly see the impact on other tests.
>
> Voting approve so you can sort out what you want to fix before landing.
>
> 46 + 'python-gnupg',
>
> Set a version if only to make sure we don't grab a newer one without noticing.

Fixed r367.

>
>
> 71 +KEY_DATA = """
> 72 +-----BEGIN PGP PUBLIC KEY BLOCK-----
> 73 +Version: GnuPG v1
>
> It would be nice to have the test infra to validate this on the fly, not a
> blocker but something to think about post phase-0.
>
> 117 + def _set_gnupg_home(self):
> 118 + os.environ["GNUPGHOME"] = self.gnupg_home
>
> You're leaking the env var, other tests may fail, you want:
>
> from ucitests import fixtures
>
> fixtures.override_env(self, 'GNUPGHOME', self.gnupg_home)
>
> which will take care of the cleanup for you.
>
> 120 + def _unset_gnupg_home(self):
> 121 + os.environ.pop("GNUPGHOME")
>
> so this can be deleted.

Nice :) Fixed r368.

>
> Likewise, using the following in setUp():
>
> fixtures.set_uniq_cwd(self)
> self.gnupg_home = '.'
>
> will take care of:
>
> 123 + def _destroy_gnupg_env(self):
> 124 + self._unset_gnupg_home()
> 125 + shutil.rmtree(self.gnupg_home)

This will take a bit more to figure out how to function properly, there are some tests that fail by setting this because they can't find sample data. Might not be hard to fix but would make this MP even bigger.

>
>
> <lots of fallouts in existing tests related to the gpg key change>
>
> I trust you got that by using that command locally, in the same vein of the
> remark about automating gpg key creation, all this data can be generated wit
> that local command and remove test code making it more readable and easier to
> reuse. Again, nothing to fix for now.

Actually I'm not using gpg directly anywhere with subprocess or similar, but python-dput is. The output you see is library output, I use python-gnupg.import_keys() and python-dput.validate_signatures(), and they give me the loads of messages you see. In near future I'll see what I can do to suppress such messages.

>
> Nit:
>
> 527 + self.assertEqual(mock_process.call_count, 2)
> 528 + self.assertEqual(mock_post.call_count, 1)
> 529 + self.assertEqual(mock_patch.call_count, 1)
>
> pick one of expected, actual or actual, expected but stick to it ;) You know
> my preference ;)

Oops, these are actually correct according to most of other tests. Two (or so) occurrences were backwards because I've changed the assertion but not the logic. Fixed r369.

>
> Nit:
>
> 860 + self.assertRaises(ChangesValidationError, processor.validate)
>
> this is valid but more and more I prefer:
>
> with self.assertRaises(ChangesValidationError) as cm:
> processor.validate()
>
> as it's easier to read and gives greater control to the test writer to add
> assertions on the exception details (if/when needed).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:369
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/358/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/358/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches