Support for MongoDB [message #1769509] |
Tue, 01 August 2017 07:35 |
Krisztian Gulyas Messages: 1 Registered: July 2017 |
Junior Member |
|
|
Dear forum members,
MongoDB is a NoSQL document database that has been enthusiastically embraced by the IoT community. Support for MongoDB in Titan comes in various forms: BSON serialization of JSON documents (see this forum link) and the MongoDB protocol module (http://git.eclipse.org/c/titan/titan.ProtocolModules.MongoDB.git), to be used together with a TCP/TLS transport, e.g. the IPL4 test port, representing an implementation of the https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/ MongoDB wire protocol.
Design considerations
The MongoDB Wire Protocol is a simple socket-based, request-response style protocol. Clients communicate with the database server through a regular TCP/IP socket. Hence MongoDB protocol has been implemented as a protocol module on the top of the TITAN TCP communication infrastructure.
Implementation details
MongoDB_Types.ttcn:
- Basic type definitions and its binary/octet representation (RAW encoding)
- OP_CODE definition
- Message header definition
- Insert, Update, Query, Delete, Get More, Kill Cursor, Reply, Command and Command Reply message definitions
- A generic message type (Msg) as the union of all possible message types
MongoDB_Functions.ttcn:
- MsgLen helper function for TCP layer to provide the proper length of the
corresponding message
- bsonStream2json function to extract json messages from the BSON stream (more BSON documents)
Test suite
You can test MongoDB communication with the simple test example defined in the src/ProtocolModules/MongoDB/demo folder:
This demo uses IPL4asp TITAN module for TCP communication:
SimpleTCP.ttcn: additional encapsulation object for more convenient usage of IPL4asp (send/receive data over the TCP layer)
mongoDBTest.ttcn:
- template definitions for messages and reply messages
- simple send/(receive) test for various MongoDB messages
- using the functionality of the new bson/json converter
Content of the folders:
src/
- install.sh (LINUX): creates symbolic links for source files linked from src/
- Makefile (LINUX)
- ProtocolModules: MongoDB definitions and demo folder
- TestPort: IPL4asp and Socket_API definitions for TCP communication
bin/
- building folder
Prerequisites
mongoDB access (local or remote):
Prepare your TTCN MongoDB test
unpack mongoDBTest.zip file, then create symbolic links with:
> cd MongoDBTest/bin
> ../src/install.script
set up your mongoDB connection parameters (host/port) in mongoDB.cfg file:
...
// Local TCP connection address
LocalTCPConnection := { "127.0.0.1", 3000 };
// Remote TCP connection address (mongoDB database)
RemoteTCPConnection := { "127.0.0.1", 27017 };
...
Build and run test(s)
> make
> ./mongoDBTest ../cfg/mongoDB.cfg
Check the results
> cat logs/[#logfilename#] | grep USER
Additional info/help
- The Makefile was generated with: makefilegen -s -e mongoDBTest *.ttcn *.cc *.hh
- The tests are not production-ready, they are provided as examples to be used as starting points for further development.
Best regards,
Krisztian
-
Attachment: mongoDB.zip
(Size: 311.25KB, Downloaded 93 times)
[Updated on: Wed, 02 August 2017 06:09] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03347 seconds