fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

e2e: introduce optional shard cache (#713)

While iterating on the ranking tests it is frustrating to wait for the
index to be built. This commit adds a "-shard_cache" flag to reuse the
computed shards. It defaults to off since this could lead to unexpected
results if we change how we index.

Test Plan: run go test several times with the flag, only the first run
should be slow. Then confirm without flag it is "slow".

$ go test -shard_cache
PASS
ok github.com/sourcegraph/zoekt/internal/e2e 23.307s
$ go test -shard_cache
PASS
ok github.com/sourcegraph/zoekt/internal/e2e 0.235s
$ go test -shard_cache
PASS
ok github.com/sourcegraph/zoekt/internal/e2e 0.218s
$ go test
PASS
ok github.com/sourcegraph/zoekt/internal/e2e 23.416s

+12 -2
+12 -2
internal/e2e/e2e_rank_test.go
··· 24 24 25 25 var update = flag.Bool("update", false, "update golden file") 26 26 27 + var useShardCache = flag.Bool("shard_cache", false, "cache computed shards for faster test runs") 28 + 27 29 // debugScore can be set to include much more output. Do not commit the 28 30 // updated golden files, this is purely used for debugging in a local 29 31 // environment. ··· 58 60 "r:cody sourcegraph url", 59 61 } 60 62 61 - indexDir := t.TempDir() 63 + var indexDir string 64 + if *useShardCache { 65 + t.Logf("reusing index dir to speed up testing. If you have unexpected results remove %s", shardCache) 66 + indexDir = shardCache 67 + } else { 68 + indexDir = t.TempDir() 69 + } 62 70 63 71 for _, u := range archiveURLs { 64 72 if err := indexURL(indexDir, u); err != nil { ··· 130 138 } 131 139 132 140 var tarballCache = "/tmp/zoekt-test-ranking-tarballs-" + os.Getenv("USER") 141 + var shardCache = "/tmp/zoekt-test-ranking-shards-" + os.Getenv("USER") 133 142 134 143 func indexURL(indexDir, u string) error { 135 144 if err := os.MkdirAll(tarballCache, 0700); err != nil { ··· 137 146 } 138 147 139 148 opts := archive.Options{ 140 - Archive: u, 149 + Archive: u, 150 + Incremental: true, 141 151 } 142 152 opts.SetDefaults() // sets metadata like Name and the codeload URL 143 153 u = opts.Archive