Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library OperatingSystem |
| 3 | Library RequestsLibrary |
| 4 | Library requests |
| 5 | Library Collections |
| 6 | Library String |
| 7 | |
| 8 | *** Variables *** |
| 9 | ${TARGETURL_PUBLISH} http://${DMAAP_MR_IP}:3904/events/TestTopic1 |
| 10 | ${TARGETURL_TOPICS} http://${DMAAP_MR_IP}:3904/topics |
| 11 | ${TARGETURL_SUBSCR} http://${DMAAP_MR_IP}:3904/events/TestTopic1/CG1/C1?timeout=1000 |
| 12 | ${TEST_DATA} {"topicName": "TestTopic1"} |
| 13 | ${TOPIC_DATA} {"topicName":"FirstTopic","topicDescription":"This is a TestTopic","partitionCount":"1","replicationCount":"3","transactionEnabled":"true"} |
| 14 | |
| 15 | *** Test Cases *** |
| 16 | Run Topic Creation and Publish |
| 17 | [Documentation] Topic Creation |
| 18 | [Timeout] 1 minute |
| 19 | ${resp}= PostCall ${TARGETURL_PUBLISH} ${TEST_DATA} |
| 20 | log ${TARGETURL_PUBLISH} |
| 21 | log ${resp.text} |
| 22 | Should Be Equal As Strings ${resp.status_code} 200 |
| 23 | ${count}= Evaluate $resp.json().get('count') |
| 24 | log 'JSON Response Code:'${resp} |
| 25 | |
| 26 | Run Subscribing a message status |
| 27 | [Documentation] Subscribide message status |
| 28 | [Timeout] 1 minute |
| 29 | ${resp}= GetCall ${TARGETURL_SUBSCR} |
| 30 | log ${TARGETURL_SUBSCR} |
| 31 | Should Be Equal As Strings ${resp.status_code} 200 |
| 32 | log 'JSON Response Code :'${resp} |
| 33 | |
| 34 | Run check topics are exisiting |
| 35 | [Documentation] Get the count of the Topics |
| 36 | [Timeout] 1 minute |
| 37 | ${resp}= GetCall ${TARGETURL_TOPICS} |
| 38 | log ${TARGETURL_TOPICS} |
| 39 | Should Be Equal As Strings ${resp.status_code} 200 |
| 40 | log 'JSON Response Code :'${resp} |
| 41 | ${topics}= Evaluate $resp.json().get('topics') |
| 42 | log ${topics} |
| 43 | ${ListLength}= Get Length ${topics} |
| 44 | log ${ListLength} |
| 45 | List Should Contain Value ${topics} TestTopic1 |
| 46 | |
| 47 | Run Publich and Subscribe a message |
| 48 | [Documentation] Publish and Subscribe the message |
| 49 | [Timeout] 1 minute |
| 50 | ${resp}= PostCall ${TARGETURL_PUBLISH} ${TEST_DATA} |
| 51 | log ${TARGETURL_PUBLISH} |
| 52 | log ${resp.text} |
| 53 | Should Be Equal As Strings ${resp.status_code} 200 |
| 54 | ${sub_resp}= GetCall ${TARGETURL_SUBSCR} |
| 55 | log ${TARGETURL_SUBSCR} |
| 56 | Should Be Equal As Strings ${sub_resp.status_code} 200 |
| 57 | log 'JSON Response Code :'${sub_resp} |
| 58 | ${ListLength}= Get Length ${sub_resp.json()} |
| 59 | log ${ListLength} |
| 60 | List Should Contain Value ${sub_resp.json()} {"topicName":"TestTopic1"} case_insensitive=yes |
| 61 | |
| 62 | *** Keywords *** |
| 63 | PostCall |
| 64 | [Arguments] ${url} ${data} |
| 65 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 66 | ${resp}= Evaluate requests.post('${url}',data='${data}', headers=${headers},verify=False) requests |
| 67 | [Return] ${resp} |
| 68 | |
| 69 | GetCall |
| 70 | [Arguments] ${url} |
| 71 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 72 | ${resp}= Evaluate requests.get('${url}', headers=${headers}, verify=False) requests |
| 73 | [Return] ${resp} |