DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 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 |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 4 | Library UUID |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 5 | Library OperatingSystem |
| 6 | Library Collections |
| 7 | Resource global_properties.robot |
| 8 | |
| 9 | *** Variables *** |
| 10 | ${DCAE_HEALTH_CHECK_BODY} robot/assets/dcae/dcae_healthcheck.json |
| 11 | ${DCAE_HEALTH_CHECK_PATH} /gui |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 12 | ${DCAE_ENDPOINT} ${GLOBAL_DCAE_SERVER_PROTOCOL}://${GLOBAL_INJECTED_DCAE_IP_ADDR}:${GLOBAL_DCAE_SERVER_PORT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 13 | |
| 14 | *** Keywords *** |
| 15 | Run DCAE Health Check |
| 16 | [Documentation] Runs a DCAE health check |
| 17 | ${auth}= Create List ${GLOBAL_DCAE_USERNAME} ${GLOBAL_DCAE_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 18 | Log Creating session ${DCAE_ENDPOINT} |
| 19 | ${session}= Create Session dcae ${DCAE_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 20 | ${uuid}= Generate UUID |
| 21 | ${data}= OperatingSystem.Get File ${DCAE_HEALTH_CHECK_BODY} |
Jerry Flood | 171c865 | 2017-05-23 13:12:43 -0400 | [diff] [blame] | 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} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 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()} |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 27 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 28 | Check DCAE Results |
Jerry Flood | cf7d746 | 2017-06-02 15:25:36 -0400 | [diff] [blame] | 29 | [Documentation] Parse DCAE JSON response and make sure all rows have healthTestStatus=GREEN (except for the exceptions ;-) |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 30 | [Arguments] ${json} |
| 31 | @{rows}= Get From Dictionary ${json['returns']} rows |
| 32 | @{headers}= Get From Dictionary ${json['returns']} columns |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 33 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 34 | # Retrieve column names from headers |
| 35 | ${columns}= Create List |
| 36 | :for ${header} in @{headers} |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 37 | \ ${colName}= Get From Dictionary ${header} colName |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 38 | \ Append To List ${columns} ${colName} |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 39 | |
| 40 | # Process each row making sure status=GREEN |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 41 | :for ${row} in @{rows} |
| 42 | \ ${cells}= Get From Dictionary ${row} cells |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 43 | \ ${dict}= Make A Dictionary ${cells} ${columns} |
Jerry Flood | cf7d746 | 2017-06-02 15:25:36 -0400 | [diff] [blame] | 44 | \ Is DCAE Status Valid ${dict} |
| 45 | |
| 46 | Is DCAE Status Valid |
| 47 | [Arguments] ${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' |
| 51 | |
| 52 | # Check for Exceptions |
| 53 | # Only 1 so far |
| 54 | ${status} ${value}= Run Keyword And Ignore Error Check For Exception ${dict} vm-controller UNDEPLOYED YELLOW |
| 55 | Return From Keyword If '${status}' == 'PASS' |
| 56 | |
| 57 | # Status not GREEN or is not an exception |
| 58 | Fail Health check failed ${dict} |
| 59 | |
| 60 | Check for Exception |
| 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} |
| 66 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 67 | |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 68 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 69 | Make A Dictionary |
| 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 |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 73 | ${collength}= Get Length ${columns} |
| 74 | ${namelength}= Get Length ${names} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 75 | :for ${index} in range 0 ${collength} |
| 76 | \ ${name}= Evaluate ${names}[${index}] |
| 77 | \ ${valued}= Evaluate ${columns}[${index}] |
| 78 | \ ${value}= Get From Dictionary ${valued} ${valueName} |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 79 | \ Set To Dictionary ${dict} ${name} ${value} |
| 80 | [Return] ${dict} |