Add etcd ha test cases
[validation.git] / tests / k8s / etcd_ha / etcd_ha.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            Process
22 Library            String
23
24 *** Variables ***
25 ${ETCD_VERSION}         3
26
27 *** Keywords ***
28 Retrieve Etcd Config
29     ${result}=     Run Process  kubectl  get  nodes  -l  node-role.kubernetes.io/master
30     ...                         -o  jsonpath\='{.items[*].metadata.name}'
31     ${output}=     Evaluate  ${result.stdout}
32     @{nodes}=      Split String  ${output}
33     Set Test Variable  ${pod}  etcd-@{nodes}[0]
34     ${members}=    Get Etcd Members
35     Set Test Variable  ${members}
36
37 Get Etcd Members
38     ${result}=     Run Process  kubectl  exec  -n  kube-system  -it  ${pod}
39     ...                         etcdctl${ETCD_VERSION}  member  list
40     [Return]       ${result.stdout}
41
42 Delete Etcd Node
43     ${result}=     Run Process  kubectl  delete  pod  -n  kube-system  ${pod}
44     Should Be Equal As Strings  ${result.stdout}  pod "${pod}" deleted  msg="pod delete failed"
45
46 Wait For Etcd Node To Recover
47     Wait Until Keyword Succeeds  5m  10s  Etcd Node Should Be Running
48
49 Etcd Node Should Be Running
50     ${result}=     Run Process  kubectl  get  -n  kube-system  -o  template  pod/${pod}
51     ...                         --template\='{{.status.phase}}'
52     Should Be Equal As Strings  ${result.stdout}  'Running'
53
54 Etcd Endpoint Should Be Healthy
55     ${result}=     Run Process  kubectl  exec  -n  kube-system  -ti  ${pod}
56     ...                         etcdctl${ETCD_VERSION}  endpoint  health
57     Should Contain  ${result.stdout}  is healthy:
58
59 Etcd Members Should Be Unchanged
60     ${output}=     Get Etcd Members
61     Should Be Equal As Strings  ${output}  ${members}
62
63 Etcd Cluster Should Be Healthy
64     Etcd Node Should Be Running
65     Etcd Endpoint Should Be Healthy
66     Etcd Members Should Be Unchanged