blob: 2f96cdc8c64ea7ea3b9a944dcbe84baea99ee318 [file] [log] [blame]
econwar3acb57a2019-01-25 12:05:45 +00001*** Settings ***
2Library OperatingSystem
3Library RequestsLibrary
4Library requests
5Library Collections
econwar3acb57a2019-01-25 12:05:45 +00006Library Process
efiacor3d4b2a42019-10-11 17:03:25 +01007Library String
econwar3acb57a2019-01-25 12:05:45 +00008
9*** Variables ***
efiacor3d4b2a42019-10-11 17:03:25 +010010${TARGET_URL} https://dmaap-dr-prov:8443/
11${TARGET_URL_FEED} https://dmaap-dr-prov:8443/feed/1
12${TARGET_URL_EXISTS_LOGGING} https://dmaap-dr-prov:8443/feedlog/1?type=pub&filename=csit_test
13${TARGET_URL_NOT_EXISTS_LOGGING} https://dmaap-dr-prov:8443/feedlog/1?type=pub&filename=file_that_doesnt_exist
14${TARGET_URL_SUBSCRIBE} https://dmaap-dr-prov:8443/subscribe/1
15${TARGET_URL_SUBSCRIPTION} https://dmaap-dr-prov:8443/subs/1
16${TARGET_URL_PUBLISH_PROV} https://dmaap-dr-prov:8443/publish/1/csit_test
17${TARGET_URL_PUBLISH_NODE} https://dmaap-dr-node:8443/publish/1/csit_test
18${TARGET_URL_DELETE_FILE} https://dmaap-dr-node: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": "dradmin", "id": "dradmin"}]}}
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": "dradmin", "id": "dradmin"}]}}
26${SUBSCRIBE_DATA} {"delivery":{ "url":"http://${DR_SUB_IP}:7070/", "user":"LOGIN", "password":"PASSWORD", "use100":true}, "metadataOnly":false, "suspend":false, "groupid":29, "subscriber":"dradmin", "privilegedSubscriber":false}
27${UPDATE_SUBSCRIPTION_DATA} {"delivery":{ "url":"http://${DR_SUB_IP}:7070/", "user":"dradmin", "password":"dradmin", "use100":true}, "metadataOnly":false, "suspend":true, "groupid":29, "subscriber":"dradmin", "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"
econwar3acb57a2019-01-25 12:05:45 +000032
33*** Test Cases ***
34Run Feed Creation
35 [Documentation] Feed Creation
36 [Timeout] 1 minute
37 ${resp}= PostCall ${TARGET_URL} ${CREATE_FEED_DATA} ${FEED_CONTENT_TYPE} dradmin
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
43Run Subscribe to Feed
44 [Documentation] Subscribe to Feed
45 [Timeout] 1 minute
efiacor3d4b2a42019-10-11 17:03:25 +010046 ${resp}= PostCall ${TARGET_URL_SUBSCRIBE} ${SUBSCRIBE_DATA} ${SUBSCRIBE_CONTENT_TYPE} dradmin
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
52Run 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}
econwar3acb57a2019-01-25 12:05:45 +000057 log ${resp.text}
58 Should Be Equal As Strings ${resp.status_code} 201
59 log 'JSON Response Code:'${resp}
60
61Run Publish to Feed
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
efiacor3d4b2a42019-10-11 17:03:25 +010065 ${resp}= PutCall ${TARGET_URL_PUBLISH_PROV} ${CREATE_FEED_DATA} ${PUBLISH_FEED_CONTENT_TYPE} dradmin
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} dradmin
econwar3acb57a2019-01-25 12:05:45 +000069 Should Be Equal As Strings ${resp.status_code} 204
70 log 'JSON Response Code:'${resp}
71
72Verify Subscriber Received Published File
efiacor3d4b2a42019-10-11 17:03:25 +010073 [Documentation] Verify file is delivered to datarouter-subscriber
econwar3acb57a2019-01-25 12:05:45 +000074 [Timeout] 1 minute
efiacor3d4b2a42019-10-11 17:03:25 +010075 Sleep 5s Time to allow subscriber to receive the file
76 ${cli_cmd_output}= Run Process ${CLI_VERIFY_SUB_RECEIVED_FILE} shell=yes
econwar3acb57a2019-01-25 12:05:45 +000077 Log ${cli_cmd_output.stdout}
efiacor3d4b2a42019-10-11 17:03:25 +010078 Should Be Equal As Strings ${cli_cmd_output.rc} 0
79 Should Contain ${cli_cmd_output.stdout} csit_test
80
81
82Verify 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} dradmin
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
96Run 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} dradmin
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} dradmin
105 log ${resp.text}
106 Should Contain ${resp.text} "password":"dradmin","user":"dradmin"
107 log 'JSON Response Code:'${resp}
108
109Run 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} dradmin
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} dradmin
118 log ${resp.text}
119 Should Contain ${resp.text} "UPDATED-CSIT_Test"
120 log 'JSON Response Code:'${resp}
121
122Run 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} dradmin
127 log ${resp.text}
128 Should Contain ${resp.text} "fileName":"csit_test"
129 log 'JSON Response Code:'${resp}
130
131Run 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} dradmin
135 log ${resp.text}
136 Should Contain ${resp.text} []
137 log 'JSON Response Code:'${resp}
138
139
140Run Delete Subscription
141 [Documentation] Delete Subscription
142 [Timeout] 1 minute
143 ${resp}= DeleteCall ${TARGET_URL_SUBSCRIPTION} dradmin
144 log ${resp.text}
145 Should Be Equal As Strings ${resp.status_code} 204
146 log 'JSON Response Code:'${resp}
147
148Run Delete Feed
149 [Documentation] Delete Feed
150 [Timeout] 1 minute
151 ${resp}= DeleteCall ${TARGET_URL_FEED} dradmin
152 log ${resp.text}
153 Should Be Equal As Strings ${resp.status_code} 204
154 log 'JSON Response Code:'${resp}
econwar3acb57a2019-01-25 12:05:45 +0000155
156*** Keywords ***
157PostCall
158 [Arguments] ${url} ${data} ${content_type} ${user}
egernug6f2874b2019-02-06 15:16:54 +0000159 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type}
econwar3acb57a2019-01-25 12:05:45 +0000160 ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, verify=True) requests
161 [Return] ${resp}
162
163PutCall
164 [Arguments] ${url} ${data} ${content_type} ${user}
egernug6f2874b2019-02-06 15:16:54 +0000165 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type} Authorization=Basic ZHJhZG1pbjpkcmFkbWlu
econwar3acb57a2019-01-25 12:05:45 +0000166 ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, verify=True, allow_redirects=False) requests
167 [Return] ${resp}
168
efiacor3d4b2a42019-10-11 17:03:25 +0100169GetCall
170 [Arguments] ${url} ${content_type} ${user}
171 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type}
172 ${resp}= Evaluate requests.get('${url}', headers=${headers}, verify=True) requests
173 [Return] ${resp}
174
econwar3acb57a2019-01-25 12:05:45 +0000175DeleteCall
176 [Arguments] ${url} ${user}
egernug6f2874b2019-02-06 15:16:54 +0000177 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user}
econwar3acb57a2019-01-25 12:05:45 +0000178 ${resp}= Evaluate requests.delete('${url}', headers=${headers}, verify=True) requests
179 [Return] ${resp}