Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library OperatingSystem |
| 3 | Library RequestsLibrary |
| 4 | Library requests |
| 5 | Library Collections |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 6 | Library Process |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 7 | Library String |
| 8 | |
| 9 | *** Variables *** |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 10 | ${TARGET_URL} https://${DR_PROV_IP}:8443 |
| 11 | ${TARGET_URL_FEED} https://${DR_PROV_IP}:8443/feed/1 |
EmmettCox | 4ec946e | 2019-02-26 13:45:00 +0000 | [diff] [blame^] | 12 | ${TARGET_URL_EXISTS_LOGGING} https://${DR_PROV_IP}:8443/feedlog/1?type=pub&filename=csit_test |
| 13 | ${TARGET_URL_NOT_EXISTS_LOGGING} https://${DR_PROV_IP}:8443/feedlog/1?type=pub&filename=file_that_doesnt_exist |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 14 | ${TARGET_URL_SUBSCRIBE} https://${DR_PROV_IP}:8443/subscribe/1 |
| 15 | ${TARGET_URL_SUBSCRIPTION} https://${DR_PROV_IP}:8443/subs/1 |
| 16 | ${TARGET_URL_PUBLISH_PROV} https://${DR_PROV_IP}:8443/publish/1/csit_test |
| 17 | ${TARGET_URL_PUBLISH_NODE} https://${DR_NODE_IP}:8443/publish/1/csit_test |
| 18 | ${TARGET_URL_DELETE_FILE} https://${DR_NODE_IP}:8443/delete/2 |
| 19 | |
| 20 | ${FEED_CONTENT_TYPE} application/vnd.dmaap-dr.feed |
| 21 | ${SUBSCRIBE_CONTENT_TYPE} application/vnd.dmaap-dr.subscription |
| 22 | ${PUBLISH_FEED_CONTENT_TYPE} application/octet-stream |
| 23 | |
| 24 | ${CREATE_FEED_DATA} {"name": "CSIT_Test", "version": "m1.0", "description": "CSIT_Test", "business_description": "CSIT_Test", "suspend": false, "deleted": false, "changeowner": true, "authorization": {"classification": "unclassified", "endpoint_addrs": [], "endpoint_ids": [{"password": "rs873m", "id": "rs873m"}]}} |
| 25 | ${UPDATE_FEED_DATA} {"name": "CSIT_Test", "version": "m1.0", "description": "UPDATED-CSIT_Test", "business_description": "CSIT_Test", "suspend": true, "deleted": false, "changeowner": true, "authorization": {"classification": "unclassified", "endpoint_addrs": [], "endpoint_ids": [{"password": "rs873m", "id": "rs873m"}]}} |
| 26 | ${SUBSCRIBE_DATA} {"delivery":{ "url":"http://${DR_SUB_IP}:7070/", "user":"LOGIN", "password":"PASSWORD", "use100":true}, "metadataOnly":false, "suspend":false, "groupid":29, "subscriber":"sg481n", "privilegedSubscriber":false} |
| 27 | ${UPDATE_SUBSCRIPTION_DATA} {"delivery":{ "url":"http://${DR_SUB_IP}:7070/", "user":"sg481n", "password":"sg481n", "use100":true}, "metadataOnly":false, "suspend":true, "groupid":29, "subscriber":"sg481n", "privilegedSubscriber":false} |
| 28 | ${SUBSCRIBE2_DATA} {"delivery":{ "url":"http://${DR_SUB2_IP}:7070/", "user":"LOGIN", "password":"PASSWORD", "use100":true}, "metadataOnly":false, "suspend":false, "groupid":29, "subscriber":"privileged", "privilegedSubscriber":true} |
| 29 | |
| 30 | ${CLI_VERIFY_SUB_RECEIVED_FILE} docker exec subscriber-node /bin/sh -c "ls /opt/app/subscriber/delivery | grep csit_test" |
| 31 | ${CLI_VERIFY_FILE_REMAINS_ON_NODE} docker exec datarouter-node /bin/sh -c "ls /opt/app/datartr/spool/s/0/2 | grep dmaap-dr-node | grep -v .M" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 32 | |
| 33 | *** Test Cases *** |
| 34 | Run Feed Creation |
| 35 | [Documentation] Feed Creation |
| 36 | [Timeout] 1 minute |
| 37 | ${resp}= PostCall ${TARGET_URL} ${CREATE_FEED_DATA} ${FEED_CONTENT_TYPE} rs873m |
| 38 | log ${TARGET_URL} |
| 39 | log ${resp.text} |
| 40 | Should Be Equal As Strings ${resp.status_code} 201 |
| 41 | log 'JSON Response Code:'${resp} |
| 42 | |
| 43 | Run Subscribe to Feed |
| 44 | [Documentation] Subscribe to Feed |
| 45 | [Timeout] 1 minute |
| 46 | ${resp}= PostCall ${TARGET_URL_SUBSCRIBE} ${SUBSCRIBE_DATA} ${SUBSCRIBE_CONTENT_TYPE} sg481n |
| 47 | log ${TARGET_URL_SUBSCRIBE} |
| 48 | log ${resp.text} |
| 49 | Should Be Equal As Strings ${resp.status_code} 201 |
| 50 | log 'JSON Response Code:'${resp} |
| 51 | |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 52 | Run Subscribe to Feed with Privileged Subscription |
| 53 | [Documentation] Subscribe to Feed with privileged subscription |
| 54 | [Timeout] 1 minute |
| 55 | ${resp}= PostCall ${TARGET_URL_SUBSCRIBE} ${SUBSCRIBE2_DATA} ${SUBSCRIBE_CONTENT_TYPE} privileged |
| 56 | log ${TARGET_URL_SUBSCRIBE} |
| 57 | log ${resp.text} |
| 58 | Should Be Equal As Strings ${resp.status_code} 201 |
| 59 | log 'JSON Response Code:'${resp} |
| 60 | |
| 61 | Run Publish to Feed |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 62 | [Documentation] Publish to Feed |
| 63 | [Timeout] 1 minute |
| 64 | Sleep 10s Behaviour was noticed where feed was not created in time for publish to be sent |
Conor Ward | fdcd89c | 2018-10-01 11:03:25 +0000 | [diff] [blame] | 65 | ${resp}= PutCall ${TARGET_URL_PUBLISH_PROV} ${CREATE_FEED_DATA} ${PUBLISH_FEED_CONTENT_TYPE} rs873m |
| 66 | log ${TARGET_URL_PUBLISH_PROV} |
| 67 | Should Contain ${resp.headers['Location']} https://dmaap-dr-node:8443/publish/1/csit_test |
| 68 | ${resp}= PutCall ${TARGET_URL_PUBLISH_NODE} ${CREATE_FEED_DATA} ${PUBLISH_FEED_CONTENT_TYPE} rs873m |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 69 | Should Be Equal As Strings ${resp.status_code} 204 |
| 70 | log 'JSON Response Code:'${resp} |
| 71 | |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 72 | Verify Subscriber Received Published File |
| 73 | [Documentation] Verify file is delivered to datarouter-subscriber |
| 74 | [Timeout] 1 minute |
| 75 | Sleep 5s Time to allow subscriber to receive the file |
| 76 | ${cli_cmd_output}= Run Process ${CLI_VERIFY_SUB_RECEIVED_FILE} shell=yes |
| 77 | Log ${cli_cmd_output.stdout} |
| 78 | Should Be Equal As Strings ${cli_cmd_output.rc} 0 |
| 79 | Should Contain ${cli_cmd_output.stdout} csit_test |
| 80 | |
| 81 | |
| 82 | Verify File Remains On Privileged Subscriber And Delete It |
| 83 | [Documentation] Verify file has not been deleted on datarouter-node and delete it using DELETE API |
| 84 | [Timeout] 1 minute |
| 85 | ${cli_cmd_output}= Run Process ${CLI_VERIFY_FILE_REMAINS_ON_NODE} shell=yes |
| 86 | log ${cli_cmd_output.stdout} |
| 87 | Should Be Equal As Strings ${cli_cmd_output.rc} 0 |
| 88 | Should Contain ${cli_cmd_output.stdout} dmaap-dr-node |
| 89 | ${resp}= DeleteCall ${TARGET_URL_DELETE_FILE}/${cli_cmd_output.stdout} rs873m |
| 90 | Should Be Equal As Strings ${resp.status_code} 200 |
| 91 | log 'JSON Response Code:'${resp} |
| 92 | ${cli_cmd_output}= Run Process ${CLI_VERIFY_FILE_REMAINS_ON_NODE} shell=yes |
| 93 | log ${cli_cmd_output.stdout} |
| 94 | Should Be Equal As Strings ${cli_cmd_output.rc} 1 |
| 95 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 96 | Run Update Subscription |
| 97 | [Documentation] Update Subscription to suspend and change delivery credentials |
| 98 | [Timeout] 1 minute |
| 99 | ${resp}= PutCall ${TARGET_URL_SUBSCRIPTION} ${UPDATE_SUBSCRIPTION_DATA} ${SUBSCRIBE_CONTENT_TYPE} sg481n |
| 100 | log ${TARGET_URL_SUBSCRIPTION} |
| 101 | log ${resp.text} |
| 102 | Should Be Equal As Strings ${resp.status_code} 200 |
| 103 | log 'JSON Response Code:'${resp} |
| 104 | ${resp}= GetCall ${TARGET_URL_SUBSCRIPTION} ${SUBSCRIBE_CONTENT_TYPE} sg481n |
| 105 | log ${resp.text} |
| 106 | Should Contain ${resp.text} "password":"sg481n","user":"sg481n" |
| 107 | log 'JSON Response Code:'${resp} |
| 108 | |
| 109 | Run Update Feed |
| 110 | [Documentation] Update Feed description and suspend |
| 111 | [Timeout] 1 minute |
| 112 | ${resp}= PutCall ${TARGET_URL_FEED} ${UPDATE_FEED_DATA} ${FEED_CONTENT_TYPE} rs873m |
| 113 | log ${TARGET_URL_FEED} |
| 114 | log ${resp.text} |
| 115 | Should Be Equal As Strings ${resp.status_code} 200 |
| 116 | log 'JSON Response Code:'${resp} |
| 117 | ${resp}= GetCall ${TARGET_URL_FEED} ${FEED_CONTENT_TYPE} rs873m |
| 118 | log ${resp.text} |
| 119 | Should Contain ${resp.text} "UPDATED-CSIT_Test" |
| 120 | log 'JSON Response Code:'${resp} |
| 121 | |
EmmettCox | 4ec946e | 2019-02-26 13:45:00 +0000 | [diff] [blame^] | 122 | Run Get With Filename That Exists |
| 123 | [Documentation] Get publish record with a specified filename |
| 124 | [Timeout] 2 minutes |
| 125 | sleep 1 minute 45 seconds needed to ensure logs have been updated |
| 126 | ${resp}= GetCall ${TARGET_URL_EXISTS_LOGGING} ${FEED_CONTENT_TYPE} rs873m |
| 127 | log ${resp.text} |
| 128 | Should Contain ${resp.text} "fileName":"csit_test" |
| 129 | log 'JSON Response Code:'${resp} |
| 130 | |
| 131 | Run Get With Filename That Doesnt Exist |
| 132 | [Documentation] Get publish record with a specified filename |
| 133 | [Timeout] 1 minute |
| 134 | ${resp}= GetCall ${TARGET_URL_NOT_EXISTS_LOGGING} ${FEED_CONTENT_TYPE} rs873m |
| 135 | log ${resp.text} |
| 136 | Should Contain ${resp.text} [] |
| 137 | log 'JSON Response Code:'${resp} |
| 138 | |
| 139 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 140 | Run Delete Subscription |
| 141 | [Documentation] Delete Subscription |
| 142 | [Timeout] 1 minute |
| 143 | ${resp}= DeleteCall ${TARGET_URL_SUBSCRIPTION} sg481n |
| 144 | log ${resp.text} |
| 145 | Should Be Equal As Strings ${resp.status_code} 204 |
| 146 | log 'JSON Response Code:'${resp} |
| 147 | |
| 148 | Run Delete Feed |
| 149 | [Documentation] Delete Feed |
| 150 | [Timeout] 1 minute |
| 151 | ${resp}= DeleteCall ${TARGET_URL_FEED} rs873m |
| 152 | log ${resp.text} |
| 153 | Should Be Equal As Strings ${resp.status_code} 204 |
| 154 | log 'JSON Response Code:'${resp} |
| 155 | |
| 156 | *** Keywords *** |
| 157 | PostCall |
| 158 | [Arguments] ${url} ${data} ${content_type} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 159 | ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type} |
Conor Ward | fdcd89c | 2018-10-01 11:03:25 +0000 | [diff] [blame] | 160 | ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, verify=False) requests |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 161 | [Return] ${resp} |
| 162 | |
| 163 | PutCall |
| 164 | [Arguments] ${url} ${data} ${content_type} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 165 | ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type} Authorization=Basic cnM4NzNtOnJzODczbQ== |
Conor Ward | fdcd89c | 2018-10-01 11:03:25 +0000 | [diff] [blame] | 166 | ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, verify=False, allow_redirects=False) requests |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 167 | [Return] ${resp} |
| 168 | |
| 169 | GetCall |
| 170 | [Arguments] ${url} ${content_type} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 171 | ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type} |
Conor Ward | fdcd89c | 2018-10-01 11:03:25 +0000 | [diff] [blame] | 172 | ${resp}= Evaluate requests.get('${url}', headers=${headers}, verify=False) requests |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 173 | [Return] ${resp} |
| 174 | |
| 175 | DeleteCall |
| 176 | [Arguments] ${url} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 177 | ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} |
Conor Ward | fdcd89c | 2018-10-01 11:03:25 +0000 | [diff] [blame] | 178 | ${resp}= Evaluate requests.delete('${url}', headers=${headers}, verify=False) requests |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 179 | [Return] ${resp} |