econwar | 3acb57a | 2019-01-25 12:05:45 +0000 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library OperatingSystem |
| 3 | Library RequestsLibrary |
| 4 | Library requests |
| 5 | Library Collections |
| 6 | Library String |
| 7 | Library Process |
| 8 | |
| 9 | *** Variables *** |
| 10 | ${TARGET_URL} https://dmaap-dr-prov:8443/ |
| 11 | ${CREATE_FEED_DATA} {"name": "CSIT_Test", "version": "v1.0.0", "description": "CSIT_Test", "business_description": "CSIT_Test", "suspend": false, "deleted": false, "changeowner": true, "authorization": {"classification": "unclassified", "endpoint_addrs": [], "endpoint_ids": [{"password": "dradmin", "id": "dradmin"}]}} |
| 12 | ${SUBSCRIBE_DATA} {"delivery":{ "url":"http://${DR_SUB_IP}:7070/", "user":"LOGIN", "password":"PASSWORD", "use100":true}, "metadataOnly":false, "suspend":false, "groupid":29, "subscriber":"dmaap-subscriber"} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 13 | ${FEED_CONTENT_TYPE} application/vnd.dmaap-dr.feed |
| 14 | ${SUBSCRIBE_CONTENT_TYPE} application/vnd.dmaap-dr.subscription |
econwar | 3acb57a | 2019-01-25 12:05:45 +0000 | [diff] [blame] | 15 | ${PUBLISH_FEED_CONTENT_TYPE} application/octet-stream |
| 16 | ${CLI_VERIFY_SUB_RECEIVED_FILE} docker exec subscriber-node /bin/sh -c "ls /opt/app/subscriber/delivery | grep csit_test" |
| 17 | |
| 18 | *** Test Cases *** |
| 19 | Run Feed Creation |
| 20 | [Documentation] Feed Creation |
| 21 | [Timeout] 1 minute |
| 22 | ${resp}= PostCall ${TARGET_URL} ${CREATE_FEED_DATA} ${FEED_CONTENT_TYPE} dradmin |
| 23 | log ${TARGET_URL} |
| 24 | log ${resp.text} |
| 25 | Should Be Equal As Strings ${resp.status_code} 201 |
| 26 | log 'JSON Response Code:'${resp} |
| 27 | |
| 28 | Run Subscribe to Feed |
| 29 | [Documentation] Subscribe to Feed |
| 30 | [Timeout] 1 minute |
| 31 | ${resp}= PostCall ${TARGET_URL}subscribe/1 ${SUBSCRIBE_DATA} ${SUBSCRIBE_CONTENT_TYPE} dradmin |
| 32 | log ${TARGET_URL}subscribe/1 |
| 33 | log ${resp.text} |
| 34 | Should Be Equal As Strings ${resp.status_code} 201 |
| 35 | log 'JSON Response Code:'${resp} |
| 36 | |
| 37 | Run Publish to Feed |
| 38 | [Documentation] Publish to Feed |
| 39 | [Timeout] 1 minute |
| 40 | Sleep 10s Behaviour was noticed where feed was not created in time for publish to be sent |
| 41 | ${resp}= PutCall ${TARGET_URL}publish/1/csit_test ${CREATE_FEED_DATA} ${PUBLISH_FEED_CONTENT_TYPE} dradmin |
| 42 | log ${TARGET_URL}publish/1/csit_test |
| 43 | ${redirect_location}= Set Variable ${resp.headers['Location']} |
| 44 | log ${redirect_location} |
| 45 | ${resp}= PutCall ${redirect_location} ${CREATE_FEED_DATA} ${PUBLISH_FEED_CONTENT_TYPE} dradmin |
| 46 | log ${resp.text} |
| 47 | Should Be Equal As Strings ${resp.status_code} 204 |
| 48 | log 'JSON Response Code:'${resp} |
| 49 | |
| 50 | Verify Subscriber Received Published File |
| 51 | [Documentation] Verify file is delivered on datarouter-subscriber |
| 52 | [Timeout] 1 minute |
| 53 | Sleep 5s Time to allow subscriber to receive the file |
| 54 | ${cli_cmd_output}= Run Process ${CLI_VERIFY_SUB_RECEIVED_FILE} shell=yes |
| 55 | Log ${cli_cmd_output.stdout} |
| 56 | Should Be Equal As Strings ${cli_cmd_output.rc} 0 |
| 57 | Should Contain ${cli_cmd_output.stdout} csit_test |
| 58 | |
| 59 | *** Keywords *** |
| 60 | PostCall |
| 61 | [Arguments] ${url} ${data} ${content_type} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 62 | ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type} |
econwar | 3acb57a | 2019-01-25 12:05:45 +0000 | [diff] [blame] | 63 | ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, verify=True) requests |
| 64 | [Return] ${resp} |
| 65 | |
| 66 | PutCall |
| 67 | [Arguments] ${url} ${data} ${content_type} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 68 | ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type} Authorization=Basic ZHJhZG1pbjpkcmFkbWlu |
econwar | 3acb57a | 2019-01-25 12:05:45 +0000 | [diff] [blame] | 69 | ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, verify=True, allow_redirects=False) requests |
| 70 | [Return] ${resp} |
| 71 | |
| 72 | DeleteCall |
| 73 | [Arguments] ${url} ${user} |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 74 | ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} |
econwar | 3acb57a | 2019-01-25 12:05:45 +0000 | [diff] [blame] | 75 | ${resp}= Evaluate requests.delete('${url}', headers=${headers}, verify=True) requests |
| 76 | [Return] ${resp} |