Deterministic PackageList search #67

Merged
merged 2 commits into from Jun 27, 2014

Conversation

Projects
None yet
2 participants
@queeno
Contributor

queeno commented Jun 13, 2014

We have noticed non-deterministic behaviour when pulling a package without specifying a version from a snapshot.
In fact, we would expect to always pull the latest version of a package, but what we were seeing was that a random version was being chosen instead.

For example, we created a sensu mirror and created a snapshot source_snap from it:

root@sim-tst-lb1:~# aptly mirror create sensu http://repos.sensuapp.org/apt sensu
...
root@sim-tst-lb1:~# aptly mirror update sensu
...
root@sim-tst-lb1:~# aptly snapshot create source_snap from mirror sensu
...
root@sim-tst-lb1:~# aptly snapshot create empty empty
...
root@sim-tst-lb1:~# aptly snapshot pull --dry-run -architectures=amd64 empty source_snap dest_snap 'sensu'
Dependencies would be pulled into snapshot:
    [empty]: Created as empty
from snapshot:
    [source_snap]: Snapshot from mirror [sensu]: http://repos.sensuapp.org/apt/ sensu
and result would be saved as new snapshot dest_snap.
Loading packages (154)...
Building indexes...
[+] sensu_0.11.0-1_amd64 added

Not creating snapshot, as dry run was requested.
root@sim-tst-lb1:~# aptly snapshot pull --dry-run -architectures=amd64 empty source_snap dest_snap 'sensu'
Dependencies would be pulled into snapshot:
    [empty]: Created as empty
from snapshot:
    [source_snap]: Snapshot from mirror [sensu]: http://repos.sensuapp.org/apt/ sensu
and result would be saved as new snapshot dest_snap.
Loading packages (154)...
Building indexes...
[+] sensu_0.9.12.beta.5-2_amd64 added

Not creating snapshot, as dry run was requested.
root@sim-tst-lb1:~# aptly snapshot pull --dry-run -architectures=amd64 empty source_snap dest_snap 'sensu'
Dependencies would be pulled into snapshot:
    [empty]: Created as empty
from snapshot:
    [source_snap]: Snapshot from mirror [sensu]: http://repos.sensuapp.org/apt/ sensu
and result would be saved as new snapshot dest_snap.
Loading packages (154)...
Building indexes...
[+] sensu_0.9.9.beta.3-1_amd64 added

Whenever we pull the sensu package from source_snap, aptly returns a random version of it.

The changes we have made to the code order the PackageList by version (latest first) as well as name so that the search function returns a consistent result.

queeno added some commits Jun 13, 2014

In PackageList, sort the package version from latest to oldest
This enables us to return the latest version of a package when no version is specified rather than the oldest.
Therefore, we don't need to modify the search algorithm to return the latest version of a package.
@smira

This comment has been minimized.

Show comment
Hide comment
@smira

smira Jun 15, 2014

Member

@simonaquino, thanks a lot! The change looks great!

Member

smira commented Jun 15, 2014

@simonaquino, thanks a lot! The change looks great!

@smira smira added this to the v0.7 milestone Jun 15, 2014

@smira smira added the enhancement label Jun 15, 2014

@smira smira merged commit e19a615 into aptly-dev:master Jun 27, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

smira added a commit that referenced this pull request Jun 27, 2014

smira added a commit that referenced this pull request Jun 27, 2014

@queeno queeno deleted the queeno:deterministic_package_search branch Jun 28, 2014

@queeno

This comment has been minimized.

Show comment
Hide comment
@queeno

queeno Jun 28, 2014

Contributor

@smira Thanks for merging it Andrey! 👍

Contributor

queeno commented Jun 28, 2014

@smira Thanks for merging it Andrey! 👍

@smira

This comment has been minimized.

Show comment
Hide comment
@smira

smira Jun 29, 2014

Member

@simonaquino, I've added system test and sensu mirror to fixture in order to test features related to multiple versions of the same package.

Member

smira commented Jun 29, 2014

@simonaquino, I've added system test and sensu mirror to fixture in order to test features related to multiple versions of the same package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment