2 Documentation The main interface for interacting with DCAE. It handles low level stuff like managing the http request library and DCAE required fields
3 Library robot_library.DcaeLibrary
4 Library robot_library.DmaapLibrary
5 Library robot_library.CertsLibrary
6 Library RequestsLibrary
7 Library OperatingSystem
9 Variables ./robot_library/DcaeVariables.py
10 Resource ../../../common.robot
11 Resource ./dcae_properties.robot
15 [Documentation] Create all required sessions
16 ${auth}= Create List ${VESC_HTTPS_USER} ${VESC_HTTPS_PD}
17 ${wrong_auth}= Create List ${VESC_HTTPS_WRONG_USER} ${VESC_HTTPS_WRONG_PD}
18 ${certs}= Create List ${VESC_CERT} ${VESC_KEY}
19 ${wrong_certs}= Create List ${VESC_WRONG_CERT} ${VESC_WRONG_KEY}
20 ${outdated_certs}= Create List ${VESC_OUTDATED_CERT} ${VESC_OUTDATED_KEY}
21 Create Session dcae_vesc_url ${VESC_URL}
22 Set Global Variable ${http_session} dcae_vesc_url
23 Create Session dcae_vesc_url_https ${VESC_URL_HTTPS} auth=${auth} disable_warnings=1
24 Set Global Variable ${https_basic_auth_session} dcae_vesc_url_https
25 Create Session dcae_vesc_url_https_wrong_auth ${VESC_URL_HTTPS} auth=${wrong_auth} disable_warnings=1
26 Set Global Variable ${https_wrong_auth_session} dcae_vesc_url_https_wrong_auth
27 Create Client Cert Session dcae_vesc_url_https_cert ${VESC_URL_HTTPS} client_certs=${certs} disable_warnings=1
28 Set Global Variable ${https_valid_cert_session} dcae_vesc_url_https_cert
29 Create Client Cert Session dcae_vesc_url_https_wrong_cert ${VESC_URL_HTTPS} client_certs=${wrong_certs} disable_warnings=1 verify=${False}
30 Set Global Variable ${https_invalid_cert_session} dcae_vesc_url_https_wrong_cert
31 Create Client Cert Session dcae_vesc_url_https_outdated_cert ${VESC_URL_HTTPS} client_certs=${outdated_certs} disable_warnings=1 verify=${False}
32 Set Global Variable ${https_outdated_cert_session} dcae_vesc_url_https_outdated_cert
33 Create Session dcae_vesc_url_https_wo_auth ${VESC_URL_HTTPS} disable_warnings=1
34 Set Global Variable ${https_no_cert_no_auth_session} dcae_vesc_url_https_wo_auth
37 ${headers}= Create Dictionary Content-Type=application/json
38 Set Global Variable ${suite_headers} ${headers}
41 [Documentation] Get DCAE Nodes from Consul Catalog
42 ${session}= Create Session dcae ${GLOBAL_DCAE_CONSUL_URL}
43 ${uuid}= Generate UUID
44 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-Consul-Token=abcd1234 X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
45 ${resp}= Get Request dcae /v1/catalog/nodes headers=${headers}
46 Log Received response from dcae consul: ${resp.json()}
47 Should Be Equal As Strings ${resp.status_code} 200
48 ${NodeList}= Get Json Value List ${resp.text} Node
49 ${NodeListLength}= Get Length ${NodeList}
50 ${len}= Get Length ${NodeList}
51 Should Not Be Equal As Integers ${len} 0
54 DCAE Node Health Check
55 [Documentation] Perform DCAE Node Health Check
56 [Arguments] ${NodeName}
57 ${session}= Create Session dcae-${NodeName} ${GLOBAL_DCAE_CONSUL_URL}
58 ${uuid}= Generate UUID
59 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-Consul-Token=abcd1234 X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
60 ${hcpath}= Catenate SEPARATOR= /v1/health/node/ ${NodeName}
61 ${resp}= Get Request dcae-${NodeName} ${hcpath} headers=${headers}
62 Log Received response from dcae consul: ${resp.json()}
63 Should Be Equal As Strings ${resp.status_code} 200
64 ${StatusList}= Get Json Value List ${resp.text} Status
65 ${len}= Get Length ${StatusList}
66 Should Not Be Equal As Integers ${len} 0
67 DCAE Check Health Status ${NodeName} ${StatusList[0]} Serf Health Status
69 DCAE Check Health Status
70 [Arguments] ${NodeName} ${ItemStatus} ${CheckType}
71 Should Be Equal As Strings ${ItemStatus} passing
72 Log Node: ${NodeName} ${CheckType} check pass ok
74 VES Collector Suite Setup DMaaP
75 [Documentation] Start DMaaP Mockup Server
76 ${ret}= Setup DMaaP Server
77 Should Be Equal As Strings ${ret} true
79 VES Collector Suite Shutdown DMaaP
80 [Documentation] Shutdown DMaaP Mockup Server
81 ${ret}= Shutdown DMaap
82 Should Be Equal As Strings ${ret} true
85 [Documentation] Parse DCAE JSON response and make sure all rows have healthTestStatus=GREEN
87 @{rows}= Get From Dictionary ${json['returns']} rows
88 @{headers}= Get From Dictionary ${json['returns']} columns
89 # Retrieve column names from headers
90 ${columns}= Create List
91 :for ${header} IN @{headers}
92 \ ${colName}= Get From Dictionary ${header} colName
93 \ Append To List ${columns} ${colName}
94 # Process each row making sure status=GREEN
95 :for ${row} IN @{rows}
96 \ ${cells}= Get From Dictionary ${row} cells
97 \ ${dict}= Make A Dictionary ${cells} ${columns}
98 \ Dictionary Should Contain Item ${dict} healthTestStatus GREEN
101 [Documentation] Given a list of column names and a list of dictionaries, map columname=value
102 [Arguments] ${columns} ${names} ${valuename}=value
103 ${dict}= Create Dictionary
104 ${collength}= Get Length ${columns}
105 ${namelength}= Get Length ${names}
106 :for ${index} IN RANGE 0 ${collength}
107 \ ${name}= Evaluate ${names}[${index}]
108 \ ${valued}= Evaluate ${columns}[${index}]
109 \ ${value}= Get From Dictionary ${valued} ${valueName}
110 \ Set To Dictionary ${dict} ${name} ${value}
113 Json String To Dictionary
114 [Arguments] ${json_string}
115 ${json_dict}= evaluate json.loads('''${json_string}''') json
116 [Return] ${json_dict}
118 Dictionary To Json String
119 [Arguments] ${json_dict}
120 ${json_string}= evaluate json.dumps(${json_dict}) json
121 [Return] ${json_string}
123 Get DCAE Service Component Status
124 [Documentation] Get the status of a DCAE Service Component
125 [Arguments] ${url} ${urlpath} ${usr} ${passwd}
126 ${auth}= Create List ${usr} ${passwd}
127 ${session}= Create Session dcae-service-component ${url} auth=${auth}
128 ${resp}= Get Request dcae-service-component ${urlpath}
131 Publish Event To VES Collector
132 [Documentation] Send an event to VES Collector
133 [Arguments] ${session} ${evtpath} ${evtdata}
134 ${resp}= Post Request ${session} ${evtpath} data=${evtdata} headers=${suite_headers}
137 Publish Event To VES Collector With Put Method
138 [Documentation] Send an event to VES Collector
139 [Arguments] ${session} ${evtpath} ${evtdata}
140 ${resp}= Put Request ${session} ${evtpath} data=${evtdata} headers=${suite_headers}
143 Send Request And Validate Response And Error Message
144 [Documentation] Post single event to passed url and validate received response code and content
145 [Arguments] ${keyword} ${session} ${evtpath} ${evtjson} ${resp_code} ${msg_content}
146 ${resp}= Send Request And Validate Response ${keyword} ${session} ${evtpath} ${evtjson} ${resp_code}
147 ${error_message}= Set Variable ${resp.json()['requestError']['ServiceException']['text']}
148 Should Be Equal As Strings ${msg_content} ${error_message}
150 Send Request And Validate Response
151 [Documentation] Post single event to passed url with passed data and validate received response
152 [Arguments] ${keyword} ${session} ${evtpath} ${evtjson} ${resp_code} ${msg_code}=None ${topic}=None
153 ${evtdata}= Get Data From File ${evtjson}
154 ${resp}= Run Keyword ${keyword} ${session} ${evtpath} ${evtdata}
155 Log Receive HTTPS Status code ${resp.status_code}
156 Should Be Equal As Strings ${resp.status_code} ${resp_code}
157 ${isEmpty}= Is Json Empty ${resp}
158 Run Keyword If '${isEmpty}' == False Log ${resp.json()}
159 Run Keyword If '${msg_code}' != 'None' Check Whether Message Received ${msg_code} ${topic}
162 Check Whether Message Received
163 [Documentation] Validate if message has been received
164 [Arguments] ${msg_code} ${topic}
165 ${ret}= Run Keyword If '${topic}' != 'None' DMaaP Message Receive On Topic ${msg_code} ${topic}
166 ... ELSE DMaaP Message Receive ${msg_code}
167 Should Be Equal As Strings ${ret} true
169 Send Request And Expect Error
170 [Documentation] Post singel event to passed url with passed data and expect error
171 [Arguments] ${keyword} ${session} ${evtpath} ${evtjson} ${error_type} @{error_content}
172 ${evtdata}= Get Data From File ${evtjson}
173 ${err_msg}= Run Keyword And Expect Error ${error_type} ${keyword} ${session} ${evtpath} ${evtdata}
174 FOR ${content} IN @{error_content}
175 Should Contain ${err_msg} ${content}
177 Log Recieved error message ${err_msg}
180 [Documentation] Run Healthcheck
181 [Arguments] ${session}
182 ${uuid}= Generate UUID
183 ${headers}= Create Dictionary Accept=*/* X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
184 ${resp}= Get Request ${session} /healthcheck headers=${headers}
185 Should Be Equal As Strings ${resp.status_code} 200