blob: 625198dca3d536767428187482b4be3dca25f38b [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
Brian Freeman19a4d2d2018-11-30 13:03:52 -05002Documentation The main interface for interacting with Message router. It handles low level stuff like managing the http request library and message router required fields
3Library RequestsClientCert
4Library RequestsLibrary
5Library UUID
DR695Hccff30b2017-02-17 18:44:24 -05006
7Resource global_properties.robot
8
9*** Variables ***
10${MR_HEALTH_CHECK_PATH} /topics
Brian Freeman19a4d2d2018-11-30 13:03:52 -050011${MR_PUB_HEALTH_CHECK_PATH} /events/TEST_TOPIC
12${MR_SUB_HEALTH_CHECK_PATH} /events/TEST_TOPIC/g1/c4?timeout=5000
Jerry Flood8fd592b2017-07-29 07:31:50 -040013${MR_ENDPOINT} ${GLOBAL_MR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_MR_IP_ADDR}:${GLOBAL_MR_SERVER_PORT}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050014${MR_PUBLISH_TEMPLATE} robot/assets/templates/mr_publish.template
DR695Hbf5a3a32017-06-30 13:09:57 -040015
DR695Hccff30b2017-02-17 18:44:24 -050016
17*** Keywords ***
18Run MR Health Check
19 [Documentation] Runs MR Health check
Jerry Flood8fd592b2017-07-29 07:31:50 -040020 ${resp}= Run MR Get Request ${MR_HEALTH_CHECK_PATH}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050021 Should Be Equal As Strings ${resp.status_code} 200
DR695Hccff30b2017-02-17 18:44:24 -050022 Should Contain ${resp.json()} topics
Jerry Flood8fd592b2017-07-29 07:31:50 -040023
Brian Freeman19a4d2d2018-11-30 13:03:52 -050024Run MR PubSub Health Check
25 [Documentation] Runs MR PubSub Health check
26 ${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH}
27 # topic may not be created which is a 400 error
28 ${resp}= Run MR Post Request ${MR_PUB_HEALTH_CHECK_PATH}
29 Should Be Equal As Strings ${resp.status_code} 200
30 Should Contain ${resp.json()} serverTimeMs Failed to Write Data
31 ${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH}
32 # ${resp} is an array
33 Should Be Equal As Strings ${resp.status_code} 200
34 Should Contain ${resp.json()[0]} timestamp Failed to Read Data
35
DR695Hccff30b2017-02-17 18:44:24 -050036Run MR Get Request
37 [Documentation] Runs MR Get request
38 [Arguments] ${data_path}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050039 ${session}= Create Session mr ${MR_ENDPOINT}
DR695Hccff30b2017-02-17 18:44:24 -050040 ${uuid}= Generate UUID
41 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050042 ${resp}= Get Request mr ${data_path} headers=${headers}
43 Log Received response from message router ${resp.text}
44 [Return] ${resp}
45
46Run MR Post Request
47 [Documentation] Runs MR Post request
48 [Arguments] ${data_path}
49 ${session}= Create Session mr ${MR_ENDPOINT}
50 ${timestamp}= Get Current Date
51 ${dict}= Create Dictionary timestamp=${timestamp}
52 ${data}= Fill JSON Template File ${MR_PUBLISH_TEMPLATE} ${dict}
53 ${uuid}= Generate UUID
54 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
55 ${resp}= Post Request mr ${data_path} data=${data} headers=${headers}
DR695Hccff30b2017-02-17 18:44:24 -050056 Log Received response from message router ${resp.text}
57 [Return] ${resp}
58