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
7 Variables ../resources/DcaeVariables.py
8 Resource ../resources/dcae_properties.robot
11 ${DCAE_HEALTH_CHECK_BODY} %{WORKSPACE}/tests/dcae/testcases/assets/json_events/dcae_healthcheck.json
16 [Documentation] Create all required sessions
17 Create Session dcae_vesc_url ${VESC_URL}
18 Set Suite Variable ${suite_dcae_vesc_url_session} dcae_vesc_url
19 ${auth}= Create List ${VESC_HTTPS_USER} ${VESC_HTTPS_PD}
20 Create Session dcae_vesc_url_https ${VESC_URL_HTTPS} auth=${auth} disable_warnings=1
21 Set Suite Variable ${suite_dcae_vesc_url_https_session} dcae_vesc_url_https
22 ${wrong_auth}= Create List ${VESC_HTTPS_WRONG_USER} ${VESC_HTTPS_WRONG_PD}
23 Create Session dcae_vesc_url_https_wrong_auth ${VESC_URL_HTTPS} auth=${wrong_auth} disable_warnings=1
24 Set Suite Variable ${suite_dcae_vesc_url_https_wrong_auth_session} dcae_vesc_url_https_wrong_auth
25 ${certs}= Create List ${VESC_ROOTCA_CERT} ${VESC_ROOTCA_KEY}
26 Create Client Cert Session dcae_vesc_url_https_cert ${VESC_URL_HTTPS} client_certs=${certs} disable_warnings=1
27 Set Suite Variable ${suite_dcae_vesc_url_https_cert_session} dcae_vesc_url_https_cert
28 ${wrong_certs}= Create List ${VESC_WRONG_CERT} ${VESC_WRONG_KEY}
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 Suite Variable ${suite_dcae_vesc_url_https_wrong_cert_session} dcae_vesc_url_https_wrong_cert
31 Create Session dcae_vesc_url_https_wo_auth ${VESC_URL_HTTPS} disable_warnings=1
32 Set Suite Variable ${suite_dcae_vesc_url_https_wo_auth_session} dcae_vesc_url_https_wo_auth
35 ${headers}= Create Dictionary Content-Type=application/json
36 Set Suite Variable ${suite_headers} ${headers}
39 [Documentation] Get DCAE Nodes from Consul Catalog
40 #Log Creating session ${GLOBAL_DCAE_CONSUL_URL}
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
67 #Run Keyword if ${len} > 1 DCAE Check Health Status ${NodeName} ${StatusList[1]} 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 No Auth
132 [Documentation] Send an event to VES Collector
133 [Arguments] ${evtpath} ${evtdata}
134 ${resp}= Post Request ${suite_dcae_vesc_url_session} ${evtpath} data=${evtdata} headers=${suite_headers}
137 Publish Event To VES Collector
138 [Documentation] Send an event to VES Collector
139 [Arguments] ${evtpath} ${evtdata}
140 ${resp}= Post Request ${suite_dcae_vesc_url_https_session} ${evtpath} data=${evtdata} headers=${suite_headers}
143 Publish Event To VES Collector With Put Method
144 [Documentation] Send an event to VES Collector
145 [Arguments] ${evtpath} ${evtdata}
146 ${resp}= Put Request ${suite_dcae_vesc_url_https_session} ${evtpath} data=${evtdata} headers=${suite_headers}
149 Publish Event To VES Collector With Put Method No Auth
150 [Documentation] Send an event to VES Collector
151 [Arguments] ${evtpath} ${evtdata}
152 ${resp}= Put Request ${suite_dcae_vesc_url_session} ${evtpath} data=${evtdata} headers=${suite_headers}
155 Publish Event To VES Collector With Wrong Auth
156 [Documentation] Send an event to VES Collector by session with wrong auth
157 [Arguments] ${evtpath} ${evtdata}
158 ${resp}= Post Request ${suite_dcae_vesc_url_https_wrong_auth_session} ${evtpath} data=${evtdata} headers=${suite_headers}
161 Publish Event To VES Collector With Cert
162 [Documentation] Send an event to VES Collector by session with certs
163 [Arguments] ${evtpath} ${evtdata}
164 ${resp}= Post Request ${suite_dcae_vesc_url_https_cert_session} ${evtpath} data=${evtdata} headers=${suite_headers}
167 Publish Event To VES Collector With Wrong Cert
168 [Documentation] Send an event to VES Collector by session with wrong certs
169 [Arguments] ${evtpath} ${evtdata}
170 ${resp}= Post Request ${suite_dcae_vesc_url_https_wrong_cert_session} ${evtpath} data=${evtdata} headers=${suite_headers}
173 Publish Event To VES Collector Without Auth And Cert
174 [Documentation] Send an event to VES Collector by session without Auth and Cert
175 [Arguments] ${evtpath} ${evtdata}
176 ${resp}= Post Request ${suite_dcae_vesc_url_https_wo_auth_session} ${evtpath} data=${evtdata} headers=${suite_headers}