Use the new oslotest library

There is a new support library extracted from oslo incubator: the patch
starts using it and removes deprecated modules.

Change-Id: I3839af20613ff6ab905dddb8fc4be65654c6e949
Update olso modules

Now at oslo commit a08a622bc68c34291a116f7073511b02585d1c17

Change-Id: Ifd335dac76cdb880661cbd6378438fcebaf295cf
Stop periodic watcher tasks before deleting stack

In the case where a stack that has a watch task associated with it is
being deleted and the engine successfully acquires a lock, no attempt to
stop the stack will be made since it has no action in-progress.  This
will result in orphaned watcher tasks being left behind, since the
watcher tasks are normally stopped as part of the call to
ThreadGroup.stop().

To fix this, explicitly stop the periodic watcher tasks before calling
stack.delete().

Change-Id: Idf5b7c1100fc85743ac6dc5831731f7ecc96bfd6
Closes-Bug: #1315044
Merge "Use the new oslotest library"
resource_get_all_by_stack returns a dict

This changes the returned results of resource_get_all_by_stack
to be a dict keyed by name, instead of a list of resources.

There appear to be zero uses of resource_get_all_by_stack so this
should have no effect on existing code, but it will be a more useful
form to consume the resources in a stack.

This change also prefetches resource data, as for
resource_get_by_name_and_stack

Change-Id: I1cc0ea7cf4852cc2407b3ada9ede7b5f6d1cc682
Fetch all db resources in one query

Instead of calling resource_get_by_name_and_stack once for every
resource in the stack, db_api.resource_get_all_by_stack is called
only once for all resources.

This reduces the number of sql queries during a describe_stack_resource
call to 3:
1. load the stack
2. load the template
3. load the resources

This is a big improvement over the start of this patch series, which
is 2 queries plus:
* 1 per resource in the stack
* 1 per access to a resource metadata attribute
* 1 per access to a resource data value

There is probably still potential to reduce queries from 3, but this
may well be a fix for
Partial-Bug: 1306743

Change-Id: I80be5d3de8744813d974f2e9860c148ad258f385
Fetch RawTemplate from Stack, not a query

This will allow a future optimisation to prefetch Stack.raw_template
in a single query.

Change-Id: I24a64d6159342b3232667e499808dc0233c83e1f
Eager-load Stack.raw_template for Stack.load

Whenever a stack is loaded from the database to perform a
parser.Stack.load, the raw_template should be prefetched to
avoid an extra sql query being performed.

However there are many calls to db_api.stack_get which do not need
to access Stack.raw_template, so the default behaviour is to
lazy-load it.

This change reduces the queries for a Stack.load from 3 to 2, so it
contributes to Related-Bug: #1306743

Change-Id: Ie6dad6ea4b1655a99e97a9ac2b7c00018406cd91
Give resource fakes a string ID

Resource ID values are actually UUIDs but unit tests assume
they are typed as integers.

This change uses the same numbers for test IDs but types them
as strings, which makes the resource fakes closer to real-world
usage.

Change-Id: I8c9d6889db6451019e3986729906b5a37188c133
Merge "Update olso modules"
Merge "Stop periodic watcher tasks before deleting stack"