mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
test(coderd/workspaceapps/apptest): fix lastusedat assertion for all test (#20827)
The test flake can be verified by setting `ReportInterval` to a really low value, like `100 * time.Millisecond`. We now set it to a really high value to avoid triggering flush without manually calling the function in test. This can easily happen because the default value is 30s and we run tests in parallel. The assertion typically happens such that: [use workspace] -> [fetch previous last used] -> [flush] -> [fetch new last used] When this edge case is triggered: [use workspace] -> [report interval flush] -> [fetch previous last used] -> [flush] -> [fetch new last used] In this case, both the previous and new last used will be the same, breaking the test assertion. Fixes coder/internal#960 Fixes coder/internal#975
This commit is contained in:
committed by
GitHub
parent
8e22cd707a
commit
f6556fce9f
@@ -195,6 +195,22 @@ func setupProxyTestWithFactory(t *testing.T, factory DeploymentFactory, opts *De
|
||||
if opts.DisableSubdomainApps {
|
||||
opts.AppHost = ""
|
||||
}
|
||||
if opts.StatsCollectorOptions.ReportInterval == 0 {
|
||||
// Set to a really high value to avoid triggering flush without manually
|
||||
// calling the function in test. This can easily happen because the
|
||||
// default value is 30s and we run tests in parallel. The assertion
|
||||
// typically happens such that:
|
||||
//
|
||||
// [use workspace] -> [fetch previous last used] -> [flush] -> [fetch new last used]
|
||||
//
|
||||
// When this edge case is triggered:
|
||||
//
|
||||
// [use workspace] -> [report interval flush] -> [fetch previous last used] -> [flush] -> [fetch new last used]
|
||||
//
|
||||
// In this case, both the previous and new last used will be the same,
|
||||
// breaking the test assertion.
|
||||
opts.StatsCollectorOptions.ReportInterval = 9001 * time.Hour
|
||||
}
|
||||
|
||||
deployment := factory(t, opts)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user