Allow more time in TestFileStoreNumPendingLargeNumBlks, improve logging on failure

Signed-off-by: Neil Twigg <neil@nats.io>
This commit is contained in:
Neil Twigg
2023-09-12 11:02:43 +01:00
parent 3fea204ba6
commit 3becc840d9
4 changed files with 23 additions and 11 deletions

3
go.mod
View File

@@ -11,7 +11,8 @@ require (
github.com/nats-io/nuid v1.0.1 github.com/nats-io/nuid v1.0.1
go.uber.org/automaxprocs v1.5.3 go.uber.org/automaxprocs v1.5.3
golang.org/x/crypto v0.12.0 golang.org/x/crypto v0.12.0
golang.org/x/sys v0.11.0 golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/sys v0.12.0
golang.org/x/time v0.3.0 golang.org/x/time v0.3.0
) )

6
go.sum
View File

@@ -28,9 +28,11 @@ go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@@ -5098,13 +5098,13 @@ func TestFileStoreNumPendingLargeNumBlks(t *testing.T) {
start := time.Now() start := time.Now()
total, _ := fs.NumPending(4000, "zzz", false) total, _ := fs.NumPending(4000, "zzz", false)
require_True(t, time.Since(start) < 10*time.Millisecond) require_LessThan(t, time.Since(start), 15*time.Millisecond)
require_True(t, total == 6001) require_Equal(t, total, 6001)
start = time.Now() start = time.Now()
total, _ = fs.NumPending(6000, "zzz", false) total, _ = fs.NumPending(6000, "zzz", false)
require_True(t, time.Since(start) < 10*time.Millisecond) require_LessThan(t, time.Since(start), 15*time.Millisecond)
require_True(t, total == 4001) require_Equal(t, total, 4001)
// Now delete a message in first half and second half. // Now delete a message in first half and second half.
fs.RemoveMsg(1000) fs.RemoveMsg(1000)
@@ -5112,13 +5112,13 @@ func TestFileStoreNumPendingLargeNumBlks(t *testing.T) {
start = time.Now() start = time.Now()
total, _ = fs.NumPending(4000, "zzz", false) total, _ = fs.NumPending(4000, "zzz", false)
require_True(t, time.Since(start) < 50*time.Millisecond) require_LessThan(t, time.Since(start), 50*time.Millisecond)
require_True(t, total == 6000) require_Equal(t, total, 6000)
start = time.Now() start = time.Now()
total, _ = fs.NumPending(6000, "zzz", false) total, _ = fs.NumPending(6000, "zzz", false)
require_True(t, time.Since(start) < 50*time.Millisecond) require_LessThan(t, time.Since(start), 50*time.Millisecond)
require_True(t, total == 4000) require_Equal(t, total, 4000)
} }
func TestFileStoreSkipMsgAndNumBlocks(t *testing.T) { func TestFileStoreSkipMsgAndNumBlocks(t *testing.T) {

View File

@@ -21,6 +21,8 @@ import (
"strings" "strings"
"testing" "testing"
"time" "time"
"golang.org/x/exp/constraints"
) )
// DefaultTestOptions are default options for the unit tests. // DefaultTestOptions are default options for the unit tests.
@@ -133,6 +135,13 @@ func require_Len(t *testing.T, a, b int) {
} }
} }
func require_LessThan[T constraints.Ordered](t *testing.T, a, b T) {
t.Helper()
if a >= b {
t.Fatalf("require %v to be less than %v", a, b)
}
}
func checkNatsError(t *testing.T, e *ApiError, id ErrorIdentifier) { func checkNatsError(t *testing.T, e *ApiError, id ErrorIdentifier) {
t.Helper() t.Helper()
ae, ok := ApiErrors[id] ae, ok := ApiErrors[id]