go.ligato.io/vpp-agent/v3@v3.5.0/tests/robot/libraries/kubernetes/KubeTestOperations.robot (about)

     1  *** Settings ***
     2  Resource    KubeEnv.robot
     3  Resource    ../SshCommons.robot
     4  
     5  *** Keywords ***
     6  Verify Pod Connectivity - Unix Ping
     7      [Documentation]    Run ping command from the named pod to the specified
     8      ...    IP address. Check that no packets were lost.
     9      [Arguments]    ${source_pod_name}    ${destination_ip}     ${count}=5
    10      ${stdout} =    Run Command In Pod    ping -c ${count} -s 1400 ${destination_ip}    ${source_pod_name}
    11      BuiltIn.Log Many    ${source_pod_name}    ${destination_ip}     ${count}
    12      BuiltIn.Should Contain    ${stdout}    ${count} received, 0% packet loss
    13  
    14  Verify Pod Connectivity - VPP Ping
    15      [Documentation]    Run ping command from the named pod's VPP command line
    16      ...    to the specified IP address. Check that no packets were lost.
    17      [Arguments]    ${source_pod_name}    ${destination_ip}     ${count}=5
    18      BuiltIn.Log Many    ${source_pod_name}    ${destination_ip}     ${count}
    19      ${stdout} =    Run Command In Pod    vppctl ping ${destination_ip} repeat ${count}    ${source_pod_name}
    20      BuiltIn.Should Contain    ${stdout}    ${count} received, 0% packet loss
    21  
    22  Trigger Pod Restart - VPP SIGSEGV
    23      [Documentation]    Trigger a pod restart by sending signal 11 to the pod's
    24      ...    running VPP process.
    25      [Arguments]    ${pod_name}
    26      BuiltIn.Log    ${pod_name}
    27      ${stdout} =    Run Command In Pod    pkill --signal 11 -f /usr/bin/vpp    ${pod_name}
    28  
    29  Trigger Pod Restart - Pod Deletion
    30      [Documentation]    Trigger a pod restart by deleting the pod using kubectl.
    31      [Arguments]    ${ssh_session}    ${pod_name}    ${vswitch}=${FALSE}
    32      BuiltIn.Log Many    ${ssh_session}    ${pod_name}    ${vswitch}
    33      ${stdout} =    Switch_And_Execute_Command    ${ssh_session}    kubectl delete pod ${pod_name}
    34      Wait Until Keyword Succeeds    20sec    1sec    KubeEnv.Verify_Pod_Not_Terminating    ${ssh_session}    ${pod_name}
    35      Run Keyword If    ${vswitch}    Get Vswitch Pod Name    ${ssh_session}
    36  
    37  Ping Until Success - Unix Ping
    38      [Documentation]    Execute ping loop on the named pod to the specified
    39      ...    IP address. Blocks until the ping succeeds or this keyword times out.
    40      [Arguments]    ${source_pod_name}    ${destination_ip}    ${timeout}
    41      [Timeout]    ${timeout}
    42      BuiltIn.Log Many    ${source_pod_name}    ${destination_ip}    ${timeout}
    43      ${stdout} =    Run Command In Pod    /bin/bash -c "until ping -c1 -w1 ${destination_ip} &>/dev/null; do :; done"    ${source_pod_name}
    44  
    45  Ping Until Success - VPP Ping
    46      [Documentation]    Repeatedly execute ping from the named pod's VPP until
    47      ...    the ping succeeds or timeout is reached.
    48      [Arguments]    ${source_pod_name}    ${destination_ip}    ${timeout}
    49      BuiltIn.Log Many    ${source_pod_name}    ${destination_ip}    ${timeout}
    50      BuiltIn.Wait Until Keyword Succeeds    ${timeout}    1s    Verify Pod Connectivity - VPP Ping    ${source_pod_name}    ${destination_ip}    count=1
    51  
    52  Get Vswitch Pod Name
    53      [Documentation]    Get the kubernetes name of currently deployed vswitch pod.
    54      ...    Note that a new name is generated after each pod restart.
    55      [Arguments]    ${ssh_session}
    56      BuiltIn.Log Many    ${ssh_session}
    57      ${vswitch_pod_name} =    Get_Deployed_Pod_Name    ${ssh_session}    vswitch-deployment-
    58      Set Global Variable    ${vswitch_pod_name}
    59  
    60  Restart Topology With Startup Sequence
    61      [Documentation]    Shutdown the kubernetes topology, then bring it back up
    62      ...    in the specified order. Note that some pods will not start
    63      ...    if ETCD is  not present.
    64      [Arguments]    @{sequence}
    65      BuiltIn.Log Many    @{sequence}
    66      Cleanup_Restarts_Deployment_On_Cluster    ${testbed_connection}
    67      :FOR    ${item}    IN    @{sequence}
    68      \    Run Keyword If    "${item}"=="etcd"       KubeEnv.Deploy_Etcd_And_Verify_Running    ${testbed_connection}
    69      \    Run Keyword If    "${item}"=="vswitch"    KubeEnv.Deploy_Vswitch_Pod_And_Verify_Running    ${testbed_connection}
    70      \    Run Keyword If    "${item}"=="sfc"        KubeEnv.Deploy_SFC_Pod_And_Verify_Running    ${testbed_connection}
    71      \    Run Keyword If    "${item}"=="vnf"        KubeEnv.Deploy_VNF_Pods    ${testbed_connection}    ${vnf_count}
    72      \    Run Keyword If    "${item}"=="novpp"      KubeEnv.Deploy_NoVPP_Pods    ${testbed_connection}    ${novpp_count}
    73  
    74  Scale Verify Connectivity - Unix Ping
    75      [Documentation]    Verify connectivity between pods in scale test scenario.
    76      ...    each non-VPP container attempts to ping every VNF pod.
    77      [Arguments]    ${timeout}=30m
    78      [Timeout]    ${timeout}
    79      BuiltIn.Log Many    ${topology}    ${timeout}
    80      :FOR    ${bridge_segment}    IN    @{topology}
    81      \    Iterate_Over_VNFs    ${bridge_segment}
    82  
    83  Iterate_Over_VNFs
    84      [Documentation]    Awkward implementation of nested for loop within robotframework.
    85      [Arguments]    ${bridge_segment}    ${timeout}=10m
    86      [Timeout]    ${timeout}
    87      BuiltIn.Log Many    ${bridge_segment}    ${timeout}
    88      :FOR    ${vnf_pod}    IN    @{bridge_segment["vnf"]}
    89      \    Iterate_Over_Novpps    ${bridge_segment}    ${vnf_pod}
    90  
    91  Iterate_Over_Novpps
    92      [Documentation]    Awkward implementation of nested for loop within robotframework.
    93      [Arguments]    ${bridge_segment}    ${vnf_pod}    ${timeout}=10s
    94      BuiltIn.Log Many    ${bridge_segment}    ${vnf_pod}    ${timeout}
    95      :FOR    ${novpp_pod}    IN    @{bridge_segment["novpp"]}
    96      \    Ping Until Success - Unix Ping    ${novpp_pod["name"]}    ${vnf_pod["ip"]}    ${timeout}
    97  
    98  Wait For Reconnect - Unix Ping
    99      [Documentation]    Run "Ping Until Success", measure and report execution time.
   100      [Arguments]    ${source_pod_Name}     ${destination_ip}    ${timeout}    ${duration_list_name}
   101      BuiltIn.Log Many    ${source_pod_Name}     ${destination_ip}    ${timeout}
   102      ${start_time} =    DateTime.Get Current Date    result_format=epoch
   103      Ping Until Success - Unix Ping    ${source_pod_Name}     ${destination_ip}    ${timeout}
   104      ${end_time} =    DateTime.Get Current Date    result_format=epoch
   105      ${duration} =    Datetime.Subtract Date from Date    ${start_time}    ${end_time}   result_format=verbose
   106      Collections.Append To List    ${duration_list_name}    ${duration}
   107  
   108  Wait For Reconnect - VPP Ping
   109      [Documentation]    Run "Ping Until Success", measure and report execution time.
   110      [Arguments]    ${source_pod_Name}     ${destination_ip}    ${timeout}    ${duration_list_name}
   111      BuiltIn.Log Many    ${source_pod_Name}     ${destination_ip}    ${timeout}
   112      ${start_time} =    DateTime.Get Current Date    result_format=epoch
   113      Ping Until Success - VPP Ping    ${source_pod_Name}     ${destination_ip}    ${timeout}
   114      ${end_time} =    DateTime.Get Current Date    result_format=epoch
   115      ${duration} =    Datetime.Subtract Date from Date    ${start_time}    ${end_time}   result_format=verbose
   116      Collections.Append To List    ${duration_list_name}    ${duration}
   117  
   118  Scale Pod Restart - Pod Deletion
   119      [Documentation]    Trigger pod restart in scale test scenario. Restart
   120      ...    the first pod of the specified type in each bridge segment.
   121      [Arguments]    ${pod_type}
   122      :FOR    ${bridge_segment}    IN    @{topology}
   123      \    Trigger Pod Restart - Pod Deletion    ${testbed_connection}    ${bridge_segment["${pod_type}"][0]["name"]}
   124  
   125  Scale Pod Restart - VPP SIGSEGV
   126      [Documentation]    Trigger pod restart in scale test scenario. Restart
   127      ...    the first pod of the specified type in each bridge segment.
   128      [Arguments]    ${pod_type}
   129      :FOR    ${bridge_segment}    IN    @{topology}
   130      \    Trigger Pod Restart - VPP SIGSEGV    ${bridge_segment["${pod_type}"][0]["name"]}
   131  
   132  Scale Wait For Reconnect - Unix Ping
   133      [Documentation]    Run "Ping Until Success" sequentially for each pod
   134      ...    restarted in scale test scenario.
   135      [Arguments]    ${timeout_per_bridge}=120s
   136      :FOR    ${bridge_segment}    IN    @{topology}
   137      \    Ping Until Success - Unix Ping    ${bridge_segment["novpp"][0]["name"]}    ${bridge_segment["vnf"][0]["ip"]}    ${timeout_per_bridge}
   138  
   139  Scale Wait For Reconnect - VPP Ping
   140      [Documentation]    Run "Ping Until Success" sequentially for each pod
   141      ...    restarted in scale test scenario.
   142      [Arguments]    ${timeout_per_bridge}=120s
   143      :FOR    ${bridge_segment}    IN    @{topology}
   144      \    Ping Until Success - VPP Ping    ${bridge_segment["vnf"][0]["name"]}    ${bridge_segment["novpp"][0]["ip"]}    ${timeout_per_bridge}