Skip to content

Commit cdd87b2

Browse files
committed
Add exponential backoff to connection checks in docker-tests
1 parent 4a1e0ce commit cdd87b2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/opentelemetry-docker-tests/tests/check_availability.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
MSSQL_USER = os.getenv("MSSQL_USER", "sa")
4444
MSSQL_PASSWORD = os.getenv("MSSQL_PASSWORD", "yourStrong(!)Password")
4545
RETRY_COUNT = 8
46-
RETRY_INTERVAL = 5 # Seconds
46+
RETRY_INITIAL_INTERVAL = 2 # Seconds
4747

4848
logger = logging.getLogger(__name__)
4949

@@ -56,14 +56,16 @@ def wrapper():
5656
func()
5757
return
5858
except Exception as ex: # pylint: disable=broad-except
59+
# Exponential backoff
60+
current_interval = RETRY_INITIAL_INTERVAL * (2**i)
5961
logger.error(
6062
"waiting for %s, retry %d/%d [%s]",
6163
func.__name__,
6264
i + 1,
6365
RETRY_COUNT,
6466
ex,
6567
)
66-
time.sleep(RETRY_INTERVAL)
68+
time.sleep(current_interval)
6769
raise Exception(f"waiting for {func.__name__} failed")
6870

6971
return wrapper

0 commit comments

Comments
 (0)