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 |
Matteo Scandolo | 10acf56 | 2021-05-03 15:35:16 -0700 | [diff] [blame] | 32 | ${INFRA_NAMESPACE} default |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 33 | ${ETCD_resources} statefulsets |
| 34 | ${ETCD_name} etcd |
| 35 | ${ETCD_pod_label_key} app |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 36 | ${common_pod_label_key} app |
| 37 | ${rwcore_pod_label_value} rw-core |
| 38 | ${ofagent_pod_label_value} ofagent |
Andrea Campanella | 3dcce27 | 2021-01-15 16:04:47 +0100 | [diff] [blame] | 39 | ${adapter_openolt_pod_label_value} ${OLT_ADAPTER_APP_LABEL} |
Matteo Scandolo | 36ac3a7 | 2021-01-05 10:18:58 -0800 | [diff] [blame] | 40 | ${teardown_device} false |
| 41 | ${has_dataplane} false |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 42 | |
Matteo Scandolo | 7e519fb | 2021-08-13 11:35:16 -0700 | [diff] [blame] | 43 | ${suppressaddsubscriber} True |
| 44 | |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 45 | # Per-test logging on failure is turned off by default; set this variable to enable |
| 46 | ${container_log_dir} ${None} |
| 47 | |
Matteo Scandolo | da1c64b | 2021-07-20 10:14:49 -0700 | [diff] [blame] | 48 | # logging flag to enable Collect Logs, can be passed via the command line too |
| 49 | # example: -v logging:False |
| 50 | ${logging} True |
| 51 | |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 52 | *** Test Cases *** |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 53 | ETCD Scale Test |
hwchiu | ab524f0 | 2020-02-03 23:24:19 +0000 | [diff] [blame] | 54 | [Documentation] Perform the sanity test if some ETCD endpoints crash |
| 55 | [Tags] functional bbsim |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 56 | [Setup] Run Keywords Start Logging EtcdScaleTest |
| 57 | ... AND Setup |
hwchiu | 3d9a098 | 2020-02-06 00:19:19 +0000 | [diff] [blame] | 58 | [Teardown] Run Keywords Collect Logs |
hwchiu | 3d9a098 | 2020-02-06 00:19:19 +0000 | [diff] [blame] | 59 | ... AND Teardown Suite |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 60 | ... AND Stop Logging EtcdScaleTest |
Matteo Scandolo | 10acf56 | 2021-05-03 15:35:16 -0700 | [diff] [blame] | 61 | ${current_size}= Get ETCD Replica Count ${INFRA_NAMESPACE} |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 62 | Pass Execution If '${current_size}' != '${desired_ETCD_cluster_size}' |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 63 | ... 'Skip the test if the cluster size smaller than minimal size 3' |
| 64 | # The minimal cluster size after scale down |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 65 | # based on https://github.com/ETCD-io/ETCD/blob/master/Documentation/faq.md#what-is-failure-tolerance |
Matteo Scandolo | 10acf56 | 2021-05-03 15:35:16 -0700 | [diff] [blame] | 66 | Scale ETCD ${INFRA_NAMESPACE} ${minimal_ETCD_cluster_size} |
hwchiu | 58af72d | 2020-01-14 00:50:35 +0000 | [diff] [blame] | 67 | Wait Until Keyword Succeeds ${timeout} 2s |
Matteo Scandolo | 10acf56 | 2021-05-03 15:35:16 -0700 | [diff] [blame] | 68 | ... Validate ETCD Size ${INFRA_NAMESPACE} ${minimal_ETCD_cluster_size} |
hwchiu | ab524f0 | 2020-02-03 23:24:19 +0000 | [diff] [blame] | 69 | # Perform the sanity-test |
| 70 | Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 71 | # We scale up the size to 3, the recommended size of ETCD cluster. |
Matteo Scandolo | 10acf56 | 2021-05-03 15:35:16 -0700 | [diff] [blame] | 72 | Scale ETCD ${INFRA_NAMESPACE} ${desired_ETCD_cluster_size} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 73 | Wait Until Keyword Succeeds ${timeout} 2s |
Matteo Scandolo | 10acf56 | 2021-05-03 15:35:16 -0700 | [diff] [blame] | 74 | ... Validate ETCD Size ${INFRA_NAMESPACE} ${desired_ETCD_cluster_size} |
Matteo Scandolo | 36ac3a7 | 2021-01-05 10:18:58 -0800 | [diff] [blame] | 75 | # Perform the sanity-test again |
| 76 | Run Keyword If ${has_dataplane} Clean Up Linux |
Matteo Scandolo | 7e519fb | 2021-08-13 11:35:16 -0700 | [diff] [blame] | 77 | Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test ${suppressaddsubscriber} |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 78 | |
| 79 | ETCD Failure Test |
| 80 | [Documentation] Failure Scenario Test: ETCD Crash |
| 81 | [Tags] FailureTest |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 82 | [Setup] Start Logging EtcdFailureTest |
| 83 | [Teardown] Run Keywords Collect Logs |
| 84 | ... AND Stop Logging EtcdFailureTest |
Matteo Scandolo | 10acf56 | 2021-05-03 15:35:16 -0700 | [diff] [blame] | 85 | Delete K8s Pods By Label ${INFRA_NAMESPACE} ${ETCD_pod_label_key} ${ETCD_name} |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 86 | #Wait Until Keyword Succeeds ${timeout} 2s |
Matteo Scandolo | 10acf56 | 2021-05-03 15:35:16 -0700 | [diff] [blame] | 87 | #... Pods Do Not Exist By Label ${INFRA_NAMESPACE} ${ETCD_pod_label_key} ${ETCD_name} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 88 | Wait Until Keyword Succeeds ${timeout} 2s |
| 89 | ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${rwcore_pod_label_value} |
| 90 | Wait Until Keyword Succeeds ${timeout} 2s |
| 91 | ... Pods Are Ready By Label ${namespace} ${common_pod_label_key} ${ofagent_pod_label_value} |
| 92 | Wait Until Keyword Succeeds ${timeout} 2s |
| 93 | ... 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] | 94 | |
| 95 | *** Keywords *** |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 96 | Get ETCD Replica Count |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 97 | [Arguments] ${namespace} |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 98 | [Documentation] Get the number of configured ETCD nodes |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 99 | ${rc} ${size}= Run and Return Rc and Output |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 100 | ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.replicas}' |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 101 | Should Be Equal As Integers ${rc} 0 |
| 102 | [Return] ${size} |
| 103 | |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 104 | Scale ETCD |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 105 | [Arguments] ${namespace} ${size} |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 106 | [Documentation] Scale down the number of ETCD pod |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 107 | ${rc}= Run and Return Rc |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 108 | ... kubectl -n ${namespace} patch ${ETCD_resources} ${ETCD_name} -p '{"spec":{"replicas": ${size}}}' |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 109 | Should Be Equal As Integers ${rc} 0 |
| 110 | |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 111 | Validate ETCD Size |
| 112 | [Arguments] ${namespace} ${ETCD_cluster_size} |
| 113 | [Documentation] Scale down the number of ETCD pod |
hwchiu | 20f35d9 | 2019-11-05 05:22:58 +0000 | [diff] [blame] | 114 | ${rc} ${size}= Run and Return Rc and Output |
Andy Bavier | 9ed5895 | 2020-06-12 17:46:53 -0700 | [diff] [blame] | 115 | ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.replicas}' |
| 116 | Should Be Equal As Integers ${rc} 0 |
| 117 | Should Be Equal As Integers ${size} ${ETCD_cluster_size} Unexpected number of replicas |
| 118 | ${rc} ${size}= Run and Return Rc and Output |
| 119 | ... kubectl -n ${namespace} get ${ETCD_resources} ${ETCD_name} -o jsonpath='{.status.readyReplicas}' |
| 120 | Should Be Equal As Integers ${rc} 0 |
| 121 | Should Be Equal As Integers ${size} ${ETCD_cluster_size} Unexpected number of ready replicas |