pam/integration-tests: Avoid downloading chromium on each test run#1040
pam/integration-tests: Avoid downloading chromium on each test run#1040
Conversation
|
|
||
| // vhs uses rod, which downloads chromium to $HOME/.cache/rod, | ||
| // so $HOME needs to be set to avoid that it downloads it every time. | ||
| cmd.Env = append(cmd.Env, fmt.Sprintf("HOME=%s", os.Getenv("HOME"))) |
There was a problem hiding this comment.
@3v1n0 do you see any reason why we shouldn't just pass the whole os.Environ to the vhs command here?
There was a problem hiding this comment.
I would prefer to control what VHS sees and ideally I'd prefer not to be potentially interfered by the developers HOME, and so to shared here. So wondering, can we just set the XDG_CACHE_HOME to make rod use it?
There was a problem hiding this comment.
BTW likely this can be confined to the cases in which: we're in CI, and no chromium or google-chrome[-unstable] is in PATH, no?
There was a problem hiding this comment.
Another option is to just set HOME for vhs itself, but then set it to some test path for the tests themselves
There was a problem hiding this comment.
The directory used by rod is: filepath.Join(os.Getenv("HOME"), ".cache", "rod", "browser")
So we could set $HOME to some temporary directory, but that could have unexpected side effects. IMO we should just keep the environment variables from the go test environment. Or is vhs more prone to interference by the developer's home directory than everything else we do in the tests (where we don't unset the environment)?
There was a problem hiding this comment.
Ah, I see. In the SSH tests we already set HOME to a temporary directory in tapeData.Env: https://github.com/ubuntu/authd/blob/0609f97a414c0b9fe366f4342e91a89d6bcf347c/pam/integration-tests/ssh_test.go#L464-L464
That means that the commands executed by the tape won't see the HOME variable we're setting for vhs anyway, right? Should I add a commit which always sets td.Env["HOME"] = t.TempDir() in RunVhs?
There was a problem hiding this comment.
Ok, I've fixed it there in go-rod/rod#1213
I added a TODO comment to set XDG_CACHE_HOME instead of HOME once that PR was merged
There was a problem hiding this comment.
That means that the commands executed by the tape won't see the HOME variable we're setting for vhs anyway, right?
Yeah, that is fine, my point was: maybe we can just do it for all the tests now (also CLI and Native) and drop it the specific case in ssh tests?
There was a problem hiding this comment.
my point was: maybe we can just do it for all the tests now (also CLI and Native) and drop it the specific case in ssh tests?
that's what I meant with "Should I add a commit which always sets td.Env["HOME"] = t.TempDir() in RunVhs"
3abe25f to
5ee79e3
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1040 +/- ##
==========================================
- Coverage 88.11% 88.10% -0.02%
==========================================
Files 85 85
Lines 6026 6026
Branches 111 111
==========================================
- Hits 5310 5309 -1
- Misses 660 661 +1
Partials 56 56 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@3v1n0 anything missing here? |
The $HOME environment variable wasn't set in the environment which the vhs command runs in, resulting in chromium being downloaded to `.cache/rod` in the current working directory, which is a temporary directory. In effect, chromium was being downloaded each time a test using vhs was executed, which made the test take ~1m longer.
a740eb1 to
7eb1f7d
Compare
The
$HOMEenvironment variable wasn't set in the environment which the vhs command runs in, resulting in chromium being downloaded to.cache/rodin the current working directory, which is a temporary directory. In effect, chromium was being downloaded each time a test using vhs was executed, which made the test take ~1m longer.UDENG-7819