Skip to content

Commit

Permalink
resilient cache tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbull committed Aug 20, 2024
1 parent a2d50d7 commit 631a27e
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions tests/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,30 @@ def test_environment_variables_force_overwrite_to(rig: CloudProviderTestRig, tmp
assert p.stat().st_mtime >= new_local.stat().st_mtime

# would raise if not set
sleep(1.01) # give time so not equal when rounded
p._upload_file_to_cloud(new_local)
assert p.stat().st_mtime > orig_cloud_mod_time # cloud now overwritten
@retry(
retry=retry_if_exception_type(AssertionError),
wait=wait_random_exponential(multiplier=0.5, max=5),
stop=stop_after_attempt(10),
reraise=True,
)
def _wait_for_cloud_newer():
p._upload_file_to_cloud(new_local)
assert p.stat().st_mtime > orig_cloud_mod_time # cloud now overwritten

_wait_for_cloud_newer()

new_also_cloud = rig.create_cloud_path("dir_0/another_cloud_file.txt")
sleep(1.01) # give time so not equal when rounded
new_also_cloud.write_text("newer")

@retry(
retry=retry_if_exception_type(OverwriteNewerLocalError),
wait=wait_random_exponential(multiplier=0.5, max=5),
stop=stop_after_attempt(10),
reraise=True,
)
def _retry_write_until_old_enough():
new_also_cloud.write_text("newer")

_retry_write_until_old_enough()

new_cloud_mod_time = new_also_cloud.stat().st_mtime

Expand Down

0 comments on commit 631a27e

Please sign in to comment.