Add support for lockable resources
This adds a new class for managing lockable resources from python. It includes some helpful context managers so you can do stuff like this:
with jenkins.lockable_resources.reservation_by_label("aaa") as r:
print(f"locked resource {r.locked_resource_name}")
The intended use case is hardware reservation systems backed by jenkins. There is no CLI.
I also found a similar implementation as external package: https://gitlab.com/alexandre-perrin1/jenkins-lockable-resources. It seems unmaintained, I was unable to install due to dependency conflicts and such.
This PR contains full systest support so the CI will test the code against a running jenkins instance. Hopefully this makes it easy to maintain.
This went through several force-pushes as I added more features and fix linting issues.
Current version is stable
Rebased addressing review comments and integrating a some other changes:
- Rewrite RetryConfig so that it is reusable.
- Turn ResourceSelector into ABC
- Add custom
ResourceReservationTimeoutErrorclass - Add LockedResourceReservation.is_active, with tests
- Remove unused LockedResourceReservation.locked field
- Improve documentation
The RetryConfig class is very basic, the purpose of this abstraction is to allow more complex implementations - for example based on tenacity. I wanted to avoid adding dependencies.
rebased to fix codacy