commands: a count reply is an int32

Two of the tests added alongside endSessions read the count reply's `n` as
int64. ReleaseFast does not check the union tag, so both passed there and
aborted in ReleaseSafe -- which is the whole argument for running the suite in
both, and the reason the plan makes ReleaseSafe non-optional.

175/175 in ReleaseFast and ReleaseSafe.
This commit is contained in:
A.Shakhmatov
2026-08-09 15:11:28 +03:00
parent f5c827e581
commit 3e2d0ab134

View File

@@ -3157,13 +3157,13 @@ fn run_for_code(ctx: *Context, name: []const u8, value: bson.Value, extra: []con
return null;
}
fn doc_count(ctx: *Context, coll: []const u8) !i64 {
fn doc_count(ctx: *Context, coll: []const u8) !i32 {
var reply = wire.Reply.init(testing.allocator);
defer reply.deinit();
var msg = try parse_fake_msg("count", .{ .string = coll }, &.{});
defer msg.deinit();
try dispatch(ctx, &msg, &reply);
return bson.get_pair(reply.pairs.items, "n").?.int64;
return bson.get_pair(reply.pairs.items, "n").?.int32;
}
test "a well-formed session id changes nothing and is not echoed" {
@@ -3191,7 +3191,7 @@ test "a well-formed session id changes nothing and is not echoed" {
// mongod answers a well-formed lsid with exactly `{ok: 1}` and no echo,
// measured; a driver reads only `$clusterTime` and `operationTime` back.
try testing.expect(bson.get_pair(reply.pairs.items, "lsid") == null);
try testing.expectEqual(@as(i64, 1), try doc_count(&ctx, "sess"));
try testing.expectEqual(@as(i32, 1), try doc_count(&ctx, "sess"));
}
test "a malformed session id is refused without leaking a lock" {
@@ -3271,7 +3271,7 @@ test "a transactional write is refused rather than applied" {
.{ .key = "startTransaction", .value = .{ .bool = true } },
.{ .key = "autocommit", .value = .{ .bool = false } },
})).?);
try testing.expectEqual(@as(i64, 0), try doc_count(&ctx, "txn"));
try testing.expectEqual(@as(i32, 0), try doc_count(&ctx, "txn"));
// The order the checks fire in is mongod's, measured: a missing session id
// is reported before the standalone refusal, and a bad type before both.
@@ -3289,7 +3289,7 @@ test "a transactional write is refused rather than applied" {
.{ .key = "lsid", .value = lsid },
.{ .key = "startTransaction", .value = .{ .bool = true } },
})).?);
try testing.expectEqual(@as(i64, 0), try doc_count(&ctx, "txn"));
try testing.expectEqual(@as(i32, 0), try doc_count(&ctx, "txn"));
}
test "endSessions judges the array it is handed" {