Skip to content

Commit 317484c

Browse files
authored
cleanup(storage): deflake integration test (#9764)
1 parent 6cfb110 commit 317484c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

google/cloud/storage/tests/object_file_multi_threaded_test.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ class ObjectFileMultiThreadedTest
7878
}
7979
auto metadata =
8080
client.InsertObject(bucket_name_, n, contents, IfGenerationMatch(0));
81-
if (!metadata) return metadata.status();
81+
if (metadata) continue;
82+
// kAlreadyExists is acceptable, it happens if (1) a retry attempt
83+
// succeeds, but returns kUnavailable or a similar error (these can be
84+
// network / overload issues), (2) the next retry attempt finds the object
85+
// was already created.
86+
if (metadata.status().code() == StatusCode::kAlreadyExists) continue;
87+
return metadata.status();
8288
}
8389
return Status();
8490
}
@@ -114,7 +120,12 @@ class ObjectFileMultiThreadedTest
114120
std::cout << '.' << std::flush;
115121
}
116122
auto result = client.DeleteObject(bucket_name_, name);
117-
if (!result.ok()) status = result;
123+
if (result.ok()) continue;
124+
// kNotFound is acceptable, it happens if (1) a retry attempt succeeds,
125+
// but returns kUnavailable or a similar error, (2) the next retry attempt
126+
// cannot find the object.
127+
if (result.code() == StatusCode::kNotFound) continue;
128+
status = result;
118129
}
119130
return status;
120131
}

0 commit comments

Comments
 (0)