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