Skip to content

Commit

Permalink
sleep 500ms before retry
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Jan 28, 2022
1 parent 6aaf919 commit 17358b6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions selfdrive/ui/replay/tests/test_replay.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include <chrono>
#include <thread>

#include <QDebug>
#include <QEventLoop>

Expand All @@ -11,11 +14,13 @@ const std::string TEST_RLOG_URL = "https://commadataci.blob.core.windows.net/ope
const std::string TEST_RLOG_CHECKSUM = "5b966d4bb21a100a8c4e59195faeb741b975ccbe268211765efd1763d892bfb3";

bool donload_to_file(const std::string &url, const std::string &local_file, int chunk_size = 5 * 1024 * 1024, int retries = 3) {
bool ret = false;
for (int i = 0; i < retries && !ret; ++i) {
ret = httpDownload(url, local_file, chunk_size);
}
return ret;
do {
if (httpDownload(url, local_file, chunk_size)) {
return true;
}
std::this_thread::sleep_for(std::chrono::milliseconds(500));
} while (--retries >= 0);
return false;
}

TEST_CASE("httpMultiPartDownload") {
Expand All @@ -31,6 +36,7 @@ TEST_CASE("httpMultiPartDownload") {
SECTION("download to buffer") {
for (int i = 0; i < 3 && content.empty(); ++i) {
content = httpGet(TEST_RLOG_URL, chunk_size);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
REQUIRE(!content.empty());
}
Expand Down

0 comments on commit 17358b6

Please sign in to comment.