blob: 392a2b043282faac83e86952e2f0be02a45ff09c [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with DCAE. It handles low level stuff like managing the http request library and DCAE required fields
3Library RequestsLibrary
Jerry Flood5db693b2017-05-24 08:52:39 -04004Library UUID
DR695Hccff30b2017-02-17 18:44:24 -05005Library OperatingSystem
6Library Collections
7Resource global_properties.robot
8
9*** Variables ***
10${DCAE_HEALTH_CHECK_BODY} robot/assets/dcae/dcae_healthcheck.json
11${DCAE_HEALTH_CHECK_PATH} /gui
DR695Hbf5a3a32017-06-30 13:09:57 -040012${DCAE_ENDPOINT} ${GLOBAL_DCAE_SERVER_PROTOCOL}://${GLOBAL_INJECTED_DCAE_IP_ADDR}:${GLOBAL_DCAE_SERVER_PORT}
DR695Hccff30b2017-02-17 18:44:24 -050013
14*** Keywords ***
15Run DCAE Health Check
16 [Documentation] Runs a DCAE health check
17 ${auth}= Create List ${GLOBAL_DCAE_USERNAME} ${GLOBAL_DCAE_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040018 Log Creating session ${DCAE_ENDPOINT}
19 ${session}= Create Session dcae ${DCAE_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050020 ${uuid}= Generate UUID
21 ${data}= OperatingSystem.Get File ${DCAE_HEALTH_CHECK_BODY}
Jerry Flood171c8652017-05-23 13:12:43 -040022 ${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}
DR695Hccff30b2017-02-17 18:44:24 -050023 ${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 Flood5db693b2017-05-24 08:52:39 -040027
DR695Hccff30b2017-02-17 18:44:24 -050028Check DCAE Results
Jerry Floodcf7d7462017-06-02 15:25:36 -040029 [Documentation] Parse DCAE JSON response and make sure all rows have healthTestStatus=GREEN (except for the exceptions ;-)
DR695Hccff30b2017-02-17 18:44:24 -050030 [Arguments] ${json}
31 @{rows}= Get From Dictionary ${json['returns']} rows
32 @{headers}= Get From Dictionary ${json['returns']} columns
Jerry Flood5db693b2017-05-24 08:52:39 -040033
DR695Hccff30b2017-02-17 18:44:24 -050034 # Retrieve column names from headers
35 ${columns}= Create List
36 :for ${header} in @{headers}
Jerry Flood5db693b2017-05-24 08:52:39 -040037 \ ${colName}= Get From Dictionary ${header} colName
DR695Hccff30b2017-02-17 18:44:24 -050038 \ Append To List ${columns} ${colName}
Jerry Flood5db693b2017-05-24 08:52:39 -040039
40 # Process each row making sure status=GREEN
DR695Hccff30b2017-02-17 18:44:24 -050041 :for ${row} in @{rows}
42 \ ${cells}= Get From Dictionary ${row} cells
Jerry Flood5db693b2017-05-24 08:52:39 -040043 \ ${dict}= Make A Dictionary ${cells} ${columns}
Jerry Floodcf7d7462017-06-02 15:25:36 -040044 \ Is DCAE Status Valid ${dict}
45
46Is 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
60Check 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
DR695Hccff30b2017-02-17 18:44:24 -050067
Jerry Flood5db693b2017-05-24 08:52:39 -040068
DR695Hccff30b2017-02-17 18:44:24 -050069Make 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 Flood5db693b2017-05-24 08:52:39 -040073 ${collength}= Get Length ${columns}
74 ${namelength}= Get Length ${names}
DR695Hccff30b2017-02-17 18:44:24 -050075 :for ${index} in range 0 ${collength}
76 \ ${name}= Evaluate ${names}[${index}]
77 \ ${valued}= Evaluate ${columns}[${index}]
78 \ ${value}= Get From Dictionary ${valued} ${valueName}
Jerry Flood5db693b2017-05-24 08:52:39 -040079 \ Set To Dictionary ${dict} ${name} ${value}
80 [Return] ${dict}