Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 1 | # Copyright 2021 - present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # FIXME Can we use the same test against BBSim and Hardware? |
| 15 | |
| 16 | *** Settings *** |
| 17 | Documentation Test Voltha Components Software Upgrade |
| 18 | Suite Setup Setup Suite |
| 19 | Test Setup Setup |
| 20 | Test Teardown Teardown |
| 21 | Suite Teardown Teardown Suite |
| 22 | Library Collections |
| 23 | Library String |
| 24 | Library OperatingSystem |
| 25 | Library XML |
| 26 | Library RequestsLibrary |
| 27 | Library ../../libraries/DependencyLibrary.py |
| 28 | Resource ../../libraries/onos.robot |
| 29 | Resource ../../libraries/voltctl.robot |
| 30 | Resource ../../libraries/voltha.robot |
| 31 | Resource ../../libraries/utils.robot |
| 32 | Resource ../../libraries/k8s.robot |
| 33 | Resource ../../variables/variables.robot |
| 34 | Resource ../../libraries/power_switch.robot |
| 35 | |
| 36 | *** Variables *** |
| 37 | ${POD_NAME} flex-ocp-cord |
| 38 | ${KUBERNETES_CONF} ${KUBERNETES_CONFIGS_DIR}/${POD_NAME}.conf |
| 39 | ${KUBERNETES_CONFIGS_DIR} ~/pod-configs/kubernetes-configs |
| 40 | #${KUBERNETES_CONFIGS_DIR} ${KUBERNETES_CONFIGS_DIR}/${POD_NAME}.conf |
| 41 | ${KUBERNETES_YAML} ${KUBERNETES_CONFIGS_DIR}/${POD_NAME}.yml |
| 42 | ${HELM_CHARTS_DIR} ~/helm-charts |
| 43 | ${VOLTHA_POD_NUM} 8 |
| 44 | ${NAMESPACE} voltha |
| 45 | # For below variable value, using deployment name as using grep for |
| 46 | # parsing radius pod name, we can also use full radius pod name |
| 47 | ${RESTART_POD_NAME} radius |
| 48 | ${timeout} 60s |
| 49 | ${of_id} 0 |
| 50 | ${logical_id} 0 |
| 51 | ${has_dataplane} True |
| 52 | ${teardown_device} False |
| 53 | ${scripts} ../../scripts |
| 54 | |
| 55 | # Per-test logging on failure is turned off by default; set this variable to enable |
| 56 | ${container_log_dir} ${None} |
| 57 | |
| 58 | ${suppressaddsubscriber} True |
| 59 | |
| 60 | # Voltha Components to Test for Software Upgrade need to be passed in the following variable in format: |
Hardik Windlass | dc2610f | 2021-03-09 07:33:51 +0000 | [diff] [blame] | 61 | # <comp-label>,<comp-container>,<comp-image>*<comp-label>,<comp-container>,<comp-image>* |
| 62 | # Example: adapter-open-olt,adapter-open-olt,voltha/voltha-openolt-adapter:3.1.3* |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 63 | ${voltha_comps_under_test} ${EMPTY} |
| 64 | |
| 65 | *** Test Cases *** |
| 66 | Test Voltha Components Minor Version Upgrade |
| 67 | [Documentation] Validates the Voltha Components Minor Version Upgrade doesn't affect the system functionality |
| 68 | ... Performs the sanity and verifies all the ONUs are authenticated/DHCP/pingable |
| 69 | ... Requirement: Components to test needs to be passed in robot command variable 'voltha_comps_under_test' in the format: |
Hardik Windlass | dc2610f | 2021-03-09 07:33:51 +0000 | [diff] [blame] | 70 | ... <comp-label>,<comp-container>,<comp-image>*<comp-label>,<comp-container>,<comp-image>* |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 71 | ... Check [VOL-3843] for more details |
| 72 | [Tags] functional VolthaCompMinorVerUpgrade |
| 73 | [Setup] Start Logging VolthaCompMinorVerUpgrade |
| 74 | [Teardown] Run Keywords Collect Logs |
| 75 | ... AND Stop Logging VolthaCompMinorVerUpgrade |
| 76 | ... AND Delete All Devices and Verify |
| 77 | # Add OLT device |
| 78 | Setup |
| 79 | # Performing Sanity Test to make sure subscribers are all DHCP and pingable |
| 80 | Run Keyword If ${has_dataplane} Clean Up Linux |
| 81 | Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test |
| 82 | ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE} |
| 83 | Log ${podStatusOutput} |
| 84 | ${countBeforeUpgrade}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l |
| 85 | ${num_comps_under_test}= Get Length ${list_voltha_comps_under_test} |
| 86 | FOR ${I} IN RANGE 0 ${num_comps_under_test} |
| 87 | ${label}= Set Variable ${list_voltha_comps_under_test}[${I}][label] |
| 88 | ${container}= Set Variable ${list_voltha_comps_under_test}[${I}][container] |
| 89 | ${image}= Set Variable ${list_voltha_comps_under_test}[${I}][image] |
Hardik Windlass | dc2610f | 2021-03-09 07:33:51 +0000 | [diff] [blame] | 90 | ${pod_image} ${app_ver} ${helm_chart} Get Pod Image And App Version And Helm Chart By Label |
| 91 | ... ${NAMESPACE} app ${label} |
| 92 | Log ${label}: image, app ver & helm chart before upgrade: ${pod_image}, ${app_ver} & ${helm_chart} |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 93 | ${deployment}= Wait Until Keyword Succeeds ${timeout} 15s |
| 94 | ... Get K8s Deployment by Pod Label ${NAMESPACE} app ${label} |
| 95 | Wait Until Keyword Succeeds ${timeout} 15s Deploy Pod New Image ${NAMESPACE} ${deployment} |
| 96 | ... ${container} ${image} |
| 97 | Wait Until Keyword Succeeds ${timeout} 3s Validate Pods Status By Label ${NAMESPACE} |
| 98 | ... app ${label} Running |
| 99 | Wait Until Keyword Succeeds ${timeout} 3s Pods Are Ready By Label ${NAMESPACE} app ${label} |
| 100 | Wait Until Keyword Succeeds ${timeout} 3s Verify Pod Image ${NAMESPACE} app ${label} ${image} |
Hardik Windlass | dc2610f | 2021-03-09 07:33:51 +0000 | [diff] [blame] | 101 | ${pod_image_1} ${app_ver_1} ${helm_chart_1} Get Pod Image And App Version And Helm Chart By Label |
| 102 | ... ${NAMESPACE} app ${label} |
| 103 | Log ${label}: image, app ver & helm chart after upgrade: ${pod_image_1}, ${app_ver_1} & ${helm_chart_1} |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 104 | Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test ${suppressaddsubscriber} |
| 105 | END |
| 106 | ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE} |
| 107 | Log ${podStatusOutput} |
| 108 | ${countAfterUpgrade}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l |
| 109 | Should Be Equal As Strings ${countAfterUpgrade} ${countBeforeUpgrade} |
| 110 | # Additional Verification |
| 111 | Wait Until Keyword Succeeds ${timeout} 2s Delete All Devices and Verify |
| 112 | Setup |
| 113 | Run Keyword If ${has_dataplane} Clean Up Linux |
| 114 | Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test |
| 115 | |
| 116 | *** Keywords *** |
| 117 | Setup Suite |
| 118 | [Documentation] Set up the test suite |
| 119 | Common Test Suite Setup |
| 120 | Create Voltha Comp Under Test List |
| 121 | |
| 122 | Teardown Suite |
| 123 | [Documentation] Tear down steps for the suite |
| 124 | Run Keyword If ${has_dataplane} Clean Up Linux |
| 125 | |
| 126 | Create Voltha Comp Under Test List |
| 127 | [Documentation] Creates a list of Voltha Components to Test from the input variable string |
| 128 | ... The input string is expected to be in format: |
Hardik Windlass | dc2610f | 2021-03-09 07:33:51 +0000 | [diff] [blame] | 129 | ... <comp-label>,<comp-container>,<comp-image>*<comp-label>,<comp-container>,<comp-image>* |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 130 | ${list_voltha_comps_under_test} Create List |
| 131 | @{comps_under_test_arr}= Split String ${voltha_comps_under_test} * |
| 132 | ${num_comps_under_test}= Get Length ${comps_under_test_arr} |
Hardik Windlass | dc2610f | 2021-03-09 07:33:51 +0000 | [diff] [blame] | 133 | FOR ${I} IN RANGE 0 ${num_comps_under_test}-1 |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 134 | @{comp_under_test_arr}= Split String ${comps_under_test_arr[${I}]} , |
| 135 | ${label}= Set Variable ${comp_under_test_arr[0]} |
| 136 | ${container}= Set Variable ${comp_under_test_arr[1]} |
| 137 | ${image}= Set Variable ${comp_under_test_arr[2]} |
| 138 | ${comp_under_test} Create Dictionary label ${label} container ${container} image ${image} |
| 139 | Append To List ${list_voltha_comps_under_test} ${comp_under_test} |
| 140 | END |
Hardik Windlass | dc2610f | 2021-03-09 07:33:51 +0000 | [diff] [blame] | 141 | Log ${list_voltha_comps_under_test} |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 142 | Set Suite Variable ${list_voltha_comps_under_test} |