diff --git a/expected_results/expected_result_series_filtered_123_normal_small_4.json b/expected_results/expected_result_series_filtered_123_normal_small_4.json new file mode 100644 index 0000000..e85f1e3 --- /dev/null +++ b/expected_results/expected_result_series_filtered_123_normal_small_4.json @@ -0,0 +1,139 @@ +{ + "expectedResults": { + "output": { + "1248156002": { + "simulation_id": "559402036", + "message": { + "timestamp": 1248156002, + "measurements": [ + { + "measurement_mrid": "_000b01a1-8238-4372-95c0-82aad26ea311", + "angle": -5.066423674487563, + "magnitude": 2388.676720682955, + "simulation_id": "1961648576", + "time": 1248156002}, + { + "measurement_mrid": "_00347396-b4b0-4218-9aba-b363f2cda841", + "angle": 118.66041090126667, + "magnitude": 2425.4464236409276, + "simulation_id": "1961648576", + "time": 1248156002}, + { + "measurement_mrid": "_0044ae64-1c72-4e81-b412-d7349ce267d3", + "angle": -38.44540074843378, + "magnitude": 374545.4981119089, + "simulation_id": "1961648576", + "time": 1248156002} + ] + } + } + }, + "input": { + "1248156016": { + "simulation_id": "559402036", + "message": { + "timestamp": 1248156016, + "measurements": [ + {"hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1248156016, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1248156016, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} + ] + } + }, + "1248156029": { + "simulation_id": "559402036", + "message": { + "timestamp": 1248156029, + "measurements": [ + {"hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1248156029, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1248156029, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"}, + {"hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1248156029, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_only_in_expected_MRID_time_does_not_matches"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1248156029, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_only_in_expected_MRID_time_does_not_matches"} + ] + } + }, + + "27": { + "simulation_id": "559402036", + "message": { + "timestamp": 1587670665, + "measurements": [ + {"hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} + ] + } + }, + "1248156044": { + "simulation_id": "559402036", + "message": { + "timestamp": 1248156044, + "measurements": [ + {"hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1248156044, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1248156044, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} + ] + } + } + } + } +} + + diff --git a/expected_results/expected_result_series_filtered_9500.json b/expected_results/expected_result_series_filtered_9500.json new file mode 100644 index 0000000..8721f0d --- /dev/null +++ b/expected_results/expected_result_series_filtered_9500.json @@ -0,0 +1,124 @@ +{ + "expectedResults": { + "output": { + "1248156002": { + "simulation_id": "559402036", + "message": { + "timestamp": 1535574871, + "measurements": [ + { + "measurement_mrid": "_00064508-231d-407d-b492-e85dc0d97c15", + "angle": -5.066423674487563, + "magnitude": 2361.0733024639117, + "simulation_id": "1961648576", + "time": 1248156002}, + { + "measurement_mrid": "_0009930b-245c-47ee-a1cb-277c5519923b", + "angle": -122.80107769837849, + "magnitude": 2520.2169329056983, + "simulation_id": "1961648576", + "time": 1248156002}, + { + "measurement_mrid": "_0010732c-c37a-4459-947b-423e1f28a76a", + "angle": -122.70461031091335, + "magnitude": 2522.818525429715, + "simulation_id": "1961648576", + "time": 1248156002} + ] + } + } + }, + "input": { + "0": { + "simulation_id": "559402036", + "message": { + "timestamp": 1587670650, + "measurements": [ + {"hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670650, + "attribute": "ShuntCompensator.sections", + "value": 1, + "object": "_F73D0A88-C00D-42A2-820B-A8C0A2B899AB"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670650, + "attribute": "ShuntCompensator.sections", + "value": 0, + "object": "_F73D0A88-C00D-42A2-820B-A8C0A2B899AB"} + ] + } + }, + "16": { + "simulation_id": "559402036", + "message": { + "timestamp": 1587670665, + "measurements": [ + {"hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 0, + "object": "_F73D0A88-C00D-42A2-820B-A8C0A2B899AB"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1, + "object": "_F73D0A88-C00D-42A2-820B-A8C0A2B899AB"} + ] + } + }, + "27": { + "simulation_id": "559402036", + "message": { + "timestamp": 1587670665, + "measurements": [ + {"hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 0, + "object": "_F73D0A88-C00D-42A2-820B-A8C0A2B899AB"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1, + "object": "_F73D0A88-C00D-42A2-820B-A8C0A2B899AB"} + ] + } + }, + "32": { + "simulation_id": "559402036", + "message": { + "timestamp": 1587670665, + "measurements": [ + {"hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 0, + "object": "_F73D0A88-C00D-42A2-820B-A8C0A2B899AB"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1, + "object": "_F73D0A88-C00D-42A2-820B-A8C0A2B899AB"} + ] + } + } + } + } +} + + diff --git a/expected_results/request_test_expected_vs_running.py b/expected_results/request_test_expected_vs_running.py new file mode 100644 index 0000000..459cb3e --- /dev/null +++ b/expected_results/request_test_expected_vs_running.py @@ -0,0 +1,94 @@ +import json +import time +import os +import argparse +from gridappsd import GOSS +import random +goss_sim = "goss.gridappsd.process.request.simulation" +test_topic = 'goss.gridappsd.test' +responseQueueTopic = '/temp-queue/response-queue' +goss_simulation_status_topic = '/topic/goss.gridappsd/simulation/status/' + +def start_test(app_name='sample_app', testOutput=True, start_time='1248156000',duration='60',feeder_name='_C1C3E687-6FFD-C753-582B-632A27E28507',expected_file="expected_result_series_filtered_123_normal_small_4.json"): + loc = os.path.realpath(__file__) + loc = os.path.dirname(loc) + print(loc) + + events = [{ + "message": { + "forward_differences": [ + { + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183", + "attribute": "ShuntCompensator.sections", + "value": "0" + } + ], + "reverse_differences": [ + { + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183", + "attribute": "ShuntCompensator.sections", + "value": "1" + } + ] + }, + "event_type": "ScheduledCommandEvent", + "occuredDateTime": 1248156002 + 6, + "stopDateTime": 1248156002 + 21 + }] + + test_id = str(random.getrandbits(32)) + testCfgAll = { + "appId": "sample_app", + "testId": str(test_id), + "testOutput": testOutput, + } + + # with open("expected_result_series_filtered_9500.json") as f: + with open(os.path.join(loc, expected_file)) as f: + expectedJson = json.load(f) + + testCfgAll['expectedResults'] = expectedJson['expectedResults'] + print(json.dumps(testCfgAll,indent=2)) + # exit(0) + # testCfgAll['events'] = events + + req_template = {"power_system_config":{"SubGeographicalRegion_name":"_1CD7D2EE-3C91-3248-5662-A43EFEFAC224","GeographicalRegion_name":"_24809814-4EC6-29D2-B509-7F8BFB646437","Line_name":"_C1C3E687-6FFD-C753-582B-632A27E28507"},"simulation_config":{"power_flow_solver_method":"NR","duration":120,"simulation_name":"ieee123","simulator":"GridLAB-D","start_time":1248156000,"run_realtime":True,"simulation_output":{},"model_creation_config":{"load_scaling_factor":1.0,"triplex":"y","encoding":"u","system_frequency":60,"voltage_multiplier":1.0,"power_unit_conversion":1.0,"unique_names":"y","schedule_name":"ieeezipload","z_fraction":0.0,"i_fraction":1.0,"p_fraction":0.0,"randomize_zipload_fractions":False,"use_houses":False},"simulation_broker_port":52798,"simulation_broker_location":"127.0.0.1"},"application_config":{"applications":[{"name":"sample_app","config_string":""}]},"simulation_request_type":"NEW"} + req_template['simulation_config']['start_time'] = start_time + req_template['simulation_config']['duration'] = duration + req_template['power_system_config']['Line_name'] = feeder_name #'_C1C3E687-6FFD-C753-582B-632A27E28507' # IEEE 123 + # req_template['power_system_config']['Line_name'] = '_AAE94E4A-2465-6F5E-37B1-3E72183A4E44' # test9500new + + req_template["application_config"]["applications"][0]['name'] = app_name + # req_template["application_config"]["applications"][0]['name'] = 'sample_app_opp' + + testCfgAll['start_time'] = req_template['simulation_config']['start_time'] + testCfgAll['duration'] = req_template['simulation_config']['duration'] + req_template['test_config'] = testCfgAll + + simCfg13pv = json.dumps(req_template) + + print("request") + print(json.dumps(req_template,indent=2)) + # exit(0) + username = "app_user" + password = "1234App" + goss = GOSS(username=username, password=password) + goss.connect() + + simulationId = goss.get_response(goss_sim, simCfg13pv, timeout=10) + print('sent simulation request') + print('simulation id ', simulationId) + + return(simulationId['simulationId'],test_id) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-t","--topic", type=str, help="topic, the default is input", default="input", required=False) + parser.add_argument("-p","--port", type=int, help="port number, the default is 5000", default=5000, required=False) + parser.add_argument("-i", "--id", type=int, help="simulation id", required=False) + # parser.add_argument("--start_date", type=str, help="Simulation start date", default="2017-07-21 12:00:00", required=False) + # parser.add_argument("--end_date", type=str, help="Simulation end date" , default="2017-07-22 12:00:00", required=False) + # parser.add_argument('-o', '--options', type=str, default='{}') + args = parser.parse_args() + + start_test() \ No newline at end of file diff --git a/expected_results/request_test_expected_vs_timeseries.py b/expected_results/request_test_expected_vs_timeseries.py new file mode 100644 index 0000000..3a20931 --- /dev/null +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -0,0 +1,57 @@ +import json +import argparse +from gridappsd import GOSS, utils,GridAPPSD +import random +import time +import os + +goss_sim = "goss.gridappsd.process.request.simulation" +test_input = "/topic/goss.gridappsd.simulation.test.input." + +def start_test(simulationID=1234, + app_name='sample_app', + testOutput=True, + start_time='1248156000', + duration='60', + feeder_name='_C1C3E687-6FFD-C753-582B-632A27E28507', + expected_file="expected_result_series_filtered_123_normal_small_4.json"): + loc = os.path.realpath(__file__) + loc = os.path.dirname(loc) + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() + + test_id = str(random.getrandbits(32)) + testCfgAll = { + "appId": app_name, + "testId": test_id, + "testOutput": testOutput, + } + + with open(os.path.join(loc,expected_file)) as f: + # with open("expected_result_series_filtered_9500.json") as f: + expectedJson = json.load(f) + + testCfgAll['compareWithSimId'] = simulationID # 847461010 + testCfgAll['start_time'] = start_time + testCfgAll['duration'] = duration + testCfgAll['interval'] = 10 + testCfgAll['expectedResults'] = expectedJson['expectedResults'] + testCfgAll['testType'] = 'expected_vs_timeseries' + request = json.dumps(testCfgAll) + print('request:') + print(json.dumps(testCfgAll,indent=2)) + + # status = goss.get_response(test_input+str(test_id), request, timeout=20) + status = gapps.send(test_input+str(test_id), request) + print(status) + print('sent test status') + return test_id + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-i", "--id", type=int, help="simulation id", required=False) + args = parser.parse_args() + + start_test(simulationID=args.id) diff --git a/expected_results/request_test_running.py b/expected_results/request_test_running.py new file mode 100644 index 0000000..fc3259e --- /dev/null +++ b/expected_results/request_test_running.py @@ -0,0 +1,50 @@ +import json +import time +import os +import argparse +from gridappsd import GridAPPSD +import random +goss_sim = "goss.gridappsd.process.request.simulation" +test_topic = 'goss.gridappsd.test' +responseQueueTopic = '/temp-queue/response-queue' +goss_simulation_status_topic = '/topic/goss.gridappsd/simulation/status/' + +# def _startTest(username,password,gossServer='localhost',stompPort='61613', simulationID=1234, rulePort=5000, topic="input"): +def start_test(app_name='sample_app'): + req_template = {"power_system_config":{"SubGeographicalRegion_name":"_1CD7D2EE-3C91-3248-5662-A43EFEFAC224","GeographicalRegion_name":"_24809814-4EC6-29D2-B509-7F8BFB646437","Line_name":"_C1C3E687-6FFD-C753-582B-632A27E28507"},"simulation_config":{"power_flow_solver_method":"NR","duration":120,"simulation_name":"ieee123","simulator":"GridLAB-D","start_time":1248156000,"run_realtime":True,"simulation_output":{},"model_creation_config":{"load_scaling_factor":1.0,"triplex":"y","encoding":"u","system_frequency":60,"voltage_multiplier":1.0,"power_unit_conversion":1.0,"unique_names":"y","schedule_name":"ieeezipload","z_fraction":0.0,"i_fraction":1.0,"p_fraction":0.0,"randomize_zipload_fractions":False,"use_houses":False},"simulation_broker_port":52798,"simulation_broker_location":"127.0.0.1"},"application_config":{"applications":[{"name":"sample_app","config_string":""}]},"simulation_request_type":"NEW"} + req_template['simulation_config']['duration'] = 60 + req_template['power_system_config']['Line_name'] = '_C1C3E687-6FFD-C753-582B-632A27E28507' # IEEE 123 + + req_template["application_config"]["applications"][0]['name'] = app_name + + simCfg13pv = json.dumps(req_template) + + print("request") + print(json.dumps(req_template,indent=2)) + # exit(0) + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() + + simulationId = gapps.get_response(goss_sim, simCfg13pv, timeout=10) + print('sent simulation request') + print('simulation id ', simulationId) + + return(simulationId['simulationId']) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-t","--topic", type=str, help="topic, the default is input", default="input", required=False) + parser.add_argument("-p","--port", type=int, help="port number, the default is 5000", default=5000, required=False) + parser.add_argument("-i", "--id", type=int, help="simulation id", required=False) + # parser.add_argument("--start_date", type=str, help="Simulation start date", default="2017-07-21 12:00:00", required=False) + # parser.add_argument("--end_date", type=str, help="Simulation end date" , default="2017-07-22 12:00:00", required=False) + # parser.add_argument('-o', '--options', type=str, default='{}') + args = parser.parse_args() + + # _startTest('system','manager',gossServer='127.0.0.1',stompPort='61613', simulationID=args.id, rulePort=args.port, topic=args.topic) + start_test() + + + # python /usr/src/gridappsd-sample/sample_app/runsample.py 1201658254 {"power_system_config":{"SubGeographicalRegion_name":"_1CD7D2EE-3C91-3248-5662-A43EFEFAC224","GeographicalRegion_name":"_24809814-4EC6-29D2-B509-7F8BFB646437","Line_name":"_C1C3E687-6FFD-C753-582B-632A27E28507"},"simulation_config":{"power_flow_solver_method":"NR","duration":120,"simulation_name":"ieee123","simulator":"GridLAB-D","start_time":1248156000,"run_realtime":true,"simulation_output":{},"model_creation_config":{"load_scaling_factor":1.0,"triplex":"y","encoding":"u","system_frequency":60,"voltage_multiplier":1.0,"power_unit_conversion":1.0,"unique_names":"y","schedule_name":"ieeezipload","z_fraction":0.0,"i_fraction":1.0,"p_fraction":0.0,"randomize_zipload_fractions":false,"use_houses":false},"simulation_broker_port":52798,"simulation_broker_location":"127.0.0.1"},"application_config":{"applications":[{"name":"sample_app","config_string":""}]},"simulation_request_type":"NEW"} \ No newline at end of file diff --git a/expected_results/request_test_running_no_application.py b/expected_results/request_test_running_no_application.py new file mode 100644 index 0000000..4b31b4d --- /dev/null +++ b/expected_results/request_test_running_no_application.py @@ -0,0 +1,198 @@ +import json +import time +import os +import argparse +# import goss_forward_sim +from gridappsd import GridAPPSD +# from pprint import pprint +goss_sim = "goss.gridappsd.process.request.simulation" +test_topic = 'goss.gridappsd.test' +responseQueueTopic = '/temp-queue/response-queue' +goss_simulation_status_topic = '/topic/goss.gridappsd/simulation/status/' +def makeJavaString(request, name="requestString"): + javaString = json.dumps(json.loads(request)).replace('"','\\"') + javaString = "String " + name + ' = "' + javaString + '";' + print(javaString) + +def _startTest(username,password,gossServer='localhost',stompPort='61613', simulationID=1234, rulePort=5000, topic="input"): + loc = os.path.realpath(__file__) + loc = os.path.dirname(loc) + # loc = os.path.dirname(os.path.dirname(os.path.dirname(loc))) + # loc ='/gridappsd/applications/sample_app/tests' # DOCKER + print(loc) + + events = [{ + "message": { + "forward_differences": [ + { + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183", + "attribute": "ShuntCompensator.sections", + "value": "0" + } + ], + "reverse_differences": [ + { + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183", + "attribute": "ShuntCompensator.sections", + "value": "1" + } + ] + }, + "event_type": "ScheduledCommandEvent", + "occuredDateTime": 1248156002 + 6, + "stopDateTime": 1248156002 + 21 + }] + + + + testCfg = {"testConfigPath":loc+"/SampleTestConfig.json", + "testScriptPath":loc+"/SampleTestScript.json", + "simulationID": 1234, + "rulePort": 5000, + "topic":"input", + "expectedResultPath":loc + "/expected_result_series_filtered_8500_2.json" + } + + testCfgAll = { + "simulationID": 1234, + "rulePort": 5000, + "topic": "input" + } + + testCfgAll = { + + "appId": "sample_app" + } + + testHistCfgAll = { + "simulationID": 1234, + "rulePort": 5000, + "topic": "input" + } + + testHistCfg = {"testConfigPath":loc+"/SampleHistoricalTestConfig.json", + "testScriptPath":loc+"/SampleTestScript.json", + "simulationID": 1234, + "rulePort": 5000, + "topic":"input", + "expectedResult":loc + "/expected_result_series_filtered_8500.json" + } + + # with open("SampleTestConfig.json") as f: + # testCfgJson = json.load(f) + + with open(os.path.join(loc,"..","SampleTestScript.json")) as f: + tesScriptJson = json.load(f) + + with open(os.path.join(loc,"..","SampleHistoricalTestConfig.json")) as f: + testHistCfg = json.load(f) + + # with open("expected_result_series_filtered_8500_2_small.json") as f: + # expectedJson = json.load(f) + + # with open("expected_result_series_filtered_123_pv_small.json") as f: + # expectedJson = json.load(f) + + with open("expected_result_series_filtered_123_normal_small_4.json") as f: + expectedJson = json.load(f) + + # print(testCfgJson) + # print(tesScriptJson) + # print(expectedJson) + # testCfgAll['test_config'] = testCfgJson + # testCfgAll['testScript'] = tesScriptJson + testCfgAll['expectedResults'] = expectedJson['expectedResults'] + testCfgAll['events'] = events + testHistCfgAll['test_config'] = testHistCfg + testHistCfgAll['testScript'] = tesScriptJson + testHistCfgAll['expectedResults'] = expectedJson['expectedResults'] + + # pprint(testCfgAll) + # print(json.dumps(testCfgAll,indent=2)) + + # 2009-07-21 00:00:00 + # 1248156000 + + req_template = {"power_system_config":{"SubGeographicalRegion_name":"_1CD7D2EE-3C91-3248-5662-A43EFEFAC224","GeographicalRegion_name":"_24809814-4EC6-29D2-B509-7F8BFB646437","Line_name":"_C1C3E687-6FFD-C753-582B-632A27E28507"},"simulation_config":{"power_flow_solver_method":"NR","duration":120,"simulation_name":"ieee123","simulator":"GridLAB-D","start_time":1248156000,"run_realtime":True,"simulation_output":{},"model_creation_config":{"load_scaling_factor":1.0,"triplex":"y","encoding":"u","system_frequency":60,"voltage_multiplier":1.0,"power_unit_conversion":1.0,"unique_names":"y","schedule_name":"ieeezipload","z_fraction":0.0,"i_fraction":1.0,"p_fraction":0.0,"randomize_zipload_fractions":False,"use_houses":False},"simulation_broker_port":52798,"simulation_broker_location":"127.0.0.1"},"application_config":{"applications":[{"name":"sample_app","config_string":""}]},"simulation_request_type":"NEW"} + req_template['simulation_config']['duration'] = 60 + # req_template['simulation_config']['start_time'] = 1538484951 + # req_template['simulation_config']['start_time'] = 1530000000 # Tuesday, June 26, 2018 2:00:00 AM GMT-06:00 DST + # req_template['power_system_config']['Line_name'] = '_E407CBB6-8C8D-9BC9-589C-AB83FBF0826D' # Mine 123pv + # req_template['power_system_config']['Line_name'] = '_4F76A5F9-271D-9EB8-5E31-AA362D86F2C3' # IEEEE 8500 + req_template['power_system_config']['Line_name'] = '_C1C3E687-6FFD-C753-582B-632A27E28507' # IEEE 123 + + # req_template['power_system_config']['Line_name'] = '_C77C898B-788F-8442-5CEA-0D06ABA0693B' # 123 PV REG + # req_template['power_system_config']['Line_name'] = '_EBDB5A4A-543C-9025-243E-8CAD24307380' + + req_template["application_config"]["applications"][0]['name'] = 'sample_app' + # req_template["application_config"]["applications"][0]['name'] = 'der_dispatch_app' + + req_template['test_config'] = testCfgAll + # testCfgAll['testScript'] = tesScriptJson + # req_template['expectedResults'] = expectedJson['expectedResults'] + + simCfg13pv = json.dumps(req_template) + print(simCfg13pv) + print() + print(makeJavaString(simCfg13pv)) + print() + print(json.dumps(testCfgAll,indent=2)) + + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() + + # simulationId =123 + test_hist_old = False + test_compare = False + if test_hist_old: + testHistCfgAll['test_config']['compareWithSimId'] = 559402036 + testHistCfgAll['test_config']['testType'] = 'simulation_vs_expected' + testHistCfgAll = json.dumps(testHistCfgAll) + print(testHistCfgAll) + goss.send(test_topic, testHistCfgAll) + + time.sleep(1) + print('sent testHistCfgAll request') + elif test_compare: + del req_template['test_config']['expectedResults'] + req_template['test_config']['compareWithSimId'] = 559402036 + exit(0) + simCfg13pv = json.dumps(req_template) + simulationId = goss.get_response(goss_sim, simCfg13pv, timeout=10) + print('sent simulation request') + time.sleep(1) + else: + simulationId = goss.get_response(goss_sim, simCfg13pv, timeout=10) + print('sent simulation request') + print('simulation id ', simulationId) + time.sleep(1) + + testCfgAll['simulationID'] = simulationId + # testCfgAll['simulationID'] = 653676970 + testCfgAll = json.dumps(testCfgAll) + print(testCfgAll) + # goss.send(test_topic, testCfgAll) + + time.sleep(1) + print('sent test request') + + + + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-t","--topic", type=str, help="topic, the default is input", default="input", required=False) + parser.add_argument("-p","--port", type=int, help="port number, the default is 5000", default=5000, required=False) + parser.add_argument("-i", "--id", type=int, help="simulation id", required=False) + # parser.add_argument("--start_date", type=str, help="Simulation start date", default="2017-07-21 12:00:00", required=False) + # parser.add_argument("--end_date", type=str, help="Simulation end date" , default="2017-07-22 12:00:00", required=False) + # parser.add_argument('-o', '--options', type=str, default='{}') + args = parser.parse_args() + + _startTest('system','manager',gossServer='127.0.0.1',stompPort='61613', simulationID=args.id, rulePort=args.port, topic=args.topic) + + + # python /usr/src/gridappsd-sample/sample_app/runsample.py 1201658254 {"power_system_config":{"SubGeographicalRegion_name":"_1CD7D2EE-3C91-3248-5662-A43EFEFAC224","GeographicalRegion_name":"_24809814-4EC6-29D2-B509-7F8BFB646437","Line_name":"_C1C3E687-6FFD-C753-582B-632A27E28507"},"simulation_config":{"power_flow_solver_method":"NR","duration":120,"simulation_name":"ieee123","simulator":"GridLAB-D","start_time":1248156000,"run_realtime":true,"simulation_output":{},"model_creation_config":{"load_scaling_factor":1.0,"triplex":"y","encoding":"u","system_frequency":60,"voltage_multiplier":1.0,"power_unit_conversion":1.0,"unique_names":"y","schedule_name":"ieeezipload","z_fraction":0.0,"i_fraction":1.0,"p_fraction":0.0,"randomize_zipload_fractions":false,"use_houses":false},"simulation_broker_port":52798,"simulation_broker_location":"127.0.0.1"},"application_config":{"applications":[{"name":"sample_app","config_string":""}]},"simulation_request_type":"NEW"} \ No newline at end of file diff --git a/expected_results/request_test_running_vs_timeseries.py b/expected_results/request_test_running_vs_timeseries.py new file mode 100644 index 0000000..7aa1cdf --- /dev/null +++ b/expected_results/request_test_running_vs_timeseries.py @@ -0,0 +1,108 @@ +import json +import time +import os +import argparse +from gridappsd import GridAPPSD +import random + +goss_sim = "goss.gridappsd.process.request.simulation" +test_topic = 'goss.gridappsd.test' +responseQueueTopic = '/temp-queue/response-queue' +goss_simulation_status_topic = '/topic/goss.gridappsd/simulation/status/' + +def start_test(simulationID, app_name ='sample_app', testOutput=False, start_time='1248156000',duration='60',feeder_name='_C1C3E687-6FFD-C753-582B-632A27E28507'): + events = [{ + "message": { + "forward_differences": [ + { + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183", + "attribute": "ShuntCompensator.sections", + "value": "0" + } + ], + "reverse_differences": [ + { + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183", + "attribute": "ShuntCompensator.sections", + "value": "1" + } + ] + }, + "event_type": "ScheduledCommandEvent", + "occuredDateTime": 1248156002 + 6, + "stopDateTime": 1248156002 + 21 + }] + + test_id = str(random.getrandbits(32)) + testCfgAll = { + "appId": app_name, + "testId": test_id, + "testOutput": testOutput, + "interval": 10 + } + + # # testCfgAll['events'] = events + + req_template = {"power_system_config": {"SubGeographicalRegion_name": "_1CD7D2EE-3C91-3248-5662-A43EFEFAC224", + "GeographicalRegion_name": "_24809814-4EC6-29D2-B509-7F8BFB646437", + "Line_name": "_C1C3E687-6FFD-C753-582B-632A27E28507"}, + "simulation_config": {"power_flow_solver_method": "NR", "duration": 120, + "simulation_name": "ieee123", "simulator": "GridLAB-D", + "start_time": 1248156000, "run_realtime": True, "simulation_output": {}, + "model_creation_config": {"load_scaling_factor": 1.0, "triplex": "y", + "encoding": "u", "system_frequency": 60, + "voltage_multiplier": 1.0, + "power_unit_conversion": 1.0, "unique_names": "y", + "schedule_name": "ieeezipload", "z_fraction": 0.0, + "i_fraction": 1.0, "p_fraction": 0.0, + "randomize_zipload_fractions": False, + "use_houses": False}, + "simulation_broker_port": 52798, "simulation_broker_location": "127.0.0.1"}, + "application_config": {"applications": [{"name": "sample_app", "config_string": ""}]}, + "simulation_request_type": "NEW"} + req_template['simulation_config']['start_time'] = start_time + req_template['simulation_config']['duration'] = duration + req_template['power_system_config']['Line_name'] = feeder_name # '_C1C3E687-6FFD-C753-582B-632A27E28507' # IEEE 123 + # req_template['power_system_config']['Line_name'] = '_AAE94E4A-2465-6F5E-37B1-3E72183A4E44' # test9500new + + req_template["application_config"]["applications"][0]['name'] = app_name + # req_template["application_config"]["applications"][0]['name'] = 'sample_app_opp' + + req_template['test_config'] = testCfgAll + + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() + + req_template['test_config']['compareWithSimId'] = simulationID # 913015800 + req_template['test_config']['testType'] ='simulation_vs_timeseries' + print(json.dumps(req_template['test_config'], indent=2)) + simCfg13pv = json.dumps(req_template) + print('request') + print(json.dumps(req_template,indent=2)) + + simulationId = gapps.get_response(goss_sim, simCfg13pv, timeout=10) + print('sent simulation request') + print('simulation id ', simulationId) + + return(simulationId['simulationId'],test_id) + +# {'status': 'start'} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '32583055-fb4e-41bc-9e7f-e40dcc327010', 'diffType': 'FORWARD', 'match': False} +# {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '32583055-fb4e-41bc-9e7f-e40dcc327010', 'diffType': 'FORWARD', 'match': False} +# {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '32583055-fb4e-41bc-9e7f-e40dcc327010', 'diffType': 'FORWARD', 'match': False} +# {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '32583055-fb4e-41bc-9e7f-e40dcc327010', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': '1', 'diffMrid': '4f93d9f5-7695-4c1e-80bd-b391462e041d', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': '0', 'diffMrid': '4f93d9f5-7695-4c1e-80bd-b391462e041d', 'diffType': 'REVERSE', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '94dc5ecd-3aa0-49cb-91be-93c81eca1726', 'diffType': 'FORWARD', 'match': False} +# {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '94dc5ecd-3aa0-49cb-91be-93c81eca1726', 'diffType': 'FORWARD', 'match': False} +# {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '94dc5ecd-3aa0-49cb-91be-93c81eca1726', 'diffType': 'FORWARD', 'match': False} +# {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '94dc5ecd-3aa0-49cb-91be-93c81eca1726', 'diffType': 'FORWARD', 'match': False} + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-i", "--id", type=int, help="simulation id", required=False) + args = parser.parse_args() + + start_test(simulationID=args.id) diff --git a/expected_results/request_test_timeseries_vs_timeseries.py b/expected_results/request_test_timeseries_vs_timeseries.py new file mode 100644 index 0000000..6b42093 --- /dev/null +++ b/expected_results/request_test_timeseries_vs_timeseries.py @@ -0,0 +1,50 @@ +import json +import argparse +import random +from gridappsd import GridAPPSD + +goss_sim = "goss.gridappsd.process.request.simulation" +test_input = "/topic/goss.gridappsd.simulation.test.input." + +def start_test(simulationID1, simulationID2, testOutput=False, start_time=1248156000,duration=60): + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + + test_id = str(random.getrandbits(32)) + testCfgAll = { + "appId": "sample_app", + "testId": test_id, + "testOutput": testOutput, + "start_time":start_time, + "duration":duration + } + + testCfgAll['compareWithSimId'] = simulationID1 # 847461010 # 660948920 + testCfgAll['compareWithSimIdTwo'] = simulationID2 # 912453649 + testCfgAll['testType'] = 'timeseries_vs_timeseries' + request = json.dumps(testCfgAll) + + # status = goss.get_response(test_input+str(test_id), request, timeout=60) + status = gapps.send(test_input+str(test_id), request) + print(status) + print('sent test status') + return test_id + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-i", "--id1", type=int, help="simulation id 1", required=False) + parser.add_argument("-j", "--id2", type=int, help="simulation id 2", required=False) + args = parser.parse_args() + + start_test(simulationID1=args.id1, simulationID2=args.id2) + +# If opposite +# {'status': 'start'} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0.0', 'diffMrid': '6cb31129-662d-4859-bd68-61d219730e2f', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': '1.0', 'diffMrid': 'ef1db14e-2cb3-43f5-b3d1-e5354e52f8ea', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': '0.0', 'diffMrid': 'ef1db14e-2cb3-43f5-b3d1-e5354e52f8ea', 'diffType': 'REVERSE', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0.0', 'diffMrid': 'd6a33bce-9a95-4d5f-83c5-29ec6d568886', 'diffType': 'FORWARD', 'match': False} +# {'status': 'finish'} +# Exit +# Error count 4 \ No newline at end of file diff --git a/expected_results/return_results_test_1.py b/expected_results/return_results_test_1.py new file mode 100644 index 0000000..df5f87a --- /dev/null +++ b/expected_results/return_results_test_1.py @@ -0,0 +1,57 @@ +import time +import json +from gridappsd import GOSS, utils, topics as t +import request_test_expected_vs_timeseries +import request_test_expected_vs_running +import request_test_running_vs_timeseries +import request_test_timeseries_vs_timeseries + + +def test_expected(): + sim_id, test_id = request_test_expected_vs_running.start_test() + print('sent test request ' + test_id) + time.sleep(75) + log_topic = 'goss.gridappsd.process.request.data.log' + + goss = GOSS() + # goss = GOSS(1234, address=utils.get_gridappsd_address(), + # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) + goss.connect() + + # test_id = "1702722370" + # sim_id = "847461010" + # select * from expected_results where match_flag=0 and difference_direction<>'NA' + count_query = '{"query":"select COUNT(*) from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + response = goss.get_response(log_topic, count_query, timeout=10) + test_1_count = response['data'][0]['COUNT(*)'] + print(test_1_count) + print(test_1_count == '7') # 5? + assert int(test_1_count) == 7, f" For expected_vs_running expecting 7 non matching results. Received {test_1_count}" + query = '{"query":"select * from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + print(query) + response = goss.get_response(log_topic, query, timeout=10) + for i in response['data']: + print(i) + + # exit(0) 1873688741 + + sim_id2, test_id2 = request_test_running_vs_timeseries.start_test(sim_id) + print('sent test request ' + test_id2) + time.sleep(75) + count_query = '{"query":"select COUNT(*) from expected_results where test_id=\'' + test_id2 + '\' and match_flag=0"}' + response = goss.get_response(log_topic, count_query, timeout=10) + print(response) + test_2_count = response['data'][0]['COUNT(*)'] + print(test_2_count == '0') + assert test_2_count == 0, f" For running_vs_timeseries expecting 0 non matching results. Received {test_2_count}" + query = '{"query":"select * from expected_results where test_id=\'' + test_id2 + '\' and match_flag=0"}' + print(query) + response = goss.get_response(log_topic, query, timeout=10) + for i in response['data']: + print(i) + + with open('test_ids.json', 'w') as f: + json.dump({'sim_id1': sim_id, 'sim_id2': sim_id2}, f) + +if __name__ == '__main__': + test_expected() diff --git a/expected_results/return_results_test_2.py b/expected_results/return_results_test_2.py new file mode 100644 index 0000000..58b3843 --- /dev/null +++ b/expected_results/return_results_test_2.py @@ -0,0 +1,93 @@ +import time +import json +from gridappsd import GOSS +import request_test_expected_vs_timeseries +import request_test_timeseries_vs_timeseries +from pytest import fixture + +@fixture +def sim_id1(): + with open('test_ids.json') as f: + d = json.load(f) + print(d) + return int(d['sim_id2']) + + +@fixture +def sim_id2(): + with open('test_ids.json') as f: + d = json.load(f) + print(d) + return int(d['sim_id2']) + +def test_expected(sim_id1, sim_id2): + # sim_id, test_id = request_test_expected_vs_running.start_test() + # time.sleep(75) + print('sent test request') + log_topic = 'goss.gridappsd.process.request.data.log' + goss = GOSS() + goss.connect() + query = '{"query":"select * from expected_results"}' + # test_id = "1702722370" + # sim_id = "847461010" + # select * from expected_results where match_flag=0 and difference_direction<>'NA' + # count_query = '{"query":"select COUNT(*) from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + # response = goss.get_response(log_topic, count_query, timeout=10) + # print(response['data'][0]['COUNT(*)'] == '5') + # query = '{"query":"select * from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + # response = goss.get_response(log_topic, query, timeout=10) + # for i in response['data']: + # print(i) + + test_id = request_test_expected_vs_timeseries.start_test(sim_id1) + time.sleep(2) + count_query = '{"query":"select COUNT(*) from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + response = goss.get_response(log_topic, count_query, timeout=10) + test_3_count = response['data'][0]['COUNT(*)'] + print(test_3_count) + print(test_3_count == '7') # 5? + # assert test_3_count != 7, f" For expected_vs_timeseries expecting 7 non matching results. Received {test_3_count}" + query = '{"query":"select * from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + print(query) + response = goss.get_response(log_topic, query, timeout=10) + for i in response['data']: + print(i) + # {"1248156014":{"message":{"measurements":[{"hasMeasurementDifference":"FORWARD","difference_mrid":"c7e477f5-208e-401f-a032-30570e86f695","attribute":"ShuntCompensator.sections","value":0.0,"object":"_939CA567-AA3D-4972-AABC-1D0AAF4859FE"},{"hasMeasurementDifference":"REVERSE","difference_mrid":"c7e477f5-208e-401f-a032-30570e86f695","attribute":"ShuntCompensator.sections","value":1.0,"object":"_939CA567-AA3D-4972-AABC-1D0AAF4859FE"}]}},"1248156029":{"message":{"measurements":[{"hasMeasurementDifference":"FORWARD","difference_mrid":"44d77bf5-0b88-4a68-acee-20cd4f72494c","attribute":"ShuntCompensator.sections","value":1.0,"object":"_939CA567-AA3D-4972-AABC-1D0AAF4859FE"},{"hasMeasurementDifference":"REVERSE","difference_mrid":"44d77bf5-0b88-4a68-acee-20cd4f72494c","attribute":"ShuntCompensator.sections","value":0.0,"object":"_939CA567-AA3D-4972-AABC-1D0AAF4859FE"}]}},"1248156044":{"message":{"measurements":[{"hasMeasurementDifference":"REVERSE","difference_mrid":"92098f43-8f26-4652-8078-072ed2a005c0","attribute":"ShuntCompensator.sections","value":1.0,"object":"_939CA567-AA3D-4972-AABC-1D0AAF4859FE"},{"hasMeasurementDifference":"FORWARD","difference_mrid":"92098f43-8f26-4652-8078-072ed2a005c0","attribute":"ShuntCompensator.sections","value":0.0,"object":"_939CA567-AA3D-4972-AABC-1D0AAF4859FE"}]}}} + # exit(0) + + test_id = request_test_timeseries_vs_timeseries.start_test(sim_id1, sim_id1) + time.sleep(2) + count_query = '{"query":"select COUNT(*) from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + response = goss.get_response(log_topic, count_query, timeout=10) + print(response['data'][0]['COUNT(*)']) + test_4_count = response['data'][0]['COUNT(*)'] + print(test_4_count == '0') + # assert test_4_count != 0, f" For timeseries_vs_timeseries expecting 0 non matching results. Received {test_4_count}" + + query = '{"query":"select * from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + print(query) + response = goss.get_response(log_topic, query, timeout=120) + for i in response['data']: + print(i) + + test_id = request_test_timeseries_vs_timeseries.start_test(sim_id1, sim_id2) + time.sleep(5) + # count_query = '{"query":"select COUNT(*) from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + # print(count_query) + # response = goss.get_response(log_topic, count_query, timeout=10) + # print(response['data'][0]['COUNT(*)']) + # print(response['data'][0]['COUNT(*)'] == '0') + query = '{"query":"select * from expected_results where test_id=\'' + test_id + '\' and match_flag=0"}' + print(query) + response = goss.get_response(log_topic, query, timeout=120) + for i in response['data']: + print(i) + + +if __name__ == '__main__': + with open('test_ids.json') as f: + d = json.load(f) + print(d) + test_expected(int(d['sim_id1']), int(d['sim_id2'])) + # test_expected(273529813, 2272136042) + # test_expected(1232216123, 2040676147) diff --git a/expected_results/test_get_results.py b/expected_results/test_get_results.py new file mode 100644 index 0000000..26dbc59 --- /dev/null +++ b/expected_results/test_get_results.py @@ -0,0 +1,54 @@ +import argparse +import json +import logging +import sys +import time + +from gridappsd import GridAPPSD, DifferenceBuilder, utils +from gridappsd.topics import simulation_input_topic, simulation_output_topic, simulation_log_topic, simulation_output_topic + +test_output_topic = "/topic/goss.gridappsd.simulation.test.output." + +class SimpleListener(object): + """ A simple class to listen for the test results + """ + + def __init__(self, gridappsd_obj, test_id): + """ Create + """ + self._gapps = gridappsd_obj + self._test_id = test_id + + def on_message(self, headers, message): + """ Handle incoming messages on the simulation_output_topic for the simulation_id + Parameters + ---------- + headers: dict + A dictionary of headers that could be used to determine topic of origin and + other attributes. + message: object + A data structure following the protocol defined in the message structure + of ``GridAPPSD``. Most message payloads will be serialized dictionaries, but that is + not a requirement. + """ + print(message) + +def _main(): + parser = argparse.ArgumentParser() + parser.add_argument("-test_id", default=3258685887, + help="Simulation id to use for responses on the message bus.") + + opts = parser.parse_args() + gapps = GridAPPSD(opts.test_id, address=utils.get_gridappsd_address(), + username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) + sl = SimpleListener(gapps, opts.test_id) + print(test_output_topic+str(opts.test_id)) + response = gapps.subscribe(test_output_topic+str(opts.test_id), sl) + + while True: + time.sleep(0.1) + + +if __name__ == "__main__": + _main() + diff --git a/expected_results/test_listen_1_sim_vs_expected.py b/expected_results/test_listen_1_sim_vs_expected.py new file mode 100644 index 0000000..5ff82c3 --- /dev/null +++ b/expected_results/test_listen_1_sim_vs_expected.py @@ -0,0 +1,163 @@ +import argparse +import json +import os +import time +import logging + +from gridappsd import GridAPPSD, DifferenceBuilder, utils +from gridappsd.topics import simulation_input_topic, simulation_output_topic, simulation_log_topic, simulation_output_topic +import request_test_expected_vs_running +test_output_topic = "/topic/goss.gridappsd.simulation.test.output." +logging.basicConfig(filename=__name__+'.log', level=logging.INFO) + +class SimpleListener(object): + """ A simple class to listen for the test results + """ + + def __init__(self, gridappsd_obj, test_id): + """ Create + """ + self._gapps = gridappsd_obj + self._test_id = test_id + self._error_count = 0 + + def on_message(self, headers, message): + """ Handle incoming messages on the simulation_output_topic for the simulation_id + Parameters + ---------- + headers: dict + A dictionary of headers that could be used to determine topic of origin and + other attributes. + message: object + A data structure following the protocol defined in the message structure + of ``GridAPPSD``. Most message payloads will be serialized dictionaries, but that is + not a requirement. + """ + print(message) + if 'status' in message and (message['status'] == 'finish' or message['status'] == 'start'): + pass + else: + self._error_count+=1 + # json_message = json.loads(message) + # "{\"status\":\"start\"}") + if 'status' in message and message['status'] == 'finish': + print("Exit") + print("Error count " + str(self._error_count)) + print(self._error_count == 7) # 5? + # assert self._error_count == 7, f" For expected_vs_running expecting 7 non matching results. Received {self._error_count}" + + # os._exit(1) + + +def test(): + # parser = argparse.ArgumentParser() + # parser.add_argument("-test_id", default=3258685887, + # help="Simulation id to use for responses on the message bus.") + # + # opts = parser.parse_args() + sim_id, test_id = request_test_expected_vs_running.start_test(testOutput=False) + time.sleep(2) + print('sent test request ' + test_id) + + # gapps = GridAPPSD(opts.test_id, address=utils.get_gridappsd_address(), + # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() + assert gapps.connected + sl = SimpleListener(gapps, 1) + print(test_output_topic+str(test_id)) + response = gapps.subscribe(test_output_topic+str(test_id), sl) + print(response) + + with open('test_id_request_1.json', 'w') as f: + json.dump({'sim_id1': sim_id}, f) + + finished=False + while not finished: + time.sleep(85) + finished = True + error_count = sl._error_count + print(error_count) + logging.info("Error count " + str(error_count)) + assert error_count == 29, f" For expected_vs_running expecting 29 non matching results. Received {error_count}" + +if __name__ == "__main__": + test() + + # {'status': 'start'} + # {'object': '_0044ae64-1c72-4e81-b412-d7349ce267d3', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '374545.4981119089', 'actual': '54911.42414314939', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'angle', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '-5.066423674487563', 'actual': '21.91525592241816', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '2388.676720682955', 'actual': '23182.721945577698', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '0da4890f-1eb5-4ef2-81e7-97ac4b15d191', 'diffType': 'FORWARD', 'match': False} + # {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '0da4890f-1eb5-4ef2-81e7-97ac4b15d191', 'diffType': 'FORWARD', 'match': False} + # {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '0da4890f-1eb5-4ef2-81e7-97ac4b15d191', 'diffType': 'FORWARD', 'match': False} + # {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '0da4890f-1eb5-4ef2-81e7-97ac4b15d191', 'diffType': 'FORWARD', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156016, 'indexTwo': 1248156016, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'FORWARD', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': '1', 'diffMrid': '3cf5c2fd-9bd1-4636-80d0-00d6a16d2318', 'diffType': 'FORWARD', 'match': False} + # {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'value', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': '0', 'diffMrid': '3cf5c2fd-9bd1-4636-80d0-00d6a16d2318', 'diffType': 'REVERSE', 'match': False} + # {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'value', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # {'status': 'finish'} + + ## Added reverse + # {'status': 'start'} + # {'object': '_0044ae64-1c72-4e81-b412-d7349ce267d3', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '374545.4981119089', 'actual': '54911.42414314939', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'angle', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '-5.066423674487563', 'actual': '21.91525592241816', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '2388.676720682955', 'actual': '23182.721945577698', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'a20d42c1-022f-4338-b25c-67a415803c95', 'diffType': 'FORWARD', 'match': False} + # {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'a20d42c1-022f-4338-b25c-67a415803c95', 'diffType': 'FORWARD', 'match': False} + # {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'a20d42c1-022f-4338-b25c-67a415803c95', 'diffType': 'FORWARD', 'match': False} + # {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'a20d42c1-022f-4338-b25c-67a415803c95', 'diffType': 'FORWARD', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'a20d42c1-022f-4338-b25c-67a415803c95', 'diffType': 'REVERSE', 'match': False} + # {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'a20d42c1-022f-4338-b25c-67a415803c95', 'diffType': 'REVERSE', 'match': False} + # {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'a20d42c1-022f-4338-b25c-67a415803c95', 'diffType': 'REVERSE', 'match': False} + # {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'a20d42c1-022f-4338-b25c-67a415803c95', 'diffType': 'REVERSE', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156016, 'indexTwo': 1248156016, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'FORWARD', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156016, 'indexTwo': 1248156016, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'REVERSE', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': '1', 'diffMrid': '6842fe8e-555b-464f-a52a-4c03783ae46a', 'diffType': 'FORWARD', 'match': False} + # {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'value', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': '0', 'diffMrid': '6842fe8e-555b-464f-a52a-4c03783ae46a', 'diffType': 'REVERSE', 'match': False} + # {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'value', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} + # 17 + +# /topic/goss.gridappsd.simulation.test.output.2406795910 +# 591460 +# {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'angle', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '-5.066423674487563', 'actual': '26.565023654742475', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '2388.676720682955', 'actual': '23058.218465547878', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_0044ae64-1c72-4e81-b412-d7349ce267d3', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '374545.4981119089', 'actual': '52991.38083465865', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'daab84ef-548d-41fb-b299-c392056e0ffc', 'diffType': 'FORWARD', 'match': False} +# {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'daab84ef-548d-41fb-b299-c392056e0ffc', 'diffType': 'FORWARD', 'match': False} +# {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'daab84ef-548d-41fb-b299-c392056e0ffc', 'diffType': 'FORWARD', 'match': False} +# {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'daab84ef-548d-41fb-b299-c392056e0ffc', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'daab84ef-548d-41fb-b299-c392056e0ffc', 'diffType': 'REVERSE', 'match': False} +# {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'daab84ef-548d-41fb-b299-c392056e0ffc', 'diffType': 'REVERSE', 'match': False} +# {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'daab84ef-548d-41fb-b299-c392056e0ffc', 'diffType': 'REVERSE', 'match': False} +# {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'daab84ef-548d-41fb-b299-c392056e0ffc', 'diffType': 'REVERSE', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156016, 'indexTwo': 1248156016, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156016, 'indexTwo': 1248156016, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'REVERSE', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': '1', 'diffMrid': 'b8db3372-149c-4e06-9d80-0a5cf8844b2b', 'diffType': 'FORWARD', 'match': False} +# {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'FORWARD', 'match': False} +# {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'b8db3372-149c-4e06-9d80-0a5cf8844b2b', 'diffType': 'FORWARD', 'match': False} +# {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'b8db3372-149c-4e06-9d80-0a5cf8844b2b', 'diffType': 'FORWARD', 'match': False} +# {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': 'b8db3372-149c-4e06-9d80-0a5cf8844b2b', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': '0', 'diffMrid': 'b8db3372-149c-4e06-9d80-0a5cf8844b2b', 'diffType': 'REVERSE', 'match': False} +# {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'REVERSE', 'match': False} +# {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'b8db3372-149c-4e06-9d80-0a5cf8844b2b', 'diffType': 'REVERSE', 'match': False} +# {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'b8db3372-149c-4e06-9d80-0a5cf8844b2b', 'diffType': 'REVERSE', 'match': False} +# {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': 'b8db3372-149c-4e06-9d80-0a5cf8844b2b', 'diffType': 'REVERSE', 'match': False} +# {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '3e6b6897-0458-41f8-9778-8d12df38d400', 'diffType': 'FORWARD', 'match': False} +# {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '3e6b6897-0458-41f8-9778-8d12df38d400', 'diffType': 'FORWARD', 'match': False} +# {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0', 'diffMrid': '3e6b6897-0458-41f8-9778-8d12df38d400', 'diffType': 'FORWARD', 'match': False} +# {'object': '_CABBC3A1-66F5-4B9C-ACB9-476E2389D119', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': '3e6b6897-0458-41f8-9778-8d12df38d400', 'diffType': 'REVERSE', 'match': False} +# {'object': '_D6C44FF1-BC60-49D3-9438-DFAD1AED0A28', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': '3e6b6897-0458-41f8-9778-8d12df38d400', 'diffType': 'REVERSE', 'match': False} +# {'object': '_3DE55D2D-34D3-487E-9D6E-3A4DB1E38E47', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1', 'diffMrid': '3e6b6897-0458-41f8-9778-8d12df38d400', 'diffType': 'REVERSE', 'match': False} +# {'status': 'finish'} +# Exit +# Error count 29 +# False +# {'status': 'finish'} +# Exit +# Error count 29 +# False \ No newline at end of file diff --git a/expected_results/test_listen_2_sim_vs_timeseries.py b/expected_results/test_listen_2_sim_vs_timeseries.py new file mode 100644 index 0000000..f8d172f --- /dev/null +++ b/expected_results/test_listen_2_sim_vs_timeseries.py @@ -0,0 +1,86 @@ +import argparse +import json +import os +import time +import logging + +from gridappsd import GridAPPSD, DifferenceBuilder, utils +from gridappsd.topics import simulation_input_topic, simulation_output_topic, simulation_log_topic, simulation_output_topic +import request_test_running +import request_test_running_vs_timeseries +test_output_topic = "/topic/goss.gridappsd.simulation.test.output." +logging.basicConfig(filename=__name__+'.log', level=logging.INFO) + +class SimpleListener(object): + """ A simple class to listen for the test results + """ + + def __init__(self, gridappsd_obj, test_id): + """ Create + """ + self._gapps = gridappsd_obj + self._test_id = test_id + self._error_count = 0 + + def on_message(self, headers, message): + """ Handle incoming messages on the simulation_output_topic for the simulation_id + Parameters + ---------- + headers: dict + A dictionary of headers that could be used to determine topic of origin and + other attributes. + message: object + A data structure following the protocol defined in the message structure + of ``GridAPPSD``. Most message payloads will be serialized dictionaries, but that is + not a requirement. + """ + print(message) + if 'status' in message and (message['status'] == 'finish' or message['status'] == 'start'): + pass + else: + self._error_count+=1 + # json_message = json.loads(message) + # "{\"status\":\"start\"}") + if 'status' in message and message['status'] == 'finish': + print("Exit") + print("Error count " + str(self._error_count)) + print(self._error_count == 0) + # assert self._error_count != 0, f" For running_vs_timeseries expecting 0 non matching results. Received {self._error_count}" + # + # os._exit(1) + + + +def test(): + sim_id = request_test_running.start_test('sample_app') + time.sleep(90) + print('sent run request ' + sim_id) + with open('test_id_request_2.json', 'w') as f: + json.dump({'sim_id1': sim_id}, f) + # sim_id = 476685412 # 68942381 + sim_id2, test_id2 = request_test_running_vs_timeseries.start_test(sim_id, 'sample_app', duration='60') + print('simid ' + sim_id2) + print('sent test request ' + test_id2) + + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() + sl = SimpleListener(gapps, 1) + print(test_output_topic+str(test_id2)) + response = gapps.subscribe(test_output_topic+str(test_id2), sl) + print('response') + print(response) + + finished = False + while not finished: + time.sleep(120) + finished = True + error_count = sl._error_count + print(error_count) + logging.info("Error count " + str(error_count)) + assert error_count == 0, f" For running_vs_timeseries expecting 0 non matching results. Received {error_count}" + + +if __name__ == "__main__": + test() diff --git a/expected_results/test_listen_3_timeseries_vs_expected.py b/expected_results/test_listen_3_timeseries_vs_expected.py new file mode 100644 index 0000000..e1c6ca3 --- /dev/null +++ b/expected_results/test_listen_3_timeseries_vs_expected.py @@ -0,0 +1,118 @@ +import time +import logging +import random +import pytest + +from gridappsd import GridAPPSD, DifferenceBuilder, utils +from gridappsd.topics import simulation_input_topic, simulation_output_topic, simulation_log_topic, simulation_output_topic +import request_test_expected_vs_timeseries +import request_test_running +test_output_topic = "/topic/goss.gridappsd.simulation.test.output." +# LOGGER = logging.getLogger(__name__) +logging.basicConfig(filename=__name__+'.log', level=logging.INFO) + +class SimpleListener(object): + """ A simple class to listen for the test results + """ + def __init__(self, gridappsd_obj, test_id): + """ Create + """ + self._gapps = gridappsd_obj + self._test_id = test_id + self._error_count = 0 + + def on_message(self, headers, message): + """ Handle incoming messages on the simulation_output_topic for the simulation_id + Parameters + ---------- + headers: dict + A dictionary of headers that could be used to determine topic of origin and + other attributes. + message: object + A data structure following the protocol defined in the message structure + of ``GridAPPSD``. Most message payloads will be serialized dictionaries, but that is + not a requirement. + """ + print(message) + if 'status' in message and (message['status'] == 'finish' or message['status'] == 'start'): + pass + else: + self._error_count+=1 + # json_message = json.loads(message) + # "{\"status\":\"start\"}") + if 'status' in message and message['status'] == 'finish': + print("Exit") + print("Error count " + str(self._error_count)) + print(self._error_count == 7) # 5? + +def test(): + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() + logging.info('Starting') + sl = SimpleListener(gapps, 1) + + sim_id = request_test_running.start_test() + time.sleep(65) + print('sent run request ' + sim_id) + + # import json + # with open('test_id_request_1.json') as f: + # sim_id = json.load(f) + # sim_id = sim_id['sim_id1'] + # sim_id='2105518764' + test_id2 = request_test_expected_vs_timeseries.start_test(simulationID=sim_id, + app_name='sample_app', + testOutput=False) + + response = gapps.subscribe(test_output_topic + str(test_id2), sl) + print(response) + print(type(test_id2)) + print('simid ' + str(sim_id)) + print('sent test request ' + str(test_id2)) + print(test_output_topic + str(test_id2)) + + logging.info("Start waiting") + finished = False + while not finished: + time.sleep(5) + finished = True + error_count = sl._error_count + print(error_count) + logging.info("Error count " + str(error_count)) + assert error_count == 11, f" For expected_vs_timeseries expecting 11 non matching results. Received {error_count}" + +if __name__ == "__main__": + test() + +# {'status': 'start'} +# {'object': '_0044ae64-1c72-4e81-b412-d7349ce267d3', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '374545.4981119089', 'actual': '54911.42414314939', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'angle', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '-5.066423674487563', 'actual': '21.91525592241816', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '2388.676720682955', 'actual': '23182.721945577698', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156016, 'indexTwo': 1248156016, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0.0', 'diffMrid': '07e75eb1-d72b-4e6b-8aae-fe7cef810001', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': '1.0', 'diffMrid': 'fca0f5c2-b4fa-49ec-8a73-278cc541af03', 'diffType': 'FORWARD', 'match': False} +# {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'value', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': '0.0', 'diffMrid': 'fca0f5c2-b4fa-49ec-8a73-278cc541af03', 'diffType': 'REVERSE', 'match': False} +# {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'value', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'status': 'finish'} +# Exit +# Error count 9 + +# +# {'status': 'start'} +# {'object': '_0044ae64-1c72-4e81-b412-d7349ce267d3', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '374545.4981119089', 'actual': '54911.42414314939', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'angle', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '-5.066423674487563', 'actual': '21.91525592241816', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_000b01a1-8238-4372-95c0-82aad26ea311', 'attribute': 'magnitude', 'indexOne': 1248156002, 'indexTwo': 1248156002, 'simulationTimestamp': 0, 'expected': '2388.676720682955', 'actual': '23182.721945577698', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156016, 'indexTwo': 1248156016, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156016, 'indexTwo': 1248156016, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': '1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4', 'diffType': 'REVERSE', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '0.0', 'diffMrid': 'ddfc2e02-fea7-4d5f-a2a7-d855c750779b', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': 'NA', 'actual': '1.0', 'diffMrid': 'ddfc2e02-fea7-4d5f-a2a7-d855c750779b', 'diffType': 'REVERSE', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': '1.0', 'diffMrid': 'f7167aa0-8e04-4a67-ac00-65ebc19d533b', 'diffType': 'FORWARD', 'match': False} +# {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'value', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': '0.0', 'diffMrid': 'f7167aa0-8e04-4a67-ac00-65ebc19d533b', 'diffType': 'REVERSE', 'match': False} +# {'object': '_only_in_expected_MRID_time_does_not_matches', 'attribute': 'value', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': 'NA', 'diffType': 'NA', 'match': False} +# {'status': 'finish'} +# Exit +# Error count 11 \ No newline at end of file diff --git a/expected_results/test_listen_4_timeseries_vs_timeseries.py b/expected_results/test_listen_4_timeseries_vs_timeseries.py new file mode 100644 index 0000000..7a22d84 --- /dev/null +++ b/expected_results/test_listen_4_timeseries_vs_timeseries.py @@ -0,0 +1,98 @@ +import time +import logging +import json + +from gridappsd import GridAPPSD, DifferenceBuilder, utils +from gridappsd.topics import simulation_input_topic, simulation_output_topic, simulation_log_topic, simulation_output_topic +import request_test_timeseries_vs_timeseries +import request_test_running +test_output_topic = "/topic/goss.gridappsd.simulation.test.output." + +class SimpleListener(object): + """ A simple class to listen for the test results + """ + def __init__(self, gridappsd_obj, test_id): + """ Create + """ + self._gapps = gridappsd_obj + self._test_id = test_id + self._error_count = 0 + + def on_message(self, headers, message): + """ Handle incoming messages on the simulation_output_topic for the simulation_id + Parameters + ---------- + headers: dict + A dictionary of headers that could be used to determine topic of origin and + other attributes. + message: object + A data structure following the protocol defined in the message structure + of ``GridAPPSD``. Most message payloads will be serialized dictionaries, but that is + not a requirement. + """ + print(message) + if 'status' in message and (message['status'] == 'finish' or message['status'] == 'start'): + pass + else: + self._error_count+=1 + # json_message = json.loads(message) + # "{\"status\":\"start\"}") + if 'status' in message and message['status'] == 'finish': + print("Exit") + print("Error count " + str(self._error_count)) + print(self._error_count == 0) + + +def test(): + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() + logging.info('Starting') + sl = SimpleListener(gapps, 1) + sim_id = request_test_running.start_test('sample_app') + time.sleep(90) + print('sent run request ' + sim_id) + + sim_id2 = request_test_running.start_test('sample_app') + # sim_id2 = request_test_running.start_test('sample_app_opp') + time.sleep(90) + print('sent run request ' + sim_id) + # sim_id='1290306857' + # sim_id2='156135802' + with open('test_id_request_4.json', 'w') as f: + json.dump({'sim_id1': sim_id, 'sim_id2':sim_id2}, f) + + test_id2 = request_test_timeseries_vs_timeseries.start_test(sim_id, sim_id2) + print('simid ' + str(sim_id)) + print('sent test request ' + test_id2) + print(test_output_topic + str(test_id2)) + + response = gapps.subscribe(test_output_topic+str(test_id2), sl) + print(response) + time.sleep(2) + + finished = False + while not finished: + time.sleep(120) + finished = True + + gapps.disconnect() + + error_count = sl._error_count + print(error_count) + assert error_count == 0, f" For timeseries_vs_timeseries expecting 0 non matching results. Received {error_count}" + +if __name__ == "__main__": + test() + +# {'status': 'start'} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': '87ac3700-0e81-4f35-8062-6a9aa4f762bc', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156014, 'indexTwo': 1248156014, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': '87ac3700-0e81-4f35-8062-6a9aa4f762bc', 'diffType': 'REVERSE', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': '0.0', 'diffMrid': '5c7bbd6e-790d-4abe-9804-dd59840a1ce3', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156029, 'indexTwo': 1248156029, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': '1.0', 'diffMrid': '5c7bbd6e-790d-4abe-9804-dd59840a1ce3', 'diffType': 'REVERSE', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': '0.0', 'actual': 'NA', 'diffMrid': '2bf77715-7c0f-48cb-8982-b848f057ac15', 'diffType': 'FORWARD', 'match': False} +# {'object': '_939CA567-AA3D-4972-AABC-1D0AAF4859FE', 'attribute': 'ShuntCompensator.sections', 'indexOne': 1248156044, 'indexTwo': 1248156044, 'simulationTimestamp': 0, 'expected': '1.0', 'actual': 'NA', 'diffMrid': '2bf77715-7c0f-48cb-8982-b848f057ac15', 'diffType': 'REVERSE', 'match': False} +# {'status': 'finish'} +# Exit +# Error count 6 diff --git a/expected_results/test_script_sample1.json b/expected_results/test_script_sample1.json new file mode 100644 index 0000000..50cf4db --- /dev/null +++ b/expected_results/test_script_sample1.json @@ -0,0 +1,143 @@ +{ + "appId": "sample_app", + "testId": "2207296283", + "expectedResults": { + "output": { + "1248156002": { + "simulation_id": "559402036", + "message": { + "timestamp": 1535574871, + "measurements": [ + { + "measurement_mrid": "_0055de94-7d7e-4931-a884-cab596cc191b", + "angle": -5.066423674487563, + "magnitude": 235525.8716877966, + "simulation_id": "1961648576", + "time": 1248156002 + }, + { + "measurement_mrid": "_00ce801b-214d-4540-9cbb-1ddcac0c0495", + "angle": -86.36800510651457, + "magnitude": 1.4651647694061578, + "simulation_id": "1961648576", + "time": 1248156002 + }, + { + "measurement_mrid": "_0058123f-da11-4f7c-a429-e47e5949465f", + "angle": 28.940770423235723, + "magnitude": 374545.4981119089, + "simulation_id": "1961648576", + "time": 1248156002 + } + ] + } + } + }, + "input": { + "0": { + "simulation_id": "559402036", + "message": { + "timestamp": 1587670650, + "measurements": [ + { + "hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670650, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" + }, + { + "hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670650, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" + } + ] + } + }, + "15": { + "simulation_id": "559402036", + "message": { + "timestamp": 1587670665, + "measurements": [ + { + "hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" + }, + { + "hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" + } + ] + } + }, + "27": { + "simulation_id": "559402036", + "message": { + "timestamp": 1587670665, + "measurements": [ + { + "hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" + }, + { + "hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" + } + ] + } + }, + "30": { + "simulation_id": "559402036", + "message": { + "timestamp": 1587670665, + "measurements": [ + { + "hasMeasurementDifference": "FORWARD", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" + }, + { + "hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" + } + ] + } + } + } + } +} \ No newline at end of file