Merge "bluval engine refactoring"
[validation.git] / ceph / ceph_service.resource
1 ##############################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property.                             #
3 # Copyright (c) 2019 Nokia.                                                  #
4 #                                                                            #
5 # Licensed under the Apache License, Version 2.0 (the "License");            #
6 # you maynot use this file except in compliance with the License.            #
7 #                                                                            #
8 # You may obtain a copy of the License at                                    #
9 #       http://www.apache.org/licenses/LICENSE-2.0                           #
10 #                                                                            #
11 # Unless required by applicable law or agreed to in writing, software        #
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
14 # See the License for the specific language governing permissions and        #
15 # limitations under the License.                                             #
16 ##############################################################################
17
18
19 *** Settings ***
20 Library           BuiltIn
21 Library           SSHLibrary
22 Resource          variables.resource
23
24
25 *** Keywords ***
26 Open Connection And Log In
27     Open Connection          ${HOST}
28     Login With Public Key    ${USERNAME}  ${KEYFILE}
29
30 Start Ceph Manager
31     [Arguments]              @{nodes}
32     :FOR  ${node}  IN  @{nodes}
33     \   ${result}=           Run Manager Start  ${node}
34
35 Start Ceph Monitor
36     [Arguments]              @{nodes}
37     :FOR  ${node}  IN  @{nodes}
38     \   ${result}=           Run Monitor Start  ${node}
39
40 Start Ceph OSD
41     [Arguments]              @{nodes}
42     :FOR  ${node}  IN  @{nodes}
43     \   ${result}=           Run Ceph OSD Start  ${node}
44
45 Kill Ceph Manager
46     [Arguments]              @{nodes}
47     :FOR  ${node}  IN  @{nodes}
48     \   ${stdout}=           Execute Command  ${SSH_CMD} ${node} "sudo pkill -u ceph ceph-mgr"
49
50 Kill Ceph Monitor
51     [Arguments]              @{nodes}
52     :FOR  ${node}  IN  @{nodes}
53     \   ${stdout}=           Execute Command  ${SSH_CMD} ${node} "sudo pkill -u ceph ceph-mon"
54
55 Kill Ceph OSD
56     [Arguments]              @{nodes}
57     :FOR  ${node}  IN  @{nodes}
58     \   ${stdout}=           Execute Command  ${SSH_CMD} ${node} "sudo pkill -u ceph ceph-osd"
59
60 Ceph Should Be Healthy
61     ${stdout}=               Execute Command  ceph health --connect-timeout 20  sudo=True
62     Should Contain  ${stdout}  HEALTH_OK
63
64 Ceph Health Should Be Degraded
65     ${stdout}=               Execute Command  ceph health --connect-timeout 20  sudo=True
66     Should Contain  ${stdout}  HEALTH_WARN
67
68 Number Of OSDs Up
69     ${stdout}=               Execute Command  ceph -f json osd stat  sudo=True
70     ${stat}=                 Evaluate  json.loads($stdout)  json
71     [Return]                 ${stat["num_up_osds"]}
72
73 Number Of OSDs Up Should Be
74     [Arguments]              ${num_expected}
75     ${num_up_osds}=          Number Of OSDs Up
76     Should Be Equal          ${num_up_osds}  ${num_expected}
77
78 Run Manager Start
79     [Arguments]              ${node}
80     Execute Command          ${SSH_CMD} ${node} "sudo systemctl start ceph-mgr@${node}"
81     ${stdout}=               Execute Command  ${SSH_CMD} ${node} "systemctl is-active ceph-mgr@${node}"
82     Return From Keyword If   '${stdout}' == 'active'
83     Execute Command          ${SSH_CMD} ${node} "sudo systemctl reset-failed ceph-mgr@${node}"
84     Execute Command          ${SSH_CMD} ${node} "sudo systemctl start ceph-mgr@${node}"
85     ${stdout}=               Execute Command  ${SSH_CMD} ${node} "systemctl is-active ceph-mgr@${node}"
86     Should Be Equal As Strings  ${stdout}  active
87
88 Run Monitor Start
89     [Arguments]              ${node}
90     Execute Command          ${SSH_CMD} ${node} "sudo systemctl start ceph-mon@${node}"
91     ${stdout}=               Execute Command  ${SSH_CMD} ${node} "systemctl is-active ceph-mon@${node}"
92     Return From Keyword If   '${stdout}' == 'active'
93     Execute Command          ${SSH_CMD} ${node} "sudo systemctl reset-failed ceph-mon@${node}"
94     Execute Command          ${SSH_CMD} ${node} "sudo systemctl start ceph-mon@${node}"
95     ${stdout}=               Execute Command  ${SSH_CMD} ${node} "systemctl is-active ceph-mon@${node}"
96     Should Be Equal As Strings  ${stdout}  active
97
98 Run Ceph OSD Start
99     [Arguments]              ${node}
100     Execute Command          ${SSH_CMD} ${node} "sudo systemctl -a start ceph-osd@*"
101     ${stdout}=               Execute Command  ${SSH_CMD} ${node} "systemctl -a is-active ceph-osd@*"
102     Return From Keyword If   '${stdout}' == 'active'
103     Execute Command          ${SSH_CMD} ${node} "sudo systemctl -a reset-failed ceph-osd@*"
104     Execute Command          ${SSH_CMD} ${node} "sudo systemctl -a start ceph-osd@*"
105     ${stdout}=               Execute Command  ${SSH_CMD} ${node} "systemctl -a is-active ceph-osd@*"
106     Should Be Equal As Strings  ${stdout}  active