Commit 43cf3899 authored by Federico Sismondi's avatar Federico Sismondi
Browse files

fix error in perf message, added agent.configured, fixed doc

parent bc674a0e
......@@ -27,7 +27,7 @@ Usage:
>>> from messages import * # doctest: +SKIP
>>> m = MsgTestCaseSkip()
>>> m
MsgTestCaseSkip(_api_version = 0.1.32, _type = testcoordination.testcase.skip, testcase_id = TD_COAP_CORE_02_v01, )
MsgTestCaseSkip(_api_version = 0.1.34, _type = testcoordination.testcase.skip, testcase_id = TD_COAP_CORE_02_v01, )
>>> m.routing_key
'control.testcoordination'
>>> m.message_id # doctest: +SKIP
......@@ -38,18 +38,18 @@ MsgTestCaseSkip(_api_version = 0.1.32, _type = testcoordination.testcase.skip, t
# also we can modify some of the fields (rewrite the default ones)
>>> m = MsgTestCaseSkip(testcase_id = 'TD_COAP_CORE_03_v01')
>>> m
MsgTestCaseSkip(_api_version = 0.1.32, _type = testcoordination.testcase.skip, testcase_id = TD_COAP_CORE_03_v01, )
MsgTestCaseSkip(_api_version = 0.1.34, _type = testcoordination.testcase.skip, testcase_id = TD_COAP_CORE_03_v01, )
>>> m.testcase_id
'TD_COAP_CORE_03_v01'
# and even export the message in json format (for example for sending the message though the amqp event bus)
>>> m.to_json()
'{"_api_version": "0.1.32", "_type": "testcoordination.testcase.skip", "testcase_id": "TD_COAP_CORE_03_v01"}'
'{"_api_version": "0.1.34", "_type": "testcoordination.testcase.skip", "testcase_id": "TD_COAP_CORE_03_v01"}'
# We can use the Message class to import json into Message objects:
>>> m=MsgTestSuiteStart()
>>> m.to_json()
'{"_api_version": "0.1.32", "_type": "testcoordination.testsuite.start"}'
'{"_api_version": "0.1.34", "_type": "testcoordination.testsuite.start"}'
>>> json_message = m.to_json()
>>> obj=Message.from_json(json_message)
>>> type(obj)
......@@ -62,7 +62,7 @@ MsgTestCaseSkip(_api_version = 0.1.32, _type = testcoordination.testcase.skip, t
# the error reply (note that we pass the message of the request to build the reply):
>>> err = MsgErrorReply(m)
>>> err
MsgErrorReply(_api_version = 0.1.32, _type = sniffing.start, error_code = Some error code TBD, error_message = Some
MsgErrorReply(_api_version = 0.1.34, _type = sniffing.start, error_code = Some error code TBD, error_message = Some
error message TBD, ok = False, )
>>> m.reply_to
'control.sniffing.service.reply'
......@@ -266,7 +266,7 @@ class MsgAgentTunStart(Message):
Type: Event
Typical_use: Testing Tool -> Agent
Pub/Sub: Testing Tool -> Agent
Description: Message for triggering start IP tun interface in OS where the agent is running
"""
......@@ -290,7 +290,7 @@ class MsgAgentTunStarted(Message):
Type: Event
Typical_use: Testing Tool -> Agent
Pub/Sub: Testing Tool -> Agent
Description: TBD
"""
......@@ -329,7 +329,7 @@ class MsgTestingToolTerminate(Message):
Type: Event
Typical_use: GUI, (or Orchestrator) -> Testing Tool
Pub/Sub: GUI, (or Orchestrator) -> Testing Tool
Description: Testing tool should stop all it's processes gracefully.
"""
......@@ -365,7 +365,7 @@ class MsgTestingToolComponentReady(Message):
Type: Event
Typical_use: Any Testing tool's component -> Test Coordinator
Pub/Sub: Any Testing tool's component -> Test Coordinator
Description: Once a testing tool's component is ready, it should publish a compoennt ready message
"""
......@@ -384,7 +384,7 @@ class MsgInteropSessionConfiguration(Message):
Type: Event
Typical_use: Orchestrator -> Testing Tool
Pub/Sub: Orchestrator -> Testing Tool
Description: Testing tool MUST listen to this message and configure the testsuite correspondingly
"""
......@@ -433,13 +433,33 @@ class MsgInteropSessionConfiguration(Message):
}
class MsgAgentConfigured(Message):
"""
Requirements: Testing Tool SHOULD publish event
Type: Event
Pub/Sub: Testing Tool -> GUI
Description: The goal is to notify GUI when agents are ready to start the session
"""
routing_key = "control.session"
_msg_data_template = {
"_type": "agent.configured",
"description": "Event agent successfully CONFIGURED",
'name': 'agent_TT'
}
class MsgTestingToolConfigured(Message):
"""
Requirements: Testing Tool MUST publish event
Type: Event
Typical_use: Testing Tool -> Orchestrator, GUI
Pub/Sub: Testing Tool -> Orchestrator, GUI
Description: The goal is to notify orchestrator and other components that the testing tool has been configured
"""
......@@ -460,7 +480,7 @@ class MsgTestingToolComponentShutdown(Message):
Type: Event
Typical_use: Any Testing tool's component -> Test Coordinator
Pub/Sub: Any Testing tool's component -> Test Coordinator
Description: tbd
"""
......@@ -481,7 +501,7 @@ class MsgTestSuiteStart(Message):
Type: Event
Typical_use: GUI -> Testing Tool
Pub/Sub: GUI -> Testing Tool
Description: tbd
"""
......@@ -500,7 +520,7 @@ class MsgTestSuiteFinish(Message):
Type: Event
Typical_use: GUI -> Testing Tool
Pub/Sub: GUI -> Testing Tool
Description: tbd
"""
......@@ -519,7 +539,7 @@ class MsgTestCaseReady(Message):
Type: Event
Typical_use: GUI -> Testing Tool
Pub/Sub: GUI -> Testing Tool
Description:
- Used to indicate to the GUI (or automated-iut) which is the next test case to be executed.
......@@ -544,7 +564,7 @@ class MsgTestCaseStart(Message):
Type: Event
Typical_use: GUI -> Testing Tool
Pub/Sub: GUI -> Testing Tool
Description:
- Message used for indicating the testing tool to start the test case (the one previously selected)
......@@ -566,7 +586,7 @@ class MsgTestCaseConfiguration(Message):
Type: Event
Typical_use: Testing Tool -> GUI & automated-iut
Pub/Sub: Testing Tool -> GUI & automated-iut
Description:
- Message used to indicate GUI and/or automated-iut which configuration to use.
......@@ -609,7 +629,7 @@ class MsgTestCaseStop(Message):
Type: Event
Typical_use: GUI & automated-iut -> Testing Tool
Pub/Sub: GUI & automated-iut -> Testing Tool
Description:
- Message used for indicating the testing tool to stop the test case (the one running).
......@@ -629,7 +649,7 @@ class MsgTestCaseRestart(Message):
Type: Event
Typical_use: GUI -> Testing Tool
Pub/Sub: GUI -> Testing Tool
Description: Restart the running test cases.
"""
......@@ -648,7 +668,7 @@ class MsgStepStimuliExecute(Message):
Type: Event
Typical_use: Testing Tool -> GUI
Pub/Sub: Testing Tool -> GUI
Description:
- Used to indicate to the GUI (or automated-iut) which is the stimuli step to be executed by the user (or
......@@ -681,7 +701,7 @@ class MsgStepStimuliExecuted(Message):
Type: Event
Typical_use: GUI (or automated-IUT)-> Testing Tool
Pub/Sub: GUI (or automated-IUT)-> Testing Tool
Description:
- Used to indicate stimuli has been executed by user (and it's user-assisted iut) or by automated-iut
......@@ -703,7 +723,7 @@ class MsgStepCheckExecute(Message):
Type: Event
Typical_use: Testing Tool -> Analysis
Pub/Sub: Testing Tool -> Analysis
Description:
- Used to indicate to the GUI (or automated-iut) which is the stimuli step to be executed by the user (or
......@@ -736,7 +756,7 @@ class MsgStepCheckExecuted(Message):
Type: Event
Typical_use: test coordination -> test analysis
Pub/Sub: test coordination -> test analysis
Description:
- In the context of IUT to IUT test execution, this message is used for indicating that the previously
......@@ -760,7 +780,7 @@ class MsgStepVerifyExecute(Message):
Type: Event
Typical_use: Testing Tool -> GUI (or automated-IUT)
Pub/Sub: Testing Tool -> GUI (or automated-IUT)
Description:
- Used to indicate to the GUI (or automated-iut) which is the verify step to be executed by the user (or
......@@ -793,7 +813,7 @@ class MsgStepVerifyExecuted(Message):
Type: Event
Typical_use: GUI (or automated-IUT)-> Testing Tool
Pub/Sub: GUI (or automated-IUT)-> Testing Tool
Description:
- Message generated by user (GUI or automated-IUT) declaring if the IUT VERIFY verifies the expected behaviour.
......@@ -816,7 +836,7 @@ class MsgStepVerifyExecuted(Message):
#
# Requirements: Testing Tool MAY listen to event
# Type: Event
# Typical_use: GUI (or automated-IUT)-> Testing Tool
# Pub/Sub: GUI (or automated-IUT)-> Testing Tool
# Description:
# - Used for indicating that the test case has finished.
# - Test coordinator deduces it automatically by using the testcase's step sequence
......@@ -836,7 +856,7 @@ class MsgTestCaseFinished(Message):
Type: Event
Typical_use: Testing Tool -> GUI
Pub/Sub: Testing Tool -> GUI
Description:
- Used for indicating to subscribers that the test cases has finished.
......@@ -859,7 +879,7 @@ class MsgTestCaseSkip(Message):
Type: Event
Typical_use: GUI (or automated-IUT)-> Testing Tool
Pub/Sub: GUI (or automated-IUT)-> Testing Tool
Description:
- Used for skipping a test cases event when was previusly selected to be executed.
......@@ -882,7 +902,7 @@ class MsgTestCaseSelect(Message):
Type: Event
Typical_use: GUI (or automated-IUT)-> Testing Tool
Pub/Sub: GUI (or automated-IUT)-> Testing Tool
Description: tbd
......@@ -902,7 +922,7 @@ class MsgTestSuiteAbort(Message):
Type: Event
Typical_use: GUI (or automated-IUT)-> Testing Tool
Pub/Sub: GUI (or automated-IUT)-> Testing Tool
Description: Event test suite ABORT
"""
......@@ -921,7 +941,7 @@ class MsgTestSuiteGetStatus(Message):
Type: Request (service)
Typical_use: GUI -> Testing Tool
Pub/Sub: GUI -> Testing Tool
Description:
- Describes current state of the test suite.
......@@ -941,7 +961,7 @@ class MsgTestSuiteGetStatusReply(MsgReply):
Type: Reply (service)
Typical_use: Testing Tool -> GUI
Pub/Sub: Testing Tool -> GUI
Description:
- Describes current state of the test suite.
......@@ -967,7 +987,7 @@ class MsgTestSuiteGetTestCases(Message):
Type: Request (service)
Typical_use: GUI -> Testing Tool
Pub/Sub: GUI -> Testing Tool
Description: TBD
"""
......@@ -985,7 +1005,7 @@ class MsgTestSuiteGetTestCasesReply(MsgReply):
Type: Reply (service)
Typical_use: Testing Tool -> GUI
Pub/Sub: Testing Tool -> GUI
Description: TBD
"""
......@@ -1024,7 +1044,7 @@ class MsgTestCaseVerdict(Message):
Type: Event
Typical_use: Testing Tool -> GUI
Pub/Sub: Testing Tool -> GUI
Description: Used to indicate to the GUI (or automated-iut) which is the final verdict of the testcase.
"""
......@@ -1060,7 +1080,7 @@ class MsgTestSuiteReport(Message):
Type: Event
Typical_use: Testing Tool -> GUI
Pub/Sub: Testing Tool -> GUI
Description: Used to indicate to the GUI (or automated-iut) the final results of the test session.
"""
......@@ -1123,7 +1143,7 @@ class MsgSniffingStart(Message):
Type: Request (service)
Typical_use: coordination -> sniffing
Pub/Sub: coordination -> sniffing
Description: tbd
"""
......@@ -1142,7 +1162,7 @@ class MsgSniffingStartReply(MsgReply):
"""
Requirements: Testing Tool SHOULD implement (other components should not subscribe to event)
Type: Reply (service)
Typical_use: sniffing -> coordination
Pub/Sub: sniffing -> coordination
Description: tbd
"""
......@@ -1160,7 +1180,7 @@ class MsgSniffingStop(Message):
Type: Request (service)
Typical_use: coordination -> sniffing
Pub/Sub: coordination -> sniffing
Description: tbd
"""
......@@ -1178,7 +1198,7 @@ class MsgSniffingStoptReply(MsgReply):
Type: Reply (service)
Typical_use: sniffing -> coordination
Pub/Sub: sniffing -> coordination
Description: tbd
"""
......@@ -1197,7 +1217,7 @@ class MsgSniffingGetCapture(Message):
Type: Request (service)
Typical_use: coordination -> sniffing
Pub/Sub: coordination -> sniffing
Description: tbd
"""
......@@ -1217,7 +1237,7 @@ class MsgSniffingGetCaptureReply(MsgReply):
Type: Reply (service)
Typical_use: sniffing -> coordination
Pub/Sub: sniffing -> coordination
Description: tbd
"""
......@@ -1238,7 +1258,7 @@ class MsgSniffingGetCaptureLast(Message):
Type: Request (service)
Typical_use: coordination -> sniffing
Pub/Sub: coordination -> sniffing
Description: tbd
"""
......@@ -1256,7 +1276,7 @@ class MsgSniffingGetCaptureLastReply(MsgReply):
Type: Reply (service)
Typical_use: sniffing -> coordination
Pub/Sub: sniffing -> coordination
Description: tbd
"""
......@@ -1279,7 +1299,7 @@ class MsgInteropTestCaseAnalyze(Message):
Type: Request (service)
Typical_use: coordination -> analysis
Pub/Sub: coordination -> analysis
Description:
- Method to launch an analysis from a pcap file or a token if the pcap file has already been provided.
......@@ -1307,11 +1327,10 @@ class MsgInteropTestCaseAnalyzeReply(MsgReply):
Type: Reply (service)
Typical_use: analysis -> coordination
Pub/Sub: analysis -> coordination
Description:
- The recommended structure for the partial_verdicts field is a list of partial verdicts with the following
requirements:
- The recommended structure for the partial_verdicts field is a list of partial verdicts which complies to:
- each one of those elements of the list correspond to one CHECK or VERIFY steps of the test description
- first value of the list MUST be a "pass", "fail", "inconclusive" or eventually "error" partial verdict (
string)
......@@ -1359,7 +1378,7 @@ class MsgDissectionDissectCapture(Message):
Type: Request (service)
Typical_use: coordination -> dissection, analysis -> dissection
Pub/Sub: coordination -> dissection, analysis -> dissection
Description: TBD
"""
......@@ -1390,7 +1409,7 @@ class MsgDissectionDissectCaptureReply(MsgReply):
Type: Reply (service)
Typical_use: Dissector -> Coordinator, Dissector -> Analyzer
Pub/Sub: Dissector -> Coordinator, Dissector -> Analyzer
Description: TBD
"""
......@@ -1445,7 +1464,7 @@ class MsgDissectionAutoDissect(Message):
Type: Event
Typical_use: Testing Tool -> GUI
Pub/Sub: Testing Tool -> GUI
Description: Used to indicate to the GUI the dissection of the exchanged packets.
- GUI MUST display this info during execution:
......@@ -1639,6 +1658,7 @@ class MsgPrivacyIssue(Message):
"verdict": json.dumps(MsgPrivacyAnalyzeReply._privacy_empty_report),
}
# # # # # # PERFORMANCE TESTING TOOL MESSAGES # # # # # #
class MsgPerformanceHeartbeat(Message):
......@@ -1653,11 +1673,12 @@ class MsgPerformanceHeartbeat(Message):
routing_key = "control.performance"
_msg_data_template = {
"_type" : "performance.heartbeat",
"mod_name" : "unknown"
"status" : "ready", # ready, configured or failed
"_type": "performance.heartbeat",
"mod_name": "unknown",
"status": "ready", # ready, configured or failed
}
class MsgPerformanceConfiguration(Message):
"""
Requirements: Timeline Controller MUST listen to event
......@@ -1669,14 +1690,15 @@ class MsgPerformanceConfiguration(Message):
routing_key = "control.performance"
_msg_data_template = {
"_type" : "performance.configuration",
"configuration" : { # As produced by configuration GUI
"static" : { }, # Static configuration of submodules
"initial" : { }, # Initial values for dynamic parameters
"segments" : [ ], # Timeline segments
"_type": "performance.configuration",
"configuration": { # As produced by configuration GUI
"static": {}, # Static configuration of submodules
"initial": {}, # Initial values for dynamic parameters
"segments": [], # Timeline segments
}
}
class MsgPerformanceSetValues(Message):
"""
Requirements: Performance Submodules MUST listen to event
......@@ -1689,10 +1711,11 @@ class MsgPerformanceSetValues(Message):
routing_key = "control.performance"
_msg_data_template = {
"_type" : "performance.setvalues",
"values" : { }
"_type": "performance.setvalues",
"values": {}
}
class MsgPerformanceStats(Message):
"""
Requirements: Performance Submodules SHOULD emit this event periodically
......@@ -1706,13 +1729,15 @@ class MsgPerformanceStats(Message):
routing_key = "control.performance"
_msg_data_template = {
"_type" : "performance.setvalues",
"mod_name" : "unknown",
"timestamp" : 0,
"stats" : { },
"_type": "performance.setvalues",
"mod_name": "unknown",
"timestamp": 0,
"stats": {},
}
message_types_dict = {
"agent.configured": MsgAgentConfigured, # TestingTool -> GUI
"tun.start": MsgAgentTunStart, # TestingTool -> Agent
"tun.started": MsgAgentTunStarted, # Agent -> TestingTool
"session.interop.configuration": MsgInteropSessionConfiguration, # Orchestrator -> TestingTool
......@@ -1766,10 +1791,10 @@ message_types_dict = {
"privacy.configuration.set": MsgPrivacySetConfiguration, # GUI -> TestingTool,
"privacy.configuration.set.reply": MsgPrivacySetConfigurationReply, # GUI -> TestingTool (reply),
# PERFORMANCE TESTING TOOL -> Reference: Eduard Bröse (EANTC)
"performance.heartbeat": MsgPerformanceHeartbeat, # Perf. Submodules -> Timeline Controller
"performance.configuration": MsgPerformanceConfiguration, # Orchestrator -> Timeline Controller
"performance.stats": MsgPerformanceStats, # Perf. Submodules -> Visualization
"performance.setvalues": MsgPerformanceSetValues, # Timeline Controller -> Perf. Submodules
"performance.heartbeat": MsgPerformanceHeartbeat, # Perf. Submodules -> Timeline Controller
"performance.configuration": MsgPerformanceConfiguration, # Orchestrator -> Timeline Controller
"performance.stats": MsgPerformanceStats, # Perf. Submodules -> Visualization
"performance.setvalues": MsgPerformanceSetValues, # Timeline Controller -> Perf. Submodules
}
......
"""
Module for building automatically the doc of the API messages in markdown format.
"""
import inspect
from messages import *
import inspect
gitlab_url = 'https://gitlab.f-interop.eu/f-interop-contributors/utils/blob/master/messages.py'
doc_parser = 'https://gitlab.f-interop.eu/f-interop-contributors/utils/blob/master/messages_doc.py'
header = """Messages format
This section describes the format of the messages used by the testing tool.
This section of the documentation is autogenerated by
[tool](https://gitlab.f-interop.eu/f-interop-contributors/utils/blob/master/messages_doc.py)
[tool](%s)
Check out the messages library
[tool](%s)
Version %s
""" %API_VERSION
""" % (doc_parser, gitlab_url, API_VERSION)
services = []
events = []
def message_amqp_section(file, message_instance):
file.write("\n\n```amqp")
file.write("\n %s" % message_instance)
file.write("\n ```")
return
def message_json_section(file, message_instance):
file.write("\n\n```json")
file.write("\n %s" % json.dumps(message_instance.to_dict(),indent=4,))
file.write("\n %s" % json.dumps(message_instance.to_dict(), indent=4, ))
file.write("\n ```")
return
def print_doc_tables(services, events):
"""
......@@ -42,8 +49,10 @@ def print_doc_tables(services, events):
|SERVICES | DESCRIPTION|
|---| ---|
|[*testcoordination.testsuite.getstatus*](#testcoordination-testsuite-getstatus) | Message for debugging purposes. The coordination component returns the status of the execution |
|[*testcoordination.testsuite.gettestcases*](#testcoordination-testsuite-gettestcases) | Message for requesting the list of test cases included in the test suite.|
|[*testcoordination.testsuite.getstatus*](#testcoordination-testsuite-getstatus) | Message for debugging
purposes. The coordination component returns the status of the execution |
|[*testcoordination.testsuite.gettestcases*](#testcoordination-testsuite-gettestcases) | Message for requesting
the list of test cases included in the test suite.|
### API events
......@@ -51,16 +60,20 @@ def print_doc_tables(services, events):
|MESSAGES CONSUMED | DESCRIPTION|
|---| ---|
|[*testcoordination.testsuite.start*](#testcoordination-testsuite-start) | Message for triggering start of test suite. The command is given by one of the users of the session.|
|[*testcoordination.testsuite.abort*](#testcoordination-testsuite-abort)| Message for aborting the ongoing test session.|
|[*testcoordination.testcase.skip*](#testcoordination-testcase-skip) | Message for skipping a test case. Coordinator passes to the next test case if there is any left.|
|[*testcoordination.testsuite.start*](#testcoordination-testsuite-start) | Message for triggering start of test
suite. The command is given by one of the users of the session.|
|[*testcoordination.testsuite.abort*](#testcoordination-testsuite-abort)| Message for aborting the ongoing test
session.|
|[*testcoordination.testcase.skip*](#testcoordination-testcase-skip) | Message for skipping a test case.
Coordinator passes to the next test case if there is any left.|
Coordinator generates and publishes the following messages:
|MESSAGES PUBLISHED | DESCRIPTION|
|---| ---|
|[*testcoordination.testcase.next*](#testcoordination-testcase-next) | Indicates next testcase to be executed |
|[*testcoordination.testsuite.finished*](#testcoordination-testsuite-finished) | Indicates there's no more test cases to execute |
|[*testcoordination.testsuite.finished*](#testcoordination-testsuite-finished) | Indicates there's no more test
cases to execute |
|[*testcoordination.error*](#testcoordination-error) | Message used to indicate errors on coordiation component |
......@@ -86,12 +99,12 @@ TBD listens and consumes the following messages from the bus:
|---| ---|"""
def table_row(event_type):
s=""
s+="|[*%s*](#%s) | Some description that needs to be writen manually |"\
%(
event_type,
event_type.replace('.','-')
)
s = ""
s += "|[*%s*](#%s) | Some description that needs to be writen manually |" \
% (
event_type,
event_type.replace('.', '-')
)
return s
print(head_1)
......@@ -111,7 +124,6 @@ TBD listens and consumes the following messages from the bus:
print(table_row(e._type))
if __name__ == '__main__':
with open('_messages.md', "w+") as f:
......@@ -122,27 +134,68 @@ if __name__ == '__main__':
for msg_type, msg_class in sorted(message_types_dict.items()):
# Message Type
f.write('\n\n\n## %s' %(msg_type))
f.write('\n\n\n## %s' % (msg_type))
# Message docstring
f.write('\n\n### Description:\n%s' % (msg_class.__doc__))
# Header
f.write('\n\n### Description:\n\n')
# Message code source:
line_number = (inspect.findsource(msg_class)[1])
url = gitlab_url + "#L%s" %line_number
f.write('\n\n### Source code: \n[%s](%s)\n' %(msg_class.__name__,url))
# markdown table header
f.write("\n| []() | |\n| --- | --- |\n")
md_bullet_list = ''
unknown = ''
# Message class docstring to table
for line in msg_class.__doc__.splitlines():
if line and not line.isspace():