Skip to content

Commit

Permalink
util: mock disk hang and slow in random fail tests (#53924)
Browse files Browse the repository at this point in the history
close #53923
  • Loading branch information
xzhangxian1008 authored Jun 12, 2024
1 parent 8d28b23 commit fe5003b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/util/chunk/chunk_in_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"math/rand"
"os"
"strconv"
"time"
"unsafe"

errors2 "github.com/pingcap/errors"
Expand Down Expand Up @@ -333,6 +334,9 @@ func injectChunkInDiskRandomError() error {
randNum := rand.Int31n(10000)
if randNum < 3 {
err = errors2.New("random error is triggered")
} else if randNum < 6 {
delayTime := rand.Int31n(10) + 5
time.Sleep(time.Duration(delayTime) * time.Millisecond)
}
}
})
Expand Down

0 comments on commit fe5003b

Please sign in to comment.