Correct how positions were managed.

Insert/Update have different rules depending on where the new/update buildpack needs to slot into.
Added testcases to cover the more basic insert in the middle.
Overall test cleanup, removed tests that no longer made sense, fixed ones that had misleading intent.
Use the new buildpack installer task
Merge remote-tracking branch 'origin/pr/190'

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Introduce default rake task

- Runs rubocop then specs
- [Finishes #62743498]

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Reraise error if e is not unauthorized
On drain, unregister from the router and wait before shutting down

* sending USR2 signal to cloud controller will cause it to unregister from the router
* during drain, after 20 seconds, stops accepting requests.  The wait is a poor-man's
solution to increase the chance that no requests get routed to the CC during restart.
If a router doesn't receive the message, or if there is a network delay causing the
unregister to take especially long, you could still see the cloud controller receiving
requests (which would cause 502s for a user).

Signed-off-by: Kai Zhang <kaizhang@cn.ibm.com>
Restore max_package_size in the config template

The recent refactor to pull cc templates out of cf-release reverted a
change to support large application packages.
Merge pull request #188 from fraenkel/addbuildpacks

Inject the new buildpack installer task
Remove dead code related to prioritized buildpacks

[#68432850]

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Need to call destroy to exercise after_destroy

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Extract BuildpackPositioner

An attempt to reduce the logic in Buildpack and eventually write clearer specs around the positioning

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Encapsulate shift_to_position in update

- update was the only method using shift_to_position
- there was a second (sorta nested) transaction that was not needed
- [#68432850]

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Reduce knowledge about the db in positioner

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Be defensive about hash key style

buildpack_contoller_spec.rb uses string keys but buildpack_installer.rb symbolizes keys, it is not clear which is correct
Positioner no longer know about Buildpack.db
Split responsibilities of calculating position and shifting

In an attempt to marginally improve clarity. They are not unit tested as they are, and are instead exercised via buildpack_spec
Clean up in drain script

Including better logging

Signed-off-by: Aram Price <aprice@pivotallabs.com>
Add more logging and DRY up router deregister

Signed-off-by: Aram Price <aprice@pivotallabs.com>
Hoist timeout values to the top, trim comments

Signed-off-by: Ruth Byers <rbyers@pivotallabs.com>
Merge branch 'pr/196'