blob: c4379153d1b62f4c250b6d57899a186007ea78be [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** Settings ***
2Library OperatingSystem
3Library RequestsLibrary
4Library requests
5Library Collections
econwar624a9bd2019-02-08 16:02:29 +00006Library Process
Gary Wu9abb61c2018-09-27 10:38:50 -07007Library String
8
9*** Variables ***
econwar624a9bd2019-02-08 16:02:29 +000010${TARGET_URL} https://${DR_PROV_IP}:8443
11${TARGET_URL_FEED} https://${DR_PROV_IP}:8443/feed/1
EmmettCox4ec946e2019-02-26 13:45:00 +000012${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
econwar624a9bd2019-02-08 16:02:29 +000014${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 Wu9abb61c2018-09-27 10:38:50 -070032
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} 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
43Run 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
econwar624a9bd2019-02-08 16:02:29 +000052Run 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
61Run Publish to Feed
Gary Wu9abb61c2018-09-27 10:38:50 -070062 [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 Wardfdcd89c2018-10-01 11:03:25 +000065 ${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 Wu9abb61c2018-09-27 10:38:50 -070069 Should Be Equal As Strings ${resp.status_code} 204
70 log 'JSON Response Code:'${resp}
71
econwar624a9bd2019-02-08 16:02:29 +000072Verify 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
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} 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 Wu9abb61c2018-09-27 10:38:50 -070096Run 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
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} 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
EmmettCox4ec946e2019-02-26 13:45:00 +0000122Run 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
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} rs873m
135 log ${resp.text}
136 Should Contain ${resp.text} []
137 log 'JSON Response Code:'${resp}
138
139
Gary Wu9abb61c2018-09-27 10:38:50 -0700140Run 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
148Run 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 ***
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}
Conor Wardfdcd89c2018-10-01 11:03:25 +0000160 ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, verify=False) requests
Gary Wu9abb61c2018-09-27 10:38:50 -0700161 [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 cnM4NzNtOnJzODczbQ==
Conor Wardfdcd89c2018-10-01 11:03:25 +0000166 ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, verify=False, allow_redirects=False) requests
Gary Wu9abb61c2018-09-27 10:38:50 -0700167 [Return] ${resp}
168
169GetCall
170 [Arguments] ${url} ${content_type} ${user}
egernug6f2874b2019-02-06 15:16:54 +0000171 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type}
Conor Wardfdcd89c2018-10-01 11:03:25 +0000172 ${resp}= Evaluate requests.get('${url}', headers=${headers}, verify=False) requests
Gary Wu9abb61c2018-09-27 10:38:50 -0700173 [Return] ${resp}
174
175DeleteCall
176 [Arguments] ${url} ${user}
egernug6f2874b2019-02-06 15:16:54 +0000177 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user}
Conor Wardfdcd89c2018-10-01 11:03:25 +0000178 ${resp}= Evaluate requests.delete('${url}', headers=${headers}, verify=False) requests
Gary Wu9abb61c2018-09-27 10:38:50 -0700179 [Return] ${resp}