Athens: Fix test_e2e.sh - set GOPATH to the temp dir

Created on 19 Aug 2018  路  16Comments  路  Source: gomods/athens

At the moment
https://github.com/gomods/athens/blob/493945c13a740e790ef9d04b638598f3445d5d7d/scripts/test_e2e.sh#L14-L16
doesn't clear the cache because the cache is under GOPATH/pkg/mod Because of that go doesn't use the proxy which is the point of the test.

To fix that we need to temporary set GOPATH to
https://github.com/gomods/athens/blob/493945c13a740e790ef9d04b638598f3445d5d7d/scripts/test_e2e.sh#L10

ccd good first issue

Most helpful comment

I will take this one.

All 16 comments

@marpio GOMOD_CACHE is already using TMPDIR, am I missing something?

https://github.com/gomods/athens/blob/493945c13a740e790ef9d04b638598f3445d5d7d/scripts/test_e2e.sh#L11

@mydiemho GOMOD_CACHE isn't something go knows about so the cache won't be there. It's just a var set to path where the cache _should_ be (but it's not right now). If we set GOPATH env var to TMPDIR go will actually put the cache there.

@michalpristas thanks for the inspiration, but not sure what I'm looking at.

@marpio I'm still confuse by what this issue is trying to solve. Is it

  1. Cache is not being clear and we would like to clear cache. OR
  2. GOPATH is not correct so tests are failing

When you say temporary, do you mean within the script or through the whole script, ie. unset it at the end of the script.

In the script, we are calling clearGoModCache twice. Why?

in the script i linked, they use gopath like env GOPATH=$WORK/gopath1 where WORK is something like tmp
at the end they clean the whole work

Cache is not being clear and we would like to clear cache.

Yes, we even need to do that!
We are executing go run . twice:

In the script, we are calling clearGoModCache twice. Why?

The first time to ensure that go run . is using the proxy and not cache.
The second time just to clean up after the script so that we don't leave any unnecessary files on disk. We could actually clear the whole GOPATH dir as Michal suggested.

When you say temporary, do you mean within the script or through the whole script, ie. unset it at the end of the script.

Yes, we want to set it back to the original value at the end so we don't mess up someone's environment.

Yes, we want to set it back to the original value at the end so we don't mess up someone's environment.

馃憤 for being a good citizen

We should also unset or set the GO111MODULE env var to the original value since it's not mandatory in 1.11

That should be part of #378

@robjloranger could you expand on that?
The scenario I had in mind was running the test-e2e on a development machine. At the end of the test we should leave the environment as it was before.

Oh sorry @marpio I misread. I thought the comment was for setting the variable in CI.

@mydiemho are you working on this?

@marpio sorry I got busy and won't have time to work on this right now

No worries @mydiemho ! thanks for the info.

I will take this one.

Was this page helpful?
0 / 5 - 0 ratings