Skip to content

Commit

Permalink
Add retries.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsimantov committed Jan 17, 2024
1 parent e54cc9a commit 14f4841
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions storage/integration_test/src/integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class FirebaseStorageTest : public FirebaseTest {
firebase::storage::StorageReference CreateFolder();

int64_t GetRemoteTimeInMilliseconds();

static firebase::App* shared_app_;
static firebase::auth::Auth* shared_auth_;

Expand Down Expand Up @@ -329,13 +329,17 @@ firebase::storage::StorageReference FirebaseStorageTest::CreateFolder() {
int64_t FirebaseStorageTest::GetRemoteTimeInMilliseconds() {
SignIn();

firebase::storage::StorageReference ref = CreateFolder().Child("timestamp.txt");
firebase::Future<firebase::storage::Metadata> future = ref.PutBytes("TS00", 4);
firebase::storage::StorageReference ref =
CreateFolder().Child("timestamp.txt");
firebase::Future<firebase::storage::Metadata> future =
RunWithRetry<firebase::storage::Metadata>(
[&]() { return ref.PutBytes("TS00", 4); });
WaitForCompletionAnyResult(future, "GetRemoteTime_PutBytes");
if (future.error() == 0 && future.result() != nullptr &&
future.result()->creation_time() > 0) {
int64_t timestamp = future.result()->creation_time();
WaitForCompletionAnyResult(ref.Delete(), "GetRemoteTime_Delete");
WaitForCompletionAnyResult(RunWithRetry([&]() { return ref.Delete(); }),
"GetRemoteTime_Delete");
return timestamp;
} else {
LogWarning("Couldn't get remote timestamp, using local time");
Expand Down

0 comments on commit 14f4841

Please sign in to comment.