Add remote session to etcd HA testcases 93/1793/1
authorIndumathi Buddi <ib405q@att.com>
Wed, 16 Oct 2019 04:54:46 +0000 (04:54 +0000)
committerIndumathi Buddi <ib405q@att.com>
Wed, 16 Oct 2019 04:55:37 +0000 (04:55 +0000)
Signed-off-by: Indumathi Buddi <ib405q@att.com>
Change-Id: I9219a85f48cb722d609793e8f43dc953328d4ae6

tests/k8s/etcd_ha/etcd_ha.resource
tests/k8s/etcd_ha/etcd_ha.robot

index aa6fb08..1486b9e 100644 (file)
 Library            BuiltIn
 Library            Process
 Library            String
 Library            BuiltIn
 Library            Process
 Library            String
+Library            SSHLibrary
+Library            OperatingSystem
 
 *** Variables ***
 ${ETCD_VERSION}         3
 
 *** Variables ***
 ${ETCD_VERSION}         3
+${SSH_KEYFILE}          ${HOME}/.ssh/id_rsa
 
 *** Keywords ***
 
 *** Keywords ***
+Open Connection And Log In
+    Open Connection        ${HOST}
+    Login With Public Key  ${USERNAME}  ${SSH_KEYFILE}
+
 Retrieve Etcd Config
 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
 
 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
 
 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
 
 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
 
 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
 
 Etcd Members Should Be Unchanged
     ${output}=     Get Etcd Members
index 7998ef7..b110d49 100644 (file)
@@ -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
 ...               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 ***
 
 
 *** Test Cases ***