blob: 7810ef84227cfafde447a300e4358bc9906ac7b4 [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
20Suite Teardown Teardown Suite
21Resource ../../libraries/onos.robot
22Resource ../../libraries/voltctl.robot
23Resource ../../libraries/voltha.robot
24Resource ../../libraries/utils.robot
hwchiu85695932019-12-18 08:05:25 +000025Resource ../../libraries/k8s.robot
hwchiuab524f02020-02-03 23:24:19 +000026Resource ../../variables/variables.robot
hwchiu20f35d92019-11-05 05:22:58 +000027
28*** Variables ***
hwchiu58af72d2020-01-14 00:50:35 +000029${timeout} 120s
Zack Williamsa8fe75a2020-01-10 14:25:27 -070030${desired_ETCD_cluster_size} 3
31${minimal_ETCD_cluster_size} 2
32${namespace} voltha
33${ETCD_resources} etcdclusters.etcd.database.coreos.com
34${ETCD_name} voltha-etcd-cluster
hwchiu74380812020-01-08 18:05:18 +080035${ETCD_pod_label_key} etcd_cluster
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
39${adapter_openolt_pod_label_value} adapter-open-olt
hwchiu20f35d92019-11-05 05:22:58 +000040
41*** Test Cases ***
hwchiuab524f02020-02-03 23:24:19 +000042ECTD Scale Test
43 [Documentation] Perform the sanity test if some ETCD endpoints crash
44 [Tags] functional bbsim
Zack Williamsa8fe75a2020-01-10 14:25:27 -070045 ${current_size}= Get ETCD Running Size voltha
hwchiu85695932019-12-18 08:05:25 +000046 Pass Execution If '${current_size}' != '${desired_ETCD_cluster_size}'
hwchiu20f35d92019-11-05 05:22:58 +000047 ... 'Skip the test if the cluster size smaller than minimal size 3'
48 # The minimal cluster size after scale down
hwchiu85695932019-12-18 08:05:25 +000049 # based on https://github.com/ETCD-io/ETCD/blob/master/Documentation/faq.md#what-is-failure-tolerance
50 Scale ETCD ${namespace} ${minimal_ETCD_cluster_size}
hwchiu58af72d2020-01-14 00:50:35 +000051 Wait Until Keyword Succeeds ${timeout} 2s
Zack Williamsa8fe75a2020-01-10 14:25:27 -070052 ... Validate ETCD Size ${namespace} ${minimal_ETCD_cluster_size}
53 Wait Until Keyword Succeeds ${timeout} 2s
54 ... Check Expected Running Pods Number By Label ${namespace}
55 ... ${ETCD_pod_label_key} ${ETCD_name} 2
hwchiuab524f02020-02-03 23:24:19 +000056 # Perform the sanity-test
57 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test
hwchiu85695932019-12-18 08:05:25 +000058 # We scale up the size to 3, the recommended size of ETCD cluster.
hwchiuab524f02020-02-03 23:24:19 +000059 Scale ETCD ${namespace} ${desired_ETCD_cluster_size}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070060 Wait Until Keyword Succeeds ${timeout} 2s
61 ... Validate ETCD Size ${namespace} ${desired_ETCD_cluster_size}
hwchiu85695932019-12-18 08:05:25 +000062
63ETCD Failure Test
64 [Documentation] Failure Scenario Test: ETCD Crash
65 [Tags] FailureTest
66 Delete K8s Pods By Label ${namespace} ${ETCD_pod_label_key} ${ETCD_name}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070067 Wait Until Keyword Succeeds ${timeout} 2s
68 ... Pods Do Not Exist By Label ${namespace} ${ETCD_pod_label_key} ${ETCD_name}
69 Wait Until Keyword Succeeds ${timeout} 2s
70 ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${rwcore_pod_label_value}
71 Wait Until Keyword Succeeds ${timeout} 2s
72 ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${ofagent_pod_label_value}
73 Wait Until Keyword Succeeds ${timeout} 2s
74 ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${adapter_openolt_pod_label_value}
hwchiu20f35d92019-11-05 05:22:58 +000075
76*** Keywords ***
hwchiu85695932019-12-18 08:05:25 +000077Get ETCD Running Size
hwchiu20f35d92019-11-05 05:22:58 +000078 [Arguments] ${namespace}
hwchiu85695932019-12-18 08:05:25 +000079 [Documentation] Get the number of running ETCD nodes
hwchiu20f35d92019-11-05 05:22:58 +000080 ${rc} ${size}= Run and Return Rc and Output
hwchiu85695932019-12-18 08:05:25 +000081 ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.size}'
hwchiu20f35d92019-11-05 05:22:58 +000082 Should Be Equal As Integers ${rc} 0
83 [Return] ${size}
84
hwchiu85695932019-12-18 08:05:25 +000085Scale ETCD
hwchiu20f35d92019-11-05 05:22:58 +000086 [Arguments] ${namespace} ${size}
hwchiu85695932019-12-18 08:05:25 +000087 [Documentation] Scale down the number of ETCD pod
hwchiu20f35d92019-11-05 05:22:58 +000088 ${rc}= Run and Return Rc
hwchiu85695932019-12-18 08:05:25 +000089 ... kubectl -n ${namespace} patch ${ETCD_resources} ${ETCD_name} --type='merge' -p '{"spec":{"size":${size}}}'
hwchiu20f35d92019-11-05 05:22:58 +000090 Should Be Equal As Integers ${rc} 0
91
hwchiu85695932019-12-18 08:05:25 +000092Validate ETCD Size
93 [Arguments] ${namespace} ${ETCD_cluster_size}
94 [Documentation] Scale down the number of ETCD pod
hwchiu20f35d92019-11-05 05:22:58 +000095 ${rc} ${size}= Run and Return Rc and Output
hwchiu85695932019-12-18 08:05:25 +000096 ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.size}'
97 Should Be Equal As Integers ${size} ${ETCD_cluster_size}