blob: 9bdcc859f1ff2c75409d03b3cdb11f9478674d41 [file] [log] [blame]
hwchiu20f35d92019-11-05 05:22:58 +00001#Copyright 2017-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
15*** Settings ***
hwchiu85695932019-12-18 08:05:25 +000016Documentation Provide the function to perform system related test
hwchiuab524f02020-02-03 23:24:19 +000017Suite Setup Common Test Suite Setup
18Test Setup Setup
19Test Teardown Teardown
hwchiuab524f02020-02-03 23:24:19 +000020Resource ../../libraries/onos.robot
21Resource ../../libraries/voltctl.robot
22Resource ../../libraries/voltha.robot
23Resource ../../libraries/utils.robot
hwchiu85695932019-12-18 08:05:25 +000024Resource ../../libraries/k8s.robot
hwchiuab524f02020-02-03 23:24:19 +000025Resource ../../variables/variables.robot
hwchiu20f35d92019-11-05 05:22:58 +000026
27*** Variables ***
hwchiu58af72d2020-01-14 00:50:35 +000028${timeout} 120s
Zack Williamsa8fe75a2020-01-10 14:25:27 -070029${desired_ETCD_cluster_size} 3
30${minimal_ETCD_cluster_size} 2
31${namespace} voltha
Matteo Scandolo10acf562021-05-03 15:35:16 -070032${INFRA_NAMESPACE} default
Andy Bavier9ed58952020-06-12 17:46:53 -070033${ETCD_resources} statefulsets
34${ETCD_name} etcd
35${ETCD_pod_label_key} app
hwchiu85695932019-12-18 08:05:25 +000036${common_pod_label_key} app
37${rwcore_pod_label_value} rw-core
38${ofagent_pod_label_value} ofagent
Andrea Campanella3dcce272021-01-15 16:04:47 +010039${adapter_openolt_pod_label_value} ${OLT_ADAPTER_APP_LABEL}
Matteo Scandolo36ac3a72021-01-05 10:18:58 -080040${teardown_device} false
41${has_dataplane} false
hwchiu20f35d92019-11-05 05:22:58 +000042
Andy Bavier9ed58952020-06-12 17:46:53 -070043# Per-test logging on failure is turned off by default; set this variable to enable
44${container_log_dir} ${None}
45
Matteo Scandoloda1c64b2021-07-20 10:14:49 -070046# logging flag to enable Collect Logs, can be passed via the command line too
47# example: -v logging:False
48${logging} True
49
hwchiu20f35d92019-11-05 05:22:58 +000050*** Test Cases ***
Andy Bavier9ed58952020-06-12 17:46:53 -070051ETCD Scale Test
hwchiuab524f02020-02-03 23:24:19 +000052 [Documentation] Perform the sanity test if some ETCD endpoints crash
53 [Tags] functional bbsim
Andy Bavier9ed58952020-06-12 17:46:53 -070054 [Setup] Run Keywords Start Logging EtcdScaleTest
55 ... AND Setup
hwchiu3d9a0982020-02-06 00:19:19 +000056 [Teardown] Run Keywords Collect Logs
hwchiu3d9a0982020-02-06 00:19:19 +000057 ... AND Teardown Suite
Andy Bavier9ed58952020-06-12 17:46:53 -070058 ... AND Stop Logging EtcdScaleTest
Matteo Scandolo10acf562021-05-03 15:35:16 -070059 ${current_size}= Get ETCD Replica Count ${INFRA_NAMESPACE}
hwchiu85695932019-12-18 08:05:25 +000060 Pass Execution If '${current_size}' != '${desired_ETCD_cluster_size}'
hwchiu20f35d92019-11-05 05:22:58 +000061 ... 'Skip the test if the cluster size smaller than minimal size 3'
62 # The minimal cluster size after scale down
hwchiu85695932019-12-18 08:05:25 +000063 # based on https://github.com/ETCD-io/ETCD/blob/master/Documentation/faq.md#what-is-failure-tolerance
Matteo Scandolo10acf562021-05-03 15:35:16 -070064 Scale ETCD ${INFRA_NAMESPACE} ${minimal_ETCD_cluster_size}
hwchiu58af72d2020-01-14 00:50:35 +000065 Wait Until Keyword Succeeds ${timeout} 2s
Matteo Scandolo10acf562021-05-03 15:35:16 -070066 ... Validate ETCD Size ${INFRA_NAMESPACE} ${minimal_ETCD_cluster_size}
hwchiuab524f02020-02-03 23:24:19 +000067 # Perform the sanity-test
68 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test
hwchiu85695932019-12-18 08:05:25 +000069 # We scale up the size to 3, the recommended size of ETCD cluster.
Matteo Scandolo10acf562021-05-03 15:35:16 -070070 Scale ETCD ${INFRA_NAMESPACE} ${desired_ETCD_cluster_size}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070071 Wait Until Keyword Succeeds ${timeout} 2s
Matteo Scandolo10acf562021-05-03 15:35:16 -070072 ... Validate ETCD Size ${INFRA_NAMESPACE} ${desired_ETCD_cluster_size}
Matteo Scandolo36ac3a72021-01-05 10:18:58 -080073 # Perform the sanity-test again
74 Run Keyword If ${has_dataplane} Clean Up Linux
75 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test
hwchiu85695932019-12-18 08:05:25 +000076
77ETCD Failure Test
78 [Documentation] Failure Scenario Test: ETCD Crash
79 [Tags] FailureTest
Andy Bavier9ed58952020-06-12 17:46:53 -070080 [Setup] Start Logging EtcdFailureTest
81 [Teardown] Run Keywords Collect Logs
82 ... AND Stop Logging EtcdFailureTest
Matteo Scandolo10acf562021-05-03 15:35:16 -070083 Delete K8s Pods By Label ${INFRA_NAMESPACE} ${ETCD_pod_label_key} ${ETCD_name}
Andy Bavier9ed58952020-06-12 17:46:53 -070084 #Wait Until Keyword Succeeds ${timeout} 2s
Matteo Scandolo10acf562021-05-03 15:35:16 -070085 #... Pods Do Not Exist By Label ${INFRA_NAMESPACE} ${ETCD_pod_label_key} ${ETCD_name}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070086 Wait Until Keyword Succeeds ${timeout} 2s
87 ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${rwcore_pod_label_value}
88 Wait Until Keyword Succeeds ${timeout} 2s
89 ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${ofagent_pod_label_value}
90 Wait Until Keyword Succeeds ${timeout} 2s
91 ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${adapter_openolt_pod_label_value}
hwchiu20f35d92019-11-05 05:22:58 +000092
93*** Keywords ***
Andy Bavier9ed58952020-06-12 17:46:53 -070094Get ETCD Replica Count
hwchiu20f35d92019-11-05 05:22:58 +000095 [Arguments] ${namespace}
Andy Bavier9ed58952020-06-12 17:46:53 -070096 [Documentation] Get the number of configured ETCD nodes
hwchiu20f35d92019-11-05 05:22:58 +000097 ${rc} ${size}= Run and Return Rc and Output
Andy Bavier9ed58952020-06-12 17:46:53 -070098 ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.replicas}'
hwchiu20f35d92019-11-05 05:22:58 +000099 Should Be Equal As Integers ${rc} 0
100 [Return] ${size}
101
hwchiu85695932019-12-18 08:05:25 +0000102Scale ETCD
hwchiu20f35d92019-11-05 05:22:58 +0000103 [Arguments] ${namespace} ${size}
hwchiu85695932019-12-18 08:05:25 +0000104 [Documentation] Scale down the number of ETCD pod
hwchiu20f35d92019-11-05 05:22:58 +0000105 ${rc}= Run and Return Rc
Andy Bavier9ed58952020-06-12 17:46:53 -0700106 ... kubectl -n ${namespace} patch ${ETCD_resources} ${ETCD_name} -p '{"spec":{"replicas": ${size}}}'
hwchiu20f35d92019-11-05 05:22:58 +0000107 Should Be Equal As Integers ${rc} 0
108
hwchiu85695932019-12-18 08:05:25 +0000109Validate ETCD Size
110 [Arguments] ${namespace} ${ETCD_cluster_size}
111 [Documentation] Scale down the number of ETCD pod
hwchiu20f35d92019-11-05 05:22:58 +0000112 ${rc} ${size}= Run and Return Rc and Output
Andy Bavier9ed58952020-06-12 17:46:53 -0700113 ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.replicas}'
114 Should Be Equal As Integers ${rc} 0
115 Should Be Equal As Integers ${size} ${ETCD_cluster_size} Unexpected number of replicas
116 ${rc} ${size}= Run and Return Rc and Output
117 ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.readyReplicas}'
118 Should Be Equal As Integers ${rc} 0
119 Should Be Equal As Integers ${size} ${ETCD_cluster_size} Unexpected number of ready replicas