Fix flakiness in team sync tests
This commit is contained in:
parent
b26bd3c9c5
commit
bdd07d4f39
1 changed files with 13 additions and 9 deletions
|
@ -1,5 +1,4 @@
|
||||||
from datetime import timedelta
|
from datetime import datetime, timedelta
|
||||||
import time
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -211,8 +210,6 @@ def test_sync_teams_to_groups(app):
|
||||||
|
|
||||||
# Call to sync all teams.
|
# Call to sync all teams.
|
||||||
fake_auth = FakeUsers([])
|
fake_auth = FakeUsers([])
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
sync_teams_to_groups(fake_auth, timedelta(seconds=1))
|
sync_teams_to_groups(fake_auth, timedelta(seconds=1))
|
||||||
|
|
||||||
# Ensure the team was synced.
|
# Ensure the team was synced.
|
||||||
|
@ -221,16 +218,23 @@ def test_sync_teams_to_groups(app):
|
||||||
assert updated_sync_info.transaction_id != sync_team_info.transaction_id
|
assert updated_sync_info.transaction_id != sync_team_info.transaction_id
|
||||||
|
|
||||||
# Set the stale threshold to a high amount and ensure the team is not resynced.
|
# Set the stale threshold to a high amount and ensure the team is not resynced.
|
||||||
time.sleep(1)
|
current_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
||||||
|
current_info.last_updated = datetime.now() - timedelta(seconds=2)
|
||||||
|
current_info.save()
|
||||||
|
|
||||||
sync_teams_to_groups(fake_auth, timedelta(seconds=120))
|
sync_teams_to_groups(fake_auth, timedelta(seconds=120))
|
||||||
|
|
||||||
third_sync_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
third_sync_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
||||||
assert third_sync_info.last_updated == updated_sync_info.last_updated
|
assert third_sync_info.last_updated == current_info.last_updated
|
||||||
assert third_sync_info.transaction_id == updated_sync_info.transaction_id
|
assert third_sync_info.transaction_id == updated_sync_info.transaction_id
|
||||||
|
|
||||||
# Set the stale threshold to -120 seconds, and ensure the team is resynced.
|
# Set the stale threshold to 10 seconds, and ensure the team is resynced, after making it
|
||||||
time.sleep(1)
|
# "updated" 20s ago.
|
||||||
sync_teams_to_groups(fake_auth, timedelta(seconds=-120))
|
current_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
||||||
|
current_info.last_updated = datetime.now() - timedelta(seconds=20)
|
||||||
|
current_info.save()
|
||||||
|
|
||||||
|
sync_teams_to_groups(fake_auth, timedelta(seconds=10))
|
||||||
|
|
||||||
fourth_sync_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
fourth_sync_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
||||||
assert fourth_sync_info.transaction_id != updated_sync_info.transaction_id
|
assert fourth_sync_info.transaction_id != updated_sync_info.transaction_id
|
||||||
|
|
Reference in a new issue