From cca93b8afbca719909a2a6a380e048520e6366a4 Mon Sep 17 00:00:00 2001 From: Juha Kosonen Date: Thu, 23 May 2019 16:31:02 +0300 Subject: [PATCH] Add etcd ha test cases 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 Change-Id: I492ac86d0c34b3768469c4272bfc4a502a2847f7 Signed-off-by: Indumathi Buddi --- tests/k8s/etcd_ha/etcd_ha.resource | 66 ++++++++++++++++++++++++++++++++++++++ tests/k8s/etcd_ha/etcd_ha.robot | 32 ++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 tests/k8s/etcd_ha/etcd_ha.resource create mode 100644 tests/k8s/etcd_ha/etcd_ha.robot diff --git a/tests/k8s/etcd_ha/etcd_ha.resource b/tests/k8s/etcd_ha/etcd_ha.resource new file mode 100644 index 0000000..aa6fb08 --- /dev/null +++ b/tests/k8s/etcd_ha/etcd_ha.resource @@ -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 index 0000000..7998ef7 --- /dev/null +++ b/tests/k8s/etcd_ha/etcd_ha.robot @@ -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 -- 2.16.6