When a jjb run is thrown when another jjb is already running, it can
cause corruption of cache. Start using a fasteners to ensure this
won't be happening and run securely on automated systems.
Ensure unlock is called from only the destructor, so that it is only
called when the JJB process is guaranteed to be finished using it.
Make it obvious that _lock is intended to be internal to the cache
storage implementation.
Potentially we may not need to call it at all, as python might unlock
it for us on exit by closing the file when no longer needed. However
better to make it explicit.
Change-Id: I53a1f92cf2bfbbe87c9ea205c377f93869353620
Refactor base test class inheritance to allow for BaseTest class to be
reused without needing to also import the TestCase class everywhere in
order to avoid having the common test function executed on base classes.
This makes it easier to build base testing classes and then simplifies
the subclassing of these for actual tests.
Change-Id: I89809e8082469f814f245db4a9ab7658aac8a405
And rename it to JobCache. The word "Cache" already implies "Storage"
so it makes more sense to name it after the things that it
stores...Jobs!
Change-Id: If7a7a56e8f6a3637f62e285eaa7ba989f67002dc
This reverts commit d1df3359b3c9fd968e8e35c51dc36b0b90ffa216.
The lockfile management code attempts to do IO on a closed file and
throws errors.
Change-Id: Ied58185758fd7c8c822624e169216441341a75d0
When a jjb run is thrown when another jjb is already running,
it can cause corruption of cache. Start using a lockfile to
ensure this won't be happening and run securely on automated
systems.
Change-Id: I3ac37e738b3bb87c04a47afb8adb3e25f8fb4ea8
Capture logs to attach them on exceptions to simplify the debugging of
errors in tests when they occur.
Change-Id: I5c1b5c306aba37789a8d41eabf65e0ac628af838
Replace check for single call with ensuring that it is called at least
once.
As mock patching affects global state by patching the class rather than
the instance, other tests creating the CacheStorage object via separate
test threads can result in the 'save' method being called more than
once. Therefore just test to ensure that it has been called at least
once.
Change-Id: Ice3d13536bafa04713f4c226273898806926067d
Use a destructor to write out the cache to file when the cache object
object goes out of scope, which will typically be on exit.
This ensures that the CacheStorage class behaviour is fully
encapsulated and doesn't require a caller to be aware to ensure the
cache is saved when finished. Although it may still do so.
Take care to preserve a references to any required modules since python
does not guarantee that any global modules will not be unloaded before
the destructor is called.
Change-Id: I2b066ceff5e23a725132569df85c004cd58b367a