Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archive: re-use shard cache in e2e rank tests #697

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cmd/zoekt-archive-index/e2e_rank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

var update = flag.Bool("update", false, "update golden file")
var noShardCache = flag.Bool("noShardCache", os.Getenv("CI") != "", "by default we reuse the shard cache to speed up testing")

func TestRanking(t *testing.T) {
requireCTags(t)
Expand All @@ -32,7 +33,13 @@ func TestRanking(t *testing.T) {
"graphql type User",
}

indexDir := t.TempDir()
var indexDir string
if *noShardCache {
indexDir = t.TempDir()
} else {
t.Logf("reusing index dir to speed up testing. If you have unexpected results try go test -no_shard_cache or remove %s", shardCache)
indexDir = shardCache
}

for _, u := range archiveURLs {
if err := indexURL(indexDir, u); err != nil {
Expand Down Expand Up @@ -97,14 +104,16 @@ func TestRanking(t *testing.T) {
}

var tarballCache = "/tmp/zoekt-test-ranking-tarballs-" + os.Getenv("USER")
var shardCache = "/tmp/zoekt-test-ranking-shards-" + os.Getenv("USER")

func indexURL(indexDir, u string) error {
if err := os.MkdirAll(tarballCache, 0700); err != nil {
return err
}

opts := Options{
Archive: u,
Incremental: true,
Archive: u,
}
opts.SetDefaults() // sets metadata like Name and the codeload URL
u = opts.Archive
Expand Down
Loading