2 Resource ../../common.robot
5 Library OperatingSystem
6 Library RequestsLibrary
7 Library HttpLibrary.HTTP
13 ${DBC_URL} http://${DMAAP_BC_IP}:8080/${DBC_URI}
14 ${TOPIC_NS} org.onap.dmaap.onapCSIT
15 ${LOC} csit-sanfrancisco
16 ${PUB_CORE} "dcaeLocationName": "${LOC}", "clientRole": "org.onap.dmaap.client.pub", "action": [ "pub", "view" ]
17 ${SUB_CORE} "dcaeLocationName": "${LOC}", "clientRole": "org.onap.dmaap.client.sub", "action": [ "sub", "view" ]
18 ${PUB} { ${PUB_CORE} }
19 ${SUB} { ${SUB_CORE} }
20 ${TOPIC1_DATA} { "topicName":"singleMRtopic1", "topicDescription":"generated for CSIT", "owner":"dgl"}
21 ${TOPIC2_DATA} { "topicName":"singleMRtopic2", "topicDescription":"generated for CSIT", "owner":"dgl", "clients": [ ${PUB}, ${SUB}] }
22 ${TOPIC3_DATA} { "topicName":"singleMRtopic3", "topicDescription":"generated for CSIT", "owner":"dgl"}
23 ${PUB3_DATA} { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${PUB_CORE} }
24 ${SUB3_DATA} { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${SUB_CORE} }
29 [Documentation] Create Topic w no clients POST ${DBC_URI}/topics endpoint
30 ${resp}= PostCall ${DBC_URL}/topics ${TOPIC1_DATA}
31 Should Be Equal As Integers ${resp.status_code} 201
34 [Documentation] Create Topic w pub and sub clients POST ${DBC_URI}/topics endpoint
35 ${resp}= PostCall ${DBC_URL}/topics ${TOPIC2_DATA}
36 Should Be Equal As Integers ${resp.status_code} 201
39 [Documentation] Create Topic w no clients and then add a client POST ${DBC_URI}/mr_clients endpoint
40 ${resp}= PostCall ${DBC_URL}/topics ${TOPIC3_DATA}
41 Should Be Equal As Integers ${resp.status_code} 201
42 ${resp}= PostCall ${DBC_URL}/mr_clients ${PUB3_DATA}
43 Should Be Equal As Integers ${resp.status_code} 200
44 ${resp}= PostCall ${DBC_URL}/mr_clients ${SUB3_DATA}
45 Should Be Equal As Integers ${resp.status_code} 200
48 [Documentation] Query for all topics and specific topic
49 Create Session get ${DBC_URL}
50 ${resp}= GET On Session get /topics
51 Should Be Equal As Integers ${resp.status_code} 200
52 ${resp}= GET On Session get /topics/${TOPIC_NS}.singleMRtopic3
53 Should Be Equal As Integers ${resp.status_code} 200
56 [Documentation] Delete a subscriber
57 Create Session get ${DBC_URL}
58 ${resp}= GET On Session get /topics/${TOPIC_NS}.singleMRtopic3
59 Should Be Equal As Integers ${resp.status_code} 200
60 ${JSON}= Evaluate json.loads(r"""${resp.content}""", strict=False)
61 ${clientId}= Set Variable ${JSON['clients'][1]['mrClientId']}
62 ${resp}= DelCall ${DBC_URL}/mr_clients/${clientId}
63 Should Be Equal As Integers ${resp.status_code} 204
66 [Documentation] Delete a publisher
67 Create Session get ${DBC_URL}
68 ${resp}= GET On Session get /topics/${TOPIC_NS}.singleMRtopic3
69 Should Be Equal As Integers ${resp.status_code} 200
70 ${JSON}= Evaluate json.loads(r"""${resp.content}""", strict=False)
71 ${clientId}= Set Variable ${JSON['clients'][0]['mrClientId']}
72 ${resp}= DelCall ${DBC_URL}/mr_clients/${clientId}
73 Should Be Equal As Integers ${resp.status_code} 204
78 [Arguments] ${url} ${data}
79 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
80 ${resp}= Evaluate requests.post('${url}',data='${data}', headers=${headers},verify=False) requests
85 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
86 ${resp}= Evaluate requests.delete('${url}', headers=${headers},verify=False) requests