From: Indumathi Buddi Date: Wed, 16 Oct 2019 04:54:46 +0000 (+0000) Subject: Add remote session to etcd HA testcases X-Git-Tag: 2.0.0~15^2 X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F93%2F1793%2F1;p=validation.git Add remote session to etcd HA testcases Signed-off-by: Indumathi Buddi Change-Id: I9219a85f48cb722d609793e8f43dc953328d4ae6 --- diff --git a/tests/k8s/etcd_ha/etcd_ha.resource b/tests/k8s/etcd_ha/etcd_ha.resource index aa6fb08..1486b9e 100644 --- a/tests/k8s/etcd_ha/etcd_ha.resource +++ b/tests/k8s/etcd_ha/etcd_ha.resource @@ -20,41 +20,43 @@ Library BuiltIn Library Process Library String +Library SSHLibrary +Library OperatingSystem *** Variables *** ${ETCD_VERSION} 3 +${SSH_KEYFILE} ${HOME}/.ssh/id_rsa *** Keywords *** +Open Connection And Log In + Open Connection ${HOST} + Login With Public Key ${USERNAME} ${SSH_KEYFILE} + 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} + ${result}= Execute Command kubectl get nodes -l node-role.kubernetes.io/master -o jsonpath\='{.items[*].metadata.name}' + @{nodes}= Split String ${result} + 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} + ${result}= Execute Command kubectl exec -n kube-system -it ${pod} etcdctl${ETCD_VERSION} member list + log ${result} 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" + ${result}= Execute Command kubectl delete pod -n kube-system ${pod} + Should Be Equal As Strings ${result} 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' + ${result}= Execute Command kubectl get -n kube-system -o template pod/${pod} --template\='{{.status.phase}}' + Should Contain ${result} 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: + ${result}= Execute Command kubectl exec -n kube-system -ti ${pod} etcdctl${ETCD_VERSION} endpoint health + Should Contain ${result} healthy Etcd Members Should Be Unchanged ${output}= Get Etcd Members diff --git a/tests/k8s/etcd_ha/etcd_ha.robot b/tests/k8s/etcd_ha/etcd_ha.robot index 7998ef7..b110d49 100644 --- a/tests/k8s/etcd_ha/etcd_ha.robot +++ b/tests/k8s/etcd_ha/etcd_ha.robot @@ -21,6 +21,8 @@ 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 +Suite Setup Open Connection And Log In +Suite Teardown Close All Connections *** Test Cases ***