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 |
Brian Freeman | ed66ff9 | 2019-05-02 15:30:02 -0500 | [diff] [blame] | 4 | Library RequestsLibrary |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 5 | Library UUID |
Brian Freeman | ed66ff9 | 2019-05-02 15:30:02 -0500 | [diff] [blame] | 6 | Library DateTime |
| 7 | Library Process |
| 8 | Library JSONUtils |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 9 | |
| 10 | Resource global_properties.robot |
Brian Freeman | ed66ff9 | 2019-05-02 15:30:02 -0500 | [diff] [blame] | 11 | Resource ../resources/json_templater.robot |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 12 | |
| 13 | *** Variables *** |
| 14 | ${MR_HEALTH_CHECK_PATH} /topics |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 15 | ${MR_PUB_HEALTH_CHECK_PATH} /events/TEST_TOPIC |
| 16 | ${MR_SUB_HEALTH_CHECK_PATH} /events/TEST_TOPIC/g1/c4?timeout=5000 |
Brian Freeman | ed66ff9 | 2019-05-02 15:30:02 -0500 | [diff] [blame] | 17 | ${MR_CREATE_TOPIC_PATH} /topics/create |
| 18 | ${MR_UPDATE_ACL_TOPIC_PATH} /topics/TEST_TOPIC_ACL/producers |
Jerry Flood | 8fd592b | 2017-07-29 07:31:50 -0400 | [diff] [blame] | 19 | ${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] | 20 | ${MR_PUBLISH_TEMPLATE} robot/assets/templates/mr_publish.template |
Brian Freeman | ed66ff9 | 2019-05-02 15:30:02 -0500 | [diff] [blame] | 21 | ${MR_PUT_ACL_TEMPLATE} robot/assets/templates/mr_put_acl.template |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 22 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 23 | |
| 24 | *** Keywords *** |
| 25 | Run MR Health Check |
| 26 | [Documentation] Runs MR Health check |
Jerry Flood | 8fd592b | 2017-07-29 07:31:50 -0400 | [diff] [blame] | 27 | ${resp}= Run MR Get Request ${MR_HEALTH_CHECK_PATH} |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 28 | Should Be Equal As Strings ${resp.status_code} 200 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 29 | Should Contain ${resp.json()} topics |
Jerry Flood | 8fd592b | 2017-07-29 07:31:50 -0400 | [diff] [blame] | 30 | |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 31 | Run MR PubSub Health Check |
| 32 | [Documentation] Runs MR PubSub Health check |
Brian Freeman | a8ceb69 | 2019-03-03 09:37:54 -0500 | [diff] [blame] | 33 | #${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH} |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 34 | # topic may not be created which is a 400 error |
Brian Freeman | a8ceb69 | 2019-03-03 09:37:54 -0500 | [diff] [blame] | 35 | |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 36 | ${resp}= Run MR Post Request ${MR_PUB_HEALTH_CHECK_PATH} |
| 37 | Should Be Equal As Strings ${resp.status_code} 200 |
| 38 | Should Contain ${resp.json()} serverTimeMs Failed to Write Data |
| 39 | ${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH} |
Brian Freeman | a8ceb69 | 2019-03-03 09:37:54 -0500 | [diff] [blame] | 40 | # Always Write twice to catch lost first message |
| 41 | ${resp}= Run MR Post Request ${MR_PUB_HEALTH_CHECK_PATH} |
| 42 | ${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH} |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 43 | # ${resp} is an array |
| 44 | Should Be Equal As Strings ${resp.status_code} 200 |
| 45 | Should Contain ${resp.json()[0]} timestamp Failed to Read Data |
| 46 | |
Brian Freeman | ed66ff9 | 2019-05-02 15:30:02 -0500 | [diff] [blame] | 47 | |
| 48 | Run MR Update Topic Acl |
| 49 | [Documentation] Runs MR create topic and update producer credentials |
| 50 | # |
| 51 | # Testing to Delete a Topic: |
| 52 | # /opt/kafka/bin/kafka-topics.sh --zookeeper message-router-zookeeper:2181 --delete --topic <topic_name> |
| 53 | # /opt/kafka/bin/kafka-topics.sh --zookeeper message-router-zookeeper:2181 --delete --topic TEST_TOPIC_ACL |
| 54 | # |
| 55 | # Appears to not care if topic already exists with the POST / PUT method |
| 56 | # |
| 57 | ${dict}= Create Dictionary TOPIC_NAME=TEST_TOPIC_ACL |
| 58 | ${data}= Fill JSON Template File ${MR_PUT_ACL_TEMPLATE} ${dict} |
| 59 | #Log To Console ${\n}Create TEST_TOPIC_ACL |
| 60 | ${resp}= Run MR Auth Post Request ${MR_CREATE_TOPIC_PATH} iPIxkpAMI8qTcQj8 Ehq3WyT4bkif4zwgEbvshGal ${data} |
| 61 | #Log To Console Update Owner for TEST_TOPIC_ACL |
| 62 | ${resp}= Run MR Auth Put Request ${MR_UPDATE_ACL_TOPIC_PATH}/iPIxkpAMI8qTcQj8 iPIxkpAMI8qTcQj8 Ehq3WyT4bkif4zwgEbvshGal ${data} |
| 63 | Should Be Equal As Strings ${resp.status_code} 200 |
| 64 | |
| 65 | Run MR Auth Post Request |
| 66 | [Documentation] Runs MR Authenticated Post Request |
| 67 | [Arguments] ${data_path} ${id_key} ${secret_key} ${data} |
| 68 | ${current_time}= Get Time |
| 69 | ${time}= Evaluate datetime.datetime.today().replace(tzinfo=pytz.UTC).replace(microsecond=0).isoformat() modules=datetime,pytz |
| 70 | ${command}= Set Variable /bin/echo -n "${time}" | /usr/bin/openssl sha1 -hmac "${secret_key}" -binary | /usr/bin/openssl base64 |
| 71 | ${result}= Run Process ${command} shell=True |
| 72 | ${signature}= Set Variable ${result.stdout} |
| 73 | ${xAuth}= Set Variable ${id_key}:${signature} |
| 74 | ${headers}= Create Dictionary Content-Type=application/json X-CambriaAuth=${xAuth} X-CambriaDate=${time} |
| 75 | ${session}= Create Session mr ${MR_ENDPOINT} |
| 76 | ${resp}= Post Request mr ${data_path} headers=${headers} data=${data} |
| 77 | ${status_string}= Convert To String ${resp.status_code} |
| 78 | Should Match Regexp ${status_string} ^(204|200)$ |
| 79 | Log Received response from message router ${resp.text} |
| 80 | [Return] ${resp} |
| 81 | |
| 82 | |
| 83 | Run MR Auth Put Request |
| 84 | [Documentation] Runs MR Authenticated Put Request |
| 85 | [Arguments] ${data_path} ${id_key} ${secret_key} ${data} |
| 86 | ${current_time}= Get Time |
| 87 | ${time}= Evaluate datetime.datetime.today().replace(tzinfo=pytz.UTC).replace(microsecond=0).isoformat() modules=datetime,pytz |
| 88 | ${command}= Set Variable /bin/echo -n "${time}" | /usr/bin/openssl sha1 -hmac "${secret_key}" -binary | /usr/bin/openssl base64 |
| 89 | ${result}= Run Process ${command} shell=True |
| 90 | ${signature}= Set Variable ${result.stdout} |
| 91 | ${xAuth}= Set Variable ${id_key}:${signature} |
| 92 | ${headers}= Create Dictionary Content-Type=application/json X-CambriaAuth=${xAuth} X-CambriaDate=${time} |
| 93 | ${session}= Create Session mr ${MR_ENDPOINT} |
| 94 | ${resp}= Put Request mr ${data_path} headers=${headers} data=${data} |
| 95 | Should Be Equal As Strings ${resp.status_code} 200 |
| 96 | Log Received response from message router ${resp.text} |
| 97 | [Return] ${resp} |
| 98 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 99 | Run MR Get Request |
| 100 | [Documentation] Runs MR Get request |
| 101 | [Arguments] ${data_path} |
Brian Freeman | 19a4d2d | 2018-11-30 13:03:52 -0500 | [diff] [blame] | 102 | ${session}= Create Session mr ${MR_ENDPOINT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 103 | ${uuid}= Generate UUID |
| 104 | ${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] | 105 | ${resp}= Get Request mr ${data_path} headers=${headers} |
| 106 | Log Received response from message router ${resp.text} |
| 107 | [Return] ${resp} |
| 108 | |
| 109 | Run MR Post Request |
| 110 | [Documentation] Runs MR Post request |
| 111 | [Arguments] ${data_path} |
| 112 | ${session}= Create Session mr ${MR_ENDPOINT} |
| 113 | ${timestamp}= Get Current Date |
| 114 | ${dict}= Create Dictionary timestamp=${timestamp} |
| 115 | ${data}= Fill JSON Template File ${MR_PUBLISH_TEMPLATE} ${dict} |
| 116 | ${uuid}= Generate UUID |
| 117 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 118 | ${resp}= Post Request mr ${data_path} data=${data} headers=${headers} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 119 | Log Received response from message router ${resp.text} |
| 120 | [Return] ${resp} |
| 121 | |