Skip to content

Commit

Permalink
Add test for retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatia committed Sep 3, 2024
1 parent 694d318 commit d9a38d7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/src/unit-curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,34 @@ TEST_CASE(
const auto& extra_headers = resources.rest_client()->extra_headers();
CHECK(extra_headers.at("X-Payer") == "foo");
}

TEST_CASE("Test retry logic", "[rest-client][retries]") {
// set the HTTP codes to retry
tiledb::sm::Config cfg;
REQUIRE(cfg.set("rest.retry_http_codes", "503").ok());

std::unordered_map<std::string, std::string> extra_headers;
std::unordered_map<std::string, std::string> res_headers;
std::mutex res_mtx;
Curl curl(tiledb::test::g_helper_logger());
auto rc = curl.init(&cfg, extra_headers, &res_headers, &res_mtx);

// http error not in retry list
CURLcode curl_code = CURLE_OK;
long http_code = 504;
REQUIRE(curl.should_retry_request(curl_code, http_code) == false);

// http error in retry list
http_code = 503;
REQUIRE(curl.should_retry_request(curl_code, http_code) == true);

// Curl error not in retry list
curl_code = CURLE_SSL_SHUTDOWN_FAILED;
REQUIRE(curl.should_retry_request(curl_code, http_code) == false);

// Curl error in retry list
curl_code = CURLE_RECV_ERROR;
// and http error not in retry list
http_code = 504;
REQUIRE(curl.should_retry_request(curl_code, http_code) == true);
}

0 comments on commit d9a38d7

Please sign in to comment.