blob: 85c5a614672e6bdf72172db7778a0dbed3697fb9 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
Brian Freeman19a4d2d2018-11-30 13:03:52 -05002Documentation The main interface for interacting with Message router. It handles low level stuff like managing the http request library and message router required fields
Brian Freemaned66ff92019-05-02 15:30:02 -05003Library RequestsLibrary
Brian Freemaned66ff92019-05-02 15:30:02 -05004Library DateTime
5Library Process
DR695H7aca1a42019-06-03 17:08:34 -04006Library ONAPLibrary.JSON
DR695H18872bc2019-06-13 16:16:52 -04007Library ONAPLibrary.Utilities
DR695Hccff30b2017-02-17 18:44:24 -05008
9Resource global_properties.robot
Brian Freemaned66ff92019-05-02 15:30:02 -050010Resource ../resources/json_templater.robot
DR695Hccff30b2017-02-17 18:44:24 -050011
12*** Variables ***
13${MR_HEALTH_CHECK_PATH} /topics
Brian Freeman19a4d2d2018-11-30 13:03:52 -050014${MR_PUB_HEALTH_CHECK_PATH} /events/TEST_TOPIC
15${MR_SUB_HEALTH_CHECK_PATH} /events/TEST_TOPIC/g1/c4?timeout=5000
Brian Freemaned66ff92019-05-02 15:30:02 -050016${MR_CREATE_TOPIC_PATH} /topics/create
17${MR_UPDATE_ACL_TOPIC_PATH} /topics/TEST_TOPIC_ACL/producers
Jerry Flood8fd592b2017-07-29 07:31:50 -040018${MR_ENDPOINT} ${GLOBAL_MR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_MR_IP_ADDR}:${GLOBAL_MR_SERVER_PORT}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050019${MR_PUBLISH_TEMPLATE} robot/assets/templates/mr_publish.template
Brian Freemaned66ff92019-05-02 15:30:02 -050020${MR_PUT_ACL_TEMPLATE} robot/assets/templates/mr_put_acl.template
DR695Hbf5a3a32017-06-30 13:09:57 -040021
DR695Hccff30b2017-02-17 18:44:24 -050022
23*** Keywords ***
24Run MR Health Check
25 [Documentation] Runs MR Health check
Jerry Flood8fd592b2017-07-29 07:31:50 -040026 ${resp}= Run MR Get Request ${MR_HEALTH_CHECK_PATH}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050027 Should Be Equal As Strings ${resp.status_code} 200
DR695Hccff30b2017-02-17 18:44:24 -050028 Should Contain ${resp.json()} topics
Jerry Flood8fd592b2017-07-29 07:31:50 -040029
Brian Freeman19a4d2d2018-11-30 13:03:52 -050030Run MR PubSub Health Check
31 [Documentation] Runs MR PubSub Health check
Brian Freemana8ceb692019-03-03 09:37:54 -050032 #${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050033 # topic may not be created which is a 400 error
Brian Freemana8ceb692019-03-03 09:37:54 -050034
Brian Freeman19a4d2d2018-11-30 13:03:52 -050035 ${resp}= Run MR Post Request ${MR_PUB_HEALTH_CHECK_PATH}
36 Should Be Equal As Strings ${resp.status_code} 200
37 Should Contain ${resp.json()} serverTimeMs Failed to Write Data
38 ${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH}
Brian Freemana8ceb692019-03-03 09:37:54 -050039 # Always Write twice to catch lost first message
40 ${resp}= Run MR Post Request ${MR_PUB_HEALTH_CHECK_PATH}
41 ${resp}= Run MR Get Request ${MR_SUB_HEALTH_CHECK_PATH}
Brian Freeman19a4d2d2018-11-30 13:03:52 -050042 # ${resp} is an array
43 Should Be Equal As Strings ${resp.status_code} 200
44 Should Contain ${resp.json()[0]} timestamp Failed to Read Data
45
Brian Freemaned66ff92019-05-02 15:30:02 -050046
47Run MR Update Topic Acl
48 [Documentation] Runs MR create topic and update producer credentials
49 #
50 # Testing to Delete a Topic:
51 # /opt/kafka/bin/kafka-topics.sh --zookeeper message-router-zookeeper:2181 --delete --topic <topic_name>
52 # /opt/kafka/bin/kafka-topics.sh --zookeeper message-router-zookeeper:2181 --delete --topic TEST_TOPIC_ACL
53 #
54 # Appears to not care if topic already exists with the POST / PUT method
55 #
56 ${dict}= Create Dictionary TOPIC_NAME=TEST_TOPIC_ACL
57 ${data}= Fill JSON Template File ${MR_PUT_ACL_TEMPLATE} ${dict}
58 #Log To Console ${\n}Create TEST_TOPIC_ACL
59 ${resp}= Run MR Auth Post Request ${MR_CREATE_TOPIC_PATH} iPIxkpAMI8qTcQj8 Ehq3WyT4bkif4zwgEbvshGal ${data}
60 #Log To Console Update Owner for TEST_TOPIC_ACL
61 ${resp}= Run MR Auth Put Request ${MR_UPDATE_ACL_TOPIC_PATH}/iPIxkpAMI8qTcQj8 iPIxkpAMI8qTcQj8 Ehq3WyT4bkif4zwgEbvshGal ${data}
62 Should Be Equal As Strings ${resp.status_code} 200
63
64Run MR Auth Post Request
65 [Documentation] Runs MR Authenticated Post Request
66 [Arguments] ${data_path} ${id_key} ${secret_key} ${data}
67 ${current_time}= Get Time
68 ${time}= Evaluate datetime.datetime.today().replace(tzinfo=pytz.UTC).replace(microsecond=0).isoformat() modules=datetime,pytz
69 ${command}= Set Variable /bin/echo -n "${time}" | /usr/bin/openssl sha1 -hmac "${secret_key}" -binary | /usr/bin/openssl base64
70 ${result}= Run Process ${command} shell=True
71 ${signature}= Set Variable ${result.stdout}
72 ${xAuth}= Set Variable ${id_key}:${signature}
73 ${headers}= Create Dictionary Content-Type=application/json X-CambriaAuth=${xAuth} X-CambriaDate=${time}
74 ${session}= Create Session mr ${MR_ENDPOINT}
75 ${resp}= Post Request mr ${data_path} headers=${headers} data=${data}
76 ${status_string}= Convert To String ${resp.status_code}
77 Should Match Regexp ${status_string} ^(204|200)$
78 Log Received response from message router ${resp.text}
79 [Return] ${resp}
80
81
82Run MR Auth Put Request
83 [Documentation] Runs MR Authenticated Put Request
84 [Arguments] ${data_path} ${id_key} ${secret_key} ${data}
85 ${current_time}= Get Time
86 ${time}= Evaluate datetime.datetime.today().replace(tzinfo=pytz.UTC).replace(microsecond=0).isoformat() modules=datetime,pytz
87 ${command}= Set Variable /bin/echo -n "${time}" | /usr/bin/openssl sha1 -hmac "${secret_key}" -binary | /usr/bin/openssl base64
88 ${result}= Run Process ${command} shell=True
89 ${signature}= Set Variable ${result.stdout}
90 ${xAuth}= Set Variable ${id_key}:${signature}
91 ${headers}= Create Dictionary Content-Type=application/json X-CambriaAuth=${xAuth} X-CambriaDate=${time}
92 ${session}= Create Session mr ${MR_ENDPOINT}
93 ${resp}= Put Request mr ${data_path} headers=${headers} data=${data}
94 Should Be Equal As Strings ${resp.status_code} 200
95 Log Received response from message router ${resp.text}
96 [Return] ${resp}
97
DR695Hccff30b2017-02-17 18:44:24 -050098Run MR Get Request
99 [Documentation] Runs MR Get request
100 [Arguments] ${data_path}
Brian Freeman19a4d2d2018-11-30 13:03:52 -0500101 ${session}= Create Session mr ${MR_ENDPOINT}
DR695H18872bc2019-06-13 16:16:52 -0400102 ${uuid}= Generate UUID4
DR695Hccff30b2017-02-17 18:44:24 -0500103 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
Brian Freeman19a4d2d2018-11-30 13:03:52 -0500104 ${resp}= Get Request mr ${data_path} headers=${headers}
105 Log Received response from message router ${resp.text}
106 [Return] ${resp}
107
108Run MR Post Request
109 [Documentation] Runs MR Post request
110 [Arguments] ${data_path}
111 ${session}= Create Session mr ${MR_ENDPOINT}
112 ${timestamp}= Get Current Date
113 ${dict}= Create Dictionary timestamp=${timestamp}
114 ${data}= Fill JSON Template File ${MR_PUBLISH_TEMPLATE} ${dict}
DR695H18872bc2019-06-13 16:16:52 -0400115 ${uuid}= Generate UUID4
Brian Freeman19a4d2d2018-11-30 13:03:52 -0500116 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
117 ${resp}= Post Request mr ${data_path} data=${data} headers=${headers}
DR695Hccff30b2017-02-17 18:44:24 -0500118 Log Received response from message router ${resp.text}
119 [Return] ${resp}
120