From 685cf2ab6bf4b9a411f0bae37a82fa1a762511eb Mon Sep 17 00:00:00 2001 From: Junyu Wang Date: Tue, 14 May 2024 23:14:03 -0700 Subject: [PATCH] added test data json gen --- tests/data/json_gen.py | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/data/json_gen.py diff --git a/tests/data/json_gen.py b/tests/data/json_gen.py new file mode 100644 index 0000000..50bac27 --- /dev/null +++ b/tests/data/json_gen.py @@ -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) +