Skip to content

Commit e3e8a39

Browse files
committed
fix(test): prevent data file clobbering when running --suite=all
When running `make test` (--suite=all), the load and ldbc download blocks in t/t.go shared the same *tmp directory. The ldbc block's MakeDirEmpty call wiped files downloaded by the load block, causing systest/1million to fail with missing schema files. Hoist directory initialization above both download blocks so MakeDirEmpty runs exactly once. Both datasets coexist in the same directory since their filenames don't overlap. Also use a dedicated subdirectory (dgraph-test-data) instead of bare os.TempDir() to avoid wiping the system temp directory. Add testSuiteContainsAny() helper to replace repeated testSuiteContains("x") || testSuiteContains("y") patterns.
1 parent 702e740 commit e3e8a39

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

t/t.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,15 @@ func testSuiteContains(suite string) bool {
899899
return false
900900
}
901901

902+
func testSuiteContainsAny(suites ...string) bool {
903+
for _, suite := range suites {
904+
if testSuiteContains(suite) {
905+
return true
906+
}
907+
}
908+
return false
909+
}
910+
902911
func isValidPackageForSuite(pkg string) bool {
903912
valid := false
904913
if testSuiteContains("all") {
@@ -1211,19 +1220,18 @@ func run() error {
12111220
go func() {
12121221
defer close(testCh)
12131222
valid := getPackages()
1214-
1215-
if testSuiteContains("load") || testSuiteContains("all") {
1216-
if *tmp == "" {
1217-
*tmp = os.TempDir()
1218-
}
1223+
// in "all" mode we can download both data files and
1224+
// ldbc files into the same directory, no duplicated
1225+
// filenames between the two
1226+
needsData := testSuiteContainsAny("load", "ldbc", "all")
1227+
if needsData && *tmp == "" {
1228+
*tmp = filepath.Join(os.TempDir(), "dgraph-test-data")
12191229
x.Check(testutil.MakeDirEmpty([]string{*tmp}))
1230+
}
1231+
if testSuiteContainsAny("load", "all") {
12201232
downloadDataFiles()
12211233
}
1222-
if testSuiteContains("ldbc") || testSuiteContains("all") {
1223-
if *tmp == "" {
1224-
*tmp = filepath.Join(os.TempDir(), "/ldbcdata")
1225-
}
1226-
x.Check(testutil.MakeDirEmpty([]string{*tmp}))
1234+
if testSuiteContainsAny("ldbc", "all") {
12271235
downloadLDBCFiles()
12281236
}
12291237
for i, task := range valid {

0 commit comments

Comments
 (0)