blob: 4ae876c79105766ddf057e8e417f0bf3276cc2ef [file] [log] [blame]
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001# 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 ***
17Documentation Test Voltha Components Software Upgrade
18Suite Setup Setup Suite
19Test Setup Setup
20Test Teardown Teardown
21Suite Teardown Teardown Suite
22Library Collections
23Library String
24Library OperatingSystem
25Library XML
26Library RequestsLibrary
27Library ../../libraries/DependencyLibrary.py
28Resource ../../libraries/onos.robot
29Resource ../../libraries/voltctl.robot
30Resource ../../libraries/voltha.robot
31Resource ../../libraries/utils.robot
32Resource ../../libraries/k8s.robot
33Resource ../../variables/variables.robot
34Resource ../../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
Hardik Windlass4288c6a2021-09-28 07:22:06 +000045${INFRA_NAMESPACE} default
Hardik Windlassdd1a9a12021-02-23 15:34:50 +000046# For below variable value, using deployment name as using grep for
47# parsing radius pod name, we can also use full radius pod name
48${RESTART_POD_NAME} radius
49${timeout} 60s
50${of_id} 0
51${logical_id} 0
52${has_dataplane} True
53${teardown_device} False
54${scripts} ../../scripts
55
56# Per-test logging on failure is turned off by default; set this variable to enable
57${container_log_dir} ${None}
58
Matteo Scandoloda1c64b2021-07-20 10:14:49 -070059# logging flag to enable Collect Logs, can be passed via the command line too
60# example: -v logging:False
61${logging} True
62
Hardik Windlassdd1a9a12021-02-23 15:34:50 +000063${suppressaddsubscriber} True
64
65# Voltha Components to Test for Software Upgrade need to be passed in the following variable in format:
Hardik Windlassdc2610f2021-03-09 07:33:51 +000066# <comp-label>,<comp-container>,<comp-image>*<comp-label>,<comp-container>,<comp-image>*
67# Example: adapter-open-olt,adapter-open-olt,voltha/voltha-openolt-adapter:3.1.3*
Hardik Windlassdd1a9a12021-02-23 15:34:50 +000068${voltha_comps_under_test} ${EMPTY}
69
70*** Test Cases ***
71Test Voltha Components Minor Version Upgrade
72 [Documentation] Validates the Voltha Components Minor Version Upgrade doesn't affect the system functionality
73 ... Performs the sanity and verifies all the ONUs are authenticated/DHCP/pingable
74 ... Requirement: Components to test needs to be passed in robot command variable 'voltha_comps_under_test' in the format:
Hardik Windlassdc2610f2021-03-09 07:33:51 +000075 ... <comp-label>,<comp-container>,<comp-image>*<comp-label>,<comp-container>,<comp-image>*
Hardik Windlassdd1a9a12021-02-23 15:34:50 +000076 ... Check [VOL-3843] for more details
77 [Tags] functional VolthaCompMinorVerUpgrade
78 [Setup] Start Logging VolthaCompMinorVerUpgrade
79 [Teardown] Run Keywords Collect Logs
80 ... AND Stop Logging VolthaCompMinorVerUpgrade
81 ... AND Delete All Devices and Verify
82 # Add OLT device
83 Setup
84 # Performing Sanity Test to make sure subscribers are all DHCP and pingable
85 Run Keyword If ${has_dataplane} Clean Up Linux
86 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test
87 ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
88 Log ${podStatusOutput}
89 ${countBeforeUpgrade}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
90 ${num_comps_under_test}= Get Length ${list_voltha_comps_under_test}
91 FOR ${I} IN RANGE 0 ${num_comps_under_test}
92 ${label}= Set Variable ${list_voltha_comps_under_test}[${I}][label]
93 ${container}= Set Variable ${list_voltha_comps_under_test}[${I}][container]
94 ${image}= Set Variable ${list_voltha_comps_under_test}[${I}][image]
Hardik Windlassdc2610f2021-03-09 07:33:51 +000095 ${pod_image} ${app_ver} ${helm_chart} Get Pod Image And App Version And Helm Chart By Label
96 ... ${NAMESPACE} app ${label}
97 Log ${label}: image, app ver & helm chart before upgrade: ${pod_image}, ${app_ver} & ${helm_chart}
Hardik Windlassdd1a9a12021-02-23 15:34:50 +000098 ${deployment}= Wait Until Keyword Succeeds ${timeout} 15s
99 ... Get K8s Deployment by Pod Label ${NAMESPACE} app ${label}
100 Wait Until Keyword Succeeds ${timeout} 15s Deploy Pod New Image ${NAMESPACE} ${deployment}
101 ... ${container} ${image}
102 Wait Until Keyword Succeeds ${timeout} 3s Validate Pods Status By Label ${NAMESPACE}
103 ... app ${label} Running
104 Wait Until Keyword Succeeds ${timeout} 3s Pods Are Ready By Label ${NAMESPACE} app ${label}
105 Wait Until Keyword Succeeds ${timeout} 3s Verify Pod Image ${NAMESPACE} app ${label} ${image}
Hardik Windlassdc2610f2021-03-09 07:33:51 +0000106 ${pod_image_1} ${app_ver_1} ${helm_chart_1} Get Pod Image And App Version And Helm Chart By Label
107 ... ${NAMESPACE} app ${label}
108 Log ${label}: image, app ver & helm chart after upgrade: ${pod_image_1}, ${app_ver_1} & ${helm_chart_1}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700109 Restart VOLTHA Port Forward voltha-api
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000110 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test ${suppressaddsubscriber}
111 END
112 ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
113 Log ${podStatusOutput}
114 ${countAfterUpgrade}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
115 Should Be Equal As Strings ${countAfterUpgrade} ${countBeforeUpgrade}
116 # Additional Verification
117 Wait Until Keyword Succeeds ${timeout} 2s Delete All Devices and Verify
118 Setup
119 Run Keyword If ${has_dataplane} Clean Up Linux
120 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test
121
122*** Keywords ***
123Setup Suite
124 [Documentation] Set up the test suite
125 Common Test Suite Setup
126 Create Voltha Comp Under Test List
127
128Teardown Suite
129 [Documentation] Tear down steps for the suite
130 Run Keyword If ${has_dataplane} Clean Up Linux
TorstenThieme4e2168e2021-06-22 14:01:47 +0000131 Close All ONOS SSH Connections
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000132
133Create Voltha Comp Under Test List
134 [Documentation] Creates a list of Voltha Components to Test from the input variable string
135 ... The input string is expected to be in format:
Hardik Windlassdc2610f2021-03-09 07:33:51 +0000136 ... <comp-label>,<comp-container>,<comp-image>*<comp-label>,<comp-container>,<comp-image>*
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000137 ${list_voltha_comps_under_test} Create List
138 @{comps_under_test_arr}= Split String ${voltha_comps_under_test} *
139 ${num_comps_under_test}= Get Length ${comps_under_test_arr}
Hardik Windlassdc2610f2021-03-09 07:33:51 +0000140 FOR ${I} IN RANGE 0 ${num_comps_under_test}-1
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000141 @{comp_under_test_arr}= Split String ${comps_under_test_arr[${I}]} ,
142 ${label}= Set Variable ${comp_under_test_arr[0]}
143 ${container}= Set Variable ${comp_under_test_arr[1]}
144 ${image}= Set Variable ${comp_under_test_arr[2]}
145 ${comp_under_test} Create Dictionary label ${label} container ${container} image ${image}
146 Append To List ${list_voltha_comps_under_test} ${comp_under_test}
147 END
Hardik Windlassdc2610f2021-03-09 07:33:51 +0000148 Log ${list_voltha_comps_under_test}
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000149 Set Suite Variable ${list_voltha_comps_under_test}