Skip to content

Commit

Permalink
[MySQL] make the tests go faster (#392)
Browse files Browse the repository at this point in the history
Awaiting in the loop was causing this to take ages as it was doing one leaf at a time. They now happen in parallel, and we make sure they're all done before we allow the read parts of the test to start.
  • Loading branch information
mhutchinson authored Dec 5, 2024
1 parent 4b60f59 commit c6816de
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions storage/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,20 @@ func TestGetTile(t *testing.T) {
awaiter := tessera.NewIntegrationAwaiter(ctx, s.ReadCheckpoint, 10*time.Millisecond)

treeSize := 258
var lastIndex uint64

wg := errgroup.Group{}
for i := range treeSize {
idx, _, err := awaiter.Await(ctx, s.Add(ctx, tessera.NewEntry([]byte(fmt.Sprintf("TestGetTile %d", i)))))
if err != nil {
t.Fatalf("Failed to prep test with entry: %v", err)
}
if idx > lastIndex {
lastIndex = idx
}
wg.Go(
func() error {
_, _, err := awaiter.Await(ctx, s.Add(ctx, tessera.NewEntry([]byte(fmt.Sprintf("TestGetTile %d", i)))))
if err != nil {
return fmt.Errorf("failed to prep test with entry: %v", err)
}
return nil
})
}
if got, want := lastIndex, uint64(treeSize-1); got != want {
t.Fatalf("expected only newly created entries in database; tests are not hermetic (got %d, want %d)", got, want)
if err := wg.Wait(); err != nil {
t.Fatalf("Failed to set up database with required leaves: %v", err)
}

for _, test := range []struct {
Expand Down

0 comments on commit c6816de

Please sign in to comment.