forked from TrueCloudLab/frostfs-node
[#667] writecache: Fix flush test
Allow to disable background flusher for testing purposes. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
02454df14a
commit
8d18fa159e
8 changed files with 40 additions and 36 deletions
|
@ -97,6 +97,9 @@ func (c *collector) send(ctx context.Context, cancel func(), buf *z.Buffer) erro
|
|||
|
||||
// runFlushLoop starts background workers which periodically flush objects to the blobstor.
|
||||
func (c *cache) runFlushLoop(ctx context.Context) {
|
||||
if c.disableBackgroundFlush {
|
||||
return
|
||||
}
|
||||
for i := 0; i < c.workersCount; i++ {
|
||||
c.wg.Add(1)
|
||||
go c.workerFlushSmall(ctx)
|
||||
|
|
|
@ -28,6 +28,7 @@ func TestFlush(t *testing.T) {
|
|||
WithMetabase(mb),
|
||||
WithBlobstor(bs),
|
||||
WithGCInterval(1 * time.Second),
|
||||
WithDisableBackgroundFlush(),
|
||||
}, opts...)...)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ type options struct {
|
|||
metrics writecache.Metrics
|
||||
// gcInterval is the interval duration to run the GC cycle.
|
||||
gcInterval time.Duration
|
||||
// disableBackgroundFlush is for testing purposes only.
|
||||
disableBackgroundFlush bool
|
||||
}
|
||||
|
||||
// WithLogger sets logger.
|
||||
|
@ -108,3 +110,10 @@ func WithGCInterval(d time.Duration) Option {
|
|||
o.gcInterval = d
|
||||
}
|
||||
}
|
||||
|
||||
// WithDisableBackgroundFlush disables background flush, for testing purposes only.
|
||||
func WithDisableBackgroundFlush() Option {
|
||||
return func(o *options) {
|
||||
o.disableBackgroundFlush = true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue