Add etcd ha test cases 02/802/6
authorJuha Kosonen <juha.kosonen@nokia.com>
Thu, 23 May 2019 13:31:02 +0000 (16:31 +0300)
committerIndumathi Buddi <ib405q@att.com>
Mon, 16 Sep 2019 03:59:04 +0000 (03:59 +0000)
This is on par with the etcd tests for Airship on
ha/ha_etcd_api_ctl_sch.robot.

JIRA: VAL-25

Co-Authored-By: Juha Kosonen <juha.kosonen@nokia.com>
Change-Id: I492ac86d0c34b3768469c4272bfc4a502a2847f7
Signed-off-by: Indumathi Buddi <ib405q@att.com>
tests/k8s/etcd_ha/etcd_ha.resource [new file with mode: 0644]
tests/k8s/etcd_ha/etcd_ha.robot [new file with mode: 0644]

diff --git a/tests/k8s/etcd_ha/etcd_ha.resource b/tests/k8s/etcd_ha/etcd_ha.resource
new file mode 100644 (file)
index 0000000..aa6fb08
--- /dev/null
@@ -0,0 +1,66 @@
+##############################################################################
+# Copyright (c) 2019 AT&T Intellectual Property.                             #
+# Copyright (c) 2019 Nokia.                                                  #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License");            #
+# you maynot use this file except in compliance with the License.            #
+#                                                                            #
+# You may obtain a copy of the License at                                    #
+#       http://www.apache.org/licenses/LICENSE-2.0                           #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+##############################################################################
+
+
+*** Settings ***
+Library            BuiltIn
+Library            Process
+Library            String
+
+*** Variables ***
+${ETCD_VERSION}         3
+
+*** Keywords ***
+Retrieve Etcd Config
+    ${result}=     Run Process  kubectl  get  nodes  -l  node-role.kubernetes.io/master
+    ...                         -o  jsonpath\='{.items[*].metadata.name}'
+    ${output}=     Evaluate  ${result.stdout}
+    @{nodes}=      Split String  ${output}
+    Set Test Variable  ${pod}  etcd-@{nodes}[0]
+    ${members}=    Get Etcd Members
+    Set Test Variable  ${members}
+
+Get Etcd Members
+    ${result}=     Run Process  kubectl  exec  -n  kube-system  -it  ${pod}
+    ...                         etcdctl${ETCD_VERSION}  member  list
+    [Return]       ${result.stdout}
+
+Delete Etcd Node
+    ${result}=     Run Process  kubectl  delete  pod  -n  kube-system  ${pod}
+    Should Be Equal As Strings  ${result.stdout}  pod "${pod}" deleted  msg="pod delete failed"
+
+Wait For Etcd Node To Recover
+    Wait Until Keyword Succeeds  5m  10s  Etcd Node Should Be Running
+
+Etcd Node Should Be Running
+    ${result}=     Run Process  kubectl  get  -n  kube-system  -o  template  pod/${pod}
+    ...                         --template\='{{.status.phase}}'
+    Should Be Equal As Strings  ${result.stdout}  'Running'
+
+Etcd Endpoint Should Be Healthy
+    ${result}=     Run Process  kubectl  exec  -n  kube-system  -ti  ${pod}
+    ...                         etcdctl${ETCD_VERSION}  endpoint  health
+    Should Contain  ${result.stdout}  is healthy:
+
+Etcd Members Should Be Unchanged
+    ${output}=     Get Etcd Members
+    Should Be Equal As Strings  ${output}  ${members}
+
+Etcd Cluster Should Be Healthy
+    Etcd Node Should Be Running
+    Etcd Endpoint Should Be Healthy
+    Etcd Members Should Be Unchanged
diff --git a/tests/k8s/etcd_ha/etcd_ha.robot b/tests/k8s/etcd_ha/etcd_ha.robot
new file mode 100644 (file)
index 0000000..7998ef7
--- /dev/null
@@ -0,0 +1,32 @@
+##############################################################################
+# Copyright (c) 2019 AT&T Intellectual Property.                             #
+# Copyright (c) 2019 Nokia.                                                  #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License");            #
+# you maynot use this file except in compliance with the License.            #
+#                                                                            #
+# You may obtain a copy of the License at                                    #
+#       http://www.apache.org/licenses/LICENSE-2.0                           #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+##############################################################################
+
+
+*** Settings ***
+Documentation     Test to verify the recovery and health of etcd cluster
+...               If the etcd node command line supports etcdctl3 then pass ${ETCD_VERSION} as "3"
+...               If the etcd node command line supports etcdctl then pass ${ETCD_VERSION} as "${EMPTY}"
+Resource          etcd_ha.resource
+
+
+*** Test Cases ***
+Failure Of Etcd Node
+    Retrieve Etcd Config
+    Etcd Cluster Should Be Healthy
+    Delete Etcd Node
+    Wait For Etcd Node To Recover
+    Etcd Cluster Should Be Healthy