Athens: If GOPROXY is set, Athens unit tests will use them implicitly

Created on 30 May 2019  路  5Comments  路  Source: gomods/athens

If a developer runs go test ./... from within the Athens project and they have a GOPROXY environment set, our tests will actually use that variable because our tests run the go command internally.

We have 4 options:

  1. Leave it be, and have the user figure out what's going on.
  2. Check GOPROXY, and warn the user that their tests might be affected (especially if their GOPROXY url is broken for any reason)
  3. Explicitly set GORPOXY to either off or proxy.golang.org so that our tests are more reproducible
  4. Run an Athens instance in the background and kill it
bug good first issue

Most helpful comment

I might just take this haha.

All 5 comments

I might just take this haha.

@Mark-Jung thank you! I think the best thing to do is maybe temporarily set GOPROXY=off in TestMain for the tests that use the GoGetFetcher internally

But would love to get more opinions on this issue from you and others as well :)

I vote for reproducibility as much as possible, which IMO would be setting GOPROXY=https://proxy.golang.org.

On top of that, we would be testing Athens against another implementation of the download protocol, which helps us make sure that we work in the larger ecosystem.

@marwan-at-work
Not sure I understand why go "knows" about GOPROXY env var.
Aren't we creating a separate env here? https://github.com/gomods/athens/blob/a4cf4eb991f375724426d7b466c0705386ad7da3/pkg/module/go_get_fetcher.go#L139
Why is GOPROXY leaked?

@marpio very good point, I totally forgot about that :)

Looking back at the slack channel where the issue was originally reported:

image

I just realized that I misdiagnosed the issue, it's not that our unit tests were seeing the GOPROXY environment variables and using it, it's that @Mark-Jung had set the GOPROXY variable and that his local cache did not have the Athens dependencies yet, and it tried to download them before running the actual unit tests...Hah!

I just locally ran GOPROXY=<fake-domain> go test ./... and everything worked normally

Thanks again for bringing it up!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arschles picture arschles  路  3Comments

opinionsDazzle picture opinionsDazzle  路  4Comments

marpio picture marpio  路  4Comments

weitangli picture weitangli  路  3Comments

arschles picture arschles  路  4Comments