1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-03 23:51:48 +00:00

refactor: reuse exponential_backoff_function from hcloud-python (#535)

Replace the local function with the exponential_backoff_function from
hcloud-python
This commit is contained in:
Jonas L. 2024-07-25 16:20:23 +02:00 committed by GitHub
parent b9a1509378
commit c665629f7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 40 deletions

View file

@ -1,14 +1 @@
from __future__ import annotations
from ansible_collections.hetzner.hcloud.plugins.module_utils.client import (
exponential_backoff_poll_interval,
)
def test_exponential_backoff_poll_interval():
poll_interval = exponential_backoff_poll_interval(base=1.0, multiplier=2, cap=5.0, jitter=0.0)
poll_max_retries = 25
results = [poll_interval(i) for i in range(poll_max_retries)]
assert sum(results) == 117.0
assert results[:6] == [1.0, 2.0, 4.0, 5.0, 5.0, 5.0]