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 |
| 12 | ${TARGET_URL_SUBSCRIBE} https://${DR_PROV_IP}:8443/subscribe/1 |
| 13 | ${TARGET_URL_SUBSCRIPTION} https://${DR_PROV_IP}:8443/subs/1 |
| 14 | ${TARGET_URL_PUBLISH_PROV} https://${DR_PROV_IP}:8443/publish/1/csit_test |
| 15 | ${TARGET_URL_PUBLISH_NODE} https://${DR_NODE_IP}:8443/publish/1/csit_test |
| 16 | ${TARGET_URL_DELETE_FILE} https://${DR_NODE_IP}:8443/delete/2 |
| 17 | |
| 18 | ${FEED_CONTENT_TYPE} application/vnd.dmaap-dr.feed |
| 19 | ${SUBSCRIBE_CONTENT_TYPE} application/vnd.dmaap-dr.subscription |
| 20 | ${PUBLISH_FEED_CONTENT_TYPE} application/octet-stream |
| 21 | |
| 22 | ${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"}]}} |
| 23 | ${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"}]}} |
| 24 | ${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} |
| 25 | ${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} |
| 26 | ${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} |
| 27 | |
| 28 | ${CLI_VERIFY_SUB_RECEIVED_FILE} docker exec subscriber-node /bin/sh -c "ls /opt/app/subscriber/delivery | grep csit_test" |
| 29 | ${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] | 30 | |
| 31 | *** Test Cases *** |
| 32 | Run Feed Creation |
| 33 | [Documentation] Feed Creation |
| 34 | [Timeout] 1 minute |
| 35 | ${resp}= PostCall ${TARGET_URL} ${CREATE_FEED_DATA} ${FEED_CONTENT_TYPE} rs873m |
| 36 | log ${TARGET_URL} |
| 37 | log ${resp.text} |
| 38 | Should Be Equal As Strings ${resp.status_code} 201 |
| 39 | log 'JSON Response Code:'${resp} |
| 40 | |
| 41 | Run Subscribe to Feed |
| 42 | [Documentation] Subscribe to Feed |
| 43 | [Timeout] 1 minute |
| 44 | ${resp}= PostCall ${TARGET_URL_SUBSCRIBE} ${SUBSCRIBE_DATA} ${SUBSCRIBE_CONTENT_TYPE} sg481n |
| 45 | log ${TARGET_URL_SUBSCRIBE} |
| 46 | log ${resp.text} |
| 47 | Should Be Equal As Strings ${resp.status_code} 201 |
| 48 | log 'JSON Response Code:'${resp} |
| 49 | |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 50 | Run Subscribe to Feed with Privileged Subscription |
| 51 | [Documentation] Subscribe to Feed with privileged subscription |
| 52 | [Timeout] 1 minute |
| 53 | ${resp}= PostCall ${TARGET_URL_SUBSCRIBE} ${SUBSCRIBE2_DATA} ${SUBSCRIBE_CONTENT_TYPE} privileged |
| 54 | log ${TARGET_URL_SUBSCRIBE} |
| 55 | log ${resp.text} |
| 56 | Should Be Equal As Strings ${resp.status_code} 201 |
| 57 | log 'JSON Response Code:'${resp} |
| 58 | |
| 59 | Run Publish to Feed |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 60 | [Documentation] Publish to Feed |
| 61 | [Timeout] 1 minute |
| 62 | 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] | 63 | ${resp}= PutCall ${TARGET_URL_PUBLISH_PROV} ${CREATE_FEED_DATA} ${PUBLISH_FEED_CONTENT_TYPE} rs873m |
| 64 | log ${TARGET_URL_PUBLISH_PROV} |
| 65 | Should Contain ${resp.headers['Location']} https://dmaap-dr-node:8443/publish/1/csit_test |
| 66 | ${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] | 67 | Should Be Equal As Strings ${resp.status_code} 204 |
| 68 | log 'JSON Response Code:'${resp} |
| 69 | |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 70 | Verify Subscriber Received Published File |
| 71 | [Documentation] Verify file is delivered to datarouter-subscriber |
| 72 | [Timeout] 1 minute |
| 73 | Sleep 5s Time to allow subscriber to receive the file |
| 74 | ${cli_cmd_output}= Run Process ${CLI_VERIFY_SUB_RECEIVED_FILE} shell=yes |
| 75 | Log ${cli_cmd_output.stdout} |
| 76 | Should Be Equal As Strings ${cli_cmd_output.rc} 0 |
| 77 | Should Contain ${cli_cmd_output.stdout} csit_test |
| 78 | |
| 79 | |
| 80 | Verify File Remains On Privileged Subscriber And Delete It |
| 81 | [Documentation] Verify file has not been deleted on datarouter-node and delete it using DELETE API |
| 82 | [Timeout] 1 minute |
| 83 | ${cli_cmd_output}= Run Process ${CLI_VERIFY_FILE_REMAINS_ON_NODE} shell=yes |
| 84 | log ${cli_cmd_output.stdout} |
| 85 | Should Be Equal As Strings ${cli_cmd_output.rc} 0 |
| 86 | Should Contain ${cli_cmd_output.stdout} dmaap-dr-node |
| 87 | ${resp}= DeleteCall ${TARGET_URL_DELETE_FILE}/${cli_cmd_output.stdout} rs873m |
| 88 | Should Be Equal As Strings ${resp.status_code} 200 |
| 89 | log 'JSON Response Code:'${resp} |
| 90 | ${cli_cmd_output}= Run Process ${CLI_VERIFY_FILE_REMAINS_ON_NODE} shell=yes |
| 91 | log ${cli_cmd_output.stdout} |
| 92 | Should Be Equal As Strings ${cli_cmd_output.rc} 1 |
| 93 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 94 | Run Update Subscription |
| 95 | [Documentation] Update Subscription to suspend and change delivery credentials |
| 96 | [Timeout] 1 minute |
| 97 | ${resp}= PutCall ${TARGET_URL_SUBSCRIPTION} ${UPDATE_SUBSCRIPTION_DATA} ${SUBSCRIBE_CONTENT_TYPE} sg481n |
| 98 | log ${TARGET_URL_SUBSCRIPTION} |
| 99 | log ${resp.text} |
| 100 | Should Be Equal As Strings ${resp.status_code} 200 |
| 101 | log 'JSON Response Code:'${resp} |
| 102 | ${resp}= GetCall ${TARGET_URL_SUBSCRIPTION} ${SUBSCRIBE_CONTENT_TYPE} sg481n |
| 103 | log ${resp.text} |
| 104 | Should Contain ${resp.text} "password":"sg481n","user":"sg481n" |
| 105 | log 'JSON Response Code:'${resp} |
| 106 | |
| 107 | Run Update Feed |
| 108 | [Documentation] Update Feed description and suspend |
| 109 | [Timeout] 1 minute |
| 110 | ${resp}= PutCall ${TARGET_URL_FEED} ${UPDATE_FEED_DATA} ${FEED_CONTENT_TYPE} rs873m |
| 111 | log ${TARGET_URL_FEED} |
| 112 | log ${resp.text} |
| 113 | Should Be Equal As Strings ${resp.status_code} 200 |
| 114 | log 'JSON Response Code:'${resp} |
| 115 | ${resp}= GetCall ${TARGET_URL_FEED} ${FEED_CONTENT_TYPE} rs873m |
| 116 | log ${resp.text} |
| 117 | Should Contain ${resp.text} "UPDATED-CSIT_Test" |
| 118 | log 'JSON Response Code:'${resp} |
| 119 | |
| 120 | Run Delete Subscription |
| 121 | [Documentation] Delete Subscription |
| 122 | [Timeout] 1 minute |
| 123 | ${resp}= DeleteCall ${TARGET_URL_SUBSCRIPTION} sg481n |
| 124 | log ${resp.text} |
| 125 | Should Be Equal As Strings ${resp.status_code} 204 |
| 126 | log 'JSON Response Code:'${resp} |
| 127 | |
| 128 | Run Delete Feed |
| 129 | [Documentation] Delete Feed |
| 130 | [Timeout] 1 minute |
| 131 | ${resp}= DeleteCall ${TARGET_URL_FEED} rs873m |
| 132 | log ${resp.text} |
| 133 | Should Be Equal As Strings ${resp.status_code} 204 |
| 134 | log 'JSON Response Code:'${resp} |
| 135 | |
| 136 | *** Keywords *** |
| 137 | PostCall |
| 138 | [Arguments] ${url} ${data} ${content_type} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 139 | ${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] | 140 | ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, verify=False) requests |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 141 | [Return] ${resp} |
| 142 | |
| 143 | PutCall |
| 144 | [Arguments] ${url} ${data} ${content_type} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 145 | ${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] | 146 | ${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] | 147 | [Return] ${resp} |
| 148 | |
| 149 | GetCall |
| 150 | [Arguments] ${url} ${content_type} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 151 | ${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] | 152 | ${resp}= Evaluate requests.get('${url}', headers=${headers}, verify=False) requests |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 153 | [Return] ${resp} |
| 154 | |
| 155 | DeleteCall |
| 156 | [Arguments] ${url} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 157 | ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} |
Conor Ward | fdcd89c | 2018-10-01 11:03:25 +0000 | [diff] [blame] | 158 | ${resp}= Evaluate requests.delete('${url}', headers=${headers}, verify=False) requests |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 159 | [Return] ${resp} |