Skip to content

Commit

Permalink
lightning: fix data race in lightning serial test suite (pingcap#32237)
Browse files Browse the repository at this point in the history
  • Loading branch information
glorv authored Feb 10, 2022
1 parent 30cd559 commit 7929a5c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions br/pkg/lightning/lightning_server_serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
"net/http"
"strings"
"sync"
"testing"
"time"

Expand All @@ -33,13 +34,18 @@ import (
"github.com/stretchr/testify/require"
)

// initProgressOnce is used to ensure init progress once to avoid data race.
var initProgressOnce sync.Once

type lightningServerSuite struct {
lightning *Lightning
taskCfgCh chan *config.Config
taskRunCh chan struct{}
}

func createSuite(t *testing.T) (s *lightningServerSuite, clean func()) {
initProgressOnce.Do(web.EnableCurrentProgress)

cfg := config.NewGlobalConfig()
cfg.TiDB.Host = "test.invalid"
cfg.TiDB.Port = 4000
Expand All @@ -64,8 +70,6 @@ func createSuite(t *testing.T) (s *lightningServerSuite, clean func()) {
s.lightning.Stop()
}

web.EnableCurrentProgress()

return
}

Expand Down

0 comments on commit 7929a5c

Please sign in to comment.