From 402188a98c9449754a0b22d733d2e85bb4954836 Mon Sep 17 00:00:00 2001 From: SimFG <1142838399@qq.com> Date: Mon, 13 Jun 2022 11:30:49 +0800 Subject: [PATCH] wal: remove the repeated test case The TestFilePipelineFailLockFile case maybe test the line 77 in the alloc function. But the LockFile will not throw an error when the file lock is hold. And TestFilePipelineFailPreallocate and TestFilePipelineFailLockFile are exactly the same except for the comments. Signed-off-by: SimFG <1142838399@qq.com> --- server/storage/wal/file_pipeline.go | 1 + server/storage/wal/file_pipeline_test.go | 12 ------------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/server/storage/wal/file_pipeline.go b/server/storage/wal/file_pipeline.go index c2feba6c1..9d3a78104 100644 --- a/server/storage/wal/file_pipeline.go +++ b/server/storage/wal/file_pipeline.go @@ -58,6 +58,7 @@ func newFilePipeline(lg *zap.Logger, dir string, fileSize int64) *filePipeline { // Open returns a fresh file for writing. Rename the file before calling // Open again or there will be file collisions. +// it will 'block' if the tmp file lock is already taken. func (fp *filePipeline) Open() (f *fileutil.LockedFile, err error) { select { case f = <-fp.filec: diff --git a/server/storage/wal/file_pipeline_test.go b/server/storage/wal/file_pipeline_test.go index b79927146..bb59270bf 100644 --- a/server/storage/wal/file_pipeline_test.go +++ b/server/storage/wal/file_pipeline_test.go @@ -45,15 +45,3 @@ func TestFilePipelineFailPreallocate(t *testing.T) { t.Fatal("expected error on invalid pre-allocate size, but no error") } } - -func TestFilePipelineFailLockFile(t *testing.T) { - tdir := t.TempDir() - - fp := newFilePipeline(zaptest.NewLogger(t), tdir, math.MaxInt64) - defer fp.Close() - - f, ferr := fp.Open() - if f != nil || ferr == nil { // no such file or directory - t.Fatal("expected error on invalid pre-allocate size, but no error") - } -}