From 8751e252a76ae6e83e52a2018ba55e4a9b89ed7d Mon Sep 17 00:00:00 2001 From: matthewpeterkort Date: Tue, 27 Feb 2024 15:33:47 -0800 Subject: [PATCH 1/2] adds bulk load at scale --- conformance/tests/ot_bulk.py | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/conformance/tests/ot_bulk.py b/conformance/tests/ot_bulk.py index bf12556e..826bdd90 100644 --- a/conformance/tests/ot_bulk.py +++ b/conformance/tests/ot_bulk.py @@ -1,3 +1,79 @@ +import uuid +import datetime +import random + + +def test_bulkload_scale(man): + errors = [] + G = man.writeTest() + + bulk = G.bulkAdd() + + for i in range(10000): + random_time = str(datetime.datetime(2000, 1, 1, + random.choice(range(24)), + random.choice(range(60)), + random.choice(range(60)), + random.choice(range(1000000)))) + + observation_template = {"resourceType": "Observation", + "id": str(uuid.uuid4()), + "meta": + {"versionId": "1", + "lastUpdated": random_time, + "source": "#DmW9sueQ4yuQdyA9", + "profile": ["http://hl7.org/fhir/StructureDefinition/bodyheight", + "http://hl7.org/fhir/StructureDefinition/vitalsigns"] + }, + "status": "final", + "category": [{"coding": + [{"system": "http://terminology.hl7.org/CodeSystem/observation-category", + "code": "vital-signs", + "display": "vital-signs"}] + }], + "code": + {"coding": + [{"system": "http://loinc.org", + "code": "8302-2", "display": "8302-2"}], + "text": "Body Height"}, + "subject": {"reference": f"Patient/{str(uuid.uuid4())}"}, + "effectiveDateTime": random_time, + "issued": random_time, + "valueQuantity": + {"value": str(random.choice(range(500))), + "unit": "cm", + "system": "http://unitsofmeasure.org", + "code": "cm"} + } + bulk.addVertex(str(i), str(random.choice(["Patient", "Observation", "File"])), observation_template) + err = bulk.execute() + print(err) + if err.get("errorCount", 0) != 0: + print(err) + errors.append("Bulk insertion error") + + res = G.query().V().count().execute()[0] + if res["count"] != 10000: + count = 10000 + errors.append(f"Bulk Add wrong number of vertices: {res["count"]} != {count}") + + npatients = G.query().V().hasLabel("Patient").count().execute()[0]["count"] + nobservations = G.query().V().hasLabel("Observation").count().execute()[0]["count"] + nfiles = G.query().V().hasLabel("File").count().execute()[0]["count"] + + print(f"npatients: {npatients}, nobservations: {nobservations}, nfiles: {nfiles}") + + if npatients + nobservations + nfiles != 10000: + errors.append("npatients + nobservations + nfiles != 10000") + + if npatients == 0: + errors.append(f"npatients == {npatients}") + if nobservations == 0: + errors.append(f"nobservations == {nobservations}") + if nfiles == 0: + errors.append(f"nfiles == {nfiles}") + + return errors def test_bulkload(man): From c7590e5e16d68570f45cbfd39441eace40d7c146 Mon Sep 17 00:00:00 2001 From: matthewpeterkort Date: Tue, 27 Feb 2024 15:45:38 -0800 Subject: [PATCH 2/2] fix --- conformance/tests/ot_bulk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conformance/tests/ot_bulk.py b/conformance/tests/ot_bulk.py index 826bdd90..3b3b967a 100644 --- a/conformance/tests/ot_bulk.py +++ b/conformance/tests/ot_bulk.py @@ -55,7 +55,7 @@ def test_bulkload_scale(man): res = G.query().V().count().execute()[0] if res["count"] != 10000: count = 10000 - errors.append(f"Bulk Add wrong number of vertices: {res["count"]} != {count}") + errors.append(f"Bulk Add wrong number of vertices: {res['count']} != {count}") npatients = G.query().V().hasLabel("Patient").count().execute()[0]["count"] nobservations = G.query().V().hasLabel("Observation").count().execute()[0]["count"]