(→Opening and Closing Broker Connection) |
(→Messaging Sub-system) |
||
| Line 174: | Line 174: | ||
==== Messaging Sub-system ==== | ==== Messaging Sub-system ==== | ||
| - | Qpid broker supports currently AMQP 0-10. Qpid provides a C++ version of the Client API for communicating with broker (http://qpid.apache.org/apis/0.8/cpp/html/). [[http://qpid.apache.org/apis/0.8/cpp/html/a00479.html Messaging API]] abstracts the the AMQP protocol specific functionality very well | + | Qpid broker supports currently AMQP 0-10. Qpid provides a C++ version of the Client API for communicating with broker (http://qpid.apache.org/apis/0.8/cpp/html/). [[http://qpid.apache.org/apis/0.8/cpp/html/a00479.html Messaging API]] abstracts the the AMQP protocol specific functionality very well. This allows the developers to put their focus on message sending and receiving without needing to worry about the underlying AMQP. Downside of the Qpid is, that it doesn't provide C-language version of the API. This is clearly needed since many of the test tools and cases are implemented in C. Therefore a C-wrapper for the Qpid C++ Messaging API is provided. |
'''Draft''' version of wrapper can be found from here: http://gitorious.org/qpid-c-wrapper | '''Draft''' version of wrapper can be found from here: http://gitorious.org/qpid-c-wrapper | ||
| Line 187: | Line 187: | ||
* Client in the picture represents a test case or test tool (e.g. testrunner-lite) which communicates via Qpid | * Client in the picture represents a test case or test tool (e.g. testrunner-lite) which communicates via Qpid | ||
* libqpidc is the C-wrapper for the Qpid C++ Client API | * libqpidc is the C-wrapper for the Qpid C++ Client API | ||
| + | |||
| + | Qpid uses addresses to identify message senders and receiver. Both are create to a specific address which is just a string. Client API supports currently to types of adresses: '''queues''' and '''topics'''. | ||
| + | |||
| + | * Messages sent to queues are stored to the broker and delivered, when there is a subscriber for the message. Each message is allocated to a one subscriber | ||
| + | * Messages sent to topics are not stored, and delivered to all subscribers | ||
| + | |||
| + | In AMQP, addresses can have a '''subject''' and a routing key is use to deliver the message to a correct subscriber. | ||
| + | |||
| + | In this context we can map address type: '''queue''' or '''topic''' and '''subject''' in the following way to achieve the needed messaging patterns: | ||
| + | |||
| + | * '''address''' is a name of a service providing some specific functionality e.g. '''call_service''' providing services for answering, creating phone calls etc. | ||
| + | ** To send a message to a '''queue''' type of address, a request - response messaging pattern is achieved for requesting some service. | ||
| + | ** To send a message to a '''topic''' type of address, a publish - subscribe messaging pattern is achieved for requesting some service from multiple services or receiving an event when something has happened. | ||
| + | * '''subject''' is a name of the request or event provided by the service. | ||
| + | |||
| + | Address - subject pairs are described with the following syntax: '''Address / [subject]''' e.g. call_service/create_phone_call. | ||
==== Opening and Closing Broker Connection ==== | ==== Opening and Closing Broker Connection ==== | ||
!!!!!!!!!!! WORK IN PROGRESS !!!!!!!!!!!
Contents |
This document provides a technical architecture and system design for MCTS Test Automation environment. The purpose is to introduce a new subsystem to the existing MeeGo test automation environment (OTS), where external devices can be connected and controlled on test case or test step level. In this context an external device can for example be, a network simulator, a WLAN analyzer or even another DUT. The new subsystem utilizes test tools already in place in MeeGo by extending their functionality, and also introduces additional components to provide needed new functionality. Suitable open-source will also be utilized as much as it is rationale to do. Intended readers for this document are the developers contributing MeeGo QA Tools area and MCTS test asset developers. Contributions to this document are welcome.
This document first gives an insight to the overall system with some background information before moving to the system architecture and detailed design chapters. Document focuses on solving following design issues:
| Term | Definition |
|---|---|
| DUT | Device Under Test |
| OTS | Link to wiki |
| test-definition | Link to wiki |
| testrunner-lite | Link to wiki |
| Testrunner | Link to wiki |
| AMQP | [Advanced Message Queuing Protocol] |
Current OTS environment allows to execute test cases in a single DUT. When executing automated functional test cases in a simulated live environment, it is usually required to verify the result from another device. An example from such test case would be a voice call between two or more DUTs. This is a typical master – slave test case, where master DUT is used to initiate MO call, which is then verified in the receiving slave device. Another situation, when test case verdict needs to be verified from external device is for example tests related to audio playback. In this case the result is fetched from audio analyzer for example. This design will introduce new messaging and communication method to the system, which is used to handle interaction between devices. The system overview is presented in Picture 1.
Any assumptions, dependencies and requirements regarding the system and operating environment are listed here.
Any global limitations or constraints that have a significant impact on the design of the system's software are listed here.
For controlling multiple devices and executing commands either sequential or parallel, some short of event/mesaging mechanism is clearly needed. Implementing such subsystem from scratch would require too much effort. Thus existing open solutions are studied and utilized for this. Also extending some of the existing test tools (e.g. OTS) with such functionality would make the architecture too complex. To keep architecture modular, the component controlling handling the communication should be its own subsystem, which then will be connected to OTS.
This section describes the chosen architecture for the system. Also, the alternative architectures, which have been considered are discussed here.
Picture 2 illustrates the layered architecture of the system. NOTE: only the essential components are shown in the picture.
Picture 3 illustrates the component view of the architecture. Each component in the diagram represents an individual subsystem (executable, library or data). For simplicity, only the relevant component and interfaces are described. Note: component names are preliminary.
For communication between devices, system will be using Advanced Message Queuing Protocol (AMQP).
Selected components for the message exchange are:
Qpid broker supports currently AMQP 0-10. Qpid provides a C++ version of the Client API for communicating with broker (http://qpid.apache.org/apis/0.8/cpp/html/). [Messaging API] abstracts the the AMQP protocol specific functionality very well. This allows the developers to put their focus on message sending and receiving without needing to worry about the underlying AMQP. Downside of the Qpid is, that it doesn't provide C-language version of the API. This is clearly needed since many of the test tools and cases are implemented in C. Therefore a C-wrapper for the Qpid C++ Messaging API is provided.
Draft version of wrapper can be found from here: http://gitorious.org/qpid-c-wrapper
Picture 4 illustrates the messaging sub-system architecture.
Qpid uses addresses to identify message senders and receiver. Both are create to a specific address which is just a string. Client API supports currently to types of adresses: queues and topics.
In AMQP, addresses can have a subject and a routing key is use to deliver the message to a correct subscriber.
In this context we can map address type: queue or topic and subject in the following way to achieve the needed messaging patterns:
Address - subject pairs are described with the following syntax: Address / [subject] e.g. call_service/create_phone_call.
Picture 5 illustrates the sequence for opening and closing the connection to Qpid broker using the libqpidc. Wrapper function names maps closely to the C++ Messaging API.
Rationale, why this approach was chosen.
This section describes architectures which have been considered.
This chapter describes the changes needed to test definition to meet the requirements.
Test definition needs to be extended by introducing new markup for events on test plan XML level. This is achieved by defining new event -element. This element can be a child of pre_steps, case, post_steps and get -elements.
Components affected: testrunner-lite, testrunner
Element event can have the following attributes:
| Attribute | Mandatory/ optional | Description |
|---|---|---|
| type | Mandatory | Defines the event type. |
| name | Mandatory, if type=send or type=wait. | Specifies the name of the event to produce or wait. |
| timeout | Optional | Can be used to together type=get or type=wait. Fails, if response is not received within the specified time. |
Example:
<event type="send" name="event1"/>
Attribute type of the, will be used to define the type of the event. Value can be any of the following:
| Value | Description |
|---|---|
| send | Produces event and sends it to exchange (asynchronous). Used for requesting service from |
| wait | Waits for event. Blocks test run until event is received or timeout occurs. |
Send event is used to request service from another device via AMQP. This event type causes testrunner-lite to send event to message queue. This event type can have zero or more param child elements.
Example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<testdefinition version="0.1">
<suite name="example-suite">
<set name="example-set" description="example tests">
<case name="example-case" description="event tests">
<!-- Send event1 with 2 parameters -->
<event type="send" name="event1">
<param type="string">foo</param>
<param type="number">123</param>
</event>
</case>
</set>
</suite>
</testdefinition>
Parameters (param -element) has a mandatory type attribute, which corresponds to [JSON] data types (except binary type, which is not supported be JSON).
Type attribute can have the following values:
<param type="string">foo</param>
<param type="number">123</param>
<param type="boolean">true</param>
Object type corresponds to JSON object structure forming key/value pairs. Type object SHALL have 1 or more item child elements, which have a MANDATORY name and type -attributes.
<param type="object"> <item name="firstname" type="string">John</item> <item name="lastname" type="string">Doe</item> </param>
Array type corresponds to JSON array structure forming ordered collection of values. Type array SHALL have 1 or more item child elements, which have a MANDATORY type -attribute.
<param type="array"> <item type="string">test</item> <item type="number">1111</item> </param>
JSON doesn't support presenting binary format. Thus, a binary -type introduced is used to present base64 encoded binary data.
<param type="binary">/9j/4AAQSkZJRgABAQAMKKM3c18pHlu0djQPahC5OrN9JlT1S7msOo/LyLRSUbImhkTGsaNTWgNHYF7oQus17be9ghCEICEIQH/9k=</param>
Event type wait causes testrunner-lite to wait for a certain event. This can be used to synchronize test execution between devices.
<event type="wait" name="event2"/>
<event type="wait" name="event2" timeout="30000"/>
With the event support on test plan XML level a sequential test case utilizing multiple devices can be defined as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<testdefinition version="0.1">
<suite name="example-suite">
<set name="seq-example-set" description="sequential example tests">
<case name="seq-example-case" description="sequential event tests">
<!-- Execute in DUT. -->
<step>/usr/bin/test1</step>
<!-- Send event1 with 2 parameters. -->
<event type="send" name="event1">
<param type="string">foo</param>
<param type="number">123</param>
</event>
<!-- Wait for event2. -->
<event type="wait" name="event2"/>
<!-- Execute in DUT. -->
<step>/usr/bin/test2</step>
</case>
</set>
</suite>
</testdefinition>
To support parallel test execution between two testrunner-lite instances for example, a parallel -element is introduced.
<?xml version="1.0" encoding="ISO-8859-1"?>
<testdefinition version="0.1">
<suite name="example-suite">
<set name="paral-example-set" description="parallel example tests">
<parallel>
<case name="paral-example-case1" description="parallel tests">
<step>/usr/bin/test1</step>
<step event="wait">event1</step>
<step event="wait">event2</step>
<step event="send">myevent1</step>
<step event="send">myevent2</step>
</case>
<case name="paral-example-case2" description="parallel tests">
<step event="send">event1</step>
<step event="send">event2</step>
<step event="wait">myevent1</step>
<step event="wait">myevent2</step>
</case>
</parallel>
</set>
</suite>
</testdefinition>
System shall support validating the environment before executing any tests. This is needed to ensure that the environment has the required devices to execute test cases. Test environment is described in the test plan XML enclosed in environment -element. Environment can be defined on testdefinition, suite or set level. Environment MUST have one or more capability -element.
Components affected: testrunner-lite, testrunner, qa-reports, (OTS)
<?xml version="1.0" encoding="ISO-8859-1"?>
<testdefinition version="0.1">
<environment>
<capability>sms</capability>
<capability>phone_call</capability>
<capability>power_measurement</capability>
<environment>
<suite name="example-suite">
<!-- set, case ... -->
</suite>
</testdefinition>
Test plan XML needs to support steps executed on host. This frees testrunner-lite from responsibility of being aware of state information and other logic in test cases. Logic is then implemented in the test case running on host machine. An OPTIONAL target -attribute will be added to step -element to achieve this. If target-attribute is not provided in the test plan, command is executed in the device to maintain backward compatibility.
Components affected: testrunner-lite
<?xml version="1.0" encoding="ISO-8859-1"?>
<testdefinition version="0.1">
<suite name="example-suite">
<set name="example-set" description="example tests">
<case name="example-case" description="event tests">
<step target="host">/usr/bin/test1</step>
<step target="target">/usr/bin/test2</step>
<step>/usr/bin/test2</step>
</case>
</set>
</suite>
</testdefinition>
This section is meant for meeting and planning activities related to this work.