Convention over configuration
[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 Library            SSHLibrary
24 Library            OperatingSystem
25
26 *** Variables ***
27 ${ETCD_VERSION}         3
28 ${SSH_KEYFILE}          /root/.ssh/id_rsa
29
30 *** Keywords ***
31 Open Connection And Log In
32     Open Connection        ${HOST}
33     Login With Public Key  ${USERNAME}  ${SSH_KEYFILE}
34
35 Retrieve Etcd Config
36      ${result}=     Execute Command    kubectl get nodes -l node-role.kubernetes.io/master -o jsonpath\='{.items[*].metadata.name}'
37      @{nodes}=      Split String  ${result}
38      Set Test Variable  ${pod}  etcd-@{nodes}[0]
39      ${members}=    Get Etcd Members
40      Set Test Variable  ${members}
41
42 Get Etcd Members
43     ${result}=     Execute Command  kubectl exec -n kube-system -it ${pod} etcdctl${ETCD_VERSION} member list
44     log        ${result}
45
46 Delete Etcd Node
47     ${result}=     Execute Command  kubectl delete pod -n kube-system ${pod}
48     Should Be Equal As Strings  ${result}  pod "${pod}" deleted  msg="pod delete failed"
49
50 Wait For Etcd Node To Recover
51     Wait Until Keyword Succeeds  5m  10s  Etcd Node Should Be Running
52
53 Etcd Node Should Be Running
54     ${result}=     Execute Command  kubectl get -n kube-system -o template pod/${pod} --template\='{{.status.phase}}'
55     Should Contain  ${result}  Running
56
57 Etcd Endpoint Should Be Healthy
58     ${result}=     Execute Command  kubectl exec -n kube-system -ti ${pod} etcdctl${ETCD_VERSION} endpoint health
59     Should Contain  ${result}  healthy
60
61 Etcd Members Should Be Unchanged
62     ${output}=     Get Etcd Members
63     Should Be Equal As Strings  ${output}  ${members}
64
65 Etcd Cluster Should Be Healthy
66     Etcd Node Should Be Running
67     Etcd Endpoint Should Be Healthy
68     Etcd Members Should Be Unchanged