Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sbws
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
juga
sbws
Commits
c36518cb
Commit
c36518cb
authored
5 years ago
by
juga
Browse files
Options
Downloads
Patches
Plain Diff
fix: tests: Test maximum retry delta in destination
parent
d7acfa7f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/lib/test_destination.py
+20
-0
20 additions, 0 deletions
tests/unit/lib/test_destination.py
with
20 additions
and
0 deletions
tests/unit/lib/test_destination.py
+
20
−
0
View file @
c36518cb
"""
Unit tests for sbws.lib.destination.
"""
from
datetime
import
datetime
,
timedelta
from
sbws.globals
import
MAX_SECONDS_RETRY_DESTINATION
from
sbws.lib
import
destination
...
...
@@ -8,6 +9,12 @@ def test_destination_is_functional():
eleven_mins_ago
=
datetime
.
utcnow
()
-
timedelta
(
minutes
=
11
)
six_mins_ago
=
datetime
.
utcnow
()
-
timedelta
(
minutes
=
6
)
four_mins_ago
=
datetime
.
utcnow
()
-
timedelta
(
minutes
=
4
)
# Make last time tried a bit bigger than the half of the maximum, so that
# it's bigger than the delta time to retry, and when delta time to retry
# is muliplied by a factor (2) it reaches the maximum.
long_ago
=
datetime
.
utcnow
()
-
timedelta
(
(
MAX_SECONDS_RETRY_DESTINATION
/
2
)
+
2
)
d
=
destination
.
Destination
(
'
unexistenturl
'
,
0
,
False
)
assert
d
.
is_functional
()
...
...
@@ -52,3 +59,16 @@ def test_destination_is_functional():
assert
d
.
is_functional
()
# And the delta to try is resetted
assert
not
d
.
_is_last_try_old_enough
()
# When the delta time to retry a destination increase too much,
# set it to a maximum, and try the destination again
d
.
add_failure
()
d
.
add_failure
()
d
.
add_failure
(
long_ago
)
# Pretend the delta seconds was already set to a bit more than
# half the maximum.
d
.
_delta_seconds_retry
=
(
MAX_SECONDS_RETRY_DESTINATION
/
2
)
+
1
assert
d
.
_are_last_attempts_failures
()
assert
d
.
_is_last_try_old_enough
()
assert
d
.
is_functional
()
assert
d
.
_delta_seconds_retry
==
MAX_SECONDS_RETRY_DESTINATION
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment