DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 2 | Documentation The main interface for interacting with Message router. It handles low level stuff like managing the http request library and message router required fields |
| 3 | Library RequestsClientCert |
| 4 | Library RequestsLibrary |
| 5 | Library UUID |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 6 | |
| 7 | Resource global_properties.robot |
| 8 | |
| 9 | *** Variables *** |
| 10 | ${MR_HEALTH_CHECK_PATH} /topics |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 11 | ${MR_PUB_HEALTH_CHECK_PATH} /events/TEST_TOPIC |
| 12 | ${MR_SUB_HEALTH_CHECK_PATH} /events/TEST_TOPIC/g1/c4?timeout=5000 |
Jerry Flood | 8fd592b | 2017-07-29 07:31:50 -0400 | [diff] [blame] | 13 | ${MR_ENDPOINT} ${GLOBAL_MR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_MR_IP_ADDR}:${GLOBAL_MR_SERVER_PORT} |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 14 | ${MR_PUBLISH_TEMPLATE} robot/assets/templates/mr_publish.template |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 15 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 16 | |
| 17 | *** Keywords *** |
| 18 | Run MR Health Check |
| 19 | [Documentation] Runs MR Health check |
Jerry Flood | 8fd592b | 2017-07-29 07:31:50 -0400 | [diff] [blame] | 20 | ${resp}= Run MR Get Request ${MR_HEALTH_CHECK_PATH} |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 21 | Should Be Equal As Strings ${resp.status_code} 200 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 22 | Should Contain ${resp.json()} topics |
Jerry Flood | 8fd592b | 2017-07-29 07:31:50 -0400 | [diff] [blame] | 23 | |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 24 | Run MR PubSub Health Check |
| 25 | [Documentation] Runs MR PubSub Health check |
Brian Freeman | a8ceb69 | 2019-03-03 09:37:54 -0500 | [diff] [blame] | 26 | #${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH} |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 27 | # topic may not be created which is a 400 error |
Brian Freeman | a8ceb69 | 2019-03-03 09:37:54 -0500 | [diff] [blame] | 28 | |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 29 | ${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 Freeman | a8ceb69 | 2019-03-03 09:37:54 -0500 | [diff] [blame] | 33 | # 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 Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 36 | # ${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 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 40 | Run MR Get Request |
| 41 | [Documentation] Runs MR Get request |
| 42 | [Arguments] ${data_path} |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 43 | ${session}= Create Session mr ${MR_ENDPOINT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 44 | ${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 Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 46 | ${resp}= Get Request mr ${data_path} headers=${headers} |
| 47 | Log Received response from message router ${resp.text} |
| 48 | [Return] ${resp} |
| 49 | |
| 50 | Run 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} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 60 | Log Received response from message router ${resp.text} |
| 61 | [Return] ${resp} |
| 62 | |