-
Notifications
You must be signed in to change notification settings - Fork 9
Added test manager documentation. #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jeffrey-Simpson
wants to merge
17
commits into
GRIDAPPSD:master
Choose a base branch
from
Jeffrey-Simpson:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
be35870
Added test manager
Jeffrey-Simpson 832a76f
Fixes based on comments.
Jeffrey-Simpson 0f18053
Merge branch 'master' of https://github.com/GRIDAPPSD/gridappsd-docs
Jeffrey-Simpson e8ce8dd
Added Solar Forecasting app
Jeffrey-Simpson e6c0569
Intial checkin of test_manager_events.rst
Jeffrey-Simpson 1f87b8c
Updated code blocks, and query
Jeffrey-Simpson efa7a8d
Merge branch 'master' into master
Jeffrey-Simpson a90a853
Updated diagram
Jeffrey-Simpson 791bf4c
Updated for new command structure.
Jeffrey-Simpson a68715d
Merged
Jeffrey-Simpson c91d2d1
Removed titles I has put in for some reason
Jeffrey-Simpson 38a57a6
Updated CIM Fault Event
Jeffrey-Simpson 4af16f5
Updated Comm and Fault events
Jeffrey-Simpson b8f2ea6
Updated
Jeffrey-Simpson db0ff2e
Updated
Jeffrey-Simpson 7c4e3f7
Merged with master
Jeffrey-Simpson 5d9f6d2
Merged
Jeffrey-Simpson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| The Test Manager is responsible for testing an application or service against different events or scenarios. | ||
| The Test Manager Configuration is sent as part of the RequestSimulation. The expected results and events are sent to the Test Manager for processing. | ||
|
|
||
| 1. Test Configuration | ||
|
|
||
| The test configuration contains the application ID, rules settings, expected results, and events. | ||
| Other information need by the Test Manager like the simulation ID is obtained by the Simulation Context. | ||
|
|
||
| Example: | ||
|
|
||
| :: | ||
|
|
||
| { | ||
| "appId":String | ||
| "rules":{} | ||
| "expectedResults":{ | ||
| }, | ||
| "events":{ | ||
| } | ||
| } | ||
|
|
||
|
|
||
| 2. Expected results series: | ||
|
|
||
| Time series json structure with expected results. | ||
|
|
||
| .. code-block:: JSON | ||
| :caption: Expected results | ||
|
|
||
| { | ||
| "output": { | ||
| "1248130802": { | ||
| "simulation_id": "559402036", | ||
| "message": { | ||
| "timestamp": 1535574871, | ||
| "measurements": [ | ||
| { | ||
| "angle": -122.66883087158203, | ||
| "magnitude": 2438.561767578125, | ||
| "measurement_mrid": "_84541f26-084d-4ea7-a254-ea43678d51f9" | ||
| }, | ||
| { | ||
| "angle": 21.723935891052907, | ||
| "magnitude": 45368.78524042436, | ||
| "measurement_mrid": "_c48d8d88-12be-4b15-8b44-eedc752250c6" | ||
| }, | ||
| { | ||
| "measurement_mrid": "_4a316ed2-4e5f-4b8c-9b25-605f5c9e249c", | ||
| "value": 0 | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "1248130805": { | ||
| "simulation_id": "559402036", | ||
| "message": { | ||
| "timestamp": 1535574872, | ||
| "measurements": [ | ||
| { | ||
| "angle": -38.381605233862224, | ||
| "magnitude": 52769.16136465681, | ||
| "measurement_mrid": "_84541f26-084d-4ea7-a254-ea43678d51f9" | ||
| }, | ||
| { | ||
| "angle": 21.723935891052907, | ||
| "magnitude": 45368.78524042436, | ||
| "measurement_mrid": "_c48d8d88-12be-4b15-8b44-eedc752250c6" | ||
| }, | ||
| { | ||
| "measurement_mrid": "_4a316ed2-4e5f-4b8c-9b25-605f5c9e249c", | ||
| "value": 1 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| 3. Rules | ||
|
|
||
| The rules application is started by the test manager and messages sent to | ||
| simulation.input.[simulationId] and simulation.output.[simulationId] will be | ||
| forwarded to http://localhost:5000/input/events | ||
|
|
||
| Snippet to listen for changes to ShuntCompensators, i.e. CIM capacitors. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| shunt_dict = defaultdict(lambda: {'count':0}) | ||
| shunt_threshold = 4 | ||
|
|
||
| # A Reverse and a Forward difference is a state change. | ||
| @when_all((m.message.reverse_differences.allItems(item.attribute == 'ShuntCompensator.sections')) & ( | ||
| m.message.forward_differences.allItems(item.attribute == 'ShuntCompensator.sections'))) | ||
| def shunt_change(c): | ||
| # consequent | ||
| for i,f in enumerate(c.m.message.reverse_differences): | ||
| c.post({'shunt_object': f['object'], | ||
| 'action': f['attribute'], | ||
| 'timestamp': c.m.message.timestamp}) | ||
|
|
||
| @when_all(+m.shunt_object) | ||
| def count_shunt_object(c): | ||
| shunt_dict[c.m.shunt_object]['count']+=1 | ||
| if shunt_dict[c.m.shunt_object]['count'] == shunt_threshold: | ||
| print ('Shunt change threshold '+str(shunt_threshold)+' exceeded for shunt object ' + c.m.shunt_object) | ||
| send_log_msg('Shunt change threshold '+str(shunt_threshold)+' exceeded for shunt object ' + c.m.shunt_object) | ||
|
|
||
|
|
||
| 5. Request Test message API | ||
|
|
||
| There is a request_test.py python script provided for the sample app in gridappsd-sample-app/sample_app/tests/request_test.py | ||
| The request_test script will work outside the docker container and submits a request to run a simulation. | ||
| It will wait to capture the returned simulation ID. The simulation ID is set in the | ||
| test configuration message and that message is sent to the "goss.gridappsd.test" topic. | ||
| This will cause put the test manager into test mode. The test manager will now forward simulation | ||
| input and output to the specified port for the rules application. | ||
|
|
||
| The test message contains the following: | ||
|
|
||
| * testConfigPath - Full path to the test config. | ||
| * testScriptPath - Full path to the test config. | ||
| * rulePort - Port to use for the rules app, the default is 5000. | ||
| * topic - topic to use for the rule app, the default is input. | ||
| * expectedResult - Full path to the expected result test series data. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| loc ='/gridappsd/applications/sample_app/tests' | ||
| testCfg = {"testConfigPath":loc+"/SampleTestConfig.json", | ||
| "testScriptPath":loc+"/SampleTestScript.json", | ||
| "simulationID": 1234, | ||
| "rulePort": 5000, | ||
| "topic":"input", | ||
| "expectedResult":loc + "/expected_result_series_filtered_8500.json" | ||
| } | ||
|
|
||
|
|
||
| The script works from outside of the docker container from either an IDE like PyCharm or from the command line. | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| user@usermachine>python sample_app/tests/request_test.py |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.