Skip to content

Commit

Permalink
Allow more time in TestFileStoreNumPendingLargeNumBlks, improve log…
Browse files Browse the repository at this point in the history
…ging on failure

Signed-off-by: Neil Twigg <[email protected]>
  • Loading branch information
neilalexander committed Sep 12, 2023
1 parent 3fea204 commit 3becc84
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ require (
github.com/nats-io/nuid v1.0.1
go.uber.org/automaxprocs v1.5.3
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
)

Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
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/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.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
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/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
16 changes: 8 additions & 8 deletions server/filestore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5098,27 +5098,27 @@ func TestFileStoreNumPendingLargeNumBlks(t *testing.T) {

start := time.Now()
total, _ := fs.NumPending(4000, "zzz", false)
require_True(t, time.Since(start) < 10*time.Millisecond)
require_True(t, total == 6001)
require_LessThan(t, time.Since(start), 15*time.Millisecond)
require_Equal(t, total, 6001)

start = time.Now()
total, _ = fs.NumPending(6000, "zzz", false)
require_True(t, time.Since(start) < 10*time.Millisecond)
require_True(t, total == 4001)
require_LessThan(t, time.Since(start), 15*time.Millisecond)
require_Equal(t, total, 4001)

// Now delete a message in first half and second half.
fs.RemoveMsg(1000)
fs.RemoveMsg(9000)

start = time.Now()
total, _ = fs.NumPending(4000, "zzz", false)
require_True(t, time.Since(start) < 50*time.Millisecond)
require_True(t, total == 6000)
require_LessThan(t, time.Since(start), 50*time.Millisecond)
require_Equal(t, total, 6000)

start = time.Now()
total, _ = fs.NumPending(6000, "zzz", false)
require_True(t, time.Since(start) < 50*time.Millisecond)
require_True(t, total == 4000)
require_LessThan(t, time.Since(start), 50*time.Millisecond)
require_Equal(t, total, 4000)
}

func TestFileStoreSkipMsgAndNumBlocks(t *testing.T) {
Expand Down
9 changes: 9 additions & 0 deletions server/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"strings"
"testing"
"time"

"golang.org/x/exp/constraints"
)

// DefaultTestOptions are default options for the unit tests.
Expand Down Expand Up @@ -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) {

This comment has been minimized.

Copy link
@misterpickypants

misterpickypants Oct 25, 2023

Contributor

It would be nice to avoid the dep on golang.org/x/exp (and subsequent transitive deps) by just inlining the ordered definition here:

type ordered interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
		~float32 | ~float64 |
		~string
}

func require_LessThan[T ordered](t *testing.T, a, b T) {

This ordered definition matches the go 1.21.3 cmp definition:
https://pkg.go.dev/[email protected]#Ordered

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) {
t.Helper()
ae, ok := ApiErrors[id]
Expand Down

0 comments on commit 3becc84

Please sign in to comment.