blob: 29e9dd3eb60ddc7ce245369b8d9a087433059060 [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
Brian Freemana8ceb692019-03-03 09:37:54 -050026 #${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050027 # topic may not be created which is a 400 error
Brian Freemana8ceb692019-03-03 09:37:54 -050028
Brian Freeman19a4d2d2018-11-30 13:03:52 -050029 ${resp}= Run MR Post Request ${MR_PUB_HEALTH_CHECK_PATH}
30 Should Be Equal As Strings ${resp.status_code} 200
31 Should Contain ${resp.json()} serverTimeMs Failed to Write Data
32 ${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH}
Brian Freemana8ceb692019-03-03 09:37:54 -050033 # Always Write twice to catch lost first message
34 ${resp}= Run MR Post Request ${MR_PUB_HEALTH_CHECK_PATH}
35 ${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050036 # ${resp} is an array
37 Should Be Equal As Strings ${resp.status_code} 200
38 Should Contain ${resp.json()[0]} timestamp Failed to Read Data
39
DR695Hccff30b2017-02-17 18:44:24 -050040Run MR Get Request
41 [Documentation] Runs MR Get request
42 [Arguments] ${data_path}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050043 ${session}= Create Session mr ${MR_ENDPOINT}
DR695Hccff30b2017-02-17 18:44:24 -050044 ${uuid}= Generate UUID
45 ${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 -050046 ${resp}= Get Request mr ${data_path} headers=${headers}
47 Log Received response from message router ${resp.text}
48 [Return] ${resp}
49
50Run MR Post Request
51 [Documentation] Runs MR Post request
52 [Arguments] ${data_path}
53 ${session}= Create Session mr ${MR_ENDPOINT}
54 ${timestamp}= Get Current Date
55 ${dict}= Create Dictionary timestamp=${timestamp}
56 ${data}= Fill JSON Template File ${MR_PUBLISH_TEMPLATE} ${dict}
57 ${uuid}= Generate UUID
58 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
59 ${resp}= Post Request mr ${data_path} data=${data} headers=${headers}
DR695Hccff30b2017-02-17 18:44:24 -050060 Log Received response from message router ${resp.text}
61 [Return] ${resp}
62