Skip to content

Commit 7c66c8f

Browse files
ashwin2002claude
authored andcommitted
Fix: Support doc_size=0 in doc_generator to create empty JSON docs
When doc_size=0, use an empty template {} instead of the standard template with body padding, producing minimal {} documents. This allows Magma doc size tests to load truly minimum-size documents without hitting the "doc_size must be positive" ValueError. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Change-Id: Id87754c727e827bebcaf09bafd6e9e953112a01c Reviewed-on: https://review.couchbase.org/c/TAF/+/245017 Reviewed-by: Ritesh Agarwal <ritesh.agarwal@couchbase.com> Tested-by: Build Bot <build@couchbase.com> Tested-by: Ashwin <ashwin.govindarajulu@couchbase.com>
1 parent 9c927f4 commit 7c66c8f

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

lib/couchbase_helper/documentgenerator.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ def doc_generator(key, start, end,
3838
doc_size=doc_size, mutate=mutate)
3939

4040
# Defaults to JSON doc_type
41-
template_obj = {"mutated": mutate,
42-
"age": 5,
43-
"name": "james",
44-
"mutation_type": mutation_type,
45-
"body": ""}
46-
doc_size -= len(str(template_obj))
47-
if doc_size <= 0:
48-
raise ValueError("doc_size must be positive")
41+
if doc_size == 0:
42+
template_obj = {}
43+
else:
44+
template_obj = {"mutated": mutate,
45+
"age": 5,
46+
"name": "james",
47+
"mutation_type": mutation_type,
48+
"body": ""}
49+
doc_size -= len(str(template_obj))
50+
if doc_size <= 0:
51+
raise ValueError("doc_size must be positive")
4952
return DocumentGenerator(key, template_obj,
5053
start=start, end=end,
5154
key_size=key_size, mix_key_size=mix_key_size,

0 commit comments

Comments
 (0)