Commit Graph

13 Commits

Author SHA1 Message Date
Vsevolod Fedorov f4d64f9f66 Move tests to pytest
Pytest makes each scenario into individual selectable test.
To be able to run each scenario separately is very useful for development.

Change-Id: I4b1c990a1fd839ce327cd7faa27159a9b9632fed
2022-12-20 10:44:43 +03:00
Daniel Bengtsson 0b4ed38ca6 Fix the yaml load warning.
In the new version of PyYAML the API changed to be more explicit. Now
the default value for the Loader is None, see:

https://github.com/yaml/pyyaml/blob/5.1/lib3/yaml/__init__.py#L103

The load is unsafe. It's better to use safe_load function.

Change-Id: Ia1cd16f2ff970ca220a266c99b6554dd4254ebd9
2019-12-10 09:52:40 +01:00
Thanh Ha 4d90c187a9 Auto-generated output from python-black
Please review the following patch containing the code changes in
the repo. This patch is a transition patch and is the auto-generated
output of the python-black tool.

Change-Id: I2d2de71da8a105fb62b561899ae78441ddab4032
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
2019-09-09 19:23:24 +01:00
Darragh Bailey 6e237c4369 Allow using lockfile per jenkins master
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
2017-06-27 15:02:04 +00:00
Darragh Bailey 4573b3a25d Refactor base test classes inheritance for reuse
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
2016-09-14 14:58:57 +01:00
Wayne Warren e9a295b1fb Move CacheStorage to its own module.
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
2016-09-02 08:58:09 -07:00
Clark Boylan 5407302fdc Revert "Allow using lockfile per jenkins master"
This reverts commit d1df3359b3.

The lockfile management code attempts to do IO on a closed file and
throws errors.

Change-Id: Ied58185758fd7c8c822624e169216441341a75d0
2016-03-16 10:26:18 -07:00
Yolanda Robla d1df3359b3 Allow using lockfile per jenkins master
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
2016-03-14 17:28:39 +01:00
Darragh Bailey 9bfbffa559 Capture logs with FakeLogging Fixture
Capture logs to attach them on exceptions to simplify the debugging of
errors in tests when they occur.

Change-Id: I5c1b5c306aba37789a8d41eabf65e0ac628af838
2015-09-30 16:25:22 +01:00
Darragh Bailey 709f233bca Allow save to be called more than once
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
2015-09-22 15:00:28 +01:00
Guido Günther b43eb4ee35 Use open() instead of file()
The later isn't supported in Python3

Change-Id: I44e9e7d21d59a82648a5a78a0ebcae8f0317bb6f
2015-02-12 12:46:08 +01:00
Jeremy Stanley fbd432a0ad Use mock in a Python 3.4 compatible way
Related to https://code.google.com/p/mock/issues/detail?id=234

Change-Id: I85549fdba7b9cb575850a12d52e1ffb0d2dba8c0
2015-01-29 23:07:53 +00:00
Darragh Bailey cd266ac728 Write cache to file on CacheStorage object delete
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
2014-11-07 12:25:25 +00:00