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