Skip to content

Commit 75293c0

Browse files
committed
fix(test): resolve staticcheck SA9003 and prettier formatting
Remove empty if-branch flagged by staticcheck SA9003 in t/t.go and fix markdown table alignment in TESTING.md for prettier compliance.
1 parent 1679571 commit 75293c0

2 files changed

Lines changed: 29 additions & 22 deletions

File tree

TESTING.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -579,16 +579,16 @@ cd t && go build .
579579

580580
### Key Flags
581581

582-
| Flag | Description |
583-
| --------------- | ------------------------------------------------------------------ |
584-
| `--suite=X` | Select test suite(s): all, ldbc, load, unit, systest, vector, core |
585-
| `--pkg=X` | Run specific package |
586-
| `--test=X` | Run specific test function |
587-
| `--timeout=X` | Per-package timeout (e.g. 60m, 2h). Default: 30m (180m with --race)|
588-
| `-j=N` | Concurrency (default: 1) |
589-
| `--keep` | Keep cluster running after tests |
590-
| `-r` | Remove all test containers |
591-
| `--skip-slow` | Skip slow packages |
582+
| Flag | Description |
583+
| ------------- | ------------------------------------------------------------------- |
584+
| `--suite=X` | Select test suite(s): all, ldbc, load, unit, systest, vector, core |
585+
| `--pkg=X` | Run specific package |
586+
| `--test=X` | Run specific test function |
587+
| `--timeout=X` | Per-package timeout (e.g. 60m, 2h). Default: 30m (180m with --race) |
588+
| `-j=N` | Concurrency (default: 1) |
589+
| `--keep` | Keep cluster running after tests |
590+
| `-r` | Remove all test containers |
591+
| `--skip-slow` | Skip slow packages |
592592

593593
---
594594

t/t.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,7 @@ func runTestsFor(ctx context.Context, pkg, prefix string, xmlFile string) error
433433
default:
434434
args = append(args, "-timeout", "30m")
435435
}
436-
if *race {
437-
// Todo: There are few race errors in tests itself. Enable this once that is fixed.
438-
// args = append(args, "-race")
439-
}
436+
// Todo: There are few race errors in tests itself. Enable -race once that is fixed.
440437

441438
if *count > 0 {
442439
args = append(args, "-count="+strconv.Itoa(*count))
@@ -458,7 +455,11 @@ func runTestsFor(ctx context.Context, pkg, prefix string, xmlFile string) error
458455
if err != nil {
459456
return fmt.Errorf("while getting absolute path of tmp directory: %v Error: %v", *tmp, err)
460457
}
461-
cmd.Env = append(cmd.Env, "TEST_DATA_DIRECTORY="+abs)
458+
dataDir := abs
459+
if strings.Contains(pkg, "/ldbc") {
460+
dataDir = filepath.Join(abs, "ldbc")
461+
}
462+
cmd.Env = append(cmd.Env, "TEST_DATA_DIRECTORY="+dataDir)
462463
// Use failureCatcher.
463464
cmd.Stdout = oc
464465

@@ -1036,7 +1037,7 @@ func downloadDataFiles() {
10361037
}
10371038
}
10381039

1039-
func downloadLDBCFiles() {
1040+
func downloadLDBCFiles(dir string) {
10401041
if !*downloadResources {
10411042
fmt.Print("Skipping downloading of resources\n")
10421043
return
@@ -1054,12 +1055,12 @@ func downloadLDBCFiles() {
10541055
defer wg.Done()
10551056
start := time.Now()
10561057
cmd := exec.Command("wget", "-O", fname, link)
1057-
cmd.Dir = *tmp
1058+
cmd.Dir = dir
10581059
if out, err := cmd.CombinedOutput(); err != nil {
10591060
fmt.Printf("Error %v\n", err)
10601061
panic(fmt.Sprintf("error downloading a file: %s", string(out)))
10611062
}
1062-
fmt.Printf("Downloaded %s to %s in %s \n", fname, *tmp, time.Since(start))
1063+
fmt.Printf("Downloaded %s to %s in %s \n", fname, dir, time.Since(start))
10631064
}(fname, link, &wg)
10641065
}
10651066
wg.Wait()
@@ -1197,8 +1198,11 @@ func run() error {
11971198
closer := z.NewCloser(N)
11981199
testCh := make(chan task)
11991200
errCh := make(chan error, 1000)
1201+
var runWg sync.WaitGroup
12001202
for range N {
1203+
runWg.Add(1)
12011204
go func() {
1205+
defer runWg.Done()
12021206
if err := runTests(testCh, closer); err != nil {
12031207
errCh <- err
12041208
closer.Signal()
@@ -1227,9 +1231,6 @@ func run() error {
12271231
go func() {
12281232
defer close(testCh)
12291233
valid := getPackages()
1230-
// in "all" mode we can download both data files and
1231-
// ldbc files into the same directory, no duplicated
1232-
// filenames between the two
12331234
needsData := testSuiteContainsAny("load", "ldbc", "all")
12341235
if needsData && *tmp == "" {
12351236
*tmp = filepath.Join(os.TempDir(), "dgraph-test-data")
@@ -1239,7 +1240,12 @@ func run() error {
12391240
downloadDataFiles()
12401241
}
12411242
if testSuiteContainsAny("ldbc", "all") {
1242-
downloadLDBCFiles()
1243+
// LDBC files go into a subdirectory because the LDBC test bulk-loads
1244+
// the entire directory (-f <dir>). Mixing load data (1million, 21million)
1245+
// with LDBC data causes schema mismatches.
1246+
ldbcDir := filepath.Join(*tmp, "ldbc")
1247+
x.Check(os.MkdirAll(ldbcDir, 0755))
1248+
downloadLDBCFiles(ldbcDir)
12431249
}
12441250
for i, task := range valid {
12451251
select {
@@ -1252,6 +1258,7 @@ func run() error {
12521258
}()
12531259

12541260
closer.Wait()
1261+
runWg.Wait() // Ensure wrapper goroutines finish sending to errCh before closing it.
12551262
close(errCh)
12561263
for err := range errCh {
12571264
if err != nil {

0 commit comments

Comments
 (0)