hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 1 | #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 *** |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 16 | Documentation Provide the function to perform system related test |
hwchiu | ab524f0 | 2020-02-03 23:24:19 +0000 | [diff] [blame] | 17 | Suite Setup Common Test Suite Setup |
| 18 | Test Setup Setup |
| 19 | Test Teardown Teardown |
hwchiu | ab524f0 | 2020-02-03 23:24:19 +0000 | [diff] [blame] | 20 | Resource ../../libraries/onos.robot |
| 21 | Resource ../../libraries/voltctl.robot |
| 22 | Resource ../../libraries/voltha.robot |
| 23 | Resource ../../libraries/utils.robot |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 24 | Resource ../../libraries/k8s.robot |
hwchiu | ab524f0 | 2020-02-03 23:24:19 +0000 | [diff] [blame] | 25 | Resource ../../variables/variables.robot |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 26 | |
| 27 | *** Variables *** |
hwchiu | 58af72d | 2020-01-14 00:50:35 +0000 | [diff] [blame] | 28 | ${timeout} 120s |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 29 | ${desired_ETCD_cluster_size} 3 |
| 30 | ${minimal_ETCD_cluster_size} 2 |
| 31 | ${namespace} voltha |
| 32 | ${ETCD_resources} etcdclusters.etcd.database.coreos.com |
| 33 | ${ETCD_name} voltha-etcd-cluster |
hwchiu | 7438081 | 2020-01-08 18:05:18 +0800 | [diff] [blame] | 34 | ${ETCD_pod_label_key} etcd_cluster |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 35 | ${common_pod_label_key} app |
| 36 | ${rwcore_pod_label_value} rw-core |
| 37 | ${ofagent_pod_label_value} ofagent |
| 38 | ${adapter_openolt_pod_label_value} adapter-open-olt |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 39 | |
| 40 | *** Test Cases *** |
hwchiu | ab524f0 | 2020-02-03 23:24:19 +0000 | [diff] [blame] | 41 | ECTD Scale Test |
| 42 | [Documentation] Perform the sanity test if some ETCD endpoints crash |
| 43 | [Tags] functional bbsim |
Andy Bavier | e187eda | 2020-04-20 15:00:02 -0700 | [diff] [blame] | 44 | [Setup] Setup |
hwchiu | 3d9a098 | 2020-02-06 00:19:19 +0000 | [diff] [blame] | 45 | [Teardown] Run Keywords Collect Logs |
hwchiu | 3d9a098 | 2020-02-06 00:19:19 +0000 | [diff] [blame] | 46 | ... AND Teardown Suite |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 47 | ${current_size}= Get ETCD Running Size voltha |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 48 | Pass Execution If '${current_size}' != '${desired_ETCD_cluster_size}' |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 49 | ... 'Skip the test if the cluster size smaller than minimal size 3' |
| 50 | # The minimal cluster size after scale down |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 51 | # based on https://github.com/ETCD-io/ETCD/blob/master/Documentation/faq.md#what-is-failure-tolerance |
| 52 | Scale ETCD ${namespace} ${minimal_ETCD_cluster_size} |
hwchiu | 58af72d | 2020-01-14 00:50:35 +0000 | [diff] [blame] | 53 | Wait Until Keyword Succeeds ${timeout} 2s |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 54 | ... Validate ETCD Size ${namespace} ${minimal_ETCD_cluster_size} |
| 55 | Wait Until Keyword Succeeds ${timeout} 2s |
| 56 | ... Check Expected Running Pods Number By Label ${namespace} |
| 57 | ... ${ETCD_pod_label_key} ${ETCD_name} 2 |
hwchiu | ab524f0 | 2020-02-03 23:24:19 +0000 | [diff] [blame] | 58 | # Perform the sanity-test |
| 59 | Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 60 | # We scale up the size to 3, the recommended size of ETCD cluster. |
hwchiu | ab524f0 | 2020-02-03 23:24:19 +0000 | [diff] [blame] | 61 | Scale ETCD ${namespace} ${desired_ETCD_cluster_size} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 62 | Wait Until Keyword Succeeds ${timeout} 2s |
| 63 | ... Validate ETCD Size ${namespace} ${desired_ETCD_cluster_size} |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 64 | |
| 65 | ETCD Failure Test |
| 66 | [Documentation] Failure Scenario Test: ETCD Crash |
| 67 | [Tags] FailureTest |
| 68 | Delete K8s Pods By Label ${namespace} ${ETCD_pod_label_key} ${ETCD_name} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 69 | Wait Until Keyword Succeeds ${timeout} 2s |
| 70 | ... Pods Do Not Exist By Label ${namespace} ${ETCD_pod_label_key} ${ETCD_name} |
| 71 | Wait Until Keyword Succeeds ${timeout} 2s |
| 72 | ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${rwcore_pod_label_value} |
| 73 | Wait Until Keyword Succeeds ${timeout} 2s |
| 74 | ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${ofagent_pod_label_value} |
| 75 | Wait Until Keyword Succeeds ${timeout} 2s |
| 76 | ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${adapter_openolt_pod_label_value} |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 77 | |
| 78 | *** Keywords *** |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 79 | Get ETCD Running Size |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 80 | [Arguments] ${namespace} |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 81 | [Documentation] Get the number of running ETCD nodes |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 82 | ${rc} ${size}= Run and Return Rc and Output |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 83 | ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.size}' |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 84 | Should Be Equal As Integers ${rc} 0 |
| 85 | [Return] ${size} |
| 86 | |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 87 | Scale ETCD |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 88 | [Arguments] ${namespace} ${size} |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 89 | [Documentation] Scale down the number of ETCD pod |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 90 | ${rc}= Run and Return Rc |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 91 | ... kubectl -n ${namespace} patch ${ETCD_resources} ${ETCD_name} --type='merge' -p '{"spec":{"size":${size}}}' |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 92 | Should Be Equal As Integers ${rc} 0 |
| 93 | |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 94 | Validate ETCD Size |
| 95 | [Arguments] ${namespace} ${ETCD_cluster_size} |
| 96 | [Documentation] Scale down the number of ETCD pod |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 97 | ${rc} ${size}= Run and Return Rc and Output |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 98 | ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.size}' |
| 99 | Should Be Equal As Integers ${size} ${ETCD_cluster_size} |