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
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ Coverage includes discovery through every node, direct owner connections, typed
CRUD and Lua transformations, independent persistence checks, same-Store calls
containing many records, slice preflight and per-record validation, typed Scan filters and include/exclude projections, cross-owner continuation, Native response evidence,
cancellation, owner restart, directory convergence and persistent client recovery.
Lua tests cover missing and existing documents, explicit and implicit decisions, first creation, and concurrent read-modify-write through both owners. Missing records and missing backend targets have distinct outcomes; empty scans succeed and complete HTTP 404 responses retain Native completion evidence. Separate multi-process tests verify independent single-record callers.
Lua source returns one function receiving the current and incoming documents as
ordinary tables. Tests cover object replacements, explicit keep/delete/reject
actions, first creation, and concurrent read-modify-write through both owners.
Nil, missing or multiple callback results return INVALID_ARGUMENT, including a
callback that returns a missing current document. Missing records and missing
backend targets have distinct outcomes; empty scans succeed and complete HTTP
404 responses retain Native completion evidence. Separate multi-process tests
verify independent single-record callers.
One-RPC reads deliver 64 MiB and 256 MiB across 1024 and 4096 distinct documents while
checking bounded result credits and sampled owner RSS. Interrupted streams retain
confirmed record outcomes; unconfirmed mutations remain indeterminate.
Expand Down Expand Up @@ -97,6 +104,8 @@ MongoDB request uses a snapshot transaction with one read, revision computation,
replacement and majority commit. Each native Search request uses one real-time
read and a write conditioned on its observed sequence number and primary term.
The SDK sends one Lua `AtomicTransform` per request with the same computation.
The function updates `current.revision = 1 - current.revision` and returns the
current document; existing BSON int32 revision fields retain their width.
Fixture documents are identical on both paths; Weir adds no document metadata.

Repeat with `-backend-batch-limit 1` to disable server aggregation. Keep other
Expand Down
7 changes: 5 additions & 2 deletions internal/workload/lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ import (
)

func (d *Dataset) luaSource() string {
// The fixture stores BSON int32 and JSON 0/1, both read as Lua int32.
return `return weir.replace(weir.set(current, "revision", weir.sub(weir.i32("1"), weir.get(current, "revision"))))`
// Reassigning the existing revision field preserves its BSON int32 width.
return `return function(current)
current.revision = 1 - current.revision
return current
end`
}

// The native path performs the same single-record read-modify-write, without
Expand Down
30 changes: 15 additions & 15 deletions tests/integration/semantics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ func (s *system) testLuaSemantics(t *testing.T, backend *backendData) {
n int64
failure weir.FailureCode
}{
{name: "merge", source: "return weir.replace(weir.merge(current,input))", present: true, n: 42},
{name: "implicit_replace", source: "return weir.merge(current,input)", present: true, n: 42},
{name: "keep", source: "return weir.keep()"},
{name: "delete", source: "return weir.delete()"},
{name: "reject", source: "return weir.reject(\"rejected\")", failure: weir.FailurePreconditionFailed},
{name: "no_return", source: "local v = current"},
{name: "nil_return", source: "return nil"},
{name: "current", source: "return current"},
{name: "invalid", source: "return )", failure: weir.FailureInvalidArgument},
{name: "merge", source: "return function(current, incoming) current = current or weir.object(); for key, item in pairs(incoming) do current[key] = item end; return current end", present: true, n: 42},
{name: "replace", source: "return function(_, incoming) return incoming end", present: true, n: 42},
{name: "keep", source: "return function() return weir.keep() end"},
{name: "delete", source: "return function() return weir.delete() end"},
{name: "reject", source: "return function() return weir.reject(\"rejected\") end", failure: weir.FailurePreconditionFailed},
{name: "no_return", source: "return function(current) local v = current end", failure: weir.FailureInvalidArgument},
{name: "nil_return", source: "return function() return nil end", failure: weir.FailureInvalidArgument},
{name: "multiple_return", source: "return function() return {}, weir.keep() end", failure: weir.FailureInvalidArgument},
{name: "current", source: "return function(current) return current end"},
{name: "invalid", source: "return function() return ) end", failure: weir.FailureInvalidArgument},
}
for _, existing := range []bool{false, true} {
for _, tc := range cases {
Expand Down Expand Up @@ -78,12 +79,11 @@ func (s *system) testConcurrentLuaCreate(t *testing.T, backend *backendData) {
t.Helper()
const id = "lua_cross_owner_counter"
const iterations = 4
one := "weir.i64(\"1\")"
if backend.name == "search" {
one = "weir.i32(\"1\")"
}
source := []byte(`if weir.kind(current)=="missing" then return weir.replace(input) end
return weir.replace(weir.set(current,"n",weir.add(weir.get(current,"n"),` + one + `)))`)
source := []byte(`return function(current, incoming)
if current == nil then return incoming end
current.n = current.n + 1
return current
end`)
start := make(chan struct{})
finished := make(chan error, 2)
for _, node := range s.cluster.Nodes[:2] {
Expand Down
6 changes: 3 additions & 3 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"go": "1.27.1",
"sdk": "v0.9.0",
"protocol": "v0.7.0",
"weir_source": "c00fcec963326100f6156e183bbc074dc7a7d4d7",
"weir_source": "d3ea541143a819d6e839b6ce398221d85a20ce90",
"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.20261004162211-c00fcec96332",
"weir_sum": "h1:DowMQvE5uL5fI0iUCLenY/kaFPLr0XHIV6HYnKULr5o=",
"weir_version": "v0.1.1-0.20261007083022-d3ea541143a8",
"weir_sum": "h1:+d+Fs+R1rCYpQHindXtE8cNiMms8mlCJ5fMFWw6GMbw=",
"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