blob: d68b9ed1756d4da83a43c77dd92cfcffd06d0c2c [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** Settings ***
2Resource ../../common.robot
3Library Collections
4Library json
5Library OperatingSystem
6Library RequestsLibrary
7Library HttpLibrary.HTTP
8Library String
9
10
11*** Variables ***
12${MESSAGE} Hello, world!
13${DBC_URI} webapi
14${DBC_URL} http://${DMAAPBC_IP}:8080/${DBC_URI}
15${TOPIC_NS} org.onap.dmaap.onapCSIT
16${LOC} csit-sanfrancisco
17${PUB_CORE} "dcaeLocationName": "${LOC}", "clientRole": "org.onap.dmaap.client.pub", "action": [ "pub", "view" ]
18${SUB_CORE} "dcaeLocationName": "${LOC}", "clientRole": "org.onap.dmaap.client.sub", "action": [ "sub", "view" ]
19${PUB} { ${PUB_CORE} }
20${SUB} { ${SUB_CORE} }
21${TOPIC1_DATA} { "topicName":"singleMRtopic1", "topicDescription":"generated for CSIT", "owner":"dgl"}
22${TOPIC2_DATA} { "topicName":"singleMRtopic2", "topicDescription":"generated for CSIT", "owner":"dgl", "clients": [ ${PUB}, ${SUB}] }
23${TOPIC3_DATA} { "topicName":"singleMRtopic3", "topicDescription":"generated for CSIT", "owner":"dgl"}
24${PUB3_DATA} { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${PUB_CORE} }
25${SUB3_DATA} { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${SUB_CORE} }
26
27
28
29*** Test Cases ***
30Url Test
31 [Documentation] Check if www.onap.org can be reached
32 Create Session sanity http://onap.readthedocs.io
33 ${resp}= Get Request sanity /
34 Should Be Equal As Integers ${resp.status_code} 200
35
36(DMAAP-293)
37 [Documentation] Create Topic w no clients POST ${DBC_URI}/topics endpoint
38 ${resp}= PostCall ${DBC_URL}/topics ${TOPIC1_DATA}
39 Should Be Equal As Integers ${resp.status_code} 201
40
41(DMAAP-294)
42 [Documentation] Create Topic w pub and sub clients POST ${DBC_URI}/topics endpoint
43 ${resp}= PostCall ${DBC_URL}/topics ${TOPIC2_DATA}
44 Should Be Equal As Integers ${resp.status_code} 201
45
46(DMAAP-295)
47 [Documentation] Create Topic w no clients and then add a client POST ${DBC_URI}/mr_clients endpoint
48 ${resp}= PostCall ${DBC_URL}/topics ${TOPIC3_DATA}
49 Should Be Equal As Integers ${resp.status_code} 201
50 ${resp}= PostCall ${DBC_URL}/mr_clients ${PUB3_DATA}
51 Should Be Equal As Integers ${resp.status_code} 200
52 ${resp}= PostCall ${DBC_URL}/mr_clients ${SUB3_DATA}
53 Should Be Equal As Integers ${resp.status_code} 200
54
55(DMAAP-297)
56 [Documentation] Query for all topics and specific topic
57 Create Session get ${DBC_URL}
58 ${resp}= Get Request get /topics
59 Should Be Equal As Integers ${resp.status_code} 200
60 ${resp}= Get Request get /topics/${TOPIC_NS}.singleMRtopic3
61 Should Be Equal As Integers ${resp.status_code} 200
62
63(DMAAP-301)
64 [Documentation] Delete a subscriber
65 Create Session get ${DBC_URL}
66 ${resp}= Get Request get /topics/${TOPIC_NS}.singleMRtopic3
67 Should Be Equal As Integers ${resp.status_code} 200
68 ${tmp}= Get Json Value ${resp.text} /clients/1/mrClientId
69 ${clientId}= Remove String ${tmp} \"
70 ${resp}= DelCall ${DBC_URL}/mr_clients/${clientId}
71 Should Be Equal As Integers ${resp.status_code} 204
72
73(DMAAP-302)
74 [Documentation] Delete a publisher
75 Create Session get ${DBC_URL}
76 ${resp}= Get Request get /topics/${TOPIC_NS}.singleMRtopic3
77 Should Be Equal As Integers ${resp.status_code} 200
78 ${tmp}= Get Json Value ${resp.text} /clients/0/mrClientId
79 ${clientId}= Remove String ${tmp} \"
80 ${resp}= DelCall ${DBC_URL}/mr_clients/${clientId}
81 Should Be Equal As Integers ${resp.status_code} 204
82
83
84*** Keywords ***
85CheckDir
86 [Arguments] ${path}
87 Directory Should Exist ${path}
88
89CheckUrl
90 [Arguments] ${session} ${path} ${expect}
91 ${resp}= Get Request ${session} ${path}
92 Should Be Equal As Integers ${resp.status_code} ${expect}
93
94PostCall
95 [Arguments] ${url} ${data}
96 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
97 ${resp}= Evaluate requests.post('${url}',data='${data}', headers=${headers},verify=False) requests
98 [Return] ${resp}
99
100DelCall
101 [Arguments] ${url}
102 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
103 ${resp}= Evaluate requests.delete('${url}', headers=${headers},verify=False) requests
104 [Return] ${resp}