Repository: go
Issue: cmd/go, cmd/go/internal/modfetch: update tests not to rely on external domains that only an individual maintainer has access to
Labels: Testing,NeedsInvestigation,GoCommand

(Factoring out comment https://github.com/golang/go/issues/28856#issuecomment-665252612 into a separate issue, since it's slightly different than #28856 and out of scope for that issue.)

Some of `cmd/go` and `cmd/go/internal/modfetch` tests currently rely on content hosted on `rsc.io`, `swtch.com`, and `insecure.go-get-issue-15410.appspot.com` domains, and historically a single individual had access to those projects. They have been very reliable for many years, and since they're explicitly created as test modules for `cmd/go` tests, and we don't expect the content to change for due to active project development, as in issue #28856.

However, we still want these tests not to have a single point of failure, since an individual person may be unavailable (e.g., due to being on a vacation), and it is important that we're able to fix any issues if they come up in the future, or if the test data needs to be updated for some reason.

Perhaps this can be resolved by granting access to those hosts to the cmd/go team (as suggested by @rsc and @andybons), or by moving them to an existing host that the cmd/go team has access to (such as vcs-test.golang.org), or by starting up a test-local server (as suggested by @bcmills in https://github.com/golang/go/issues/28856#issuecomment-667261222).

Details of tests that were affected recently (from https://storage.googleapis.com/go-build-log/3c347861/linux-amd64-longtest_bb29e807.log, https://storage.googleapis.com/go-build-log/2229151e/linux-386-longtest_dca9ed82.log, and https://storage.googleapis.com/go-build-log/0fcc0a58/linux-amd64-longtest_642c58db.log):

<details><br>

```
--- FAIL: TestGoGetCustomDomainWildcard (0.24s)
    go_test.go:2628: running testgo [get -u rsc.io/pdf/...]
    go_test.go:2628: standard error:
    go_test.go:2628: package rsc.io/pdf/...: unrecognized import path "rsc.io/pdf": reading https://rsc.io/pdf?go-get=1: 503 Service Unavailable
        
    go_test.go:2628: go [get -u rsc.io/pdf/...] failed unexpectedly in /workdir/go/src/cmd/go: exit status 1
--- FAIL: TestGoGetDotSlashDownload (0.22s)
    go_test.go:2714: running testgo [get ./pprof_mac_fix]
    go_test.go:2714: standard error:
    go_test.go:2714: unrecognized import path "rsc.io/pprof_mac_fix": reading https://rsc.io/pprof_mac_fix?go-get=1: 503 Service Unavailable
        
    go_test.go:2714: go [get ./pprof_mac_fix] failed unexpectedly in /workdir/tmp/cmd-go-test-062451185/gotest700832841/src/rsc.io: exit status 1
    panic.go:617: ended in /workdir/tmp/cmd-go-test-062451185/gotest700832841/src/rsc.io
--- FAIL: TestGoGetInsecure (1.38s)
    --- FAIL: TestGoGetInsecure/gopath (0.11s)
        go_test.go:2895: running testgo [get -d insecure.go-get-issue-15410.appspot.com/pkg/p]
        go_test.go:2895: standard error:
        go_test.go:2895: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": https fetch: Get "https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1": x509: certificate is valid for *.appspot-preview.com, *.an.r.appspot.com, *.app.google, *.appspot.com, *.as.r.appspot.com, *.de.r.appspot.com, *.df.r.appspot.com, *.dt.r.appspot.com, *.du.r.appspot.com, *.el.r.appspot.com, *.et.r.appspot.com, *.ew.r.appspot.com, *.ey.r.appspot.com, *.ez.r.appspot.com, *.lz.r.appspot.com, *.nn.r.appspot.com, *.nw.r.appspot.com, *.nz.r.appspot.com, *.oa.r.appspot.com, *.rj.r.appspot.com, *.thinkwithgoogle.com, *.ts.r.appspot.com, *.tz.r.appspot.com, *.uc.r.appspot.com, *.ue.r.appspot.com, *.uk.r.appspot.com, *.uw.r.appspot.com, *.withgoogle.com, *.withyoutube.com, *.wl.r.appspot.com, *.wm.r.appspot.com, *.wn.r.appspot.com, app.google, appspot-preview.com, appspot.com, thinkwithgoogle.com, withgoogle.com, withyoutube.com, not insecure.go-get-issue-15410.appspot.com
            
        go_test.go:2895: testgo failed as expected: exit status 1
        go_test.go:2898: running testgo [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p]
        go_test.go:2898: standard error:
        go_test.go:2898: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": reading https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1: 503 Service Unavailable
            
        go_test.go:2898: go [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p] failed unexpectedly in /workdir/go/src/cmd/go: exit status 1
    --- FAIL: TestGoGetInsecure/modules (1.26s)
        go_test.go:2895: running testgo [get -d insecure.go-get-issue-15410.appspot.com/pkg/p]
        go_test.go:2895: standard error:
        go_test.go:2895: go get insecure.go-get-issue-15410.appspot.com/pkg/p: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": https fetch: Get "https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1": x509: certificate is valid for *.appspot-preview.com, *.an.r.appspot.com, *.app.google, *.appspot.com, *.as.r.appspot.com, *.de.r.appspot.com, *.df.r.appspot.com, *.dt.r.appspot.com, *.du.r.appspot.com, *.el.r.appspot.com, *.et.r.appspot.com, *.ew.r.appspot.com, *.ey.r.appspot.com, *.ez.r.appspot.com, *.lz.r.appspot.com, *.nn.r.appspot.com, *.nw.r.appspot.com, *.nz.r.appspot.com, *.oa.r.appspot.com, *.rj.r.appspot.com, *.thinkwithgoogle.com, *.ts.r.appspot.com, *.tz.r.appspot.com, *.uc.r.appspot.com, *.ue.r.appspot.com, *.uk.r.appspot.com, *.uw.r.appspot.com, *.withgoogle.com, *.withyoutube.com, *.wl.r.appspot.com, *.wm.r.appspot.com, *.wn.r.appspot.com, app.google, appspot-preview.com, appspot.com, thinkwithgoogle.com, withgoogle.com, withyoutube.com, not insecure.go-get-issue-15410.appspot.com
            
        go_test.go:2895: testgo failed as expected: exit status 1
        go_test.go:2898: running testgo [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p]
        go_test.go:2898: standard error:
        go_test.go:2898: go get insecure.go-get-issue-15410.appspot.com/pkg/p: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": reading https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1: 503 Service Unavailable
            
        go_test.go:2898: go [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p] failed unexpectedly in /workdir/tmp/cmd-go-test-062451185/gotest738708835: exit status 1
        panic.go:617: ended in /workdir/tmp/cmd-go-test-062451185/gotest738708835
--- FAIL: TestGoGetInsecureCustomDomain (0.09s)
    go_test.go:2983: running testgo [get -d insecure.go-get-issue-15410.appspot.com/pkg/p]
    go_test.go:2983: standard error:
    go_test.go:2983: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": https fetch: Get "https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1": x509: certificate is valid for *.appspot-preview.com, *.an.r.appspot.com, *.app.google, *.appspot.com, *.as.r.appspot.com, *.de.r.appspot.com, *.df.r.appspot.com, *.dt.r.appspot.com, *.du.r.appspot.com, *.el.r.appspot.com, *.et.r.appspot.com, *.ew.r.appspot.com, *.ey.r.appspot.com, *.ez.r.appspot.com, *.lz.r.appspot.com, *.nn.r.appspot.com, *.nw.r.appspot.com, *.nz.r.appspot.com, *.oa.r.appspot.com, *.rj.r.appspot.com, *.thinkwithgoogle.com, *.ts.r.appspot.com, *.tz.r.appspot.com, *.uc.r.appspot.com, *.ue.r.appspot.com, *.uk.r.appspot.com, *.uw.r.appspot.com, *.withgoogle.com, *.withyoutube.com, *.wl.r.appspot.com, *.wm.r.appspot.com, *.wn.r.appspot.com, app.google, appspot-preview.com, appspot.com, thinkwithgoogle.com, withgoogle.com, withyoutube.com, not insecure.go-get-issue-15410.appspot.com
        
    go_test.go:2983: testgo failed as expected: exit status 1
    go_test.go:2984: running testgo [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p]
    go_test.go:2984: standard error:
    go_test.go:2984: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": reading https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1: 503 Service Unavailable
        
    go_test.go:2984: go [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p] failed unexpectedly in /workdir/go/src/cmd/go: exit status 1
go test proxy running at GOPROXY=http://127.0.0.1:45253/mod
go proxy: no archive rsc.io v1.5.1: file does not exist
go proxy: no archive example.com/newcycle v1.0.0: file does not exist
go proxy: no archive rsc.io v1.0.0: file does not exist
go proxy: no archive rsc.io v1.4.0: file does not exist
go proxy: no archive rsc.io v1.5.2: file does not exist
go proxy: no archive rsc.io v1.1.0: file does not exist
go proxy: no archive rsc.io v1.0.0: file does not exist
go proxy: no archive rsc.io v1.0.0: file does not exist
go proxy: no archive rsc.io v1.0.0: file does not exist
go proxy: no archive rsc.io v1.0.0: file does not exist
go proxy: no archive golang.org v0.1.0: file does not exist
go proxy: no archive golang.org v0.3.0: file does not exist
go proxy: no archive golang.org/x v0.1.0: file does not exist
go proxy: no archive golang.org/x v0.3.0: file does not exist
go proxy: no archive example.com v0.1.0: file does not exist
go proxy: no archive rsc.io v1.5.2: file does not exist
--- FAIL: TestScript (0.00s)
    --- FAIL: TestScript/mod_init_dep (0.24s)
        script_test.go:193: 
            # modconv uses git directly to examine what old 'go get' would (0.001s)
            # go build should populate go.mod from Gopkg.lock (0.229s)
            > cp go.mod1 go.mod
            > go build
            [stderr]
            go: copying requirements from Gopkg.lock
            go: converting Gopkg.lock: stat rsc.io/sampler@v1.0.0: unrecognized import path "rsc.io/sampler": reading https://rsc.io/sampler?go-get=1: 503 Service Unavailable
            > stderr 'copying requirements from Gopkg.lock'
            > go list -m all
            [stdout]
            x
            > ! stderr 'copying requirements from Gopkg.lock'
            > stdout 'rsc.io/sampler v1.0.0'
            FAIL: testdata/script/mod_init_dep.txt:13: no match for `(?m)rsc.io/sampler v1.0.0` found in stdout
            
    --- FAIL: TestScript/mod_gonoproxy (0.78s)
        script_test.go:193: 
            # disagree with sumdb fails (0.028s)
            # but GONOSUMDB bypasses sumdb, for rsc.io/quote, rsc.io/sampler, golang.org/x/text (0.560s)
            # and GONOPROXY bypasses proxy (0.169s)
            > [!net] skip
            > [!exec:git] skip
            > env GOPRIVATE=none
            > env GONOPROXY='*/fortune'
            > ! go get rsc.io/fortune # does not exist in real world, only on test proxy
            [stderr]
            go get rsc.io/fortune: unrecognized import path "rsc.io/fortune": reading https://rsc.io/fortune?go-get=1: 503 Service Unavailable
            [exit status 1]
            > stderr 'git ls-remote'
            FAIL: testdata/script/mod_gonoproxy.txt:27: no match for `(?m)git ls-remote` found in stderr
            
    --- FAIL: TestScript/mod_download_hash (0.31s)
        script_test.go:193: 
            # Testing mod download with non semantic versions; turn off proxy. (0.307s)
            > [!net] skip
            > [!exec:git] skip
            > env GOPROXY=direct
            > env GOSUMDB=off
            > go mod download rsc.io/quote@a91498bed0a73d4bb9c1fb2597925f7883bc40a7
            [stderr]
            rsc.io/quote@a91498bed0a73d4bb9c1fb2597925f7883bc40a7: unrecognized import path "rsc.io/quote": reading https://rsc.io/quote?go-get=1: 503 Service Unavailable
            [exit status 1]
            FAIL: testdata/script/mod_download_hash.txt:9: unexpected command failure
            
    --- FAIL: TestScript/mod_sumdb_golang (0.27s)
        script_test.go:193: 
            # Test default GOPROXY and GOSUMDB (0.083s)
            # download direct from github (0.190s)
            > [!net] skip
            > [!exec:git] skip
            > env GOSUMDB=sum.golang.org
            > env GOPROXY=direct
            > go get -d rsc.io/quote@v1.5.2
            [stderr]
            go get rsc.io/quote@v1.5.2: unrecognized import path "rsc.io/quote": reading https://rsc.io/quote?go-get=1: 503 Service Unavailable
            [exit status 1]
            FAIL: testdata/script/mod_sumdb_golang.txt:17: unexpected command failure
            
    --- FAIL: TestScript/gopath_moved_repo (0.87s)
        script_test.go:193: 
            # Test that 'go get -u' reports packages whose VCS configurations do not
            # match their import paths. (0.000s)
            # We need to execute a custom Go program to break the config files.
            #
            # git will ask for a username and password when we run 'go get -d -f -u',
            # so we also need to set GIT_ASKPASS. Conveniently, a single binary can
            # perform both tasks! (0.674s)
            # Test that 'go get -u' reports moved git packages. (0.191s)
            > [exec:git] go get -d rsc.io/pdf
            [stderr]
            unrecognized import path "rsc.io/pdf": reading https://rsc.io/pdf?go-get=1: 503 Service Unavailable
            [exit status 1]
            FAIL: testdata/script/gopath_moved_repo.txt:21: unexpected command failure
            
--- FAIL: TestIssue11457 (0.20s)
    go_test.go:1087: running testgo [get -d -u rsc.io/go-get-issue-11457]
    go_test.go:1087: standard error:
    go_test.go:1087: unrecognized import path "rsc.io/go-get-issue-11457": reading https://rsc.io/go-get-issue-11457?go-get=1: 503 Service Unavailable
        
    go_test.go:1087: go [get -d -u rsc.io/go-get-issue-11457] failed unexpectedly in /workdir/go/src/cmd/go: exit status 1
--- FAIL: TestIssue16471 (1.31s)
    go_test.go:1071: git standard error:
    go_test.go:1071: Cloning into 'go-get-issue-10952'...
        
    go_test.go:1072: running testgo [get -u rsc.io/go-get-issue-10952]
    go_test.go:1072: testgo succeeded unexpectedly
FAIL
FAIL	cmd/go	132.219s
FAIL
```

```
--- FAIL: TestCodeRepo (11.97s)
    --- FAIL: TestCodeRepo/parallel (0.00s)
        --- FAIL: TestCodeRepo/parallel/swtch.com_testmod/v1.0.0 (0.14s)
            coderepo_test.go:451: Lookup("swtch.com/testmod"): unrecognized import path "swtch.com/testmod": reading https://swtch.com/testmod?go-get=1: 503 Service Unavailable
--- FAIL: TestCodeRepoVersions (1.58s)
    --- FAIL: TestCodeRepoVersions/parallel (0.00s)
        --- FAIL: TestCodeRepoVersions/parallel/swtch.com_testmod (0.00s)
            coderepo_test.go:690: Lookup("swtch.com/testmod"): unrecognized import path "swtch.com/testmod": reading https://swtch.com/testmod?go-get=1: 503 Service Unavailable
--- FAIL: TestLatest (0.47s)
    --- FAIL: TestLatest/parallel (0.00s)
        --- FAIL: TestLatest/parallel/swtch.com_testmod (0.00s)
            coderepo_test.go:768: Lookup("swtch.com/testmod"): unrecognized import path "swtch.com/testmod": reading https://swtch.com/testmod?go-get=1: 503 Service Unavailable
FAIL
FAIL	cmd/go/internal/modfetch	14.044s
```

```
--- FAIL: TestGoGetInsecure (1.44s)
    --- FAIL: TestGoGetInsecure/gopath (0.13s)
        go_test.go:2895: running testgo [get -d insecure.go-get-issue-15410.appspot.com/pkg/p]
        go_test.go:2895: standard error:
        go_test.go:2895: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": https fetch: Get "https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1": x509: certificate is valid for *.appspot-preview.com, *.an.r.appspot.com, *.app.google, *.appspot.com, *.as.r.appspot.com, *.de.r.appspot.com, *.df.r.appspot.com, *.dt.r.appspot.com, *.du.r.appspot.com, *.el.r.appspot.com, *.et.r.appspot.com, *.ew.r.appspot.com, *.ey.r.appspot.com, *.ez.r.appspot.com, *.lz.r.appspot.com, *.nn.r.appspot.com, *.nw.r.appspot.com, *.nz.r.appspot.com, *.oa.r.appspot.com, *.rj.r.appspot.com, *.thinkwithgoogle.com, *.ts.r.appspot.com, *.tz.r.appspot.com, *.uc.r.appspot.com, *.ue.r.appspot.com, *.uk.r.appspot.com, *.uw.r.appspot.com, *.withgoogle.com, *.withyoutube.com, *.wl.r.appspot.com, *.wm.r.appspot.com, *.wn.r.appspot.com, app.google, appspot-preview.com, appspot.com, thinkwithgoogle.com, withgoogle.com, withyoutube.com, not insecure.go-get-issue-15410.appspot.com
            
        go_test.go:2895: testgo failed as expected: exit status 1
        go_test.go:2898: running testgo [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p]
        go_test.go:2898: standard error:
        go_test.go:2898: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": reading https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1: 503 Service Unavailable
            
        go_test.go:2898: go [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p] failed unexpectedly in /workdir/go/src/cmd/go: exit status 1
    --- FAIL: TestGoGetInsecure/modules (1.30s)
        go_test.go:2895: running testgo [get -d insecure.go-get-issue-15410.appspot.com/pkg/p]
        go_test.go:2895: standard error:
        go_test.go:2895: go get insecure.go-get-issue-15410.appspot.com/pkg/p: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": https fetch: Get "https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1": x509: certificate is valid for *.appspot-preview.com, *.an.r.appspot.com, *.app.google, *.appspot.com, *.as.r.appspot.com, *.de.r.appspot.com, *.df.r.appspot.com, *.dt.r.appspot.com, *.du.r.appspot.com, *.el.r.appspot.com, *.et.r.appspot.com, *.ew.r.appspot.com, *.ey.r.appspot.com, *.ez.r.appspot.com, *.lz.r.appspot.com, *.nn.r.appspot.com, *.nw.r.appspot.com, *.nz.r.appspot.com, *.oa.r.appspot.com, *.rj.r.appspot.com, *.thinkwithgoogle.com, *.ts.r.appspot.com, *.tz.r.appspot.com, *.uc.r.appspot.com, *.ue.r.appspot.com, *.uk.r.appspot.com, *.uw.r.appspot.com, *.withgoogle.com, *.withyoutube.com, *.wl.r.appspot.com, *.wm.r.appspot.com, *.wn.r.appspot.com, app.google, appspot-preview.com, appspot.com, thinkwithgoogle.com, withgoogle.com, withyoutube.com, not insecure.go-get-issue-15410.appspot.com
            
        go_test.go:2895: testgo failed as expected: exit status 1
        go_test.go:2898: running testgo [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p]
        go_test.go:2898: standard error:
        go_test.go:2898: go get insecure.go-get-issue-15410.appspot.com/pkg/p: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": reading https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1: 503 Service Unavailable
            
        go_test.go:2898: go [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p] failed unexpectedly in /workdir/tmp/cmd-go-test-772897562/gotest647673300: exit status 1
        panic.go:617: ended in /workdir/tmp/cmd-go-test-772897562/gotest647673300
--- FAIL: TestGoGetInsecureCustomDomain (0.10s)
    go_test.go:2983: running testgo [get -d insecure.go-get-issue-15410.appspot.com/pkg/p]
    go_test.go:2983: standard error:
    go_test.go:2983: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": https fetch: Get "https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1": x509: certificate is valid for *.appspot-preview.com, *.an.r.appspot.com, *.app.google, *.appspot.com, *.as.r.appspot.com, *.de.r.appspot.com, *.df.r.appspot.com, *.dt.r.appspot.com, *.du.r.appspot.com, *.el.r.appspot.com, *.et.r.appspot.com, *.ew.r.appspot.com, *.ey.r.appspot.com, *.ez.r.appspot.com, *.lz.r.appspot.com, *.nn.r.appspot.com, *.nw.r.appspot.com, *.nz.r.appspot.com, *.oa.r.appspot.com, *.rj.r.appspot.com, *.thinkwithgoogle.com, *.ts.r.appspot.com, *.tz.r.appspot.com, *.uc.r.appspot.com, *.ue.r.appspot.com, *.uk.r.appspot.com, *.uw.r.appspot.com, *.withgoogle.com, *.withyoutube.com, *.wl.r.appspot.com, *.wm.r.appspot.com, *.wn.r.appspot.com, app.google, appspot-preview.com, appspot.com, thinkwithgoogle.com, withgoogle.com, withyoutube.com, not insecure.go-get-issue-15410.appspot.com
        
    go_test.go:2983: testgo failed as expected: exit status 1
    go_test.go:2984: running testgo [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p]
    go_test.go:2984: standard error:
    go_test.go:2984: unrecognized import path "insecure.go-get-issue-15410.appspot.com/pkg/p": reading https://insecure.go-get-issue-15410.appspot.com/pkg/p?go-get=1: 503 Service Unavailable
        
    go_test.go:2984: go [get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p] failed unexpectedly in /workdir/go/src/cmd/go: exit status 1
```

</details>

/cc @bcmills @jayconrod @matloob @rsc @andybons