mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
Add sufficient deadlines and countermeasures to handle hung node scenario (#19688)
Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io> Signed-off-by: Harshavardhana <harsha@minio.io>
This commit is contained in:
@@ -41,6 +41,26 @@ func (w *sleepWriter) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestDeadlineWorker(t *testing.T) {
|
||||
work := NewDeadlineWorker(500 * time.Millisecond)
|
||||
|
||||
err := work.Run(func() error {
|
||||
time.Sleep(600 * time.Millisecond)
|
||||
return nil
|
||||
})
|
||||
if err != context.DeadlineExceeded {
|
||||
t.Error("DeadlineWorker shouldn't be successful - should return context.DeadlineExceeded")
|
||||
}
|
||||
|
||||
err = work.Run(func() error {
|
||||
time.Sleep(450 * time.Millisecond)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Error("DeadlineWorker should succeed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeadlineWriter(t *testing.T) {
|
||||
w := NewDeadlineWriter(&sleepWriter{timeout: 500 * time.Millisecond}, 450*time.Millisecond)
|
||||
_, err := w.Write([]byte("1"))
|
||||
|
||||
Reference in New Issue
Block a user