Issue-ID: RIC-149
[it/test.git] / ric_robot_suite / helm / nanobot / configmap-src / public / testsuites / health-check.robot
1 #   Copyright (c) 2019 AT&T Intellectual Property.
2 #   Copyright (c) 2020 HCL Technologies Ltd. 
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15
16 *** Settings *** 
17 Documentation      Run basic health checks for all known components which have one 
18  
19 Resource           /robot/resources/global_properties.robot 
20  
21 Resource           /robot/resources/ric/ric_utils.robot 
22  
23 Library  KubernetesEntity  ${GLOBAL_RICPLT_NAMESPACE} 
24 Library  Collections 
25 Library  String 
26 Library  Process 
27 Library  OperatingSystem 
28  
29  
30 *** Test Cases *** 
31 Basic Component Health Checks 
32   [Documentation]  For any defined RIC component with a health check keyword, 
33   ...              Run that keyword.  "Health check" keywords have names of the 
34   ...              form "Run ${component} Health Check". 
35   # This could have been entirely implemented in Helm; however, I wanted to 
36   # allow for the possibility that it would be used (with some modification) 
37   # by the ric-robot, which does not perform template expansion on testsuites. 
38   [Tags]  health 
39   Set Test Variable     ${finalStatus}  PASS 
40   FOR   ${component}  IN        @{GLOBAL_RICPLT_COMPONENTS} 
41      Log To Console     component is ${component} 
42      Run Keyword And Ignore Error 
43      ...   Import Resource      /robot/resources/${component}_interface.robot 
44      ${healthCheck} =   Set Variable    Run ${component} Health Check 
45      ${status} =        Run Keyword If Present  ${healthCheck} 
46      Log To Console     ${healthcheck} 
47      Log To Console     ${status} 
48      ${finalStatus} =   Set Variable If   '${status}' == 'FAIL'  FAIL  ${finalStatus} 
49      Run Keyword If     '${status}' == 'FAIL' 
50      ...                Log To Console  ${component} is unhealthy 
51      ...  ELSE 
52      ...                Log To Console  ${component} is healthy 
53      Log To Console     ----------------------------------------------------------------- 
54   END 
55   Run Keyword If        '${finalStatus}' == 'FAIL' 
56   ...                   Fail  One or more Health Checks failed 
57