Skip to content

Commit

Permalink
added test data json gen
Browse files Browse the repository at this point in the history
  • Loading branch information
Junyu Wang committed May 15, 2024
1 parent acf21dd commit 685cf2a
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/data/json_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
This script generates a JSON file with a size of 50MB, 500MB and 3GB.
"""
import json

three_gb_json_count = 10000000
five_hundred_mb_json_count = three_gb_json_count // 6
fifty_mb_json_count = three_gb_json_count // 60

data = []
for i in range(five_hundred_mb_json_count):
charge = {
"status": "success",
"data": {
"order_id": "123456789",
"customer": {
"name": "John Doe",
"email": "johndoe@example.com",
"address": {
"street": "123 Main St",
"city": "San Francisco",
"state": "CA",
"zip": "94101"
}
},
"items": [
{
"id": "item1",
"name": "Product 1",
"price": 99.99
},
{
"id": "item2",
"name": "Product 2",
"price": 49.99
}
],
"total_amount": 149.98
}
}
if i % 2 == 0:
charge["status"] = "failed"
charge["data"].pop("items")
if i % 3 == 0:
charge["metadata"] = {
"notes": "This is a test charge"
}
data.append(charge)

# Write the JSON data to a file
with open("test_medium_500mb_full_json_array.json", "w") as file:
# json_text = "\n".join([json.dumps(charge) for charge in data])
# file.write(json_text)
json.dump(data, file)

0 comments on commit 685cf2a

Please sign in to comment.