From ba944f407f5fd292b505b612156adf67d99f9137 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Wed, 3 Jun 2020 14:51:36 -0600 Subject: [PATCH 01/18] Initial checkin. --- ...lt_series_filtered_123_normal_small_4.json | 124 +++++++++++ .../expected_result_series_filtered_9500.json | 124 +++++++++++ .../request_test_expected_vs_running.py | 103 +++++++++ .../request_test_expected_vs_timeseries.py | 37 ++++ .../request_test_running_no_application.py | 196 ++++++++++++++++++ .../request_test_running_vs_timeseries.py | 121 +++++++++++ .../request_test_timerseries_vs_timeseries.py | 35 ++++ 7 files changed, 740 insertions(+) create mode 100644 expected_results/expected_result_series_filtered_123_normal_small_4.json create mode 100644 expected_results/expected_result_series_filtered_9500.json create mode 100644 expected_results/request_test_expected_vs_running.py create mode 100644 expected_results/request_test_expected_vs_timeseries.py create mode 100644 expected_results/request_test_running_no_application.py create mode 100644 expected_results/request_test_running_vs_timeseries.py create mode 100644 expected_results/request_test_timerseries_vs_timeseries.py 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..a00aeb9 --- /dev/null +++ b/expected_results/expected_result_series_filtered_123_normal_small_4.json @@ -0,0 +1,124 @@ +{ + "expectedResults": { + "output": { + "1248156002": { + "simulation_id": "559402036", + "message": { + "timestamp": 1535574871, + "measurements": [ + { + "measurement_mrid": "_0055de94-7d7e-4931-a884-cab596cc191b", + "angle": -5.066423674487563, + "magnitude": 2361.0733024639117, + "simulation_id": "1961648576", + "time": 1248156002}, + { + "measurement_mrid": "_fff9a11e-d5d1-4824-a457-13d944ffcfdf", + "angle": -122.80107769837849, + "magnitude": 2520.2169329056983, + "simulation_id": "1961648576", + "time": 1248156002}, + { + "measurement_mrid": "_0058123f-da11-4f7c-a429-e47e5949465f", + "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.0, + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670650, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"} + ] + } + }, + "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": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"} + ] + } + }, + "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": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"} + ] + } + }, + "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": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"}, + {"hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670665, + "attribute": "ShuntCompensator.sections", + "value": 1.0, + "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"} + ] + } + } + } + } +} + + 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..b9f1fa8 --- /dev/null +++ b/expected_results/request_test_expected_vs_running.py @@ -0,0 +1,103 @@ +import json +import time +import os +import argparse +from gridappsd import GOSS +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) + 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 + }] + + + testCfgAll = { + "appId": "sample_app", + "testId": "test sample_app" + } + + # with open("expected_result_series_filtered_9500.json") as f: + with open("expected_result_series_filtered_123_normal_small_4.json") as f: + expectedJson = json.load(f) + + testCfgAll['expectedResults'] = expectedJson['expectedResults'] + # 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']['duration'] = 60 + req_template['power_system_config']['Line_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'] = 'sample_app' + # req_template["application_config"]["applications"][0]['name'] = 'sample_app_opp' + + req_template['test_config'] = testCfgAll + + simCfg13pv = json.dumps(req_template) + print(simCfg13pv) + print() + print(makeJavaString(simCfg13pv)) + print() + print(json.dumps(testCfgAll,indent=2)) + + goss = GOSS() + goss.connect() + + 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_expected_vs_timeseries.py b/expected_results/request_test_expected_vs_timeseries.py new file mode 100644 index 0000000..ce20a5f --- /dev/null +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -0,0 +1,37 @@ +import json +import time +import argparse +from gridappsd import GOSS +from pprint import pprint +goss_sim = "goss.gridappsd.process.request.simulation" +test_input = "/topic/goss.gridappsd.simulation.test.input." + +def _startTest(username,password,gossServer='localhost',stompPort='61613', simulationID=1234): + goss = GOSS() + goss.connect() + + testCfgAll = { + "appId": "sample_app" + } + testCfgAll['testType'] = 'expected_vs_timeseries' + with open("expected_result_series_filtered_123_normal_small_4.json") as f: + # with open("expected_result_series_filtered_9500.json") as f: + expectedJson = json.load(f) + + testCfgAll['expectedResults'] = expectedJson['expectedResults'] + + testCfgAll['compareWithSimId'] = 1121239269 # 272071421 + request = json.dumps(testCfgAll) + simulationID=1259505150 + + # simulationId =123 + status = goss.get_response(test_input+str(simulationID), request, timeout=10) + print(status) + print('sent test status') + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-i", "--id", type=int, help="simulation id", required=False) + args = parser.parse_args() + + _startTest('system','manager',gossServer='127.0.0.1',stompPort='61613', simulationID=args.id) 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..af60b26 --- /dev/null +++ b/expected_results/request_test_running_no_application.py @@ -0,0 +1,196 @@ +import json +import time +import os +import argparse +# import goss_forward_sim +from gridappsd import GOSS +# 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)) + + goss = GOSS() + goss.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..227e313 --- /dev/null +++ b/expected_results/request_test_running_vs_timeseries.py @@ -0,0 +1,121 @@ +import json +import time +import os +import argparse +from gridappsd import GOSS +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))) + + 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 + }] + + testCfgAll = { + "appId": "sample_app_opp", + } + + with open("expected_result_series_filtered_123_normal_small_4.json") as f: + expectedJson = json.load(f) + + # testCfgAll['expectedResults'] = expectedJson['expectedResults'] + # # 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']['duration'] = 60 + # 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'] = 'sample_app_opp' + # 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)) + + goss = GOSS() + goss.connect() + + # del req_template['test_config']['expectedResults'] + req_template['test_config']['compareWithSimId'] = 913015800 + req_template['test_config']['testType'] ='simulation_vs_timeseries' + print(json.dumps(req_template['test_config'], indent=2)) + # exit(0) + simCfg13pv = json.dumps(req_template) + print(simCfg13pv) + simulationId = goss.get_response(goss_sim, simCfg13pv, timeout=10) + print('simulation id ', simulationId) + print('sent simulation request') + time.sleep(1) + +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_timerseries_vs_timeseries.py b/expected_results/request_test_timerseries_vs_timeseries.py new file mode 100644 index 0000000..d704681 --- /dev/null +++ b/expected_results/request_test_timerseries_vs_timeseries.py @@ -0,0 +1,35 @@ +import json +import time +import argparse +from gridappsd import GOSS +from pprint import pprint +goss_sim = "goss.gridappsd.process.request.simulation" +test_input = "/topic/goss.gridappsd.simulation.test.input." + +def _startTest(username,password,gossServer='localhost',stompPort='61613', simulationID=1234): + goss = GOSS() + goss.connect() + + testCfgAll = { + "appId": "sample_app" + } + testCfgAll['compareWithSimId'] = 1062322800 # 660948920 + testCfgAll['compareWithSimIdTwo'] = 272071421 + testCfgAll['testType'] = 'timeseries_vs_timeseries' + request = json.dumps(testCfgAll) + simulationID=1259505150 + + # simulationId =123 + status = goss.get_response(test_input+str(simulationID), request, timeout=10) + print(status) + print('sent test status') + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-i", "--id", type=int, help="simulation id", required=False) + args = parser.parse_args() + + _startTest('system','manager',gossServer='127.0.0.1',stompPort='61613', simulationID=args.id) + +#{'data': [{'allOutputOutage': False, 'allInputOutage': False, 'inputOutageList': [{'objectMRID': '_233D4DC1-66EA-DF3C-D859-D10438ECCBDF', 'attribute': 'PowerElectronicsConnection.p'}, {'objectMRID': '_233D4DC1-66EA-DF3C-D859-D10438ECCBDF', 'attribute': 'PowerElectronicsConnection.q'}, {'objectMRID': '_60E702BC-A8E7-6AB8-F5EB-D038283E4D3E', 'attribute': 'PowerElectronicsConnection.p'}, {'objectMRID': '_60E702BC-A8E7-6AB8-F5EB-D038283E4D3E', 'attribute': 'PowerElectronicsConnection.q'}], 'outputOutageList': ['_facde6ab-95e2-471b-b151-1b7125d863f0', '_888e15c8-380d-4dcf-9876-ccf8949d45b1'], 'faultMRID': '_f05569df-665f-4b25-b721-926ff32b4ab3', 'event_type': 'CommOutage', 'occuredDateTime': 1374510750, 'stopDateTime': 1374510960, 'status': 'CLEARED'}]} +#{'data': [{'allOutputOutage': False, 'allInputOutage': False, 'inputOutageList': [{'objectMRID': '_233D4DC1-66EA-DF3C-D859-D10438ECCBDF', 'attribute': 'PowerElectronicsConnection.p'}, {'objectMRID': '_233D4DC1-66EA-DF3C-D859-D10438ECCBDF', 'attribute': 'PowerElectronicsConnection.q'}, {'objectMRID': '_60E702BC-A8E7-6AB8-F5EB-D038283E4D3E', 'attribute': 'PowerElectronicsConnection.p'}, {'objectMRID': '_60E702BC-A8E7-6AB8-F5EB-D038283E4D3E', 'attribute': 'PowerElectronicsConnection.q'}], 'outputOutageList': ['_facde6ab-95e2-471b-b151-1b7125d863f0', '_888e15c8-380d-4dcf-9876-ccf8949d45b1'], 'faultMRID': '_b93ae63b-c959-476f-a4e8-3020be90db2c', 'event_type': 'CommOutage', 'occuredDateTime': 1374510750, 'stopDateTime': 1374510960, 'status': 'INITIATED'}]} From adb62e3719040a0cea74082036a42c3f2f1823e5 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Wed, 3 Jun 2020 17:35:28 -0600 Subject: [PATCH 02/18] Added test_1 for expected. --- .../request_test_expected_vs_running.py | 33 +++++------------ .../request_test_expected_vs_timeseries.py | 21 ++++++----- .../request_test_running_vs_timeseries.py | 29 ++++----------- expected_results/test_1.py | 37 +++++++++++++++++++ 4 files changed, 67 insertions(+), 53 deletions(-) create mode 100644 expected_results/test_1.py diff --git a/expected_results/request_test_expected_vs_running.py b/expected_results/request_test_expected_vs_running.py index b9f1fa8..e9176b9 100644 --- a/expected_results/request_test_expected_vs_running.py +++ b/expected_results/request_test_expected_vs_running.py @@ -3,16 +3,14 @@ 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 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"): +# def _startTest(username,password,gossServer='localhost',stompPort='61613', simulationID=1234, rulePort=5000, topic="input"): +def start_test(): loc = os.path.realpath(__file__) loc = os.path.dirname(loc) print(loc) @@ -39,14 +37,14 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul "stopDateTime": 1248156002 + 21 }] - + test_id = str(random.getrandbits(32)) testCfgAll = { "appId": "sample_app", - "testId": "test sample_app" + "testId": str(test_id) } - # with open("expected_result_series_filtered_9500.json") as f: - with open("expected_result_series_filtered_123_normal_small_4.json") as f: + with open("expected_result_series_filtered_9500.json") as f: + # with open("expected_result_series_filtered_123_normal_small_4.json") as f: expectedJson = json.load(f) testCfgAll['expectedResults'] = expectedJson['expectedResults'] @@ -64,9 +62,6 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul simCfg13pv = json.dumps(req_template) print(simCfg13pv) - print() - print(makeJavaString(simCfg13pv)) - print() print(json.dumps(testCfgAll,indent=2)) goss = GOSS() @@ -75,17 +70,8 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul 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') + return(simulationId['simulationId'],test_id) if __name__ == "__main__": parser = argparse.ArgumentParser() @@ -97,7 +83,8 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul # 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) + # _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_expected_vs_timeseries.py b/expected_results/request_test_expected_vs_timeseries.py index ce20a5f..005b3f2 100644 --- a/expected_results/request_test_expected_vs_timeseries.py +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -1,17 +1,20 @@ import json -import time import argparse from gridappsd import GOSS -from pprint import pprint +import random + goss_sim = "goss.gridappsd.process.request.simulation" test_input = "/topic/goss.gridappsd.simulation.test.input." -def _startTest(username,password,gossServer='localhost',stompPort='61613', simulationID=1234): +# def _startTest(username,password,gossServer='localhost',stompPort='61613', simulationID=1234): +def start_test(simulationID=1234): goss = GOSS() goss.connect() + test_id = str(random.getrandbits(32)) testCfgAll = { - "appId": "sample_app" + "appId": "sample_app", + "testId": test_id } testCfgAll['testType'] = 'expected_vs_timeseries' with open("expected_result_series_filtered_123_normal_small_4.json") as f: @@ -20,18 +23,18 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul testCfgAll['expectedResults'] = expectedJson['expectedResults'] - testCfgAll['compareWithSimId'] = 1121239269 # 272071421 + testCfgAll['compareWithSimId'] = simulationID request = json.dumps(testCfgAll) - simulationID=1259505150 - # simulationId =123 - status = goss.get_response(test_input+str(simulationID), request, timeout=10) + # status = goss.get_response(test_input+str(simulationID), request, timeout=20) + status = goss.send(test_input+str(simulationID), 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() - _startTest('system','manager',gossServer='127.0.0.1',stompPort='61613', simulationID=args.id) + start_test(simulationID=args.id) diff --git a/expected_results/request_test_running_vs_timeseries.py b/expected_results/request_test_running_vs_timeseries.py index 227e313..0bcf199 100644 --- a/expected_results/request_test_running_vs_timeseries.py +++ b/expected_results/request_test_running_vs_timeseries.py @@ -3,15 +3,12 @@ import os import argparse from gridappsd import GOSS -from pprint import pprint +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 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__) @@ -40,9 +37,11 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul "stopDateTime": 1248156002 + 21 }] + test_id = str(random.getrandbits(32)) testCfgAll = { - "appId": "sample_app_opp", - } + "appId": "sample_app", + "testId": str(test_id) + } with open("expected_result_series_filtered_123_normal_small_4.json") as f: expectedJson = json.load(f) @@ -68,28 +67,16 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul "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'] = '_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['power_system_config']['Line_name'] = '_AAE94E4A-2465-6F5E-37B1-3E72183A4E44' # test9500new req_template["application_config"]["applications"][0]['name'] = 'sample_app' - req_template["application_config"]["applications"][0]['name'] = 'sample_app_opp' - # req_template["application_config"]["applications"][0]['name'] = 'der_dispatch_app' + # req_template["application_config"]["applications"][0]['name'] = 'sample_app_opp' 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)) - goss = GOSS() goss.connect() diff --git a/expected_results/test_1.py b/expected_results/test_1.py new file mode 100644 index 0000000..613d876 --- /dev/null +++ b/expected_results/test_1.py @@ -0,0 +1,37 @@ +import time +from gridappsd import GOSS +import request_test_expected_vs_timeseries +import request_test_expected_vs_running + +def test_expected(): + 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_id) + 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) + 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) + + +if __name__ == '__main__': + test_expected() From cd05a51dcc29d33812b671709d9431288eec2cd9 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Fri, 5 Jun 2020 15:43:53 -0600 Subject: [PATCH 03/18] Added test_2 for expected. --- expected_results/test_1.py | 37 --------------------------- expected_results/test_2.py | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 37 deletions(-) delete mode 100644 expected_results/test_1.py create mode 100644 expected_results/test_2.py diff --git a/expected_results/test_1.py b/expected_results/test_1.py deleted file mode 100644 index 613d876..0000000 --- a/expected_results/test_1.py +++ /dev/null @@ -1,37 +0,0 @@ -import time -from gridappsd import GOSS -import request_test_expected_vs_timeseries -import request_test_expected_vs_running - -def test_expected(): - 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_id) - 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) - 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) - - -if __name__ == '__main__': - test_expected() diff --git a/expected_results/test_2.py b/expected_results/test_2.py new file mode 100644 index 0000000..6c9cd99 --- /dev/null +++ b/expected_results/test_2.py @@ -0,0 +1,52 @@ +import time +from gridappsd import GOSS +import request_test_expected_vs_timeseries +import request_test_timeseries_vs_timeseries +# import request_test_expected_vs_running + +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) + print(response['data'][0]['COUNT(*)']) + 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_timeseries_vs_timeseries.start_test(sim_id1, sim_id2) + time.sleep(10) + # 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__': + test_expected(1232216123, 2040676147) From ef9fd9b8eddb229185018f978a072bb2cf0b32e5 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Tue, 9 Jun 2020 09:22:28 -0600 Subject: [PATCH 04/18] Updated test scripts. Save simulation ids from test_1 to be used for test_2 in a json file. Added script to listen for the test output. --- .../request_test_expected_vs_running.py | 8 +-- .../request_test_expected_vs_timeseries.py | 7 ++- .../request_test_running_vs_timeseries.py | 35 +++--------- .../request_test_timeseries_vs_timeseries.py | 35 ++++++++++++ expected_results/test_1.py | 49 +++++++++++++++++ expected_results/test_2.py | 13 ++++- expected_results/test_get_results.py | 54 +++++++++++++++++++ 7 files changed, 164 insertions(+), 37 deletions(-) create mode 100644 expected_results/request_test_timeseries_vs_timeseries.py create mode 100644 expected_results/test_1.py create mode 100644 expected_results/test_get_results.py diff --git a/expected_results/request_test_expected_vs_running.py b/expected_results/request_test_expected_vs_running.py index e9176b9..35e71fa 100644 --- a/expected_results/request_test_expected_vs_running.py +++ b/expected_results/request_test_expected_vs_running.py @@ -43,8 +43,8 @@ def start_test(): "testId": str(test_id) } - with open("expected_result_series_filtered_9500.json") as f: - # with open("expected_result_series_filtered_123_normal_small_4.json") as f: + # with open("expected_result_series_filtered_9500.json") as f: + with open("expected_result_series_filtered_123_normal_small_4.json") as f: expectedJson = json.load(f) testCfgAll['expectedResults'] = expectedJson['expectedResults'] @@ -61,8 +61,8 @@ def start_test(): req_template['test_config'] = testCfgAll simCfg13pv = json.dumps(req_template) - print(simCfg13pv) - print(json.dumps(testCfgAll,indent=2)) + # print(simCfg13pv) + # print(json.dumps(testCfgAll,indent=2)) goss = GOSS() goss.connect() diff --git a/expected_results/request_test_expected_vs_timeseries.py b/expected_results/request_test_expected_vs_timeseries.py index 005b3f2..82b1fbc 100644 --- a/expected_results/request_test_expected_vs_timeseries.py +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -2,15 +2,14 @@ import argparse from gridappsd import GOSS import random +import time goss_sim = "goss.gridappsd.process.request.simulation" test_input = "/topic/goss.gridappsd.simulation.test.input." -# def _startTest(username,password,gossServer='localhost',stompPort='61613', simulationID=1234): def start_test(simulationID=1234): goss = GOSS() goss.connect() - test_id = str(random.getrandbits(32)) testCfgAll = { "appId": "sample_app", @@ -23,11 +22,11 @@ def start_test(simulationID=1234): testCfgAll['expectedResults'] = expectedJson['expectedResults'] - testCfgAll['compareWithSimId'] = simulationID + testCfgAll['compareWithSimId'] = simulationID # 847461010 request = json.dumps(testCfgAll) # status = goss.get_response(test_input+str(simulationID), request, timeout=20) - status = goss.send(test_input+str(simulationID), request) + status = goss.get_response(test_input+str(test_id), request, timeout=20) print(status) print('sent test status') return test_id diff --git a/expected_results/request_test_running_vs_timeseries.py b/expected_results/request_test_running_vs_timeseries.py index 0bcf199..b8cf8e4 100644 --- a/expected_results/request_test_running_vs_timeseries.py +++ b/expected_results/request_test_running_vs_timeseries.py @@ -10,11 +10,7 @@ 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"): - loc = os.path.realpath(__file__) - loc = os.path.dirname(loc) - # loc = os.path.dirname(os.path.dirname(os.path.dirname(loc))) - +def start_test(simulationID): events = [{ "message": { "forward_differences": [ @@ -40,13 +36,9 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul test_id = str(random.getrandbits(32)) testCfgAll = { "appId": "sample_app", - "testId": str(test_id) + "testId": test_id } - with open("expected_result_series_filtered_123_normal_small_4.json") as f: - expectedJson = json.load(f) - - # testCfgAll['expectedResults'] = expectedJson['expectedResults'] # # testCfgAll['events'] = events req_template = {"power_system_config": {"SubGeographicalRegion_name": "_1CD7D2EE-3C91-3248-5662-A43EFEFAC224", @@ -74,35 +66,24 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul # req_template["application_config"]["applications"][0]['name'] = 'sample_app_opp' req_template['test_config'] = testCfgAll - # testCfgAll['testScript'] = tesScriptJson - # req_template['expectedResults'] = expectedJson['expectedResults'] goss = GOSS() goss.connect() - # del req_template['test_config']['expectedResults'] - req_template['test_config']['compareWithSimId'] = 913015800 + req_template['test_config']['compareWithSimId'] = simulationID # 913015800 req_template['test_config']['testType'] ='simulation_vs_timeseries' print(json.dumps(req_template['test_config'], indent=2)) - # exit(0) simCfg13pv = json.dumps(req_template) - print(simCfg13pv) + simulationId = goss.get_response(goss_sim, simCfg13pv, timeout=10) - print('simulation id ', simulationId) print('sent simulation request') - time.sleep(1) + 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() - _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 + 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..2a9c33a --- /dev/null +++ b/expected_results/request_test_timeseries_vs_timeseries.py @@ -0,0 +1,35 @@ +import json +import argparse +import random +from gridappsd import GOSS + +goss_sim = "goss.gridappsd.process.request.simulation" +test_input = "/topic/goss.gridappsd.simulation.test.input." + +def start_test(simulationID1, simulationID2): + goss = GOSS() + goss.connect() + + test_id = str(random.getrandbits(32)) + testCfgAll = { + "appId": "sample_app", + "testId": test_id + } + + 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) + 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) diff --git a/expected_results/test_1.py b/expected_results/test_1.py new file mode 100644 index 0000000..24686a5 --- /dev/null +++ b/expected_results/test_1.py @@ -0,0 +1,49 @@ +import time +import json +from gridappsd import GOSS +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() + time.sleep(75) + print('sent test request') + log_topic = 'goss.gridappsd.process.request.data.log' + + goss = GOSS() + 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) + print(response['data'][0]['COUNT(*)']) + print(response['data'][0]['COUNT(*)'] == '5') + 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) + + sim_id2, test_id2 = request_test_running_vs_timeseries.start_test(sim_id) + + 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) + print(response['data'][0]['COUNT(*)'] == '0') + 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/test_2.py b/expected_results/test_2.py index 6c9cd99..6015306 100644 --- a/expected_results/test_2.py +++ b/expected_results/test_2.py @@ -1,4 +1,5 @@ import time +import json from gridappsd import GOSS import request_test_expected_vs_timeseries import request_test_timeseries_vs_timeseries @@ -30,12 +31,15 @@ def test_expected(sim_id1, sim_id2): print(response['data'][0]['COUNT(*)']) print(response['data'][0]['COUNT(*)'] == '5') 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) + time.sleep(1) + test_id = request_test_timeseries_vs_timeseries.start_test(sim_id1, sim_id2) - time.sleep(10) + 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) @@ -49,4 +53,9 @@ def test_expected(sim_id1, sim_id2): if __name__ == '__main__': - test_expected(1232216123, 2040676147) + 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..46ceb19 --- /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=818730075, + 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() + From 4ae5c51bad2c0e0e1a7f02af1fc5c0a99cac5663 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Thu, 11 Jun 2020 13:49:08 -0600 Subject: [PATCH 05/18] Updated fro new blazegraph model mrid changes. --- ...lt_series_filtered_123_normal_small_4.json | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 index a00aeb9..ecda246 100644 --- a/expected_results/expected_result_series_filtered_123_normal_small_4.json +++ b/expected_results/expected_result_series_filtered_123_normal_small_4.json @@ -7,21 +7,21 @@ "timestamp": 1535574871, "measurements": [ { - "measurement_mrid": "_0055de94-7d7e-4931-a884-cab596cc191b", + "measurement_mrid": "_007d97d4-4b30-4635-8122-8e7f1e7cf3be", "angle": -5.066423674487563, - "magnitude": 2361.0733024639117, + "magnitude": 235525.8716877966, "simulation_id": "1961648576", "time": 1248156002}, { - "measurement_mrid": "_fff9a11e-d5d1-4824-a457-13d944ffcfdf", - "angle": -122.80107769837849, - "magnitude": 2520.2169329056983, + "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": -122.70461031091335, - "magnitude": 2522.818525429715, + "measurement_mrid": "_01204a90-9893-4e57-8ea5-0a09198e58fe", + "angle": 28.940770423235723, + "magnitude": 374545.4981119089, "simulation_id": "1961648576", "time": 1248156002} ] @@ -40,14 +40,14 @@ "time": 1587670650, "attribute": "ShuntCompensator.sections", "value": 1.0, - "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"}, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"}, {"hasMeasurementDifference": "REVERSE", "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", "simulation_id": "1961648576", "time": 1587670650, "attribute": "ShuntCompensator.sections", "value": 0.0, - "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"} + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} ] } }, @@ -62,14 +62,14 @@ "time": 1587670665, "attribute": "ShuntCompensator.sections", "value": 0.0, - "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"}, + "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": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"} + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} ] } }, @@ -84,14 +84,14 @@ "time": 1587670665, "attribute": "ShuntCompensator.sections", "value": 0.0, - "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"}, + "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": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"} + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} ] } }, @@ -106,14 +106,14 @@ "time": 1587670665, "attribute": "ShuntCompensator.sections", "value": 0.0, - "object": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"}, + "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": "_307E4291-5FEA-4388-B2E0-2B3D22FE8183"} + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} ] } } From b281bb0a54c930678b92671a234f43d5ce009c2d Mon Sep 17 00:00:00 2001 From: jsimpson Date: Fri, 12 Jun 2020 16:45:23 -0600 Subject: [PATCH 06/18] Updated fro new blazegraph model mrid changes. --- .../request_test_expected_vs_running.py | 2 + expected_results/test_2.py | 13 +- expected_results/test_script_sample1.json | 143 ++++++++++++++++++ 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 expected_results/test_script_sample1.json diff --git a/expected_results/request_test_expected_vs_running.py b/expected_results/request_test_expected_vs_running.py index 35e71fa..5f91396 100644 --- a/expected_results/request_test_expected_vs_running.py +++ b/expected_results/request_test_expected_vs_running.py @@ -48,6 +48,8 @@ def start_test(): 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"} diff --git a/expected_results/test_2.py b/expected_results/test_2.py index 6015306..c211173 100644 --- a/expected_results/test_2.py +++ b/expected_results/test_2.py @@ -36,7 +36,17 @@ def test_expected(sim_id1, sim_id2): for i in response['data']: print(i) - time.sleep(1) + 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(*)']) + 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) test_id = request_test_timeseries_vs_timeseries.start_test(sim_id1, sim_id2) time.sleep(5) @@ -52,6 +62,7 @@ def test_expected(sim_id1, sim_id2): print(i) + if __name__ == '__main__': with open('test_ids.json') as f: d = json.load(f) diff --git a/expected_results/test_script_sample1.json b/expected_results/test_script_sample1.json new file mode 100644 index 0000000..d7984e0 --- /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": "_007d97d4-4b30-4635-8122-8e7f1e7cf3be", + "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": "_01204a90-9893-4e57-8ea5-0a09198e58fe", + "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": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + }, + { + "hasMeasurementDifference": "REVERSE", + "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", + "simulation_id": "1961648576", + "time": 1587670650, + "attribute": "ShuntCompensator.sections", + "value": 0.0, + "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + } + ] + } + }, + "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": "_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" + } + ] + } + }, + "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" + } + ] + } + }, + "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": "_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" + } + ] + } + } + } + } +} \ No newline at end of file From 3e567f0419168fca6ba81028e8a8332d3be56b6b Mon Sep 17 00:00:00 2001 From: jsimpson Date: Mon, 15 Jun 2020 14:56:35 -0600 Subject: [PATCH 07/18] Fixed path issue. --- expected_results/request_test_expected_vs_running.py | 2 +- expected_results/request_test_expected_vs_timeseries.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/expected_results/request_test_expected_vs_running.py b/expected_results/request_test_expected_vs_running.py index 5f91396..6700e8e 100644 --- a/expected_results/request_test_expected_vs_running.py +++ b/expected_results/request_test_expected_vs_running.py @@ -44,7 +44,7 @@ def start_test(): } # with open("expected_result_series_filtered_9500.json") as f: - with open("expected_result_series_filtered_123_normal_small_4.json") as f: + with open(os.path.join(loc, "expected_result_series_filtered_123_normal_small_4.json")) as f: expectedJson = json.load(f) testCfgAll['expectedResults'] = expectedJson['expectedResults'] diff --git a/expected_results/request_test_expected_vs_timeseries.py b/expected_results/request_test_expected_vs_timeseries.py index 82b1fbc..e2dc1b1 100644 --- a/expected_results/request_test_expected_vs_timeseries.py +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -3,11 +3,14 @@ from gridappsd import GOSS 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): + loc = os.path.realpath(__file__) + loc = os.path.dirname(loc) goss = GOSS() goss.connect() test_id = str(random.getrandbits(32)) @@ -16,7 +19,7 @@ def start_test(simulationID=1234): "testId": test_id } testCfgAll['testType'] = 'expected_vs_timeseries' - with open("expected_result_series_filtered_123_normal_small_4.json") as f: + with open(os.path.join(loc,"expected_result_series_filtered_123_normal_small_4.json")) as f: # with open("expected_result_series_filtered_9500.json") as f: expectedJson = json.load(f) From 119c1fa0d66060c2db7fd448976742640ace6508 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Wed, 21 Oct 2020 15:53:51 -0600 Subject: [PATCH 08/18] Added test to listen for test results on test topic. --- ...lt_series_filtered_123_normal_small_4.json | 32 ++++---- .../test_listen_1_sim_vs_expected.py | 67 ++++++++++++++++ .../test_listen_2_sim_vs_timeseries.py | 75 ++++++++++++++++++ .../test_listen_3_timeseries_vs_expected.py | 69 +++++++++++++++++ .../test_listen_4_timeseries_vs_timeseries.py | 76 +++++++++++++++++++ 5 files changed, 303 insertions(+), 16 deletions(-) create mode 100644 expected_results/test_listen_1_sim_vs_expected.py create mode 100644 expected_results/test_listen_2_sim_vs_timeseries.py create mode 100644 expected_results/test_listen_3_timeseries_vs_expected.py create mode 100644 expected_results/test_listen_4_timeseries_vs_timeseries.py 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 index ecda246..fc0fa28 100644 --- a/expected_results/expected_result_series_filtered_123_normal_small_4.json +++ b/expected_results/expected_result_series_filtered_123_normal_small_4.json @@ -7,19 +7,19 @@ "timestamp": 1535574871, "measurements": [ { - "measurement_mrid": "_007d97d4-4b30-4635-8122-8e7f1e7cf3be", + "measurement_mrid": "_0028728e-4a2f-4ef7-b248-840319a3e370", "angle": -5.066423674487563, - "magnitude": 235525.8716877966, + "magnitude": 2388.676720682955, "simulation_id": "1961648576", "time": 1248156002}, { - "measurement_mrid": "_00ce801b-214d-4540-9cbb-1ddcac0c0495", + "measurement_mrid": "_0018886d-363a-456c-8b1b-116e8c2e6fc6", "angle": -86.36800510651457, "magnitude": 1.4651647694061578, "simulation_id": "1961648576", "time": 1248156002}, { - "measurement_mrid": "_01204a90-9893-4e57-8ea5-0a09198e58fe", + "measurement_mrid": "_00b26415-b4a0-4ef3-ab95-77e1beafc59a", "angle": 28.940770423235723, "magnitude": 374545.4981119089, "simulation_id": "1961648576", @@ -29,44 +29,44 @@ } }, "input": { - "0": { + "1248156014": { "simulation_id": "559402036", "message": { - "timestamp": 1587670650, + "timestamp": 1248156014, "measurements": [ {"hasMeasurementDifference": "FORWARD", "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", "simulation_id": "1961648576", - "time": 1587670650, + "time": 1248156014, "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": 1587670650, + "time": 1248156014, "attribute": "ShuntCompensator.sections", "value": 0.0, "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} ] } }, - "15": { + "1248156029": { "simulation_id": "559402036", "message": { - "timestamp": 1587670665, + "timestamp": 1248156029, "measurements": [ {"hasMeasurementDifference": "FORWARD", "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", "simulation_id": "1961648576", - "time": 1587670665, + "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": 1587670665, + "time": 1248156029, "attribute": "ShuntCompensator.sections", "value": 1.0, "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} @@ -95,22 +95,22 @@ ] } }, - "30": { + "1248156044": { "simulation_id": "559402036", "message": { - "timestamp": 1587670665, + "timestamp": 1248156044, "measurements": [ {"hasMeasurementDifference": "FORWARD", "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", "simulation_id": "1961648576", - "time": 1587670665, + "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": 1587670665, + "time": 1248156044, "attribute": "ShuntCompensator.sections", "value": 1.0, "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} 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..de3d759 --- /dev/null +++ b/expected_results/test_listen_1_sim_vs_expected.py @@ -0,0 +1,67 @@ +import argparse +import json +import os +import time + +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." + +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) + + # json_message = json.loads(message) + # "{\"status\":\"start\"}") + if 'status' in message and message['status'] == 'finish': + print("Exit") + os._exit(1) + + +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() + sim_id, test_id = request_test_expected_vs_running.start_test() + 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()) + sl = SimpleListener(gapps, opts.test_id) + 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) + + while True: + time.sleep(0.1) + + +if __name__ == "__main__": + _main() + 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..f896e01 --- /dev/null +++ b/expected_results/test_listen_2_sim_vs_timeseries.py @@ -0,0 +1,75 @@ +import argparse +import json +import os +import time + +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_vs_timeseries +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) + + # json_message = json.loads(message) + # "{\"status\":\"start\"}") + if 'status' in message and message['status'] == 'finish': + print("Exit") + os._exit(1) + + + +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() + + with open('test_id_request_1.json') as f: + sim_id = json.load(f) + sim_id = sim_id['sim_id1'] + # sim_id = 877159920 + sim_id2, test_id2 = request_test_running_vs_timeseries.start_test(sim_id) + print('simid ' + sim_id2) + print('sent test request ' + test_id2) + + + 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(test_id2)) + response = gapps.subscribe(test_output_topic+str(test_id2), sl) + print(response) + + with open('test_id_request_2.json', 'w') as f: + json.dump({'sim_id2': sim_id2}, f) + + while True: + time.sleep(0.1) + + +if __name__ == "__main__": + _main() + 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..fd44042 --- /dev/null +++ b/expected_results/test_listen_3_timeseries_vs_expected.py @@ -0,0 +1,69 @@ +import argparse +import json +import os +import time + +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 +test_output_topic = "/topic/goss.gridappsd.simulation.test.output." + +# KEEP_LISTENING_FLAG = True +class SimpleListener(object): + """ A simple class to listen for the test results + """ + global KEEP_LISTENING_FLAG + + 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) + + # json_message = json.loads(message) + # "{\"status\":\"start\"}") + if 'status' in message and message['status'] == 'finish': + print("Exit") + os._exit(1) + + +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) + with open('test_id_request_1.json') as f: + sim_id = json.load(f) + sim_id = sim_id['sim_id1'] + test_id2 = request_test_expected_vs_timeseries.start_test(sim_id) + 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) + + while True: + time.sleep(0.1) + + +if __name__ == "__main__": + _main() + 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..9ffc53a --- /dev/null +++ b/expected_results/test_listen_4_timeseries_vs_timeseries.py @@ -0,0 +1,76 @@ +import argparse +import json +import os +import time + +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 +test_output_topic = "/topic/goss.gridappsd.simulation.test.output." + +class SimpleListener(object): + """ A simple class to listen for the test results + """ + global KEEP_LISTENING_FLAG + + 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) + + # json_message = json.loads(message) + # "{\"status\":\"start\"}") + if 'status' in message and message['status'] == 'finish': + print("Exit") + os._exit(1) + + + +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) + + with open('test_id_request_1.json') as f: + sim_id_dict = json.load(f) + sim_id = sim_id_dict['sim_id1'] + with open('test_id_request_2.json') as f: + sim_id_dict = json.load(f) + sim_id2 = sim_id_dict['sim_id2'] + + # sim_id = 1767860274 + # sim_id2 = 1564477893 + 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) + + while True: + time.sleep(0.1) + + +if __name__ == "__main__": + _main() + From c347a5324d82d8929d67e3286d8c4d67c26e1aba Mon Sep 17 00:00:00 2001 From: jsimpson Date: Fri, 23 Oct 2020 15:54:58 -0600 Subject: [PATCH 09/18] Print error count. --- .../request_test_expected_vs_timeseries.py | 10 ++++++---- .../request_test_timeseries_vs_timeseries.py | 3 ++- expected_results/test_listen_1_sim_vs_expected.py | 7 ++++++- expected_results/test_listen_2_sim_vs_timeseries.py | 7 ++++++- .../test_listen_3_timeseries_vs_expected.py | 7 ++++++- .../test_listen_4_timeseries_vs_timeseries.py | 7 ++++++- 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/expected_results/request_test_expected_vs_timeseries.py b/expected_results/request_test_expected_vs_timeseries.py index e2dc1b1..838cc20 100644 --- a/expected_results/request_test_expected_vs_timeseries.py +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -13,23 +13,25 @@ def start_test(simulationID=1234): loc = os.path.dirname(loc) goss = GOSS() goss.connect() + test_id = str(random.getrandbits(32)) testCfgAll = { "appId": "sample_app", "testId": test_id } - testCfgAll['testType'] = 'expected_vs_timeseries' + with open(os.path.join(loc,"expected_result_series_filtered_123_normal_small_4.json")) as f: # with open("expected_result_series_filtered_9500.json") as f: expectedJson = json.load(f) - testCfgAll['expectedResults'] = expectedJson['expectedResults'] - testCfgAll['compareWithSimId'] = simulationID # 847461010 + testCfgAll['expectedResults'] = expectedJson['expectedResults'] + testCfgAll['testType'] = 'expected_vs_timeseries' request = json.dumps(testCfgAll) # status = goss.get_response(test_input+str(simulationID), request, timeout=20) - status = goss.get_response(test_input+str(test_id), request, timeout=20) + # status = goss.get_response(test_input+str(test_id), request, timeout=20) + status = goss.send(test_input+str(test_id), request) print(status) print('sent test status') return test_id diff --git a/expected_results/request_test_timeseries_vs_timeseries.py b/expected_results/request_test_timeseries_vs_timeseries.py index 2a9c33a..afc8e14 100644 --- a/expected_results/request_test_timeseries_vs_timeseries.py +++ b/expected_results/request_test_timeseries_vs_timeseries.py @@ -21,7 +21,8 @@ def start_test(simulationID1, simulationID2): testCfgAll['testType'] = 'timeseries_vs_timeseries' request = json.dumps(testCfgAll) - status = goss.get_response(test_input+str(test_id), request, timeout=60) + # status = goss.get_response(test_input+str(test_id), request, timeout=60) + status = goss.send(test_input+str(test_id), request) print(status) print('sent test status') return test_id diff --git a/expected_results/test_listen_1_sim_vs_expected.py b/expected_results/test_listen_1_sim_vs_expected.py index de3d759..b731268 100644 --- a/expected_results/test_listen_1_sim_vs_expected.py +++ b/expected_results/test_listen_1_sim_vs_expected.py @@ -17,6 +17,7 @@ def __init__(self, gridappsd_obj, test_id): """ 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 @@ -31,11 +32,15 @@ def on_message(self, headers, message): 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)) os._exit(1) diff --git a/expected_results/test_listen_2_sim_vs_timeseries.py b/expected_results/test_listen_2_sim_vs_timeseries.py index f896e01..92f22be 100644 --- a/expected_results/test_listen_2_sim_vs_timeseries.py +++ b/expected_results/test_listen_2_sim_vs_timeseries.py @@ -17,6 +17,7 @@ def __init__(self, gridappsd_obj, test_id): """ 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 @@ -31,11 +32,15 @@ def on_message(self, headers, message): 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)) os._exit(1) diff --git a/expected_results/test_listen_3_timeseries_vs_expected.py b/expected_results/test_listen_3_timeseries_vs_expected.py index fd44042..d2703f6 100644 --- a/expected_results/test_listen_3_timeseries_vs_expected.py +++ b/expected_results/test_listen_3_timeseries_vs_expected.py @@ -19,6 +19,7 @@ def __init__(self, gridappsd_obj, test_id): """ 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 @@ -33,11 +34,15 @@ def on_message(self, headers, message): 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)) os._exit(1) diff --git a/expected_results/test_listen_4_timeseries_vs_timeseries.py b/expected_results/test_listen_4_timeseries_vs_timeseries.py index 9ffc53a..e3416cb 100644 --- a/expected_results/test_listen_4_timeseries_vs_timeseries.py +++ b/expected_results/test_listen_4_timeseries_vs_timeseries.py @@ -18,6 +18,7 @@ def __init__(self, gridappsd_obj, test_id): """ 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 @@ -32,11 +33,15 @@ def on_message(self, headers, message): 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)) os._exit(1) From d392808874f8dc5e084b41dd9edb9ec15d912378 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Wed, 21 Apr 2021 11:15:41 -0600 Subject: [PATCH 10/18] Updated to run with pytest. Removed command line arg. Added longer sleep for while loop. Added asserts. Watch out for stomp.py 6.1.1 ! Use 6.1.0 instead!!! --- .../test_listen_1_sim_vs_expected.py | 40 +++-- .../test_listen_2_sim_vs_timeseries.py | 41 +++-- .../test_listen_3_timeseries_vs_expected.py | 97 +++++++++--- .../test_listen_4_timeseries_vs_timeseries.py | 144 ++++++++++++------ 4 files changed, 229 insertions(+), 93 deletions(-) diff --git a/expected_results/test_listen_1_sim_vs_expected.py b/expected_results/test_listen_1_sim_vs_expected.py index b731268..7701d3d 100644 --- a/expected_results/test_listen_1_sim_vs_expected.py +++ b/expected_results/test_listen_1_sim_vs_expected.py @@ -2,11 +2,13 @@ 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 @@ -41,21 +43,27 @@ def on_message(self, headers, message): if 'status' in message and message['status'] == 'finish': print("Exit") print("Error count " + str(self._error_count)) - os._exit(1) + 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 _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() +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() + 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()) - sl = SimpleListener(gapps, opts.test_id) + # gapps = GridAPPSD(opts.test_id, address=utils.get_gridappsd_address(), + # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) + gapps = GridAPPSD() + gapps.connect() + sl = SimpleListener(gapps, 1) print(test_output_topic+str(test_id)) response = gapps.subscribe(test_output_topic+str(test_id), sl) print(response) @@ -63,10 +71,14 @@ def _main(): with open('test_id_request_1.json', 'w') as f: json.dump({'sim_id1': sim_id}, f) - while True: - time.sleep(0.1) - + finished=False + while not finished: + time.sleep(65) + finished = True + error_count = sl._error_count + print(error_count) + logging.info("Error count " + str(error_count)) + assert error_count == 7, f" For expected_vs_running expecting 7 non matching results. Received {error_count}" if __name__ == "__main__": - _main() - + test() diff --git a/expected_results/test_listen_2_sim_vs_timeseries.py b/expected_results/test_listen_2_sim_vs_timeseries.py index 92f22be..902f166 100644 --- a/expected_results/test_listen_2_sim_vs_timeseries.py +++ b/expected_results/test_listen_2_sim_vs_timeseries.py @@ -2,11 +2,13 @@ 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_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 @@ -41,16 +43,19 @@ def on_message(self, headers, message): if 'status' in message and message['status'] == 'finish': print("Exit") print("Error count " + str(self._error_count)) - os._exit(1) + 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 _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() +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() with open('test_id_request_1.json') as f: sim_id = json.load(f) @@ -60,21 +65,29 @@ def _main(): print('simid ' + sim_id2) print('sent test request ' + test_id2) - - 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) + # gapps = GridAPPSD(opts.test_id, address=utils.get_gridappsd_address(), + # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) + gapps = GridAPPSD() + 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) with open('test_id_request_2.json', 'w') as f: json.dump({'sim_id2': sim_id2}, f) - while True: - time.sleep(0.1) + finished = False + while not finished: + time.sleep(65) + 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__": - _main() + test() diff --git a/expected_results/test_listen_3_timeseries_vs_expected.py b/expected_results/test_listen_3_timeseries_vs_expected.py index d2703f6..c1dbb28 100644 --- a/expected_results/test_listen_3_timeseries_vs_expected.py +++ b/expected_results/test_listen_3_timeseries_vs_expected.py @@ -2,18 +2,20 @@ import json import os 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 test_output_topic = "/topic/goss.gridappsd.simulation.test.output." +# LOGGER = logging.getLogger(__name__) +logging.basicConfig(filename=__name__+'.log', level=logging.INFO) -# KEEP_LISTENING_FLAG = True class SimpleListener(object): """ A simple class to listen for the test results """ - global KEEP_LISTENING_FLAG - def __init__(self, gridappsd_obj, test_id): """ Create """ @@ -43,32 +45,87 @@ def on_message(self, headers, message): if 'status' in message and message['status'] == 'finish': print("Exit") print("Error count " + str(self._error_count)) - os._exit(1) + print(self._error_count == 7) # 5? + # assert self._error_count == 7, f" For expected_vs_timeseries expecting 7 non matching results. Received {self._error_count}" + # os._exit(0) + +# # finished=False +# error_count=0 +# +# def on_message(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(headers["destination"]) +# print(message) +# global error_count +# # global error_count +# # global finished +# logging.info("On message") +# if 'status' in message and (message['status'] == 'finish' or message['status'] == 'start'): +# pass +# else: +# error_count+=1 +# # json_message = json.loads(message) +# # "{\"status\":\"start\"}") +# if 'status' in message and message['status'] == 'finish': +# print("Exit") +# print("Error count " + str(error_count)) +# logging.info("on_message error count " + str(error_count)) +# print(error_count == 7) +# # finished = True +# # os._exit(0) + +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() + # gapps = GridAPPSD(opts.test_id, address=utils.get_gridappsd_address(), + # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) + + gapps = GridAPPSD() + gapps.connect() + logging.info('Starting') + sl = SimpleListener(gapps, 1) -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) with open('test_id_request_1.json') as f: sim_id = json.load(f) sim_id = sim_id['sim_id1'] + test_id2 = request_test_expected_vs_timeseries.start_test(sim_id) - 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) + 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)) - while True: - time.sleep(0.1) + # response = gapps.subscribe(test_output_topic+str(test_id2), on_message) + # print(response) + # while True: + # time.sleep(0.1) + # time.sleep(2) + logging.info("Start waiting") + finished = False + while not finished: + time.sleep(3) + finished = True + error_count = sl._error_count + print(error_count) + logging.info("Error count " + str(error_count)) + assert error_count == 7, f" For expected_vs_timeseries expecting 7 non matching results. Received {error_count}" if __name__ == "__main__": - _main() - + test() diff --git a/expected_results/test_listen_4_timeseries_vs_timeseries.py b/expected_results/test_listen_4_timeseries_vs_timeseries.py index e3416cb..15773a1 100644 --- a/expected_results/test_listen_4_timeseries_vs_timeseries.py +++ b/expected_results/test_listen_4_timeseries_vs_timeseries.py @@ -8,52 +8,97 @@ import request_test_timeseries_vs_timeseries test_output_topic = "/topic/goss.gridappsd.simulation.test.output." -class SimpleListener(object): - """ A simple class to listen for the test results +# class SimpleListener(object): +# """ A simple class to listen for the test results +# """ +# global KEEP_LISTENING_FLAG +# +# def __init__(self, gridappsd_obj, test_id): +# """ Create +# """ +# self._gapps = gridappsd_obj +# self._test_id = test_id +# self._error_count = 0 +# self._finished = False +# +# def get_error_count(self): +# return self._error_count +# +# def get_finished(self): +# return self._finished +# +# 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) +# +# self._finished =True +# # os._exit(0) +finished=False +error_count=0 +def on_message(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. """ - global KEEP_LISTENING_FLAG + print(message) + global error_count + global finished - def __init__(self, gridappsd_obj, test_id): - """ Create - """ - self._gapps = gridappsd_obj - self._test_id = test_id - self._error_count = 0 + if 'status' in message and (message['status'] == 'finish' or message['status'] == 'start'): + pass + else: + error_count+=1 + # json_message = json.loads(message) + # "{\"status\":\"start\"}") + if 'status' in message and message['status'] == 'finish': + print("Exit") + print("Error count " + str(error_count)) + print(error_count == 0) + finished =True + # os._exit(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)) - os._exit(1) +def test(): - -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) + global error_count + global finished + assert error_count == 0, f" For timeseries_vs_timeseries expecting 0 non matching results. Received {error_count}" + # 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(1, address=utils.get_gridappsd_address(), + # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) + gapps = GridAPPSD() + gapps.connect() + # sl = SimpleListener(gapps, 1) with open('test_id_request_1.json') as f: sim_id_dict = json.load(f) @@ -69,13 +114,22 @@ def _main(): print('sent test request ' + test_id2) print(test_output_topic + str(test_id2)) - response = gapps.subscribe(test_output_topic+str(test_id2), sl) + response = gapps.subscribe(test_output_topic+str(test_id2), on_message) print(response) + time.sleep(2) + # print(sl.get_error_count()) + + while not finished: + time.sleep(3) + finished = True - while True: - time.sleep(0.1) + gapps.disconnect() + # error_count = sl.get_error_count() + print(error_count) + assert error_count == 0, f" For timeseries_vs_timeseries expecting 0 non matching results. Received {error_count}" + # os._exit(0) if __name__ == "__main__": - _main() + test() From dbec20fcc9ac89994f8cde735ce8239bffb0e4ae Mon Sep 17 00:00:00 2001 From: jsimpson Date: Wed, 21 Apr 2021 15:45:43 -0600 Subject: [PATCH 11/18] Updated to run with pytest. Removed command line arg. Added longer sleep for while loop. Added asserts. Watch out for stomp.py 6.1.1 ! Use 6.1.0 instead!!! --- .../request_test_expected_vs_running.py | 5 +- .../request_test_expected_vs_timeseries.py | 142 +++++++++++++++++- .../request_test_running_vs_timeseries.py | 2 + 3 files changed, 143 insertions(+), 6 deletions(-) diff --git a/expected_results/request_test_expected_vs_running.py b/expected_results/request_test_expected_vs_running.py index 6700e8e..d7e4086 100644 --- a/expected_results/request_test_expected_vs_running.py +++ b/expected_results/request_test_expected_vs_running.py @@ -63,9 +63,10 @@ def start_test(): req_template['test_config'] = testCfgAll simCfg13pv = json.dumps(req_template) - # print(simCfg13pv) - # print(json.dumps(testCfgAll,indent=2)) + print("request") + print(json.dumps(req_template,indent=2)) + # exit(0) goss = GOSS() goss.connect() diff --git a/expected_results/request_test_expected_vs_timeseries.py b/expected_results/request_test_expected_vs_timeseries.py index 838cc20..572291d 100644 --- a/expected_results/request_test_expected_vs_timeseries.py +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -1,6 +1,6 @@ import json import argparse -from gridappsd import GOSS +from gridappsd import GOSS, utils,GridAPPSD import random import time import os @@ -11,8 +11,8 @@ def start_test(simulationID=1234): loc = os.path.realpath(__file__) loc = os.path.dirname(loc) - goss = GOSS() - goss.connect() + gapps = GridAPPSD() + gapps.connect() test_id = str(random.getrandbits(32)) testCfgAll = { @@ -28,10 +28,144 @@ def start_test(simulationID=1234): testCfgAll['expectedResults'] = expectedJson['expectedResults'] testCfgAll['testType'] = 'expected_vs_timeseries' request = json.dumps(testCfgAll) + print('request:') + print(json.dumps(testCfgAll,indent=2)) +# test_id=3657827110 +# viz_request ={ +# "appId": "sample_app", +# "testId": 3657827110, +# "compareWithSimId": 402293585, +# "expectedResults": { +# "output": { +# "1248156002": { +# "simulation_id": "559402036", +# "message": { +# "timestamp": 1535574871, +# "measurements": [{ +# "measurement_mrid": "_0028728e-4a2f-4ef7-b248-840319a3e370", +# "angle": -5.066423674487563, +# "magnitude": 2388.676720682955, +# "simulation_id": "1961648576", +# "time": 1248156002 +# }, { +# "measurement_mrid": "_0018886d-363a-456c-8b1b-116e8c2e6fc6", +# "angle": -86.36800510651457, +# "magnitude": 1.4651647694061578, +# "simulation_id": "1961648576", +# "time": 1248156002 +# }, { +# "measurement_mrid": "_00b26415-b4a0-4ef3-ab95-77e1beafc59a", +# "angle": 28.940770423235723, +# "magnitude": 374545.4981119089, +# "simulation_id": "1961648576", +# "time": 1248156002 +# }] +# } +# } +# }, +# "input": { +# "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": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" +# }, { +# "hasMeasurementDifference": "REVERSE", +# "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", +# "simulation_id": "1961648576", +# "time": 1587670665, +# "attribute": "ShuntCompensator.sections", +# "value": 1, +# "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" +# }] +# } +# }, +# "1248156014": { +# "simulation_id": "559402036", +# "message": { +# "timestamp": 1248156014, +# "measurements": [{ +# "hasMeasurementDifference": "FORWARD", +# "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", +# "simulation_id": "1961648576", +# "time": 1248156014, +# "attribute": "ShuntCompensator.sections", +# "value": 1, +# "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" +# }, { +# "hasMeasurementDifference": "REVERSE", +# "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", +# "simulation_id": "1961648576", +# "time": 1248156014, +# "attribute": "ShuntCompensator.sections", +# "value": 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, +# "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, +# "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, +# "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, +# "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" +# }] +# } +# } +# } +# }, +# "testType": "expected_vs_timeseries" +# } +# request = json.dumps(viz_request) +# # status = goss.get_response(test_input+str(simulationID), request, timeout=20) # status = goss.get_response(test_input+str(test_id), request, timeout=20) - status = goss.send(test_input+str(test_id), request) + status = gapps.send(test_input+str(test_id), request) print(status) print('sent test status') return test_id diff --git a/expected_results/request_test_running_vs_timeseries.py b/expected_results/request_test_running_vs_timeseries.py index b8cf8e4..221e196 100644 --- a/expected_results/request_test_running_vs_timeseries.py +++ b/expected_results/request_test_running_vs_timeseries.py @@ -74,6 +74,8 @@ def start_test(simulationID): 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 = goss.get_response(goss_sim, simCfg13pv, timeout=10) print('sent simulation request') From 96beaf0e912da90af42a6aa82e68b50c80d58097 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Thu, 22 Apr 2021 10:35:32 -0600 Subject: [PATCH 12/18] Updated to run with pytest. Removed command line arg. Added longer sleep for while loop. Added asserts. Watch out for stomp.py 6.1.1 ! Use 6.1.0 instead!!! --- .../{test_1.py => return_results_test_1.py} | 20 ++++++++---- .../{test_2.py => return_results_test_2.py} | 31 ++++++++++++++++--- 2 files changed, 40 insertions(+), 11 deletions(-) rename expected_results/{test_1.py => return_results_test_1.py} (68%) rename expected_results/{test_2.py => return_results_test_2.py} (59%) diff --git a/expected_results/test_1.py b/expected_results/return_results_test_1.py similarity index 68% rename from expected_results/test_1.py rename to expected_results/return_results_test_1.py index 24686a5..df5f87a 100644 --- a/expected_results/test_1.py +++ b/expected_results/return_results_test_1.py @@ -1,6 +1,6 @@ import time import json -from gridappsd import GOSS +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 @@ -9,11 +9,13 @@ def test_expected(): sim_id, test_id = request_test_expected_vs_running.start_test() + print('sent test request ' + test_id) time.sleep(75) - print('sent test request') 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" @@ -21,21 +23,27 @@ def test_expected(): # 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(*)']) - print(response['data'][0]['COUNT(*)'] == '5') + 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) - sim_id2, test_id2 = request_test_running_vs_timeseries.start_test(sim_id) + # 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) - print(response['data'][0]['COUNT(*)'] == '0') + 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) diff --git a/expected_results/test_2.py b/expected_results/return_results_test_2.py similarity index 59% rename from expected_results/test_2.py rename to expected_results/return_results_test_2.py index c211173..58b3843 100644 --- a/expected_results/test_2.py +++ b/expected_results/return_results_test_2.py @@ -3,7 +3,22 @@ from gridappsd import GOSS import request_test_expected_vs_timeseries import request_test_timeseries_vs_timeseries -# import request_test_expected_vs_running +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() @@ -28,20 +43,27 @@ def test_expected(sim_id1, sim_id2): 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(*)']) - print(response['data'][0]['COUNT(*)'] == '5') + 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(*)']) - print(response['data'][0]['COUNT(*)'] == '0') + 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) @@ -62,7 +84,6 @@ def test_expected(sim_id1, sim_id2): print(i) - if __name__ == '__main__': with open('test_ids.json') as f: d = json.load(f) From 20cd3b8b97645c18d7926df54e76b15133ed06d9 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Tue, 27 Apr 2021 11:10:46 -0600 Subject: [PATCH 13/18] Updated MRIDs --- ...ed_result_series_filtered_123_normal_small_4.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 index fc0fa28..ae9e7e3 100644 --- a/expected_results/expected_result_series_filtered_123_normal_small_4.json +++ b/expected_results/expected_result_series_filtered_123_normal_small_4.json @@ -7,20 +7,20 @@ "timestamp": 1535574871, "measurements": [ { - "measurement_mrid": "_0028728e-4a2f-4ef7-b248-840319a3e370", + "measurement_mrid": "_000b01a1-8238-4372-95c0-82aad26ea311", "angle": -5.066423674487563, "magnitude": 2388.676720682955, "simulation_id": "1961648576", "time": 1248156002}, { - "measurement_mrid": "_0018886d-363a-456c-8b1b-116e8c2e6fc6", - "angle": -86.36800510651457, - "magnitude": 1.4651647694061578, + "measurement_mrid": "_00347396-b4b0-4218-9aba-b363f2cda841", + "angle": 118.66041090126667, + "magnitude": 2425.0820667756834, "simulation_id": "1961648576", "time": 1248156002}, { - "measurement_mrid": "_00b26415-b4a0-4ef3-ab95-77e1beafc59a", - "angle": 28.940770423235723, + "measurement_mrid": "_0044ae64-1c72-4e81-b412-d7349ce267d3", + "angle": -39.42744945710241, "magnitude": 374545.4981119089, "simulation_id": "1961648576", "time": 1248156002} From 1d0b3d989e3361910e86c8ea157e869e94df986b Mon Sep 17 00:00:00 2001 From: jsimpson Date: Mon, 16 Aug 2021 16:43:48 -0600 Subject: [PATCH 14/18] Updated requests to be more generic and the counts for the test to match the updated processing from the test manager. --- ...lt_series_filtered_123_normal_small_4.json | 27 ++- .../request_test_expected_vs_running.py | 20 +-- .../request_test_expected_vs_timeseries.py | 136 +-------------- .../request_test_running_vs_timeseries.py | 27 ++- .../request_test_timerseries_vs_timeseries.py | 35 ---- .../request_test_timeseries_vs_timeseries.py | 17 +- .../test_listen_1_sim_vs_expected.py | 40 ++++- .../test_listen_2_sim_vs_timeseries.py | 27 +-- .../test_listen_3_timeseries_vs_expected.py | 101 +++++------ .../test_listen_4_timeseries_vs_timeseries.py | 161 +++++++----------- expected_results/test_script_sample1.json | 20 +-- 11 files changed, 229 insertions(+), 382 deletions(-) delete mode 100644 expected_results/request_test_timerseries_vs_timeseries.py 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 index ae9e7e3..0726a76 100644 --- a/expected_results/expected_result_series_filtered_123_normal_small_4.json +++ b/expected_results/expected_result_series_filtered_123_normal_small_4.json @@ -4,7 +4,7 @@ "1248156002": { "simulation_id": "559402036", "message": { - "timestamp": 1535574871, + "timestamp": 1248156002, "measurements": [ { "measurement_mrid": "_000b01a1-8238-4372-95c0-82aad26ea311", @@ -29,22 +29,22 @@ } }, "input": { - "1248156014": { + "1248156016": { "simulation_id": "559402036", "message": { - "timestamp": 1248156014, + "timestamp": 1248156016, "measurements": [ {"hasMeasurementDifference": "FORWARD", "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", "simulation_id": "1961648576", - "time": 1248156014, + "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": 1248156014, + "time": 1248156016, "attribute": "ShuntCompensator.sections", "value": 0.0, "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} @@ -69,10 +69,25 @@ "time": 1248156029, "attribute": "ShuntCompensator.sections", "value": 1.0, - "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE"} + "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": { diff --git a/expected_results/request_test_expected_vs_running.py b/expected_results/request_test_expected_vs_running.py index d7e4086..33fc9a1 100644 --- a/expected_results/request_test_expected_vs_running.py +++ b/expected_results/request_test_expected_vs_running.py @@ -9,8 +9,7 @@ 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(): +def start_test(app_name='sample_app',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) @@ -44,7 +43,7 @@ def start_test(): } # with open("expected_result_series_filtered_9500.json") as f: - with open(os.path.join(loc, "expected_result_series_filtered_123_normal_small_4.json")) as f: + with open(os.path.join(loc, expected_file)) as f: expectedJson = json.load(f) testCfgAll['expectedResults'] = expectedJson['expectedResults'] @@ -53,13 +52,16 @@ def start_test(): # 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']['duration'] = 60 - req_template['power_system_config']['Line_name'] = '_C1C3E687-6FFD-C753-582B-632A27E28507' # IEEE 123 + 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'] = 'sample_app' + 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) @@ -86,8 +88,4 @@ def start_test(): # 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 + 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 index 572291d..53e6864 100644 --- a/expected_results/request_test_expected_vs_timeseries.py +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -25,145 +25,15 @@ def start_test(simulationID=1234): expectedJson = json.load(f) testCfgAll['compareWithSimId'] = simulationID # 847461010 + testCfgAll['start_time'] = 1248156000 + testCfgAll['duration'] = 60 + testCfgAll['interval'] = 10 testCfgAll['expectedResults'] = expectedJson['expectedResults'] testCfgAll['testType'] = 'expected_vs_timeseries' request = json.dumps(testCfgAll) print('request:') print(json.dumps(testCfgAll,indent=2)) -# test_id=3657827110 -# viz_request ={ -# "appId": "sample_app", -# "testId": 3657827110, -# "compareWithSimId": 402293585, -# "expectedResults": { -# "output": { -# "1248156002": { -# "simulation_id": "559402036", -# "message": { -# "timestamp": 1535574871, -# "measurements": [{ -# "measurement_mrid": "_0028728e-4a2f-4ef7-b248-840319a3e370", -# "angle": -5.066423674487563, -# "magnitude": 2388.676720682955, -# "simulation_id": "1961648576", -# "time": 1248156002 -# }, { -# "measurement_mrid": "_0018886d-363a-456c-8b1b-116e8c2e6fc6", -# "angle": -86.36800510651457, -# "magnitude": 1.4651647694061578, -# "simulation_id": "1961648576", -# "time": 1248156002 -# }, { -# "measurement_mrid": "_00b26415-b4a0-4ef3-ab95-77e1beafc59a", -# "angle": 28.940770423235723, -# "magnitude": 374545.4981119089, -# "simulation_id": "1961648576", -# "time": 1248156002 -# }] -# } -# } -# }, -# "input": { -# "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": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" -# }, { -# "hasMeasurementDifference": "REVERSE", -# "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", -# "simulation_id": "1961648576", -# "time": 1587670665, -# "attribute": "ShuntCompensator.sections", -# "value": 1, -# "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" -# }] -# } -# }, -# "1248156014": { -# "simulation_id": "559402036", -# "message": { -# "timestamp": 1248156014, -# "measurements": [{ -# "hasMeasurementDifference": "FORWARD", -# "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", -# "simulation_id": "1961648576", -# "time": 1248156014, -# "attribute": "ShuntCompensator.sections", -# "value": 1, -# "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" -# }, { -# "hasMeasurementDifference": "REVERSE", -# "difference_mrid": "1fae379c-d0e2-4c80-8f2c-c5d7a70ff4d4", -# "simulation_id": "1961648576", -# "time": 1248156014, -# "attribute": "ShuntCompensator.sections", -# "value": 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, -# "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, -# "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, -# "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, -# "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" -# }] -# } -# } -# } -# }, -# "testType": "expected_vs_timeseries" -# } -# request = json.dumps(viz_request) -# - # status = goss.get_response(test_input+str(simulationID), request, timeout=20) # status = goss.get_response(test_input+str(test_id), request, timeout=20) status = gapps.send(test_input+str(test_id), request) print(status) diff --git a/expected_results/request_test_running_vs_timeseries.py b/expected_results/request_test_running_vs_timeseries.py index 221e196..da858ca 100644 --- a/expected_results/request_test_running_vs_timeseries.py +++ b/expected_results/request_test_running_vs_timeseries.py @@ -10,7 +10,7 @@ responseQueueTopic = '/temp-queue/response-queue' goss_simulation_status_topic = '/topic/goss.gridappsd/simulation/status/' -def start_test(simulationID): +def start_test(simulationID, app_name ='sample_app', start_time='1248156000',duration='60',feeder_name='_C1C3E687-6FFD-C753-582B-632A27E28507'): events = [{ "message": { "forward_differences": [ @@ -35,8 +35,10 @@ def start_test(simulationID): test_id = str(random.getrandbits(32)) testCfgAll = { - "appId": "sample_app", - "testId": test_id + "appId": app_name, + "testId": test_id, + "testOutput": False, + "interval": 10 } # # testCfgAll['events'] = events @@ -58,11 +60,12 @@ def start_test(simulationID): "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['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'] = 'sample_app' + req_template["application_config"]["applications"][0]['name'] = app_name # req_template["application_config"]["applications"][0]['name'] = 'sample_app_opp' req_template['test_config'] = testCfgAll @@ -83,6 +86,18 @@ def start_test(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) diff --git a/expected_results/request_test_timerseries_vs_timeseries.py b/expected_results/request_test_timerseries_vs_timeseries.py deleted file mode 100644 index d704681..0000000 --- a/expected_results/request_test_timerseries_vs_timeseries.py +++ /dev/null @@ -1,35 +0,0 @@ -import json -import time -import argparse -from gridappsd import GOSS -from pprint import pprint -goss_sim = "goss.gridappsd.process.request.simulation" -test_input = "/topic/goss.gridappsd.simulation.test.input." - -def _startTest(username,password,gossServer='localhost',stompPort='61613', simulationID=1234): - goss = GOSS() - goss.connect() - - testCfgAll = { - "appId": "sample_app" - } - testCfgAll['compareWithSimId'] = 1062322800 # 660948920 - testCfgAll['compareWithSimIdTwo'] = 272071421 - testCfgAll['testType'] = 'timeseries_vs_timeseries' - request = json.dumps(testCfgAll) - simulationID=1259505150 - - # simulationId =123 - status = goss.get_response(test_input+str(simulationID), request, timeout=10) - print(status) - print('sent test status') - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-i", "--id", type=int, help="simulation id", required=False) - args = parser.parse_args() - - _startTest('system','manager',gossServer='127.0.0.1',stompPort='61613', simulationID=args.id) - -#{'data': [{'allOutputOutage': False, 'allInputOutage': False, 'inputOutageList': [{'objectMRID': '_233D4DC1-66EA-DF3C-D859-D10438ECCBDF', 'attribute': 'PowerElectronicsConnection.p'}, {'objectMRID': '_233D4DC1-66EA-DF3C-D859-D10438ECCBDF', 'attribute': 'PowerElectronicsConnection.q'}, {'objectMRID': '_60E702BC-A8E7-6AB8-F5EB-D038283E4D3E', 'attribute': 'PowerElectronicsConnection.p'}, {'objectMRID': '_60E702BC-A8E7-6AB8-F5EB-D038283E4D3E', 'attribute': 'PowerElectronicsConnection.q'}], 'outputOutageList': ['_facde6ab-95e2-471b-b151-1b7125d863f0', '_888e15c8-380d-4dcf-9876-ccf8949d45b1'], 'faultMRID': '_f05569df-665f-4b25-b721-926ff32b4ab3', 'event_type': 'CommOutage', 'occuredDateTime': 1374510750, 'stopDateTime': 1374510960, 'status': 'CLEARED'}]} -#{'data': [{'allOutputOutage': False, 'allInputOutage': False, 'inputOutageList': [{'objectMRID': '_233D4DC1-66EA-DF3C-D859-D10438ECCBDF', 'attribute': 'PowerElectronicsConnection.p'}, {'objectMRID': '_233D4DC1-66EA-DF3C-D859-D10438ECCBDF', 'attribute': 'PowerElectronicsConnection.q'}, {'objectMRID': '_60E702BC-A8E7-6AB8-F5EB-D038283E4D3E', 'attribute': 'PowerElectronicsConnection.p'}, {'objectMRID': '_60E702BC-A8E7-6AB8-F5EB-D038283E4D3E', 'attribute': 'PowerElectronicsConnection.q'}], 'outputOutageList': ['_facde6ab-95e2-471b-b151-1b7125d863f0', '_888e15c8-380d-4dcf-9876-ccf8949d45b1'], 'faultMRID': '_b93ae63b-c959-476f-a4e8-3020be90db2c', 'event_type': 'CommOutage', 'occuredDateTime': 1374510750, 'stopDateTime': 1374510960, 'status': 'INITIATED'}]} diff --git a/expected_results/request_test_timeseries_vs_timeseries.py b/expected_results/request_test_timeseries_vs_timeseries.py index afc8e14..3b83bbb 100644 --- a/expected_results/request_test_timeseries_vs_timeseries.py +++ b/expected_results/request_test_timeseries_vs_timeseries.py @@ -6,14 +6,17 @@ goss_sim = "goss.gridappsd.process.request.simulation" test_input = "/topic/goss.gridappsd.simulation.test.input." -def start_test(simulationID1, simulationID2): +def start_test(simulationID1, simulationID2, start_time=1248156000,duration=60): goss = GOSS() goss.connect() test_id = str(random.getrandbits(32)) testCfgAll = { "appId": "sample_app", - "testId": test_id + "testId": test_id, + "testOutput": False, + "start_time":start_time, + "duration":duration } testCfgAll['compareWithSimId'] = simulationID1 # 847461010 # 660948920 @@ -34,3 +37,13 @@ def start_test(simulationID1, simulationID2): 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/test_listen_1_sim_vs_expected.py b/expected_results/test_listen_1_sim_vs_expected.py index 7701d3d..89a03f9 100644 --- a/expected_results/test_listen_1_sim_vs_expected.py +++ b/expected_results/test_listen_1_sim_vs_expected.py @@ -73,12 +73,48 @@ def test(): finished=False while not finished: - time.sleep(65) + time.sleep(75) finished = True error_count = sl._error_count print(error_count) logging.info("Error count " + str(error_count)) - assert error_count == 7, f" For expected_vs_running expecting 7 non matching results. Received {error_count}" + assert error_count == 17, f" For expected_vs_running expecting 12 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 \ 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 index 902f166..9189fec 100644 --- a/expected_results/test_listen_2_sim_vs_timeseries.py +++ b/expected_results/test_listen_2_sim_vs_timeseries.py @@ -6,6 +6,7 @@ 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) @@ -51,22 +52,16 @@ def on_message(self, headers, message): 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() - - with open('test_id_request_1.json') as f: - sim_id = json.load(f) - sim_id = sim_id['sim_id1'] - # sim_id = 877159920 - sim_id2, test_id2 = request_test_running_vs_timeseries.start_test(sim_id) + 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) - # gapps = GridAPPSD(opts.test_id, address=utils.get_gridappsd_address(), - # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) gapps = GridAPPSD() gapps.connect() sl = SimpleListener(gapps, 1) @@ -75,12 +70,9 @@ def test(): print('response') print(response) - with open('test_id_request_2.json', 'w') as f: - json.dump({'sim_id2': sim_id2}, f) - finished = False while not finished: - time.sleep(65) + time.sleep(120) finished = True error_count = sl._error_count print(error_count) @@ -90,4 +82,3 @@ def test(): 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 index c1dbb28..e624c8c 100644 --- a/expected_results/test_listen_3_timeseries_vs_expected.py +++ b/expected_results/test_listen_3_timeseries_vs_expected.py @@ -1,6 +1,3 @@ -import argparse -import json -import os import time import logging import random @@ -9,6 +6,7 @@ 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) @@ -46,61 +44,21 @@ def on_message(self, headers, message): print("Exit") print("Error count " + str(self._error_count)) print(self._error_count == 7) # 5? - # assert self._error_count == 7, f" For expected_vs_timeseries expecting 7 non matching results. Received {self._error_count}" - # os._exit(0) - -# # finished=False -# error_count=0 -# -# def on_message(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(headers["destination"]) -# print(message) -# global error_count -# # global error_count -# # global finished -# logging.info("On message") -# if 'status' in message and (message['status'] == 'finish' or message['status'] == 'start'): -# pass -# else: -# error_count+=1 -# # json_message = json.loads(message) -# # "{\"status\":\"start\"}") -# if 'status' in message and message['status'] == 'finish': -# print("Exit") -# print("Error count " + str(error_count)) -# logging.info("on_message error count " + str(error_count)) -# print(error_count == 7) -# # finished = True -# # os._exit(0) 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() - # gapps = GridAPPSD(opts.test_id, address=utils.get_gridappsd_address(), - # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) - gapps = GridAPPSD() gapps.connect() logging.info('Starting') sl = SimpleListener(gapps, 1) - with open('test_id_request_1.json') as f: - sim_id = json.load(f) - sim_id = sim_id['sim_id1'] + 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'] test_id2 = request_test_expected_vs_timeseries.start_test(sim_id) @@ -111,21 +69,46 @@ def test(): print('sent test request ' + str(test_id2)) print(test_output_topic + str(test_id2)) - # response = gapps.subscribe(test_output_topic+str(test_id2), on_message) - # print(response) - - # while True: - # time.sleep(0.1) - # time.sleep(2) logging.info("Start waiting") finished = False while not finished: - time.sleep(3) + time.sleep(5) finished = True error_count = sl._error_count print(error_count) logging.info("Error count " + str(error_count)) - assert error_count == 7, f" For expected_vs_timeseries expecting 7 non matching results. Received {error_count}" + assert error_count == 0, f" For expected_vs_timeseries expecting 7 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 index 15773a1..c50591c 100644 --- a/expected_results/test_listen_4_timeseries_vs_timeseries.py +++ b/expected_results/test_listen_4_timeseries_vs_timeseries.py @@ -1,135 +1,96 @@ -import argparse -import json -import os 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 -# """ -# global KEEP_LISTENING_FLAG -# -# def __init__(self, gridappsd_obj, test_id): -# """ Create -# """ -# self._gapps = gridappsd_obj -# self._test_id = test_id -# self._error_count = 0 -# self._finished = False -# -# def get_error_count(self): -# return self._error_count -# -# def get_finished(self): -# return self._finished -# -# 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) -# -# self._finished =True -# # os._exit(0) -finished=False -error_count=0 -def on_message(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. +class SimpleListener(object): + """ A simple class to listen for the test results """ - print(message) - global error_count - global finished + def __init__(self, gridappsd_obj, test_id): + """ Create + """ + self._gapps = gridappsd_obj + self._test_id = test_id + self._error_count = 0 - if 'status' in message and (message['status'] == 'finish' or message['status'] == 'start'): - pass - else: - error_count+=1 - # json_message = json.loads(message) - # "{\"status\":\"start\"}") - if 'status' in message and message['status'] == 'finish': - print("Exit") - print("Error count " + str(error_count)) - print(error_count == 0) - finished =True - # os._exit(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(): - - global error_count - global finished - assert error_count == 0, f" For timeseries_vs_timeseries expecting 0 non matching results. Received {error_count}" - # 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(1, address=utils.get_gridappsd_address(), - # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) gapps = GridAPPSD() gapps.connect() - # sl = SimpleListener(gapps, 1) + 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) - with open('test_id_request_1.json') as f: - sim_id_dict = json.load(f) - sim_id = sim_id_dict['sim_id1'] - with open('test_id_request_2.json') as f: - sim_id_dict = json.load(f) - sim_id2 = sim_id_dict['sim_id2'] + 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) - # sim_id = 1767860274 - # sim_id2 = 1564477893 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), on_message) + response = gapps.subscribe(test_output_topic+str(test_id2), sl) print(response) time.sleep(2) - # print(sl.get_error_count()) + finished = False while not finished: - time.sleep(3) + time.sleep(120) finished = True gapps.disconnect() - # error_count = sl.get_error_count() + 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}" - # os._exit(0) 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 index d7984e0..50cf4db 100644 --- a/expected_results/test_script_sample1.json +++ b/expected_results/test_script_sample1.json @@ -9,7 +9,7 @@ "timestamp": 1535574871, "measurements": [ { - "measurement_mrid": "_007d97d4-4b30-4635-8122-8e7f1e7cf3be", + "measurement_mrid": "_0055de94-7d7e-4931-a884-cab596cc191b", "angle": -5.066423674487563, "magnitude": 235525.8716877966, "simulation_id": "1961648576", @@ -23,7 +23,7 @@ "time": 1248156002 }, { - "measurement_mrid": "_01204a90-9893-4e57-8ea5-0a09198e58fe", + "measurement_mrid": "_0058123f-da11-4f7c-a429-e47e5949465f", "angle": 28.940770423235723, "magnitude": 374545.4981119089, "simulation_id": "1961648576", @@ -46,7 +46,7 @@ "time": 1587670650, "attribute": "ShuntCompensator.sections", "value": 1.0, - "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" }, { "hasMeasurementDifference": "REVERSE", @@ -55,7 +55,7 @@ "time": 1587670650, "attribute": "ShuntCompensator.sections", "value": 0.0, - "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" } ] } @@ -72,7 +72,7 @@ "time": 1587670665, "attribute": "ShuntCompensator.sections", "value": 0.0, - "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" }, { "hasMeasurementDifference": "REVERSE", @@ -81,7 +81,7 @@ "time": 1587670665, "attribute": "ShuntCompensator.sections", "value": 1.0, - "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" } ] } @@ -98,7 +98,7 @@ "time": 1587670665, "attribute": "ShuntCompensator.sections", "value": 0.0, - "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" }, { "hasMeasurementDifference": "REVERSE", @@ -107,7 +107,7 @@ "time": 1587670665, "attribute": "ShuntCompensator.sections", "value": 1.0, - "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" } ] } @@ -124,7 +124,7 @@ "time": 1587670665, "attribute": "ShuntCompensator.sections", "value": 0.0, - "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" }, { "hasMeasurementDifference": "REVERSE", @@ -133,7 +133,7 @@ "time": 1587670665, "attribute": "ShuntCompensator.sections", "value": 1.0, - "object": "_939CA567-AA3D-4972-AABC-1D0AAF4859FE" + "object": "_232DD3A8-9A3C-4053-B972-8A5EB49FD980" } ] } From 2666d2706fbd46f4756bd5d1d0f3251046cd264a Mon Sep 17 00:00:00 2001 From: jsimpson Date: Wed, 25 Aug 2021 14:32:19 -0600 Subject: [PATCH 15/18] Added request_test_running.py --- expected_results/request_test_running.py | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 expected_results/request_test_running.py diff --git a/expected_results/request_test_running.py b/expected_results/request_test_running.py new file mode 100644 index 0000000..91c6561 --- /dev/null +++ b/expected_results/request_test_running.py @@ -0,0 +1,48 @@ +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 _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) + goss = GOSS() + goss.connect() + + simulationId = goss.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 From ea6330906efbba63ceb2ab071ef39718b6026288 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Wed, 25 Aug 2021 16:38:33 -0600 Subject: [PATCH 16/18] Added updated username and password for GridAPPS-D. --- expected_results/request_test_expected_vs_running.py | 4 +++- .../request_test_expected_vs_timeseries.py | 4 +++- expected_results/request_test_running.py | 10 ++++++---- .../request_test_running_no_application.py | 8 +++++--- expected_results/request_test_running_vs_timeseries.py | 10 ++++++---- .../request_test_timeseries_vs_timeseries.py | 9 +++++---- expected_results/test_listen_1_sim_vs_expected.py | 7 +++++-- expected_results/test_listen_2_sim_vs_timeseries.py | 4 +++- .../test_listen_3_timeseries_vs_expected.py | 6 ++++-- .../test_listen_4_timeseries_vs_timeseries.py | 4 +++- 10 files changed, 43 insertions(+), 23 deletions(-) diff --git a/expected_results/request_test_expected_vs_running.py b/expected_results/request_test_expected_vs_running.py index 33fc9a1..502db8e 100644 --- a/expected_results/request_test_expected_vs_running.py +++ b/expected_results/request_test_expected_vs_running.py @@ -69,7 +69,9 @@ def start_test(app_name='sample_app',start_time='1248156000',duration='60',feede print("request") print(json.dumps(req_template,indent=2)) # exit(0) - goss = GOSS() + username = "app_user" + password = "1234App" + goss = GOSS(username=username, password=password) goss.connect() simulationId = goss.get_response(goss_sim, simCfg13pv, timeout=10) diff --git a/expected_results/request_test_expected_vs_timeseries.py b/expected_results/request_test_expected_vs_timeseries.py index 53e6864..46717ae 100644 --- a/expected_results/request_test_expected_vs_timeseries.py +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -11,7 +11,9 @@ def start_test(simulationID=1234): loc = os.path.realpath(__file__) loc = os.path.dirname(loc) - gapps = GridAPPSD() + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) gapps.connect() test_id = str(random.getrandbits(32)) diff --git a/expected_results/request_test_running.py b/expected_results/request_test_running.py index 91c6561..fc3259e 100644 --- a/expected_results/request_test_running.py +++ b/expected_results/request_test_running.py @@ -2,7 +2,7 @@ import time import os import argparse -from gridappsd import GOSS +from gridappsd import GridAPPSD import random goss_sim = "goss.gridappsd.process.request.simulation" test_topic = 'goss.gridappsd.test' @@ -22,10 +22,12 @@ def start_test(app_name='sample_app'): print("request") print(json.dumps(req_template,indent=2)) # exit(0) - goss = GOSS() - goss.connect() + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() - simulationId = goss.get_response(goss_sim, simCfg13pv, timeout=10) + simulationId = gapps.get_response(goss_sim, simCfg13pv, timeout=10) print('sent simulation request') print('simulation id ', simulationId) diff --git a/expected_results/request_test_running_no_application.py b/expected_results/request_test_running_no_application.py index af60b26..4b31b4d 100644 --- a/expected_results/request_test_running_no_application.py +++ b/expected_results/request_test_running_no_application.py @@ -3,7 +3,7 @@ import os import argparse # import goss_forward_sim -from gridappsd import GOSS +from gridappsd import GridAPPSD # from pprint import pprint goss_sim = "goss.gridappsd.process.request.simulation" test_topic = 'goss.gridappsd.test' @@ -138,8 +138,10 @@ def _startTest(username,password,gossServer='localhost',stompPort='61613', simul print() print(json.dumps(testCfgAll,indent=2)) - goss = GOSS() - goss.connect() + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) + gapps.connect() # simulationId =123 test_hist_old = False diff --git a/expected_results/request_test_running_vs_timeseries.py b/expected_results/request_test_running_vs_timeseries.py index da858ca..daa2d8d 100644 --- a/expected_results/request_test_running_vs_timeseries.py +++ b/expected_results/request_test_running_vs_timeseries.py @@ -2,7 +2,7 @@ import time import os import argparse -from gridappsd import GOSS +from gridappsd import GridAPPSD import random goss_sim = "goss.gridappsd.process.request.simulation" @@ -70,8 +70,10 @@ def start_test(simulationID, app_name ='sample_app', start_time='1248156000',dur req_template['test_config'] = testCfgAll - goss = GOSS() - goss.connect() + 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' @@ -80,7 +82,7 @@ def start_test(simulationID, app_name ='sample_app', start_time='1248156000',dur print('request') print(json.dumps(req_template,indent=2)) - simulationId = goss.get_response(goss_sim, simCfg13pv, timeout=10) + simulationId = gapps.get_response(goss_sim, simCfg13pv, timeout=10) print('sent simulation request') print('simulation id ', simulationId) diff --git a/expected_results/request_test_timeseries_vs_timeseries.py b/expected_results/request_test_timeseries_vs_timeseries.py index 3b83bbb..3c02c8b 100644 --- a/expected_results/request_test_timeseries_vs_timeseries.py +++ b/expected_results/request_test_timeseries_vs_timeseries.py @@ -1,14 +1,15 @@ import json import argparse import random -from gridappsd import GOSS +from gridappsd import GridAPPSD goss_sim = "goss.gridappsd.process.request.simulation" test_input = "/topic/goss.gridappsd.simulation.test.input." def start_test(simulationID1, simulationID2, start_time=1248156000,duration=60): - goss = GOSS() - goss.connect() + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) test_id = str(random.getrandbits(32)) testCfgAll = { @@ -25,7 +26,7 @@ def start_test(simulationID1, simulationID2, start_time=1248156000,duration=60): request = json.dumps(testCfgAll) # status = goss.get_response(test_input+str(test_id), request, timeout=60) - status = goss.send(test_input+str(test_id), request) + status = gapps.send(test_input+str(test_id), request) print(status) print('sent test status') return test_id diff --git a/expected_results/test_listen_1_sim_vs_expected.py b/expected_results/test_listen_1_sim_vs_expected.py index 89a03f9..33cb096 100644 --- a/expected_results/test_listen_1_sim_vs_expected.py +++ b/expected_results/test_listen_1_sim_vs_expected.py @@ -61,8 +61,11 @@ def test(): # gapps = GridAPPSD(opts.test_id, address=utils.get_gridappsd_address(), # username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) - gapps = GridAPPSD() + 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) @@ -73,7 +76,7 @@ def test(): finished=False while not finished: - time.sleep(75) + time.sleep(85) finished = True error_count = sl._error_count print(error_count) diff --git a/expected_results/test_listen_2_sim_vs_timeseries.py b/expected_results/test_listen_2_sim_vs_timeseries.py index 9189fec..f8d172f 100644 --- a/expected_results/test_listen_2_sim_vs_timeseries.py +++ b/expected_results/test_listen_2_sim_vs_timeseries.py @@ -62,7 +62,9 @@ def test(): print('simid ' + sim_id2) print('sent test request ' + test_id2) - gapps = GridAPPSD() + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) gapps.connect() sl = SimpleListener(gapps, 1) print(test_output_topic+str(test_id2)) diff --git a/expected_results/test_listen_3_timeseries_vs_expected.py b/expected_results/test_listen_3_timeseries_vs_expected.py index e624c8c..f0a072a 100644 --- a/expected_results/test_listen_3_timeseries_vs_expected.py +++ b/expected_results/test_listen_3_timeseries_vs_expected.py @@ -46,7 +46,9 @@ def on_message(self, headers, message): print(self._error_count == 7) # 5? def test(): - gapps = GridAPPSD() + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) gapps.connect() logging.info('Starting') sl = SimpleListener(gapps, 1) @@ -77,7 +79,7 @@ def test(): error_count = sl._error_count print(error_count) logging.info("Error count " + str(error_count)) - assert error_count == 0, f" For expected_vs_timeseries expecting 7 non matching results. Received {error_count}" + assert error_count == 11, f" For expected_vs_timeseries expecting 11 non matching results. Received {error_count}" if __name__ == "__main__": test() diff --git a/expected_results/test_listen_4_timeseries_vs_timeseries.py b/expected_results/test_listen_4_timeseries_vs_timeseries.py index c50591c..7a22d84 100644 --- a/expected_results/test_listen_4_timeseries_vs_timeseries.py +++ b/expected_results/test_listen_4_timeseries_vs_timeseries.py @@ -44,7 +44,9 @@ def on_message(self, headers, message): def test(): - gapps = GridAPPSD() + username = "app_user" + password = "1234App" + gapps = GridAPPSD(username=username, password=password) gapps.connect() logging.info('Starting') sl = SimpleListener(gapps, 1) From 89d007f35f91c55aaa6defeb21f12f0fc6113876 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Mon, 27 Sep 2021 10:18:38 -0600 Subject: [PATCH 17/18] Updated request test functions to make them more flexible and able to test multiple feeders and applications. --- ...lt_series_filtered_123_normal_small_4.json | 4 ++-- .../request_test_expected_vs_running.py | 5 +++-- .../request_test_expected_vs_timeseries.py | 19 +++++++++++++------ .../request_test_running_vs_timeseries.py | 4 ++-- .../request_test_timeseries_vs_timeseries.py | 4 ++-- expected_results/test_get_results.py | 2 +- .../test_listen_1_sim_vs_expected.py | 2 +- .../test_listen_3_timeseries_vs_expected.py | 6 ++++-- 8 files changed, 28 insertions(+), 18 deletions(-) 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 index 0726a76..e85f1e3 100644 --- a/expected_results/expected_result_series_filtered_123_normal_small_4.json +++ b/expected_results/expected_result_series_filtered_123_normal_small_4.json @@ -15,12 +15,12 @@ { "measurement_mrid": "_00347396-b4b0-4218-9aba-b363f2cda841", "angle": 118.66041090126667, - "magnitude": 2425.0820667756834, + "magnitude": 2425.4464236409276, "simulation_id": "1961648576", "time": 1248156002}, { "measurement_mrid": "_0044ae64-1c72-4e81-b412-d7349ce267d3", - "angle": -39.42744945710241, + "angle": -38.44540074843378, "magnitude": 374545.4981119089, "simulation_id": "1961648576", "time": 1248156002} diff --git a/expected_results/request_test_expected_vs_running.py b/expected_results/request_test_expected_vs_running.py index 502db8e..459cb3e 100644 --- a/expected_results/request_test_expected_vs_running.py +++ b/expected_results/request_test_expected_vs_running.py @@ -9,7 +9,7 @@ responseQueueTopic = '/temp-queue/response-queue' goss_simulation_status_topic = '/topic/goss.gridappsd/simulation/status/' -def start_test(app_name='sample_app',start_time='1248156000',duration='60',feeder_name='_C1C3E687-6FFD-C753-582B-632A27E28507',expected_file="expected_result_series_filtered_123_normal_small_4.json"): +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) @@ -39,7 +39,8 @@ def start_test(app_name='sample_app',start_time='1248156000',duration='60',feede test_id = str(random.getrandbits(32)) testCfgAll = { "appId": "sample_app", - "testId": str(test_id) + "testId": str(test_id), + "testOutput": testOutput, } # with open("expected_result_series_filtered_9500.json") as f: diff --git a/expected_results/request_test_expected_vs_timeseries.py b/expected_results/request_test_expected_vs_timeseries.py index 46717ae..3a20931 100644 --- a/expected_results/request_test_expected_vs_timeseries.py +++ b/expected_results/request_test_expected_vs_timeseries.py @@ -8,7 +8,13 @@ goss_sim = "goss.gridappsd.process.request.simulation" test_input = "/topic/goss.gridappsd.simulation.test.input." -def start_test(simulationID=1234): +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" @@ -18,17 +24,18 @@ def start_test(simulationID=1234): test_id = str(random.getrandbits(32)) testCfgAll = { - "appId": "sample_app", - "testId": test_id + "appId": app_name, + "testId": test_id, + "testOutput": testOutput, } - with open(os.path.join(loc,"expected_result_series_filtered_123_normal_small_4.json")) as f: + 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'] = 1248156000 - testCfgAll['duration'] = 60 + testCfgAll['start_time'] = start_time + testCfgAll['duration'] = duration testCfgAll['interval'] = 10 testCfgAll['expectedResults'] = expectedJson['expectedResults'] testCfgAll['testType'] = 'expected_vs_timeseries' diff --git a/expected_results/request_test_running_vs_timeseries.py b/expected_results/request_test_running_vs_timeseries.py index daa2d8d..7aa1cdf 100644 --- a/expected_results/request_test_running_vs_timeseries.py +++ b/expected_results/request_test_running_vs_timeseries.py @@ -10,7 +10,7 @@ responseQueueTopic = '/temp-queue/response-queue' goss_simulation_status_topic = '/topic/goss.gridappsd/simulation/status/' -def start_test(simulationID, app_name ='sample_app', start_time='1248156000',duration='60',feeder_name='_C1C3E687-6FFD-C753-582B-632A27E28507'): +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": [ @@ -37,7 +37,7 @@ def start_test(simulationID, app_name ='sample_app', start_time='1248156000',dur testCfgAll = { "appId": app_name, "testId": test_id, - "testOutput": False, + "testOutput": testOutput, "interval": 10 } diff --git a/expected_results/request_test_timeseries_vs_timeseries.py b/expected_results/request_test_timeseries_vs_timeseries.py index 3c02c8b..6b42093 100644 --- a/expected_results/request_test_timeseries_vs_timeseries.py +++ b/expected_results/request_test_timeseries_vs_timeseries.py @@ -6,7 +6,7 @@ goss_sim = "goss.gridappsd.process.request.simulation" test_input = "/topic/goss.gridappsd.simulation.test.input." -def start_test(simulationID1, simulationID2, start_time=1248156000,duration=60): +def start_test(simulationID1, simulationID2, testOutput=False, start_time=1248156000,duration=60): username = "app_user" password = "1234App" gapps = GridAPPSD(username=username, password=password) @@ -15,7 +15,7 @@ def start_test(simulationID1, simulationID2, start_time=1248156000,duration=60): testCfgAll = { "appId": "sample_app", "testId": test_id, - "testOutput": False, + "testOutput": testOutput, "start_time":start_time, "duration":duration } diff --git a/expected_results/test_get_results.py b/expected_results/test_get_results.py index 46ceb19..26dbc59 100644 --- a/expected_results/test_get_results.py +++ b/expected_results/test_get_results.py @@ -35,7 +35,7 @@ def on_message(self, headers, message): def _main(): parser = argparse.ArgumentParser() - parser.add_argument("-test_id", default=818730075, + parser.add_argument("-test_id", default=3258685887, help="Simulation id to use for responses on the message bus.") opts = parser.parse_args() diff --git a/expected_results/test_listen_1_sim_vs_expected.py b/expected_results/test_listen_1_sim_vs_expected.py index 33cb096..cb54cca 100644 --- a/expected_results/test_listen_1_sim_vs_expected.py +++ b/expected_results/test_listen_1_sim_vs_expected.py @@ -55,7 +55,7 @@ def test(): # 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() + sim_id, test_id = request_test_expected_vs_running.start_test(testOutput=False) time.sleep(2) print('sent test request ' + test_id) diff --git a/expected_results/test_listen_3_timeseries_vs_expected.py b/expected_results/test_listen_3_timeseries_vs_expected.py index f0a072a..e1c6ca3 100644 --- a/expected_results/test_listen_3_timeseries_vs_expected.py +++ b/expected_results/test_listen_3_timeseries_vs_expected.py @@ -61,8 +61,10 @@ def test(): # with open('test_id_request_1.json') as f: # sim_id = json.load(f) # sim_id = sim_id['sim_id1'] - - test_id2 = request_test_expected_vs_timeseries.start_test(sim_id) + # 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) From 4811222880096eee711ce5d6e6d8732b33da17e2 Mon Sep 17 00:00:00 2001 From: jsimpson Date: Fri, 1 Oct 2021 14:46:32 -0600 Subject: [PATCH 18/18] Updated to account for inputs at time 1248156044. --- .../test_listen_1_sim_vs_expected.py | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/expected_results/test_listen_1_sim_vs_expected.py b/expected_results/test_listen_1_sim_vs_expected.py index cb54cca..5ff82c3 100644 --- a/expected_results/test_listen_1_sim_vs_expected.py +++ b/expected_results/test_listen_1_sim_vs_expected.py @@ -81,7 +81,7 @@ def test(): error_count = sl._error_count print(error_count) logging.info("Error count " + str(error_count)) - assert error_count == 17, f" For expected_vs_running expecting 12 non matching results. Received {error_count}" + assert error_count == 29, f" For expected_vs_running expecting 29 non matching results. Received {error_count}" if __name__ == "__main__": test() @@ -120,4 +120,44 @@ def test(): # {'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 \ No newline at end of file + # 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