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 Resource global_properties.robot
10 ${DCAE_HEALTH_CHECK_BODY} robot/assets/dcae/dcae_healthcheck.json
11 ${DCAE_HEALTH_CHECK_PATH} /gui
12 ${DCAE_ENDPOINT} ${GLOBAL_DCAE_SERVER_PROTOCOL}://${GLOBAL_INJECTED_DCAE_IP_ADDR}:${GLOBAL_DCAE_SERVER_PORT}
16 [Documentation] Runs a DCAE health check
17 ${auth}= Create List ${GLOBAL_DCAE_USERNAME} ${GLOBAL_DCAE_PASSWORD}
18 Log Creating session ${DCAE_ENDPOINT}
19 ${session}= Create Session dcae ${DCAE_ENDPOINT} auth=${auth}
20 ${uuid}= Generate UUID
21 ${data}= OperatingSystem.Get File ${DCAE_HEALTH_CHECK_BODY}
22 ${headers}= Create Dictionary X-ECOMP-Client-Version=ONAP-R2 action=getTable Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
23 ${resp}= Put Request dcae ${DCAE_HEALTH_CHECK_PATH} data=${data} headers=${headers}
24 Log Received response from dcae ${resp.json()}
25 Should Be Equal As Strings ${resp.status_code} 200
26 Check DCAE Results ${resp.json()}
29 [Documentation] Parse DCAE JSON response and make sure all rows have healthTestStatus=GREEN (except for the exceptions ;-)
31 @{rows}= Get From Dictionary ${json['returns']} rows
32 @{headers}= Get From Dictionary ${json['returns']} columns
34 # Retrieve column names from headers
35 ${columns}= Create List
36 :for ${header} in @{headers}
37 \ ${colName}= Get From Dictionary ${header} colName
38 \ Append To List ${columns} ${colName}
40 # Process each row making sure status=GREEN
41 :for ${row} in @{rows}
42 \ ${cells}= Get From Dictionary ${row} cells
43 \ ${dict}= Make A Dictionary ${cells} ${columns}
44 \ Is DCAE Status Valid ${dict}
48 # If it is GREEN we are done.
49 ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Item ${dict} healthTestStatus GREEN
50 Return From Keyword If '${status}' == 'PASS'
52 # Check for Exceptions
54 ${status} ${value}= Run Keyword And Ignore Error Check For Exception ${dict} vm-controller UNDEPLOYED YELLOW
55 Return From Keyword If '${status}' == 'PASS'
57 # Status not GREEN or is not an exception
58 Fail Health check failed ${dict}
61 [Arguments] ${dict} ${service} ${status} ${healthTestStatus}
62 # Test the significant attributes to see if this is a legit exception
63 ${exception}= Copy Dictionary ${dict}
64 Set To Dictionary ${exception} service=${service} status=${status} healthTestStatus=${healthTestStatus}
65 Dictionaries Should Be Equal ${dict} ${exception}
70 [Documentation] Given a list of column names and a list of dictionaries, map columname=value
71 [Arguments] ${columns} ${names} ${valuename}=value
72 ${dict}= Create Dictionary
73 ${collength}= Get Length ${columns}
74 ${namelength}= Get Length ${names}
75 :for ${index} in range 0 ${collength}
76 \ ${name}= Evaluate ${names}[${index}]
77 \ ${valued}= Evaluate ${columns}[${index}]
78 \ ${value}= Get From Dictionary ${valued} ${valueName}
79 \ Set To Dictionary ${dict} ${name} ${value}