Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/test/pull_hf_model_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,27 @@ TEST_F(HfDownloadModelModule, TestInvalidProxyTimeout) {
ConstructorEnabledConfig config;
{
EnvGuard eGuard;
// prepareLibgit2Opts() in hf_pull_model_module.cpp only applies the
// GIT_OPT_SET_SERVER_CONNECT_TIMEOUT option when https_proxy is empty,
// so we always clear https_proxy here.
//
// To make the timeout actually fire we need the destination to be
// unreachable. The behavior depends on the host's network setup:
// * Host originally used a proxy (https_proxy was set in the
// environment): the host is on a proxy-only network where a
// direct connection to huggingface.co will hang and hit the
// timeout. Keep the default HF_ENDPOINT.
// * Host has no proxy configured (direct internet access): a direct
// connection to huggingface.co would succeed within the 1 s
// timeout and the assertion below would fail. Redirect the clone
// to an unroutable RFC 5737 TEST-NET-1 address so the connect
// must time out.
const char* hostHttpsProxy = std::getenv("https_proxy");
const bool hostHadProxy = (hostHttpsProxy != nullptr) && (std::string(hostHttpsProxy) != "");
eGuard.set("https_proxy", "");
if (!hostHadProxy) {
eGuard.set("HF_ENDPOINT", "https://192.0.2.1/");
}
const std::string timeoutConnectVal = "1000";
eGuard.set(ovms::HfPullModelModule::GIT_SERVER_CONNECT_TIMEOUT_ENV, timeoutConnectVal);
config.parse(arg_count, const_cast<char**>(n_argv));
Expand Down