blob: fb70326ee985755a80e0a67a7c5ca7e298f167d2 [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
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 Wu9abb61c2018-09-27 10:38:50 -070030
31*** Test Cases ***
32Run 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
41Run 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
econwar624a9bd2019-02-08 16:02:29 +000050Run 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
59Run Publish to Feed
Gary Wu9abb61c2018-09-27 10:38:50 -070060 [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 Wardfdcd89c2018-10-01 11:03:25 +000063 ${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 Wu9abb61c2018-09-27 10:38:50 -070067 Should Be Equal As Strings ${resp.status_code} 204
68 log 'JSON Response Code:'${resp}
69
econwar624a9bd2019-02-08 16:02:29 +000070Verify 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
80Verify 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 Wu9abb61c2018-09-27 10:38:50 -070094Run 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
107Run 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
120Run 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
128Run 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 ***
137PostCall
138 [Arguments] ${url} ${data} ${content_type} ${user}
egernug6f2874b2019-02-06 15:16:54 +0000139 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type}
Conor Wardfdcd89c2018-10-01 11:03:25 +0000140 ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, verify=False) requests
Gary Wu9abb61c2018-09-27 10:38:50 -0700141 [Return] ${resp}
142
143PutCall
144 [Arguments] ${url} ${data} ${content_type} ${user}
egernug6f2874b2019-02-06 15:16:54 +0000145 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type} Authorization=Basic cnM4NzNtOnJzODczbQ==
Conor Wardfdcd89c2018-10-01 11:03:25 +0000146 ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, verify=False, allow_redirects=False) requests
Gary Wu9abb61c2018-09-27 10:38:50 -0700147 [Return] ${resp}
148
149GetCall
150 [Arguments] ${url} ${content_type} ${user}
egernug6f2874b2019-02-06 15:16:54 +0000151 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user} Content-Type=${content_type}
Conor Wardfdcd89c2018-10-01 11:03:25 +0000152 ${resp}= Evaluate requests.get('${url}', headers=${headers}, verify=False) requests
Gary Wu9abb61c2018-09-27 10:38:50 -0700153 [Return] ${resp}
154
155DeleteCall
156 [Arguments] ${url} ${user}
egernug6f2874b2019-02-06 15:16:54 +0000157 ${headers}= Create Dictionary X-DMAAP-DR-ON-BEHALF-OF=${user}
Conor Wardfdcd89c2018-10-01 11:03:25 +0000158 ${resp}= Evaluate requests.delete('${url}', headers=${headers}, verify=False) requests
Gary Wu9abb61c2018-09-27 10:38:50 -0700159 [Return] ${resp}