Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ integration-previous-sdk:
version=$$(jq -er .weir_go_previous versions.json) && \
protocol=$$(go mod download -json github.com/batchstream/weir-go@$$version | jq -er .GoMod | xargs awk '$$1 == "github.com/batchstream/weir-protocol" {print $$2}') && \
go get -modfile=.tools/previous-sdk.mod github.com/batchstream/weir-go@$$version github.com/batchstream/weir-protocol@$$protocol
GOFLAGS=-modfile="$(CURDIR)/.tools/previous-sdk.mod" WEIR_TEST_BINARY="$(CURDIR)/.tools/weir" go test -race -tags=integration,previous,previous_sdk -count=1 -timeout=10m -v ./tests/integration
GOFLAGS=-modfile="$(CURDIR)/.tools/previous-sdk.mod" WEIR_TEST_BINARY="$(CURDIR)/.tools/weir" go test -race -tags=integration,previous -count=1 -timeout=10m -v ./tests/integration

benchmark:
go run ./cmd/weir-lab -mode saturation -weir "$(CURDIR)/.tools/weir" -backend all -database-cpus 1 -client-processes 4 -concurrency-levels 4,8,32,128,256 -batch-sizes 1 -records 8192 -write-percent 0 -rounds 3 -warmup-duration 10s -duration 20s -output results/local/benchmark
Expand Down
9 changes: 0 additions & 9 deletions docs/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ only the current versions can pass goes in a file with a `!previous` build
constraint so that the rest keeps running, until the previous pin has that
behaviour too.

The SDK's API changed at v0.24.0, so `integration-previous-sdk` also sets the
`previous_sdk` tag. `sdk_current_test.go` and `sdk_previous_test.go` hold the calls
that differ. The soak and benchmark tests use packages built on the current API
only, so they do not run on the previous SDK, and neither does the native write
evidence subtest, which lives with them. That leaves the previous SDK's `MutateStream`
and query-visible writes untested against a newer server. When `weir_go_previous`
reaches v0.24.0, delete the tag, `sdk_previous_test.go` and the constraints on those
tests.

## Output

All generated output belongs under the ignored `results/` directory, conventionally
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/batchstream/weir-tests
go 1.27.3

require (
github.com/batchstream/weir-go v0.24.0
github.com/batchstream/weir-go v0.24.1
github.com/batchstream/weir-protocol v0.17.0
go.mongodb.org/mongo-driver/v2 v2.9.1
google.golang.org/grpc v1.83.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/batchstream/weir-go v0.24.0 h1:Ij8r7ceDOvEVduNOfnpSpN7mlUocF2H+e2fsp4ejiTY=
github.com/batchstream/weir-go v0.24.0/go.mod h1:tW3APP6fK6A+dVLzwcgkRECIDzlhv0hnhTCyJghcjxw=
github.com/batchstream/weir-go v0.24.1 h1:tZCq40jaJACguoIm8YDktX1Dwsjkv2QaQRhlYuourQE=
github.com/batchstream/weir-go v0.24.1/go.mod h1:tW3APP6fK6A+dVLzwcgkRECIDzlhv0hnhTCyJghcjxw=
github.com/batchstream/weir-protocol v0.17.0 h1:0gfA9nIoRu+6Lhzmtpxv4HruaB4dBDuyAL45x+9OF6g=
github.com/batchstream/weir-protocol v0.17.0/go.mod h1:05pTsdu4nJkyZjvdz67jILOiuEicw0Vq88M0ucD4GVY=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func testPublicBatch(t *testing.T, ctx context.Context, client *weir.Client, bac
duplicate := backend.write(t, "primary", 999)
mutations[24] = &weir.MutateRequest{Resource: duplicate.Resource, Action: weir.MutationCreate, Document: duplicate.Document}
rpc, cancel := context.WithTimeout(ctx, rpcTimeout)
results, err := mutateRecords(rpc, client, backend.name, mutations...)
results, err := client.Mutate(rpc, backend.name, weir.WithRequests(mutations...))
cancel()
if err != nil || len(results) != count {
t.Fatalf("public batch Mutate: length=%d error=%v", len(results), err)
Expand All @@ -56,7 +56,7 @@ func testPublicBatch(t *testing.T, ctx context.Context, client *weir.Client, bac
missing := &weir.ReadRequest{Resource: backend.resource("public_batch_absent")}
reads[count] = missing
rpc, cancel = context.WithTimeout(ctx, rpcTimeout)
readResults, err := readRecords(rpc, client, backend.name, reads...)
readResults, err := client.Read(rpc, backend.name, weir.WithRequests(reads...))
cancel()
if err != nil || len(readResults) != count+1 {
t.Fatalf("public batch Read: length=%d error=%v", len(readResults), err)
Expand All @@ -81,7 +81,7 @@ func testPublicBatch(t *testing.T, ctx context.Context, client *weir.Client, bac
}
rejected[count-1].Action = 0
rpc, cancel = context.WithTimeout(ctx, rpcTimeout)
invalidResults, err := mutateRecords(rpc, client, backend.name, rejected...)
invalidResults, err := client.Mutate(rpc, backend.name, weir.WithRequests(rejected...))
cancel()
confirmed := func(result *weir.MutationResult) bool { return result != nil }
if err == nil || slices.ContainsFunc(invalidResults, confirmed) {
Expand Down Expand Up @@ -140,7 +140,7 @@ func testDuplicateURIOrder(t *testing.T, ctx context.Context, client *weir.Clien
requests[index] = request
}
rpc, cancel := context.WithTimeout(ctx, rpcTimeout)
results, err := mutateRecords(rpc, client, backend.name, requests...)
results, err := client.Mutate(rpc, backend.name, weir.WithRequests(requests...))
cancel()
if err != nil || len(results) != len(requests) {
t.Fatalf("same-URI mutation batch: results=%v err=%v", results, err)
Expand Down Expand Up @@ -169,7 +169,7 @@ func testDuplicateURIOrder(t *testing.T, ctx context.Context, client *weir.Clien
}
}
rpc, cancel = context.WithTimeout(ctx, rpcTimeout)
readResults, err := readRecords(rpc, client, backend.name, reads...)
readResults, err := client.Read(rpc, backend.name, weir.WithRequests(reads...))
cancel()
if err != nil || len(readResults) != len(reads) {
t.Fatalf("513 duplicate URI reads: results=%d err=%v", len(readResults), err)
Expand Down Expand Up @@ -262,7 +262,7 @@ func (s *system) testLargeDistinctBatch(t *testing.T, backend *backendData) {
s.quiesce(t)
before := s.nodeMetrics(t)
rpc, cancel := context.WithTimeout(s.ctx, rpcTimeout)
results, err := mutateRecords(rpc, s.client, backend.name, mutations...)
results, err := s.client.Mutate(rpc, backend.name, weir.WithRequests(mutations...))
cancel()
if err != nil || len(results) != count {
t.Fatalf("513 distinct Put batch: results=%d err=%v", len(results), err)
Expand All @@ -277,7 +277,7 @@ func (s *system) testLargeDistinctBatch(t *testing.T, backend *backendData) {
}
before = s.nodeMetrics(t)
rpc, cancel = context.WithTimeout(s.ctx, rpcTimeout)
readResults, err := readRecords(rpc, s.client, backend.name, reads...)
readResults, err := s.client.Read(rpc, backend.name, weir.WithRequests(reads...))
cancel()
if err != nil || len(readResults) != count {
t.Fatalf("513 distinct Read batch: results=%d err=%v", len(readResults), err)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/benchmark_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration && !previous_sdk
//go:build integration

package integration_test

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,22 @@ func testTypedSequence(t *testing.T, ctx context.Context, client *weir.Client, b
t.Helper()
read := &weir.ReadRequest{Resource: backend.resource("primary")}
rpc, cancel := context.WithTimeout(ctx, rpcTimeout)
before, err := readRecords(rpc, client, backend.name, read)
before, err := client.Read(rpc, backend.name, weir.WithRequests(read))
cancel()
if err != nil || len(before) != 1 {
t.Fatalf("typed Read before mutation: results=%v err=%v", before, err)
}
backend.assertReadResult(t, before[0], nil, 4)
mutation := backend.writeAs(t, weir.MutationReplace, "primary", 5)
rpc, cancel = context.WithTimeout(ctx, rpcTimeout)
results, err := mutateRecords(rpc, client, backend.name, mutation)
results, err := client.Mutate(rpc, backend.name, weir.WithRequests(mutation))
cancel()
if err != nil || len(results) != 1 {
t.Fatalf("typed Mutate: results=%v err=%v", results, err)
}
assertApplied(t, results[0], nil)
rpc, cancel = context.WithTimeout(ctx, rpcTimeout)
after, err := readRecords(rpc, client, backend.name, read)
after, err := client.Read(rpc, backend.name, weir.WithRequests(read))
cancel()
if err != nil || len(after) != 1 {
t.Fatalf("typed Read after mutation: results=%v err=%v", after, err)
Expand Down
36 changes: 0 additions & 36 deletions tests/integration/sdk_current_test.go

This file was deleted.

70 changes: 0 additions & 70 deletions tests/integration/sdk_previous_test.go

This file was deleted.

20 changes: 11 additions & 9 deletions tests/integration/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import (
weir "github.com/batchstream/weir-go"
)

// These tests run against the current SDK and, with the previous_sdk tag, the one
// before it. sdk_current_test.go and sdk_previous_test.go hold the calls whose API
// differs, with these types in common.
func readRecord(ctx context.Context, client *weir.Client, store string, request *weir.ReadRequest) (*weir.ReadResult, error) {
results, err := client.Read(ctx, store, weir.WithRequests(request))
return results[0], err
}

// readStream is a read call fed record by record, with results handed over as they
// complete. The index is the record's position in the input, from 0.
type readStream struct {
store string
next func(context.Context) (*weir.ReadRequest, error)
consume func(ctx context.Context, index int, result *weir.ReadResult) error
func mutateRecord(ctx context.Context, client *weir.Client, store string, request *weir.MutateRequest) (*weir.MutationResult, error) {
results, err := client.Mutate(ctx, store, weir.WithRequests(request))
return results[0], err
}

// nativeCall is one Native call whose body goes to consume.
Expand All @@ -30,6 +28,10 @@ type nativeCall struct {

type nativeInvoke func(context.Context, nativeCall) (*weir.NativeResult, error)

func runNative(ctx context.Context, client *weir.Client, call nativeCall) (*weir.NativeResult, error) {
return client.Native(ctx, call.store, call.request, weir.WithChunks(call.consume))
}

// clientNative sends Native calls through client.
func clientNative(client *weir.Client) nativeInvoke {
invoke := func(ctx context.Context, call nativeCall) (*weir.NativeResult, error) {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/semantics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (s *system) testMissingTargets(t *testing.T, target *backendData) {
requests := []*weir.ReadRequest{
{Resource: target.resource("1")}, {Resource: target.resource("absent")}, {Resource: missing.resource("1")},
}
results, err := readRecords(s.ctx, s.client, target.name, requests...)
results, err := s.client.Read(s.ctx, target.name, weir.WithRequests(requests...))
if err != nil || len(results) != 3 {
t.Fatalf("mixed read results: %v %v", results, err)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/single_benchmark_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration && !previous_sdk
//go:build integration

package integration_test

Expand All @@ -16,7 +16,7 @@ import (
"github.com/batchstream/weir-tests/internal/workload"
)

// This opt-in test proves actual client OS processes, independent native/SDK
// This test proves actual client OS processes, independent native/SDK
// pools, one-record requests and persisted final state against both databases.
// It intentionally makes no assertion that Weir wins or saturates a database.
func TestIndependentSingleRequestClients(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/soak_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration && !previous_sdk
//go:build integration

package integration_test

Expand Down
53 changes: 25 additions & 28 deletions tests/integration/stream_memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (s *system) testStreamMemory(t *testing.T, backend *backendData) {
reads[index] = read
}
rpc, cancel := context.WithTimeout(s.ctx, 90*time.Second)
results, err := mutateRecords(rpc, s.client, backend.name, requests...)
results, err := s.client.Mutate(rpc, backend.name, weir.WithRequests(requests...))
cancel()
if err != nil || len(results) != distinctRecords {
t.Fatal("prepare distinct stream documents", len(results), err)
Expand Down Expand Up @@ -153,33 +153,30 @@ func (s *system) testStreamMemory(t *testing.T, backend *backendData) {
stop()
t.Fatal(err)
}
stream := readStream{
store: backend.name,
next: func(context.Context) (*weir.ReadRequest, error) {
if produced == count {
return nil, io.EOF
}
request := reads[produced%distinctRecords]
produced++
return request, nil
},
consume: func(_ context.Context, index int, result *weir.ReadResult) error {
if index < 0 || index >= count || seen[index] || result == nil || result.Document == nil || result.Failure != nil || result.Missing {
return fmt.Errorf("unexpected stream result at %d", index)
}
seen[index] = true
if n, err := backend.number(result.Document); err != nil || n != 42 || len(result.Document.Data) < payloadBytes {
return fmt.Errorf("large streamed document changed: n=%v error=%v", n, err)
}
consumed++
bytes += uint64(len(result.Document.Data))
if consumed%128 == 0 {
return sample()
}
return nil
},
}
err := streamReads(ctx, s.client, stream)
next := func(context.Context) (*weir.ReadRequest, error) {
if produced == count {
return nil, io.EOF
}
request := reads[produced%distinctRecords]
produced++
return request, nil
}
consume := func(_ context.Context, index int, result *weir.ReadResult) error {
if index < 0 || index >= count || seen[index] || result == nil || result.Document == nil || result.Failure != nil || result.Missing {
return fmt.Errorf("unexpected stream result at %d", index)
}
seen[index] = true
if n, err := backend.number(result.Document); err != nil || n != 42 || len(result.Document.Data) < payloadBytes {
return fmt.Errorf("large streamed document changed: n=%v error=%v", n, err)
}
consumed++
bytes += uint64(len(result.Document.Data))
if consumed%128 == 0 {
return sample()
}
return nil
}
_, err := s.client.Read(ctx, backend.name, weir.WithNext(next), weir.WithReadConsume(consume))
if err == nil {
err = sample()
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (s *system) testBatchSingleStream(t *testing.T, backend *backendData) {
reads[index] = request
}
rpc, cancel := context.WithTimeout(s.ctx, rpcTimeout)
results, err := readRecords(rpc, s.client, backend.name, reads...)
results, err := s.client.Read(rpc, backend.name, weir.WithRequests(reads...))
cancel()
if err != nil || len(results) != len(reads) {
t.Fatalf("streamed batch: results=%d err=%v", len(results), err)
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"weir_source": "5107986b882da60751403c7e05bbbebdb12b3cdb",
"weir_previous_source": "3717479d2820c8e99927d4e91f7c32298e0c32b1",
"weir_go_previous": "v0.23.1",
"weir_go_previous": "v0.24.0",
"mongodb_version": "8.0.32",
"mongodb_image": "mongo@sha256:d0d926f94df099bff534b7ee5b5986458131a22489dfff8664509af0c1e2ca9c",
"elasticsearch_version": "8.19.22",
Expand Down
Loading