Merge lp://staging/~vila/uci-engine/cleanup-data-store into lp://staging/uci-engine

Proposed by Vincent Ladeuil
Status: Needs review
Proposed branch: lp://staging/~vila/uci-engine/cleanup-data-store
Merge into: lp://staging/uci-engine
Prerequisite: lp://staging/~vila/uci-engine/stores-with-path
Diff against target: 213 lines (+47/-61)
2 files modified
ci-utils/ci_utils/data_store.py (+37/-43)
tests/test_data_store.py (+10/-18)
To merge this branch: bzr merge lp://staging/~vila/uci-engine/cleanup-data-store
Reviewer Review Type Date Requested Status
Joe Talbott (community) Needs Information
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+242218@code.staging.launchpad.net

This proposal supersedes a proposal from 2014-11-19.

Commit message

Cleanup data_store.py and the related tests

Description of the change

This cleans up data store and its tests as a pre-requisite for implementing reliable container deletion.

To post a comment you must log in.
905. By Vincent Ladeuil

Tested with ./run-tests ^tests.test_style ^tests.test_data_store befor submission.

(and some cosmetic changes)

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

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

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

review: Approve (continuous-integration)
Revision history for this message
Joe Talbott (joetalbott) wrote :

One in-line question, otherwise +1.

review: Needs Information
Revision history for this message
Vincent Ladeuil (vila) wrote :

Replied inline, good question ! The answer is tricky and at the core of the eventually consistent swift data model.

Revision history for this message
Joe Talbott (joetalbott) wrote :

On Thu, Nov 20, 2014 at 10:12:31PM -0000, Vincent Ladeuil wrote:
> Replied inline, good question ! The answer is tricky and at the core of the eventually consistent swift data model.
>
[snip]
> > === modified file 'tests/test_data_store.py'
> > --- tests/test_data_store.py 2014-10-08 09:54:56 +0000
> > +++ tests/test_data_store.py 2014-11-19 14:42:09 +0000
> > @@ -59,7 +59,6 @@
> > """ Test adding a file. """
> >
> > self.ds.put_file(self.filename, self.contents)
> > - self.addCleanup(self.ds.delete_file, self.filename)
>
> Yes, the container is deleted recursively (via a cleanup in setUp).
>
> Unless the test started failing I didn't realize this cleanup was harmful:
> * this cleanup delete the file,
> * the container cleanup:
> * list the container content,
> * find the file above that hasn't been deleted yet,
> * try to delete it but fails because the file is now deleted.
>
> It's hard to understand until you start realizing that each of the requests may end up on a different swift node during the inconsistency window: some nodes think the file is gone, some others think it's still there.
>
> I've tried to explain in the revno 900 commit message:
> Tests should not addCleanup(self.ds.delete_file, self.filename).
>
> It can lead to self.addCleanup(self.ds.delete, recursive=True) failing with 404 because the file is deleted after delete() calls list_files() but before it calls delete_file() for the same file.
>

That makes perfect sense.

> > files = self.ds.list_files()
> > self.assertEqual([self.filename], files)
> >
> > @@ -67,18 +66,20 @@
> > """ Test adding a file has correct contents. """
> >
> > self.ds.put_file(self.filename, self.contents)
> > - self.addCleanup(self.ds.delete_file, self.filename)
> > contents = self.ds.get_file(self.filename)
> >
> > self.assertEqual(contents, self.contents)
> >
> > - def test_public_container(self):
> > - """ Test accesssing a public container. """
> > + def test_not_public_fails(self):
> > + link = self.ds.put_file(self.filename, self.contents)
> > + self.addCleanup(self.ds.delete_file, self.filename)

So this should be removed as well?

Revision history for this message
Vincent Ladeuil (vila) wrote :

> > > - def test_public_container(self):
> > > - """ Test accesssing a public container. """
> > > + def test_not_public_fails(self):
> > > + link = self.ds.put_file(self.filename, self.contents)
> > > + self.addCleanup(self.ds.delete_file, self.filename)
>
> So this should be removed as well?

Mille sabords !

That one didn't fail....

As an experiment, I'd like to keep it and see if/when it fails.

Looking at these tests again, some use list_files() to check the container content which is *wrong*. Yet, even when the other ones were failing almost always, those ones never fail...

Yeah, I think the best way to keep learning how swift works and how wide/narrow is that inconsistency window is to keep them this way, at least we know how to fix them now.

Unmerged revisions

905. By Vincent Ladeuil

Tested with ./run-tests ^tests.test_style ^tests.test_data_store befor submission.

(and some cosmetic changes)

904. By Vincent Ladeuil

This test pollutes the run output.

903. By Vincent Ladeuil

Log auth info (except for the password).

Rewrite exception in list_files.

902. By Vincent Ladeuil

Simplify clear() and delete() by removing duplication.

901. By Vincent Ladeuil

Remove useless import.

900. By Vincent Ladeuil

Tests should not addCleanup(self.ds.delete_file, self.filename).

It can lead to self.addCleanup(self.ds.delete, recursive=True) failing with 404 because the file is deleted after delete() calls list_files() but before it calls delete_file() for the same file.

899. By Vincent Ladeuil

Remove duplication.

898. By Vincent Ladeuil

Fix pyflakes issue.

897. By Vincent Ladeuil

Now that the 'cli' is gone, nobody requires artifact paths to be reduced to their basename. The corresponding tests are not required anymore either.

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