{"thread":{"id":"61686","subject":"[PATCH 0/3] reduce test suite dependency on network","startedAt":"2024-06-26T20:53:58Z","lastAt":"2024-06-26T20:57:48Z","messageCount":4,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"497731","messageId":"20240626205355.GA1009060@coredump.intra.peff.net","threadId":"61686","inReplyTo":null,"subject":"[PATCH 0/3] reduce test suite dependency on network","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-06-26T20:53:55Z","receivedAt":"2024-06-26T20:53:58Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"I'm in a remote cabin with spotty internet this week, and I noticed\nseveral delays while running \"make test\". The culprit was DNS request\npackets being dropped due to a passing rainstorm, but not enough that\nthe OS decided the network was down (the DNS resolver was on the other\nend of a VPN). So I was waiting for DNS timeouts.\n\nThis is kind of an exotic situation, but it seems to me that the test\nsuite should avoid making network requests in general, just for the sake\nof reproducibility. And avoiding timeouts is a nice bonus.\n\nSo here are a few small fixes, after which running \"make test\" requires\nzero DNS lookups (and presumably zero external network at all, though of\ncourse we hit localhost/127.0.0.1 for various http, etc, tests).\n\n  [1/3]: t5553: use local url for invalid fetch\n  [2/3]: t5551: do not confirm that bogus url cannot be used\n  [3/3]: t/lib-bundle-uri: use local fake bundle URLs\n\n t/lib-bundle-uri-protocol.sh | 4 ++--\n t/t5551-http-fetch-smart.sh  | 1 -\n t/t5553-set-upstream.sh      | 8 ++++----\n 3 files changed, 6 insertions(+), 7 deletions(-)\n\n-Peff\n"},{"id":"497732","messageId":"20240626205428.GA1457138@coredump.intra.peff.net","threadId":"61686","inReplyTo":"20240626205355.GA1009060@coredump.intra.peff.net","subject":"[PATCH 1/3] t5553: use local url for invalid fetch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-06-26T20:54:28Z","receivedAt":"2024-06-26T20:54:31Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"We test how \"fetch --set-upstream\" behaves when given an invalid URL,\nusing the bogus URL \"http://nosuchdomain.example.com\". But finding out\nthat it is invalid requires an actual DNS lookup.\n\nReduce our dependency on external factors by using an invalid local\nfilesystem URL, which works just as well for our purposes.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n t/t5553-set-upstream.sh | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh\nindex 48050162c2..70e3376d31 100755\n--- a/t/t5553-set-upstream.sh\n+++ b/t/t5553-set-upstream.sh\n@@ -73,10 +73,10 @@ test_expect_success 'fetch --set-upstream main:other does not set the branch oth\n \tcheck_config_missing other2\n '\n \n-test_expect_success 'fetch --set-upstream http://nosuchdomain.example.com fails with invalid url' '\n+test_expect_success 'fetch --set-upstream ./does-not-exist fails with invalid url' '\n \t# main explicitly not cleared, we check that it is not touched from previous value\n \tclear_config other other2 &&\n-\ttest_must_fail git fetch --set-upstream http://nosuchdomain.example.com &&\n+\ttest_must_fail git fetch --set-upstream ./does-not-exist &&\n \tcheck_config main upstream refs/heads/other &&\n \tcheck_config_missing other &&\n \tcheck_config_missing other2\n@@ -143,10 +143,10 @@ test_expect_success 'pull --set-upstream upstream tag does not set the tag' '\n \tcheck_config_missing three\n '\n \n-test_expect_success 'pull --set-upstream http://nosuchdomain.example.com fails with invalid url' '\n+test_expect_success 'pull --set-upstream ./does-not-exist fails with invalid url' '\n \t# main explicitly not cleared, we check that it is not touched from previous value\n \tclear_config other other2 three &&\n-\ttest_must_fail git pull --set-upstream http://nosuchdomain.example.com &&\n+\ttest_must_fail git pull --set-upstream ./does-not-exist &&\n \tcheck_config main upstream refs/heads/other &&\n \tcheck_config_missing other &&\n \tcheck_config_missing other2 &&\n-- \n2.45.2.1058.g2ff574fec9\n\n"},{"id":"497733","messageId":"20240626205525.GB1457138@coredump.intra.peff.net","threadId":"61686","inReplyTo":"20240626205355.GA1009060@coredump.intra.peff.net","subject":"[PATCH 2/3] t5551: do not confirm that bogus url cannot be used","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-06-26T20:55:25Z","receivedAt":"2024-06-26T20:55:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"t5551 tries to access a URL with a bogus hostname and confirms that\nhttp.curloptResolve lets us use this otherwise unresolvable name.\n\nBefore doing so, though, we confirm that trying to access the bogus\nhostname without http.curloptResolve fails as expected. This isn't\ntesting Git at all, but is confirming the test's assumptions. That's\noften a good thing to do, but in this case it means that we'll actually\ntry to resolve the external name. Even though it's unlikely that\n\"gitbogusexamplehost.invalid\" would ever resolve, the DNS lookup itself\nmay take time.\n\nIt's probably reasonable to just assume that this obviously-bogus name\nwould not actually resolve in practice, which lets us reduce our test\nsuite's dependency on the outside world.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n t/t5551-http-fetch-smart.sh | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\nindex a623a1058c..7b5ab0eae1 100755\n--- a/t/t5551-http-fetch-smart.sh\n+++ b/t/t5551-http-fetch-smart.sh\n@@ -643,7 +643,6 @@ test_expect_success 'clone empty SHA-256 repository with protocol v0' '\n test_expect_success 'passing hostname resolution information works' '\n \tBOGUS_HOST=gitbogusexamplehost.invalid &&\n \tBOGUS_HTTPD_URL=$HTTPD_PROTO://$BOGUS_HOST:$LIB_HTTPD_PORT &&\n-\ttest_must_fail git ls-remote \"$BOGUS_HTTPD_URL/smart/repo.git\" >/dev/null &&\n \tgit -c \"http.curloptResolve=$BOGUS_HOST:$LIB_HTTPD_PORT:127.0.0.1\" ls-remote \"$BOGUS_HTTPD_URL/smart/repo.git\" >/dev/null\n '\n \n-- \n2.45.2.1058.g2ff574fec9\n\n"},{"id":"497734","messageId":"20240626205745.GC1457138@coredump.intra.peff.net","threadId":"61686","inReplyTo":"20240626205355.GA1009060@coredump.intra.peff.net","subject":"[PATCH 3/3] t/lib-bundle-uri: use local fake bundle URLs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-06-26T20:57:45Z","receivedAt":"2024-06-26T20:57:48Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"A few of the bundle URI tests point config at a fake bundle; they care\nonly that the client has been configured with _some_ bundle, but it\ndoesn't have to actually contain objects.\n\nFor the file:// tests, we use \"$BUNDLE_URI_REPO_URI/fake.bdl\", a\nnon-existent file inside the actual remote repo. But for git:// and\nhttp:// tests, we use \"https://example.com/fake.bdl\". This works OK in\npractice, but it means we actually make a request to example.com (which\nreturns a placeholder HTML response). That can be annoying when running\nthe test suite on a spotty network (it doesn't produce a wrong result,\nsince we expect it to fail, but it may introduce delays).\n\nWe can reduce our dependency on the outside world by using a local URL.\nIt would work to just do \"file://$PWD/fake.bdl\" here, since the bundle\ncode does not care about the actual location. But in the long run I\nsuspect we may have more restrictions on which protocols can be passed\naround as bundle URIs. So instead, let's stick with the file:// repo's\npattern and just point to a bogus name based on the remote repo's URL.\n\nFor http this makes perfect sense; we'll make a request to the local\nhttp server and find that there's nothing there. For git:// it's a\nlittle weird, as you wouldn't normally access a bundle file over git://\nat all. But it's probably the most reasonable guess we can make for now,\nand anybody who tightens protocol selection later will know better\nwhat's the best path forward.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n t/lib-bundle-uri-protocol.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/lib-bundle-uri-protocol.sh b/t/lib-bundle-uri-protocol.sh\nindex a4a1af8d02..de09b6b02e 100644\n--- a/t/lib-bundle-uri-protocol.sh\n+++ b/t/lib-bundle-uri-protocol.sh\n@@ -18,15 +18,15 @@ git)\n \tstart_git_daemon --export-all --enable=receive-pack\n \tBUNDLE_URI_PARENT=\"$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent\"\n \tBUNDLE_URI_REPO_URI=\"$GIT_DAEMON_URL/parent\"\n-\tBUNDLE_URI_BUNDLE_URI=\"https://example.com/fake.bdl\"\n+\tBUNDLE_URI_BUNDLE_URI=\"$BUNDLE_URI_REPO_URI/fake.bdl\"\n \ttest_set_prereq BUNDLE_URI_GIT\n \t;;\n http)\n \t. \"$TEST_DIRECTORY\"/lib-httpd.sh\n \tstart_httpd\n \tBUNDLE_URI_PARENT=\"$HTTPD_DOCUMENT_ROOT_PATH/http_parent\"\n \tBUNDLE_URI_REPO_URI=\"$HTTPD_URL/smart/http_parent\"\n-\tBUNDLE_URI_BUNDLE_URI=\"https://example.com/fake.bdl\"\n+\tBUNDLE_URI_BUNDLE_URI=\"$BUNDLE_URI_REPO_URL/fake.bdl\"\n \ttest_set_prereq BUNDLE_URI_HTTP\n \t;;\n *)\n-- \n2.45.2.1058.g2ff574fec9\n"}]}