Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Resource ../../common.robot |
| 3 | Library Collections |
| 4 | Library json |
| 5 | Library OperatingSystem |
| 6 | Library RequestsLibrary |
| 7 | Library HttpLibrary.HTTP |
| 8 | Library String |
| 9 | |
| 10 | |
| 11 | *** Variables *** |
efiacor | 3d202b5 | 2021-03-29 09:25:03 +0100 | [diff] [blame] | 12 | ${DBC_URI} webapi |
| 13 | ${DBC_URL} http://${DMAAP_BC_IP}:8080/${DBC_URI} |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 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} } |
| 25 | |
| 26 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 27 | *** Test Cases *** |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 28 | (DMAAP-293) |
| 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 |
| 32 | |
| 33 | (DMAAP-294) |
| 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 |
| 37 | |
| 38 | (DMAAP-295) |
| 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 |
| 46 | |
| 47 | (DMAAP-297) |
| 48 | [Documentation] Query for all topics and specific topic |
| 49 | Create Session get ${DBC_URL} |
efiacor | 3d202b5 | 2021-03-29 09:25:03 +0100 | [diff] [blame] | 50 | ${resp}= GET On Session get /topics |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 51 | Should Be Equal As Integers ${resp.status_code} 200 |
efiacor | 3d202b5 | 2021-03-29 09:25:03 +0100 | [diff] [blame] | 52 | ${resp}= GET On Session get /topics/${TOPIC_NS}.singleMRtopic3 |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 53 | Should Be Equal As Integers ${resp.status_code} 200 |
| 54 | |
| 55 | (DMAAP-301) |
| 56 | [Documentation] Delete a subscriber |
| 57 | Create Session get ${DBC_URL} |
efiacor | 3d202b5 | 2021-03-29 09:25:03 +0100 | [diff] [blame] | 58 | ${resp}= GET On Session get /topics/${TOPIC_NS}.singleMRtopic3 |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 59 | Should Be Equal As Integers ${resp.status_code} 200 |
efiacor | 3d202b5 | 2021-03-29 09:25:03 +0100 | [diff] [blame] | 60 | ${JSON}= Evaluate json.loads(r"""${resp.content}""", strict=False) |
| 61 | ${clientId}= Set Variable ${JSON['clients'][1]['mrClientId']} |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 62 | ${resp}= DelCall ${DBC_URL}/mr_clients/${clientId} |
| 63 | Should Be Equal As Integers ${resp.status_code} 204 |
| 64 | |
| 65 | (DMAAP-302) |
| 66 | [Documentation] Delete a publisher |
| 67 | Create Session get ${DBC_URL} |
efiacor | 3d202b5 | 2021-03-29 09:25:03 +0100 | [diff] [blame] | 68 | ${resp}= GET On Session get /topics/${TOPIC_NS}.singleMRtopic3 |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 69 | Should Be Equal As Integers ${resp.status_code} 200 |
efiacor | 3d202b5 | 2021-03-29 09:25:03 +0100 | [diff] [blame] | 70 | ${JSON}= Evaluate json.loads(r"""${resp.content}""", strict=False) |
| 71 | ${clientId}= Set Variable ${JSON['clients'][0]['mrClientId']} |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 72 | ${resp}= DelCall ${DBC_URL}/mr_clients/${clientId} |
| 73 | Should Be Equal As Integers ${resp.status_code} 204 |
| 74 | |
| 75 | |
| 76 | *** Keywords *** |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 77 | PostCall |
| 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 |
| 81 | [Return] ${resp} |
| 82 | |
| 83 | DelCall |
| 84 | [Arguments] ${url} |
| 85 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 86 | ${resp}= Evaluate requests.delete('${url}', headers=${headers},verify=False) requests |
| 87 | [Return] ${resp} |