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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ confirmed record outcomes; unconfirmed mutations remain indeterminate.
Each Execute request carries one record and its consecutive index. The client
streams records as they are produced; server aggregation stays within the Store.
Later invalid records stop the stream while preserving earlier acknowledged writes.
Documents use explicit `ContentType` fields. Native selects either a BSON MongoDB command or a typed Search HTTP request; SDK consumers receive chunks with validated response metadata.
Documents use explicit `ContentType` fields. Native carries an opaque request Document and optional response metadata; adapters own the formats. HTTP fixtures use standard messages through SDK helpers. Tests verify unknown content types reach adapter classification, while adapter-specific projection rules do not constrain other Stores.

Services bind to loopback and own exclusive namespaces. Cleanup verifies exact
process and container ownership. Fixture logs, manifests and cleanup receipts
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/batchstream/weir-tests
go 1.27.1

require (
github.com/batchstream/weir-go v0.8.0
github.com/batchstream/weir-protocol v0.6.0
github.com/batchstream/weir-go v0.9.0
github.com/batchstream/weir-protocol v0.7.0
go.mongodb.org/mongo-driver/v2 v2.9.1
google.golang.org/grpc v1.83.2
)
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/batchstream/weir-go v0.8.0 h1:NB1K66a61ceLnE7GVUw3N5VfK19D5tunqXzuK59Xkxw=
github.com/batchstream/weir-go v0.8.0/go.mod h1:nNqdGY1ajxYNkRLJWUprF+vQebxd2fOuq0ePAgo2rXs=
github.com/batchstream/weir-protocol v0.6.0 h1:Mpminz34U6IFmqJ0eIl5YA3ClyTok+sxnuLqvIBZHKU=
github.com/batchstream/weir-protocol v0.6.0/go.mod h1:hHmwPoE9yHYAz7Auc3a14Ijo/uxAef4sQ9nBtyXNcGc=
github.com/batchstream/weir-go v0.9.0 h1:a4pGdTJd9/5Y8QMTz37ipHpfSXztpPB84Wm4Wl0fc7A=
github.com/batchstream/weir-go v0.9.0/go.mod h1:lAlK3m/CBl+WZUhMIKwhGdqoeb4wnoteKWppyCfgZLo=
github.com/batchstream/weir-protocol v0.7.0 h1:+LSSLPCWv8GL8RgkH06LYNT8wDN5tFRAs0rle1Ym4sY=
github.com/batchstream/weir-protocol v0.7.0/go.mod h1:hHmwPoE9yHYAz7Auc3a14Ijo/uxAef4sQ9nBtyXNcGc=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
22 changes: 19 additions & 3 deletions tests/integration/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ func testNative(t *testing.T, ctx context.Context, client *weir.Client, backend
parts := strings.Split(backend.collection, "/")
filter := bson.D{{Key: "_id", Value: "primary"}}
command := bson.D{{Key: "count", Value: parts[len(parts)-1]}, {Key: "query", Value: filter}}
request.MongoDBCommand = bsonDocument(t, command).Data
request.Request = bsonDocument(t, command)
} else {
request.SearchHTTP = &weir.SearchHTTPRequest{Method: http.MethodGet, Path: "/_doc/primary"}
request = nativeHTTPGet(t, backend.collection, "/_doc/primary")
}
var head *weir.NativeResponse
var body []byte
Expand Down Expand Up @@ -247,7 +247,10 @@ func testNative(t *testing.T, ctx context.Context, client *weir.Client, backend
}
return
}
metadata := head.GetHttp()
metadata, err := weir.ParseHTTPNativeResponse(head)
if err != nil {
t.Fatal(err)
}
var response struct {
Found bool `json:"found"`
Source struct {
Expand All @@ -258,3 +261,16 @@ func testNative(t *testing.T, ctx context.Context, client *weir.Client, backend
t.Fatalf("Native Search response: metadata=%v body=%s err=%v", metadata, body, err)
}
}

func nativeHTTPGet(t *testing.T, resource, path string) *weir.NativeRequest {
t.Helper()
request, err := http.NewRequest(http.MethodGet, "http://weir.invalid"+path, nil)
if err != nil {
t.Fatal(err)
}
native, err := weir.NewHTTPNativeRequest(resource, request)
if err != nil {
t.Fatal(err)
}
return native
}
63 changes: 58 additions & 5 deletions tests/integration/semantics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,56 @@ func (s *system) testProjectionAndFailures(t *testing.T, backend *backendData) {
t.Fatalf("exclude projection: %v %v", end, err)
}
s.testMissingTargets(t, target)
s.testAdapterOwnedEnvelopes(t, target)
}

func (s *system) testAdapterOwnedEnvelopes(t *testing.T, target *backendData) {
t.Helper()
payload := &weir.Document{ContentType: "application/vnd.example.operation", Data: []byte("opaque request")}
native := &weir.NativeRequest{Resource: target.collection, Request: payload}
options := weir.NativeOptions{StoreName: target.name, Request: native, Consume: func(context.Context, *weir.NativeResponse, []byte) error { return nil }}
result, err := s.client.Native(s.ctx, options)
if err != nil || result == nil || result.Response != nil || result.Completion != weir.NativeNotStarted || result.Failure.GetCode() != weir.FailureUnsupported {
t.Fatalf("unknown format must reach adapter classification: %v %v", result, err)
}

projection := &weir.Projection{Mode: weir.ProjectionInclude, Fields: []string{"$literal"}}
request := &weir.ScanRequest{Resource: target.collection, Projection: projection, PageSize: 1}
scan := weir.ScanOptions{StoreName: target.name, Request: request, Consume: func(context.Context, *weir.Document) error { return nil }}
if target.name == "mongo" {
end, err := s.client.Scan(s.ctx, scan)
if err != nil || end.GetDocumentCount() != 0 || end.GetFailure().GetCode() != weir.FailureUnsupported {
t.Fatalf("Mongo field rule must be enforced by adapter: %v %v", end, err)
}
return
}

literal := target.provisionTarget(t, s.ctx, "literal.fields")
document := &weir.Document{ContentType: "application/json", Data: []byte(`{"$literal":42,"n":1}`)}
write := &weir.WriteRequest{Resource: literal.resource("literal"), Document: document}
writeOptions := weir.WriteOptions{StoreName: literal.name, Request: write}
mutation, err := s.client.Create(s.ctx, writeOptions)
assertApplied(t, mutation, err)
refresh := httpRequest{method: http.MethodPost, path: "/" + literal.collection + "/_refresh"}
code, body := literal.httpDo(t, s.ctx, refresh)
if code != http.StatusOK {
t.Fatalf("refresh literal field: %d %s", code, body)
}
request.Resource = literal.collection
scan.Consume = func(_ context.Context, value *weir.Document) error {
var fields map[string]int
if err := json.Unmarshal(value.Data, &fields); err != nil {
return err
}
if len(fields) != 1 || fields["$literal"] != 42 {
return fmt.Errorf("literal field projection mismatch: %s", value.Data)
}
return nil
}
end, err := s.client.Scan(s.ctx, scan)
if err != nil || end.GetFailure() != nil || end.GetDocumentCount() != 1 {
t.Fatalf("store-neutral literal field: %v %v", end, err)
}
}

func (s *system) testMissingTargets(t *testing.T, target *backendData) {
Expand Down Expand Up @@ -258,22 +308,25 @@ func (s *system) testMissingTargets(t *testing.T, target *backendData) {
nativeMissing := &weir.NativeRequest{Resource: missing.collection}
if target.name == "mongo" {
command := bson.D{{Key: "count", Value: target.mongo.Name() + ".never_created"}}
nativeMissing.MongoDBCommand = bsonDocument(t, command).Data
nativeMissing.Request = bsonDocument(t, command)
} else {
nativeMissing.SearchHTTP = &weir.SearchHTTPRequest{Method: http.MethodGet, Path: "/_doc/absent"}
nativeMissing = nativeHTTPGet(t, missing.collection, "/_doc/absent")
}
nativeMissingOptions := weir.NativeOptions{StoreName: target.name, Request: nativeMissing, Consume: func(context.Context, *weir.NativeResponse, []byte) error { return nil }}
missingResult, err := s.client.Native(s.ctx, nativeMissingOptions)
if err != nil || missingResult == nil || missingResult.Response != nil || missingResult.Completion != weir.NativeNotStarted || missingResult.Failure.GetCode() != weir.FailureTargetNotFound {
t.Fatalf("missing Native target: %v %v", missingResult, err)
}
if target.name == "search" {
httpRequest := &weir.SearchHTTPRequest{Method: http.MethodGet, Path: "/_doc/absent"}
native := &weir.NativeRequest{Resource: target.collection, SearchHTTP: httpRequest}
native := nativeHTTPGet(t, target.collection, "/_doc/absent")
nativeOpts := weir.NativeOptions{StoreName: target.name, Request: native, Consume: func(context.Context, *weir.NativeResponse, []byte) error { return nil }}
result, err := s.client.Native(s.ctx, nativeOpts)
if err != nil || result == nil || result.Completion != weir.NativeResponseComplete || result.Failure != nil || result.Response.GetHttp().GetStatusCode() != http.StatusNotFound {
if err != nil || result == nil || result.Completion != weir.NativeResponseComplete || result.Failure != nil {
t.Fatalf("complete HTTP 404 native response: %v %v", result, err)
}
response, err := weir.ParseHTTPNativeResponse(result.Response)
if err != nil || response.StatusCode != http.StatusNotFound {
t.Fatalf("HTTP 404 metadata: %v %v", response, err)
}
}
}
10 changes: 5 additions & 5 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"go": "1.27.1",
"sdk": "v0.8.0",
"protocol": "v0.6.0",
"weir_source": "dbcf308fd682905c8d45ea631107c2e454a4af80",
"sdk": "v0.9.0",
"protocol": "v0.7.0",
"weir_source": "c00fcec963326100f6156e183bbc074dc7a7d4d7",
"mongodb_version": "8.0.32",
"elasticsearch_version": "8.19.22",
"elasticsearch_image": "docker.elastic.co/elasticsearch/elasticsearch@sha256:e98f9c3b09beb2fbb9eaf667d602df3f0e00bd3644138b8458dc17ba1a675595",
"weir_version": "v0.1.1-0.20261004150119-dbcf308fd682",
"weir_sum": "h1:FVKpFJrCgCUE3Ej9QmKIeeFU8ft40KYlRuc/Ld4Vhy8=",
"weir_version": "v0.1.1-0.20261004162211-c00fcec96332",
"weir_sum": "h1:DowMQvE5uL5fI0iUCLenY/kaFPLr0XHIV6HYnKULr5o=",
"mongodb_image": "mongo@sha256:d0d926f94df099bff534b7ee5b5986458131a22489dfff8664509af0c1e2ca9c",
"mongodb_darwin_arm64_url": "https://fastdl.mongodb.org/osx/mongodb-macos-arm64-8.0.32.tgz",
"mongodb_darwin_arm64_sha256": "f81cb258434d548dca7244d599c82eb339043d8dedd0b1b807870c9d263117f2",
Expand Down
Loading