Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include "gtest/gtest.h" |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 17 | #include "Queue.h" |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 18 | #include "bal_mocker.h" |
| 19 | #include "core.h" |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame^] | 20 | #include "core_data.h" |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 21 | #include <future> |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 22 | using namespace testing; |
| 23 | using namespace std; |
| 24 | |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 25 | extern std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *> alloc_cfg_compltd_map; |
| 26 | extern dev_log_id openolt_log_id; |
| 27 | extern bcmos_fastlock alloc_cfg_wait_lock; |
| 28 | extern bool ALLOC_CFG_FLAG; |
| 29 | |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 30 | class TestOltEnable : public Test { |
| 31 | protected: |
| 32 | virtual void SetUp() { |
| 33 | } |
| 34 | |
| 35 | virtual void TearDown() { |
| 36 | // Code here will be called immediately after each test |
| 37 | // (right before the destructor). |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | // This is used to set custom bcmolt_cfg value to bcmolt_cfg pointer coming in |
| 42 | // bcmolt_cfg_get__bal_state_stub. |
| 43 | ACTION_P(SetArg1ToBcmOltCfg, value) { *static_cast<bcmolt_olt_cfg*>(arg1) = value; }; |
| 44 | |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 45 | // This is used to set custom bcmolt_onu_cfg value to bcmolt_onu_cfg pointer coming in |
| 46 | // bcmolt_cfg_get__onu_state_stub. |
| 47 | ACTION_P(SetArg1ToBcmOltOnuCfg, value) { *static_cast<bcmolt_onu_cfg*>(arg1) = value; }; |
| 48 | |
| 49 | // This is used to set custom bcmolt_tm_sched_cfg value to bcmolt_tm_sched_cfg pointer coming in |
| 50 | // bcmolt_cfg_get__tm_sched_stub. |
| 51 | ACTION_P(SetArg1ToBcmOltTmSchedCfg, value) { *static_cast<bcmolt_tm_sched_cfg*>(arg1) = value; }; |
| 52 | |
| 53 | // This is used to set custom bcmolt_pon_interface_cfg value to bcmolt_pon_interface_cfg pointer coming in |
| 54 | // bcmolt_cfg_get__pon_intf_stub. |
| 55 | ACTION_P(SetArg1ToBcmOltPonCfg, value) { *static_cast<bcmolt_pon_interface_cfg*>(arg1) = value; }; |
| 56 | |
| 57 | // This is used to set custom bcmolt_nni_interface_cfg value to bcmolt_nni_interface_cfg pointer coming in |
| 58 | // bcmolt_cfg_get__nni_intf_stub. |
| 59 | ACTION_P(SetArg1ToBcmOltNniCfg, value) { *static_cast<bcmolt_nni_interface_cfg*>(arg1) = value; }; |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 60 | |
Thiyagarajan Subramani | 81c5611 | 2019-12-19 08:29:55 -0500 | [diff] [blame] | 61 | // This is used to set custom bcmolt_flow_cfg value to bcmolt_flow_cfg pointer coming in |
| 62 | // bcmolt_cfg_get__flow_stub. |
| 63 | ACTION_P(SetArg1ToBcmOltFlowCfg, value) { *static_cast<bcmolt_flow_cfg*>(arg1) = value; }; |
| 64 | |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 65 | // Create a mock function for bcmolt_cfg_get__bal_state_stub C++ function |
| 66 | MOCK_GLOBAL_FUNC2(bcmolt_cfg_get__bal_state_stub, bcmos_errno(bcmolt_oltid, void*)); |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 67 | MOCK_GLOBAL_FUNC2(bcmolt_cfg_get__onu_state_stub, bcmos_errno(bcmolt_oltid, void*)); |
| 68 | MOCK_GLOBAL_FUNC2(bcmolt_cfg_get__tm_sched_stub, bcmos_errno(bcmolt_oltid, void*)); |
| 69 | MOCK_GLOBAL_FUNC2(bcmolt_cfg_get__pon_intf_stub, bcmos_errno(bcmolt_oltid, void*)); |
| 70 | MOCK_GLOBAL_FUNC2(bcmolt_cfg_get__nni_intf_stub, bcmos_errno(bcmolt_oltid, void*)); |
Thiyagarajan Subramani | 81c5611 | 2019-12-19 08:29:55 -0500 | [diff] [blame] | 71 | MOCK_GLOBAL_FUNC2(bcmolt_cfg_get__flow_stub, bcmos_errno(bcmolt_oltid, void*)); |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 72 | |
| 73 | |
| 74 | // Test Fixture for OltEnable |
| 75 | |
| 76 | // Test 1: OltEnableSuccess case |
| 77 | TEST_F(TestOltEnable, OltEnableSuccess){ |
| 78 | // NiceMock is used to suppress 'WillByDefault' return errors. |
| 79 | // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md |
| 80 | NiceMock<BalMocker> balMock; |
| 81 | bcmos_errno host_init_res = BCM_ERR_OK; |
| 82 | bcmos_errno bal_cfg_get_stub_res = BCM_ERR_OK; |
| 83 | bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED; |
| 84 | bcmos_errno olt_oper_res = BCM_ERR_OK; |
| 85 | |
| 86 | bcmolt_olt_cfg olt_cfg = { }; |
| 87 | bcmolt_olt_key olt_key = { }; |
| 88 | BCMOLT_CFG_INIT(&olt_cfg, olt, olt_key); |
| 89 | olt_cfg.data.bal_state = BCMOLT_BAL_STATE_BAL_AND_SWITCH_READY; |
| 90 | |
| 91 | Status olt_enable_res; |
| 92 | |
| 93 | ON_CALL(balMock, bcmolt_host_init(_)).WillByDefault(Return(host_init_res)); |
| 94 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__bal_state_stub, bcmolt_cfg_get__bal_state_stub(_, _)) |
| 95 | .WillOnce(DoAll(SetArg1ToBcmOltCfg(olt_cfg), Return(bal_cfg_get_stub_res))); |
| 96 | EXPECT_CALL(balMock, bcmolt_cfg_get(_, _)) |
| 97 | .Times(BCM_MAX_DEVS_PER_LINE_CARD) |
| 98 | .WillRepeatedly(Return(bal_cfg_get_res)); |
| 99 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_res)); |
| 100 | |
| 101 | olt_enable_res = Enable_(1, NULL); |
| 102 | ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() ); |
| 103 | } |
| 104 | |
| 105 | // Test 2: OltEnableFail_host_init_fail |
| 106 | TEST_F(TestOltEnable, OltEnableFail_host_init_fail) { |
| 107 | // NiceMock is used to suppress 'WillByDefault' return errors. |
| 108 | // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md |
| 109 | NiceMock<BalMocker> balMock; |
| 110 | bcmos_errno host_init_res = BCM_ERR_INTERNAL; |
| 111 | |
| 112 | Status olt_enable_res; |
| 113 | |
| 114 | // Ensure that the state of the OLT is in deactivated to start with.. |
| 115 | state.deactivate(); |
| 116 | |
| 117 | ON_CALL(balMock, bcmolt_host_init(_)).WillByDefault(Return(host_init_res)); |
| 118 | |
| 119 | olt_enable_res = Enable_(1, NULL); |
| 120 | ASSERT_TRUE( olt_enable_res.error_message() != Status::OK.error_message() ); |
| 121 | } |
| 122 | |
| 123 | // Test 3: OltEnableSuccess_PON_Device_Connected |
| 124 | TEST_F(TestOltEnable, OltEnableSuccess_PON_Device_Connected) { |
| 125 | |
| 126 | // NiceMock is used to suppress 'WillByDefault' return errors. |
| 127 | // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md |
| 128 | NiceMock<BalMocker> balMock; |
| 129 | bcmos_errno host_init_res = BCM_ERR_OK; |
| 130 | bcmos_errno bal_cfg_get_stub_res = BCM_ERR_OK; |
| 131 | bcmos_errno bal_cfg_get_res = BCM_ERR_OK; |
| 132 | bcmos_errno olt_oper_res = BCM_ERR_OK; |
| 133 | |
| 134 | bcmolt_olt_cfg olt_cfg = { }; |
| 135 | bcmolt_olt_key olt_key = { }; |
| 136 | BCMOLT_CFG_INIT(&olt_cfg, olt, olt_key); |
| 137 | olt_cfg.data.bal_state = BCMOLT_BAL_STATE_BAL_AND_SWITCH_READY; |
| 138 | |
| 139 | Status olt_enable_res; |
| 140 | |
| 141 | // Ensure that the state of the OLT is in deactivated to start with.. |
| 142 | state.deactivate(); |
| 143 | |
| 144 | ON_CALL(balMock, bcmolt_host_init(_)).WillByDefault(Return(host_init_res)); |
| 145 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__bal_state_stub, bcmolt_cfg_get__bal_state_stub(_, _)) |
| 146 | .WillOnce(DoAll(SetArg1ToBcmOltCfg(olt_cfg), Return(bal_cfg_get_stub_res))); |
| 147 | EXPECT_CALL(balMock, bcmolt_cfg_get(_, _)) |
| 148 | .Times(BCM_MAX_DEVS_PER_LINE_CARD) |
| 149 | .WillRepeatedly(Return(bal_cfg_get_res)); |
| 150 | |
| 151 | olt_enable_res = Enable_(1, NULL); |
| 152 | ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() ); |
| 153 | |
| 154 | } |
| 155 | |
| 156 | // Test 4: OltEnableFail_All_PON_Enable_Fail |
| 157 | TEST_F(TestOltEnable, OltEnableFail_All_PON_Enable_Fail) { |
| 158 | |
| 159 | // NiceMock is used to suppress 'WillByDefault' return errors. |
| 160 | // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md |
| 161 | NiceMock<BalMocker> balMock; |
| 162 | bcmos_errno host_init_res = BCM_ERR_OK; |
| 163 | bcmos_errno bal_cfg_get_stub_res = BCM_ERR_OK; |
| 164 | bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED; |
| 165 | bcmos_errno olt_oper_res = BCM_ERR_INTERNAL; |
| 166 | |
| 167 | bcmolt_olt_cfg olt_cfg = { }; |
| 168 | bcmolt_olt_key olt_key = { }; |
| 169 | BCMOLT_CFG_INIT(&olt_cfg, olt, olt_key); |
| 170 | olt_cfg.data.bal_state = BCMOLT_BAL_STATE_BAL_AND_SWITCH_READY; |
| 171 | |
| 172 | Status olt_enable_res; |
| 173 | |
| 174 | // Ensure that the state of the OLT is in deactivated to start with.. |
| 175 | state.deactivate(); |
| 176 | |
| 177 | ON_CALL(balMock, bcmolt_host_init(_)).WillByDefault(Return(host_init_res)); |
| 178 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__bal_state_stub, bcmolt_cfg_get__bal_state_stub(_, _)) |
| 179 | .WillOnce(DoAll(SetArg1ToBcmOltCfg(olt_cfg), Return(bal_cfg_get_stub_res))); |
| 180 | EXPECT_CALL(balMock, bcmolt_cfg_get(_, _)) |
| 181 | .Times(BCM_MAX_DEVS_PER_LINE_CARD) |
| 182 | .WillRepeatedly(Return(bal_cfg_get_res)); |
| 183 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_res)); |
| 184 | |
| 185 | olt_enable_res = Enable_(1, NULL); |
| 186 | |
| 187 | ASSERT_TRUE( olt_enable_res.error_message() != Status::OK.error_message() ); |
| 188 | } |
| 189 | |
| 190 | // Test 5 OltEnableSuccess_One_PON_Enable_Fail : One PON device enable fails, but all others succeed. |
| 191 | TEST_F(TestOltEnable, OltEnableSuccess_One_PON_Enable_Fail) { |
| 192 | |
| 193 | // NiceMock is used to suppress 'WillByDefault' return errors. |
| 194 | // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md |
| 195 | NiceMock<BalMocker> balMock; |
| 196 | bcmos_errno host_init_res = BCM_ERR_OK; |
| 197 | bcmos_errno bal_cfg_get_stub_res = BCM_ERR_OK; |
| 198 | bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED; |
| 199 | bcmos_errno olt_oper_res_fail = BCM_ERR_INTERNAL; |
| 200 | bcmos_errno olt_oper_res_success = BCM_ERR_OK; |
| 201 | |
| 202 | bcmolt_olt_cfg olt_cfg = { }; |
| 203 | bcmolt_olt_key olt_key = { }; |
| 204 | BCMOLT_CFG_INIT(&olt_cfg, olt, olt_key); |
| 205 | olt_cfg.data.bal_state = BCMOLT_BAL_STATE_BAL_AND_SWITCH_READY; |
| 206 | |
| 207 | Status olt_enable_res; |
| 208 | |
| 209 | // Ensure that the state of the OLT is in deactivated to start with.. |
| 210 | state.deactivate(); |
| 211 | |
| 212 | ON_CALL(balMock, bcmolt_host_init(_)).WillByDefault(Return(host_init_res)); |
| 213 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__bal_state_stub, bcmolt_cfg_get__bal_state_stub(_, _)) |
| 214 | .WillOnce(DoAll(SetArg1ToBcmOltCfg(olt_cfg), Return(bal_cfg_get_stub_res))); |
| 215 | EXPECT_CALL(balMock, bcmolt_cfg_get(_, _)) |
| 216 | .Times(BCM_MAX_DEVS_PER_LINE_CARD) |
| 217 | .WillRepeatedly(Return(bal_cfg_get_res)); |
| 218 | // For the the first PON mac device, the activation result will fail, and will succeed for all other PON mac devices. |
| 219 | EXPECT_CALL(balMock, bcmolt_oper_submit(_, _)) |
| 220 | .WillOnce(Return(olt_oper_res_fail)) |
| 221 | .WillRepeatedly(Return(olt_oper_res_success)); |
| 222 | olt_enable_res = Enable_(1, NULL); |
| 223 | |
| 224 | ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() ); |
| 225 | } |
| 226 | |
| 227 | //////////////////////////////////////////////////////////////////////// |
| 228 | // For testing Enable/Disable functionality |
| 229 | //////////////////////////////////////////////////////////////////////// |
| 230 | |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame^] | 231 | int num_of_pon_port = 16; |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 232 | |
| 233 | // Create a mock function for bcmolt_cfg_get__olt_topology_stub C++ function |
| 234 | MOCK_GLOBAL_FUNC2(bcmolt_cfg_get__olt_topology_stub, bcmos_errno(bcmolt_oltid, void*)); |
| 235 | |
| 236 | class TestOltDisableReenable : public Test { |
| 237 | protected: |
| 238 | virtual void SetUp() { |
| 239 | NiceMock<BalMocker> balMock; |
| 240 | bcmos_errno bal_cfg_get_stub_res = BCM_ERR_OK; |
| 241 | |
| 242 | bcmolt_olt_cfg olt_cfg = { }; |
| 243 | bcmolt_olt_key olt_key = { }; |
| 244 | |
| 245 | BCMOLT_CFG_INIT(&olt_cfg, olt, olt_key); |
| 246 | |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame^] | 247 | olt_cfg.data.topology.topology_maps.len = num_of_pon_port; |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 248 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__olt_topology_stub, bcmolt_cfg_get__olt_topology_stub(_, _)) |
| 249 | .WillOnce(DoAll(SetArg1ToBcmOltCfg(olt_cfg), Return(bal_cfg_get_stub_res))); |
| 250 | |
| 251 | ProbeDeviceCapabilities_(); |
| 252 | |
| 253 | } |
| 254 | |
| 255 | virtual void TearDown() { |
| 256 | // Code here will be called immediately after each test |
| 257 | // (right before the destructor). |
| 258 | } |
| 259 | }; |
| 260 | |
| 261 | |
| 262 | // Test Fixture for OltDisable |
| 263 | |
| 264 | // Test 1: OltDisableSuccess case |
| 265 | TEST_F(TestOltDisableReenable, OltDisableSuccess){ |
| 266 | // NiceMock is used to suppress 'WillByDefault' return errors. |
| 267 | // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md |
| 268 | NiceMock<BalMocker> balMock; |
Chaitrashree G S | 73e084d | 2019-11-20 16:18:59 -0500 | [diff] [blame] | 269 | bcmos_errno olt_oper_res = BCM_ERR_OK; |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 270 | |
| 271 | Status olt_disable_res; |
Chaitrashree G S | 73e084d | 2019-11-20 16:18:59 -0500 | [diff] [blame] | 272 | state.deactivate(); |
| 273 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_res)); |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 274 | olt_disable_res = Disable_(); |
| 275 | ASSERT_TRUE( olt_disable_res.error_message() == Status::OK.error_message() ); |
| 276 | |
| 277 | } |
| 278 | |
| 279 | // Test 2: OltDisableAllPonFailed case |
| 280 | TEST_F(TestOltDisableReenable, OltDisableAllPonFailed){ |
| 281 | // NiceMock is used to suppress 'WillByDefault' return errors. |
| 282 | // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md |
| 283 | NiceMock<BalMocker> balMock; |
Chaitrashree G S | 73e084d | 2019-11-20 16:18:59 -0500 | [diff] [blame] | 284 | bcmos_errno olt_oper_res = BCM_ERR_INTERNAL; |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 285 | |
| 286 | Status olt_disable_res; |
Chaitrashree G S | 73e084d | 2019-11-20 16:18:59 -0500 | [diff] [blame] | 287 | state.deactivate(); |
| 288 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_res)); |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 289 | olt_disable_res = Disable_(); |
| 290 | ASSERT_TRUE( olt_disable_res.error_code() == grpc::StatusCode::INTERNAL); |
| 291 | } |
| 292 | |
| 293 | |
| 294 | // Test Fixture for OltReenable |
| 295 | |
| 296 | // Test 1: OltReenableSuccess case |
| 297 | TEST_F(TestOltDisableReenable, OltReenableSuccess){ |
| 298 | // NiceMock is used to suppress 'WillByDefault' return errors. |
| 299 | // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md |
| 300 | NiceMock<BalMocker> balMock; |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 301 | uint32_t pon_id = 0; |
| 302 | bcmos_errno olt_cfg_get_tmstub_res = BCM_ERR_OK; |
| 303 | bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK; |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 304 | Status olt_reenable_res; |
| 305 | |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 306 | bcmolt_pon_interface_key pon_key; |
| 307 | bcmolt_pon_interface_cfg pon_cfg; |
| 308 | pon_key.pon_ni = pon_id; |
| 309 | BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key); |
| 310 | pon_cfg.data.state = BCMOLT_INTERFACE_STATE_INACTIVE; |
| 311 | |
| 312 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _)) |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame^] | 313 | .Times(num_of_pon_port) |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 314 | .WillRepeatedly(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res))); |
| 315 | |
| 316 | bcmolt_tm_sched_cfg tm_sched_cfg; |
| 317 | bcmolt_tm_sched_key tm_sched_key = {.id = 1004}; |
| 318 | BCMOLT_CFG_INIT(&tm_sched_cfg, tm_sched, tm_sched_key); |
| 319 | tm_sched_cfg.data.state = BCMOLT_CONFIG_STATE_NOT_CONFIGURED; |
| 320 | |
| 321 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__tm_sched_stub, bcmolt_cfg_get__tm_sched_stub(_, _)) |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame^] | 322 | .Times(num_of_pon_port) |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 323 | .WillRepeatedly(DoAll(SetArg1ToBcmOltTmSchedCfg(tm_sched_cfg), Return(olt_cfg_get_tmstub_res))); |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 324 | |
| 325 | olt_reenable_res = Reenable_(); |
| 326 | ASSERT_TRUE( olt_reenable_res.error_message() == Status::OK.error_message() ); |
| 327 | |
| 328 | } |
| 329 | |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 330 | // Test 2: OltReenableAllPonFailed case |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 331 | TEST_F(TestOltDisableReenable, OltReenableAllPonFailed){ |
| 332 | // NiceMock is used to suppress 'WillByDefault' return errors. |
| 333 | // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md |
| 334 | NiceMock<BalMocker> balMock; |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 335 | uint32_t pon_id = 0; |
| 336 | bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK; |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 337 | bcmos_errno olt_oper_res = BCM_ERR_INTERNAL; |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 338 | Status olt_reenable_res; |
| 339 | |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 340 | bcmolt_pon_interface_key pon_key; |
| 341 | bcmolt_pon_interface_cfg pon_cfg; |
| 342 | pon_key.pon_ni = pon_id; |
| 343 | BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key); |
| 344 | pon_cfg.data.state = BCMOLT_INTERFACE_STATE_INACTIVE; |
| 345 | |
| 346 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _)) |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame^] | 347 | .Times(num_of_pon_port) |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 348 | .WillRepeatedly(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res))); |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 349 | EXPECT_CALL(balMock,bcmolt_oper_submit(_, _)) |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame^] | 350 | .Times(num_of_pon_port) |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 351 | .WillRepeatedly(Return(olt_oper_res)); |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 352 | |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 353 | olt_reenable_res = Reenable_(); |
| 354 | ASSERT_TRUE( olt_reenable_res.error_code() == grpc::StatusCode::INTERNAL); |
| 355 | } |
| 356 | |
| 357 | //////////////////////////////////////////////////////////////////////////// |
| 358 | // For testing ProbeDeviceCapabilities functionality |
| 359 | //////////////////////////////////////////////////////////////////////////// |
| 360 | class TestProbeDevCapabilities : public Test { |
| 361 | protected: |
| 362 | NiceMock<BalMocker> balMock; |
| 363 | bcmos_errno olt_res_success = BCM_ERR_OK; |
| 364 | bcmos_errno olt_res_fail = BCM_ERR_COMM_FAIL; |
| 365 | bcmos_errno dev_res_success = BCM_ERR_OK; |
| 366 | bcmos_errno dev_res_fail = BCM_ERR_COMM_FAIL; |
| 367 | |
| 368 | virtual void SetUp() { |
| 369 | bcmos_errno bal_cfg_get_stub_res = BCM_ERR_OK; |
| 370 | |
| 371 | bcmolt_olt_cfg olt_cfg = { }; |
| 372 | bcmolt_olt_key olt_key = { }; |
| 373 | |
| 374 | BCMOLT_CFG_INIT(&olt_cfg, olt, olt_key); |
| 375 | |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame^] | 376 | olt_cfg.data.topology.topology_maps.len = num_of_pon_port; |
Amit Ghosh | fcad4d3 | 2019-11-13 10:24:55 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | virtual void TearDown() { |
| 380 | } |
| 381 | }; |
| 382 | |
| 383 | // Test 1 - If querying the OLT fails, the method must return error |
| 384 | TEST_F(TestProbeDevCapabilities, ProbeDev_OltQueryFailed) { |
| 385 | |
| 386 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__olt_topology_stub, bcmolt_cfg_get__olt_topology_stub(_,_)) |
| 387 | .WillOnce(Return(olt_res_fail)); |
| 388 | |
| 389 | Status query_status = ProbeDeviceCapabilities_(); |
| 390 | ASSERT_TRUE( query_status.error_message() != Status::OK.error_message() ); |
| 391 | } |
| 392 | |
| 393 | // Test 2 - If all devices are queried successfully, the method must return Status::OK |
| 394 | TEST_F(TestProbeDevCapabilities, ProbeDev_OltQuerySucceeded_DevQueriesSucceeded) { |
| 395 | |
| 396 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__olt_topology_stub, bcmolt_cfg_get__olt_topology_stub(_,_)) |
| 397 | .WillOnce(Return(olt_res_success)); |
| 398 | |
| 399 | EXPECT_CALL(balMock, bcmolt_cfg_get(_, _)) |
| 400 | .WillRepeatedly(Return(dev_res_success)); |
| 401 | |
| 402 | Status query_status = ProbeDeviceCapabilities_(); |
| 403 | |
| 404 | ASSERT_TRUE( query_status.error_message() == Status::OK.error_message() ); |
| 405 | } |
| 406 | |
| 407 | // Test 3 - After successfully probing the OLT, even if probing all devices failed, the method must return error |
| 408 | TEST_F(TestProbeDevCapabilities, ProbedDev_OltQuerySucceeded_AllDevQueriesFailed) { |
| 409 | |
| 410 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__olt_topology_stub, bcmolt_cfg_get__olt_topology_stub(_,_)) |
| 411 | .WillOnce(Return(olt_res_success)); |
| 412 | |
| 413 | EXPECT_CALL(balMock, bcmolt_cfg_get(_, _)) |
| 414 | .WillRepeatedly(Return(dev_res_fail)); |
| 415 | |
| 416 | Status query_status = ProbeDeviceCapabilities_(); |
| 417 | |
| 418 | ASSERT_TRUE( query_status.error_message() != Status::OK.error_message() ); |
| 419 | } |
| 420 | |
| 421 | // Test 4 - After successfully probing the OLT, if probing some devices fail, the method returns success |
| 422 | TEST_F(TestProbeDevCapabilities, ProbedDev_OltQuerySucceeded_SomeDevQueriesFailed) { |
| 423 | |
| 424 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__olt_topology_stub, bcmolt_cfg_get__olt_topology_stub(_,_)) |
| 425 | .WillOnce(Return(olt_res_success)); |
| 426 | |
| 427 | EXPECT_CALL(balMock, bcmolt_cfg_get(_, _)) |
| 428 | .WillOnce(Return(olt_res_success)) |
| 429 | .WillRepeatedly(Return(dev_res_fail)); |
| 430 | |
| 431 | Status query_status = ProbeDeviceCapabilities_(); |
| 432 | |
| 433 | ASSERT_TRUE( query_status.error_message() == Status::OK.error_message() ); |
| 434 | } |
| 435 | |
Chaitrashree G S | 73e084d | 2019-11-20 16:18:59 -0500 | [diff] [blame] | 436 | //////////////////////////////////////////////////////////////////////////// |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 437 | // For testing EnablePonIf functionality |
| 438 | //////////////////////////////////////////////////////////////////////////// |
| 439 | |
| 440 | class TestEnablePonIf : public Test { |
| 441 | protected: |
| 442 | uint32_t pon_id = 0; |
| 443 | NiceMock<BalMocker> balMock; |
| 444 | |
| 445 | virtual void SetUp() { |
| 446 | } |
| 447 | |
| 448 | virtual void TearDown() { |
| 449 | } |
| 450 | }; |
| 451 | |
| 452 | // Test 1 - EnablePonIf, Downstream DefaultSched & DefaultQueues creation success case |
| 453 | TEST_F(TestEnablePonIf, EnablePonIfDefaultSchedQueuesSuccess) { |
| 454 | bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK; |
| 455 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 456 | bcmos_errno olt_cfg_get_tmstub_res = BCM_ERR_OK; |
| 457 | bcmos_errno olt_oper_sub_res = BCM_ERR_OK; |
| 458 | |
| 459 | bcmolt_pon_interface_key pon_key; |
| 460 | bcmolt_pon_interface_cfg pon_cfg; |
| 461 | pon_key.pon_ni = pon_id; |
| 462 | BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key); |
| 463 | pon_cfg.data.state = BCMOLT_INTERFACE_STATE_INACTIVE; |
| 464 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _)) |
| 465 | .WillOnce(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res))); |
| 466 | |
| 467 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 468 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_sub_res)); |
| 469 | |
| 470 | bcmolt_tm_sched_cfg tm_sched_cfg; |
| 471 | bcmolt_tm_sched_key tm_sched_key = {.id = 1004}; |
| 472 | BCMOLT_CFG_INIT(&tm_sched_cfg, tm_sched, tm_sched_key); |
| 473 | tm_sched_cfg.data.state = BCMOLT_CONFIG_STATE_NOT_CONFIGURED; |
| 474 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__tm_sched_stub, bcmolt_cfg_get__tm_sched_stub(_, _)) |
| 475 | .WillOnce(DoAll(SetArg1ToBcmOltTmSchedCfg(tm_sched_cfg), Return(olt_cfg_get_tmstub_res))); |
| 476 | |
| 477 | Status status = EnablePonIf_(pon_id); |
| 478 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 479 | } |
| 480 | |
| 481 | // Test 2 - EnablePonIf success but Downstream DefaultSched Query failure case |
| 482 | TEST_F(TestEnablePonIf, EnablePonIfSuccessDefaultSchedQueryFailure) { |
| 483 | bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK; |
| 484 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 485 | bcmos_errno olt_cfg_get_tmstub_res = BCM_ERR_INTERNAL; |
| 486 | bcmos_errno olt_oper_sub_res = BCM_ERR_OK; |
| 487 | |
| 488 | bcmolt_pon_interface_key pon_key; |
| 489 | bcmolt_pon_interface_cfg pon_cfg; |
| 490 | pon_key.pon_ni = pon_id; |
| 491 | BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key); |
| 492 | pon_cfg.data.state = BCMOLT_INTERFACE_STATE_INACTIVE; |
| 493 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _)) |
| 494 | .WillOnce(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res))); |
| 495 | |
| 496 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 497 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_sub_res)); |
| 498 | |
| 499 | bcmolt_tm_sched_cfg tm_sched_cfg; |
| 500 | bcmolt_tm_sched_key tm_sched_key = {.id = 1004}; |
| 501 | BCMOLT_CFG_INIT(&tm_sched_cfg, tm_sched, tm_sched_key); |
| 502 | tm_sched_cfg.data.state = BCMOLT_CONFIG_STATE_CONFIGURED; |
| 503 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__tm_sched_stub, bcmolt_cfg_get__tm_sched_stub(_, _)) |
| 504 | .WillOnce(DoAll(SetArg1ToBcmOltTmSchedCfg(tm_sched_cfg), Return(olt_cfg_get_tmstub_res))); |
| 505 | |
| 506 | Status status = EnablePonIf_(pon_id); |
| 507 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 508 | } |
| 509 | |
| 510 | // Test 3 - EnablePonIf success but Downstream DefaultSched already in Configured state |
| 511 | TEST_F(TestEnablePonIf, EnablePonIfSuccessDefaultSchedAlreadyConfigured) { |
| 512 | bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK; |
| 513 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 514 | bcmos_errno olt_cfg_get_res = BCM_ERR_OK; |
| 515 | bcmos_errno olt_cfg_get_tmstub_res = BCM_ERR_OK; |
| 516 | bcmos_errno olt_oper_sub_res = BCM_ERR_OK; |
| 517 | |
| 518 | bcmolt_pon_interface_key pon_key; |
| 519 | bcmolt_pon_interface_cfg pon_cfg; |
| 520 | pon_key.pon_ni = pon_id; |
| 521 | BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key); |
| 522 | pon_cfg.data.state = BCMOLT_INTERFACE_STATE_INACTIVE; |
| 523 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _)) |
| 524 | .WillOnce(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res))); |
| 525 | |
| 526 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 527 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_sub_res)); |
| 528 | ON_CALL(balMock, bcmolt_cfg_get(_, _)).WillByDefault(Return(olt_cfg_get_res)); |
| 529 | |
| 530 | bcmolt_tm_sched_cfg tm_sched_cfg; |
| 531 | bcmolt_tm_sched_key tm_sched_key = {.id = 1004}; |
| 532 | BCMOLT_CFG_INIT(&tm_sched_cfg, tm_sched, tm_sched_key); |
| 533 | tm_sched_cfg.data.state = BCMOLT_CONFIG_STATE_CONFIGURED; |
| 534 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__tm_sched_stub, bcmolt_cfg_get__tm_sched_stub(_, _)) |
| 535 | .WillOnce(DoAll(SetArg1ToBcmOltTmSchedCfg(tm_sched_cfg), Return(olt_cfg_get_tmstub_res))); |
| 536 | |
| 537 | Status status = EnablePonIf_(pon_id); |
| 538 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 539 | } |
| 540 | |
| 541 | // Test 4 - EnablePonIf success but Downstream DefaultSched & DefaultQueues creation failed |
| 542 | TEST_F(TestEnablePonIf, EnablePonIfSuccessDefaultSchedQueuesFailed) { |
| 543 | bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK; |
| 544 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 545 | bcmos_errno olt_cfg_set_err = BCM_ERR_INTERNAL; |
| 546 | bcmos_errno olt_cfg_get_res = BCM_ERR_OK; |
| 547 | bcmos_errno olt_cfg_get_tmstub_res = BCM_ERR_OK; |
| 548 | bcmos_errno olt_oper_sub_res = BCM_ERR_OK; |
| 549 | |
| 550 | bcmolt_pon_interface_key pon_key; |
| 551 | bcmolt_pon_interface_cfg pon_cfg; |
| 552 | pon_key.pon_ni = pon_id; |
| 553 | BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key); |
| 554 | pon_cfg.data.state = BCMOLT_INTERFACE_STATE_INACTIVE; |
| 555 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _)) |
| 556 | .WillOnce(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res))); |
| 557 | |
| 558 | EXPECT_CALL(balMock, bcmolt_cfg_set(_, _)) |
| 559 | .WillOnce(Return(olt_cfg_set_res)) |
| 560 | .WillRepeatedly(Return(olt_cfg_set_err)); |
| 561 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_sub_res)); |
| 562 | ON_CALL(balMock, bcmolt_cfg_get(_, _)).WillByDefault(Return(olt_cfg_get_res)); |
| 563 | |
| 564 | bcmolt_tm_sched_cfg tm_sched_cfg; |
| 565 | bcmolt_tm_sched_key tm_sched_key = {.id = 1004}; |
| 566 | BCMOLT_CFG_INIT(&tm_sched_cfg, tm_sched, tm_sched_key); |
| 567 | tm_sched_cfg.data.state = BCMOLT_CONFIG_STATE_NOT_CONFIGURED; |
| 568 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__tm_sched_stub, bcmolt_cfg_get__tm_sched_stub(_, _)) |
| 569 | .WillOnce(DoAll(SetArg1ToBcmOltTmSchedCfg(tm_sched_cfg), Return(olt_cfg_get_tmstub_res))); |
| 570 | |
| 571 | Status status = EnablePonIf_(pon_id); |
| 572 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 573 | } |
| 574 | |
| 575 | // Test 5 - EnablePonIf already enabled success |
| 576 | TEST_F(TestEnablePonIf, EnablePonIfAlreadyEnabled) { |
| 577 | bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK; |
| 578 | |
| 579 | bcmolt_pon_interface_key pon_key; |
| 580 | bcmolt_pon_interface_cfg pon_cfg; |
| 581 | pon_key.pon_ni = pon_id; |
| 582 | BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key); |
| 583 | pon_cfg.data.state = BCMOLT_INTERFACE_STATE_ACTIVE_WORKING; |
| 584 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _)) |
| 585 | .WillOnce(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res))); |
| 586 | |
| 587 | Status status = EnablePonIf_(pon_id); |
| 588 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 589 | } |
| 590 | |
| 591 | // Test 6 - EnablePonIf - enable onu discovery failure case |
| 592 | TEST_F(TestEnablePonIf, EnablePonIfEnableOnuDiscFailed) { |
| 593 | bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK; |
| 594 | bcmos_errno olt_cfg_set_res = BCM_ERR_INTERNAL; |
| 595 | |
| 596 | bcmolt_pon_interface_key pon_key; |
| 597 | bcmolt_pon_interface_cfg pon_cfg; |
| 598 | pon_key.pon_ni = pon_id; |
| 599 | BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key); |
| 600 | pon_cfg.data.state = BCMOLT_INTERFACE_STATE_INACTIVE; |
| 601 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _)) |
| 602 | .WillOnce(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res))); |
| 603 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 604 | |
| 605 | Status status = EnablePonIf_(pon_id); |
| 606 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 607 | } |
| 608 | |
| 609 | // Test 7 - EnablePonIf failure case |
| 610 | TEST_F(TestEnablePonIf, EnablePonIfFailed) { |
| 611 | bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK; |
| 612 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 613 | bcmos_errno olt_oper_sub_res = BCM_ERR_INTERNAL; |
| 614 | |
| 615 | bcmolt_pon_interface_key pon_key; |
| 616 | bcmolt_pon_interface_cfg pon_cfg; |
| 617 | pon_key.pon_ni = pon_id; |
| 618 | BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key); |
| 619 | pon_cfg.data.state = BCMOLT_INTERFACE_STATE_INACTIVE; |
| 620 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _)) |
| 621 | .WillOnce(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res))); |
| 622 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 623 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_sub_res)); |
| 624 | |
| 625 | Status status = EnablePonIf_(pon_id); |
| 626 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 627 | } |
| 628 | |
| 629 | //////////////////////////////////////////////////////////////////////////// |
| 630 | // For testing SetStateUplinkIf functionality |
| 631 | //////////////////////////////////////////////////////////////////////////// |
| 632 | |
| 633 | class TestSetStateUplinkIf : public Test { |
| 634 | protected: |
| 635 | uint32_t intf_id = 0; |
| 636 | NiceMock<BalMocker> balMock; |
| 637 | |
| 638 | virtual void SetUp() { |
| 639 | } |
| 640 | |
| 641 | virtual void TearDown() { |
| 642 | } |
| 643 | }; |
| 644 | |
| 645 | // Test 1 - SetStateUplinkIf NNI intf already enabled, Upstream DefaultSched & DefaultQueues creation success case |
| 646 | TEST_F(TestSetStateUplinkIf, SetStateUplinkIfAlreadyEnabledDefaultSchedQueuesSuccess) { |
| 647 | bcmos_errno olt_cfg_get_nni_stub_res = BCM_ERR_OK; |
| 648 | bcmos_errno olt_cfg_get_tmstub_res = BCM_ERR_OK; |
| 649 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 650 | |
| 651 | bcmolt_nni_interface_key nni_key; |
| 652 | bcmolt_nni_interface_cfg nni_cfg; |
| 653 | nni_key.id = intf_id; |
| 654 | BCMOLT_CFG_INIT(&nni_cfg, nni_interface, nni_key); |
| 655 | nni_cfg.data.state = BCMOLT_INTERFACE_STATE_ACTIVE_WORKING; |
| 656 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__nni_intf_stub, bcmolt_cfg_get__nni_intf_stub(_, _)) |
| 657 | .WillOnce(DoAll(SetArg1ToBcmOltNniCfg(nni_cfg), Return(olt_cfg_get_nni_stub_res))); |
| 658 | |
| 659 | bcmolt_tm_sched_cfg tm_sched_cfg; |
| 660 | bcmolt_tm_sched_key tm_sched_key = {.id = 1004}; |
| 661 | BCMOLT_CFG_INIT(&tm_sched_cfg, tm_sched, tm_sched_key); |
| 662 | tm_sched_cfg.data.state = BCMOLT_CONFIG_STATE_NOT_CONFIGURED; |
| 663 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__tm_sched_stub, bcmolt_cfg_get__tm_sched_stub(_, _)) |
| 664 | .WillOnce(DoAll(SetArg1ToBcmOltTmSchedCfg(tm_sched_cfg), Return(olt_cfg_get_tmstub_res))); |
| 665 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 666 | |
| 667 | Status status = SetStateUplinkIf_(intf_id, true); |
| 668 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 669 | } |
| 670 | |
| 671 | // Test 2 - SetStateUplinkIf, NNI interface already disabled case |
| 672 | TEST_F(TestSetStateUplinkIf, SetStateUplinkIfAlreadyDisabled) { |
| 673 | bcmos_errno olt_cfg_get_nni_stub_res = BCM_ERR_OK; |
| 674 | |
| 675 | bcmolt_nni_interface_key nni_key; |
| 676 | bcmolt_nni_interface_cfg nni_cfg; |
| 677 | nni_key.id = intf_id; |
| 678 | BCMOLT_CFG_INIT(&nni_cfg, nni_interface, nni_key); |
| 679 | nni_cfg.data.state = BCMOLT_INTERFACE_STATE_INACTIVE; |
| 680 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__nni_intf_stub, bcmolt_cfg_get__nni_intf_stub(_, _)) |
| 681 | .WillOnce(DoAll(SetArg1ToBcmOltNniCfg(nni_cfg), Return(olt_cfg_get_nni_stub_res))); |
| 682 | |
| 683 | Status status = SetStateUplinkIf_(intf_id, false); |
| 684 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 685 | } |
| 686 | |
| 687 | // Test 3 - SetStateUplinkIf Enable success, Upstream DefaultSched & DefaultQueues creation success case |
| 688 | TEST_F(TestSetStateUplinkIf, SetStateUplinkIfDefaultSchedQueuesSuccess) { |
| 689 | bcmos_errno olt_cfg_get_nni_stub_res = BCM_ERR_OK; |
| 690 | bcmos_errno olt_cfg_get_tmstub_res = BCM_ERR_OK; |
| 691 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 692 | bcmos_errno olt_oper_sub_res = BCM_ERR_OK; |
| 693 | |
| 694 | bcmolt_nni_interface_key nni_key; |
| 695 | bcmolt_nni_interface_cfg nni_cfg; |
| 696 | nni_key.id = intf_id; |
| 697 | BCMOLT_CFG_INIT(&nni_cfg, nni_interface, nni_key); |
| 698 | nni_cfg.data.state = BCMOLT_INTERFACE_STATE__BEGIN; |
| 699 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__nni_intf_stub, bcmolt_cfg_get__nni_intf_stub(_, _)) |
| 700 | .WillOnce(DoAll(SetArg1ToBcmOltNniCfg(nni_cfg), Return(olt_cfg_get_nni_stub_res))); |
| 701 | |
| 702 | bcmolt_tm_sched_cfg tm_sched_cfg; |
| 703 | bcmolt_tm_sched_key tm_sched_key = {.id = 1004}; |
| 704 | BCMOLT_CFG_INIT(&tm_sched_cfg, tm_sched, tm_sched_key); |
| 705 | tm_sched_cfg.data.state = BCMOLT_CONFIG_STATE_NOT_CONFIGURED; |
| 706 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__tm_sched_stub, bcmolt_cfg_get__tm_sched_stub(_, _)) |
| 707 | .WillOnce(DoAll(SetArg1ToBcmOltTmSchedCfg(tm_sched_cfg), Return(olt_cfg_get_tmstub_res))); |
| 708 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 709 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_sub_res)); |
| 710 | |
| 711 | Status status = SetStateUplinkIf_(intf_id, true); |
| 712 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 713 | } |
| 714 | |
| 715 | // Test 4 - SetStateUplinkIf Enable failure case |
| 716 | TEST_F(TestSetStateUplinkIf, SetStateUplinkIfEnableFailure) { |
| 717 | bcmos_errno olt_cfg_get_nni_stub_res = BCM_ERR_OK; |
| 718 | bcmos_errno olt_oper_sub_res = BCM_ERR_INTERNAL; |
| 719 | |
| 720 | bcmolt_nni_interface_key nni_key; |
| 721 | bcmolt_nni_interface_cfg nni_cfg; |
| 722 | nni_key.id = intf_id; |
| 723 | BCMOLT_CFG_INIT(&nni_cfg, nni_interface, nni_key); |
| 724 | nni_cfg.data.state = BCMOLT_INTERFACE_STATE__BEGIN; |
| 725 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__nni_intf_stub, bcmolt_cfg_get__nni_intf_stub(_, _)) |
| 726 | .WillOnce(DoAll(SetArg1ToBcmOltNniCfg(nni_cfg), Return(olt_cfg_get_nni_stub_res))); |
| 727 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_sub_res)); |
| 728 | |
| 729 | Status status = SetStateUplinkIf_(intf_id, true); |
| 730 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 731 | } |
| 732 | |
| 733 | // Test 5 - SetStateUplinkIf Disable success case |
| 734 | TEST_F(TestSetStateUplinkIf, SetStateUplinkIfDisableSuccess) { |
| 735 | bcmos_errno olt_cfg_get_nni_stub_res = BCM_ERR_OK; |
| 736 | bcmos_errno olt_oper_sub_res = BCM_ERR_OK; |
| 737 | |
| 738 | bcmolt_nni_interface_key nni_key; |
| 739 | bcmolt_nni_interface_cfg nni_cfg; |
| 740 | nni_key.id = intf_id; |
| 741 | BCMOLT_CFG_INIT(&nni_cfg, nni_interface, nni_key); |
| 742 | nni_cfg.data.state = BCMOLT_INTERFACE_STATE_ACTIVE_WORKING; |
| 743 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__nni_intf_stub, bcmolt_cfg_get__nni_intf_stub(_, _)) |
| 744 | .WillOnce(DoAll(SetArg1ToBcmOltNniCfg(nni_cfg), Return(olt_cfg_get_nni_stub_res))); |
| 745 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_sub_res)); |
| 746 | |
| 747 | Status status = SetStateUplinkIf_(intf_id, false); |
| 748 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 749 | } |
| 750 | |
| 751 | // Test 6 - SetStateUplinkIf Disable failure case |
| 752 | TEST_F(TestSetStateUplinkIf, SetStateUplinkIfDisableFailure) { |
| 753 | bcmos_errno olt_cfg_get_nni_stub_res = BCM_ERR_OK; |
| 754 | bcmos_errno olt_oper_sub_res = BCM_ERR_INTERNAL; |
| 755 | |
| 756 | bcmolt_nni_interface_key nni_key; |
| 757 | bcmolt_nni_interface_cfg nni_cfg; |
| 758 | nni_key.id = intf_id; |
| 759 | BCMOLT_CFG_INIT(&nni_cfg, nni_interface, nni_key); |
| 760 | nni_cfg.data.state = BCMOLT_INTERFACE_STATE_ACTIVE_WORKING; |
| 761 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__nni_intf_stub, bcmolt_cfg_get__nni_intf_stub(_, _)) |
| 762 | .WillOnce(DoAll(SetArg1ToBcmOltNniCfg(nni_cfg), Return(olt_cfg_get_nni_stub_res))); |
| 763 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_sub_res)); |
| 764 | |
| 765 | Status status = SetStateUplinkIf_(intf_id, false); |
| 766 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 767 | } |
| 768 | |
| 769 | //////////////////////////////////////////////////////////////////////////// |
Chaitrashree G S | 73e084d | 2019-11-20 16:18:59 -0500 | [diff] [blame] | 770 | // For testing DisablePonIf functionality |
| 771 | //////////////////////////////////////////////////////////////////////////// |
| 772 | |
| 773 | class TestDisablePonIf : public Test { |
| 774 | protected: |
| 775 | virtual void SetUp() { |
| 776 | } |
| 777 | |
| 778 | virtual void TearDown() { |
| 779 | } |
| 780 | }; |
| 781 | |
| 782 | // Test 1 - DisablePonIf success case |
| 783 | TEST_F(TestDisablePonIf, DisablePonIfSuccess) { |
| 784 | bcmos_errno olt_oper_res = BCM_ERR_OK; |
| 785 | bcmos_errno bal_cfg_set_res = BCM_ERR_OK; |
| 786 | NiceMock<BalMocker> balMock; |
| 787 | uint32_t pon_id=1; |
| 788 | |
| 789 | //ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(bal_cfg_set_res)); |
| 790 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_res)); |
| 791 | state.deactivate(); |
| 792 | Status status = DisablePonIf_(pon_id); |
| 793 | |
| 794 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 795 | } |
| 796 | |
| 797 | // Test 2 - DisablePonIf Failure case |
| 798 | TEST_F(TestDisablePonIf, DisablePonIfFailed) { |
| 799 | bcmos_errno olt_oper_res = BCM_ERR_INTERNAL; |
| 800 | NiceMock<BalMocker> balMock; |
| 801 | uint32_t pon_id=1; |
| 802 | |
| 803 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(olt_oper_res)); |
| 804 | state.deactivate(); |
| 805 | Status status = DisablePonIf_(pon_id); |
| 806 | |
| 807 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 808 | } |
| 809 | |
| 810 | // Test 3 - DisablePonIf ONU discovery failure case |
| 811 | TEST_F(TestDisablePonIf, DisablePonIfOnuDiscoveryFail) { |
| 812 | NiceMock<BalMocker> balMock; |
| 813 | uint32_t pon_id=1; |
| 814 | bcmos_errno bal_cfg_set_res= BCM_ERR_INTERNAL; |
| 815 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(bal_cfg_set_res)); |
| 816 | state.deactivate(); |
| 817 | Status status = DisablePonIf_(pon_id); |
| 818 | |
| 819 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 820 | } |
| 821 | |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 822 | //////////////////////////////////////////////////////////////////////////// |
| 823 | // For testing ActivateOnu functionality |
| 824 | //////////////////////////////////////////////////////////////////////////// |
| 825 | |
| 826 | class TestActivateOnu : public Test { |
| 827 | protected: |
| 828 | uint32_t pon_id = 0; |
| 829 | uint32_t onu_id = 1; |
| 830 | std::string vendor_id = "TWSH"; |
| 831 | std::string vendor_specific = "80808080"; |
| 832 | uint32_t pir = 1000000; |
| 833 | NiceMock<BalMocker> balMock; |
| 834 | |
| 835 | virtual void SetUp() { |
| 836 | } |
| 837 | |
| 838 | virtual void TearDown() { |
| 839 | } |
| 840 | }; |
| 841 | |
| 842 | // Test 1 - ActivateOnu success case |
| 843 | TEST_F(TestActivateOnu, ActivateOnuSuccess) { |
| 844 | bcmos_errno onu_cfg_get_res = BCM_ERR_INTERNAL; |
| 845 | bcmos_errno onu_cfg_get_stub_res = BCM_ERR_INTERNAL; |
| 846 | bcmos_errno onu_cfg_set_res = BCM_ERR_OK; |
| 847 | |
| 848 | bcmolt_onu_cfg onu_cfg; |
| 849 | bcmolt_onu_key onu_key; |
| 850 | BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key); |
| 851 | onu_cfg.data.onu_state = BCMOLT_ONU_STATE_ACTIVE; |
| 852 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__onu_state_stub, bcmolt_cfg_get__onu_state_stub(_, _)) |
| 853 | .WillOnce(DoAll(SetArg1ToBcmOltOnuCfg(onu_cfg), Return(onu_cfg_get_stub_res))); |
| 854 | |
| 855 | ON_CALL(balMock, bcmolt_cfg_get(_, _)).WillByDefault(Return(onu_cfg_get_res)); |
| 856 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(onu_cfg_set_res)); |
| 857 | |
| 858 | Status status = ActivateOnu_(pon_id, onu_id, vendor_id.c_str(), vendor_specific.c_str(), pir); |
| 859 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 860 | } |
| 861 | |
| 862 | // Test 2 - ActivateOnu failure case |
| 863 | TEST_F(TestActivateOnu, ActivateOnuFailure) { |
| 864 | bcmos_errno onu_cfg_get_res = BCM_ERR_INTERNAL; |
| 865 | bcmos_errno onu_cfg_get_stub_res = BCM_ERR_INTERNAL; |
| 866 | bcmos_errno onu_cfg_set_res = BCM_ERR_INTERNAL; |
| 867 | |
| 868 | bcmolt_onu_cfg onu_cfg; |
| 869 | bcmolt_onu_key onu_key; |
| 870 | BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key); |
| 871 | onu_cfg.data.onu_state = BCMOLT_ONU_STATE_ACTIVE; |
| 872 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__onu_state_stub, bcmolt_cfg_get__onu_state_stub(_, _)) |
| 873 | .WillOnce(DoAll(SetArg1ToBcmOltOnuCfg(onu_cfg), Return(onu_cfg_get_stub_res))); |
| 874 | |
| 875 | ON_CALL(balMock, bcmolt_cfg_get(_, _)).WillByDefault(Return(onu_cfg_get_res)); |
| 876 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(onu_cfg_set_res)); |
| 877 | |
| 878 | Status status = ActivateOnu_(pon_id, onu_id, vendor_id.c_str(), vendor_specific.c_str(), pir); |
| 879 | ASSERT_FALSE( status.error_message() == Status::OK.error_message() ); |
| 880 | } |
| 881 | |
| 882 | // Test 3 - ActivateOnu - Onu already under processing case |
| 883 | TEST_F(TestActivateOnu, ActivateOnuProcessing) { |
| 884 | bcmos_errno onu_cfg_get_res = BCM_ERR_OK; |
| 885 | bcmos_errno onu_cfg_get_stub_res = BCM_ERR_OK; |
| 886 | |
| 887 | bcmolt_onu_cfg onu_cfg; |
| 888 | bcmolt_onu_key onu_key; |
| 889 | BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key); |
| 890 | onu_cfg.data.onu_state = BCMOLT_ONU_STATE_ACTIVE; |
| 891 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__onu_state_stub, bcmolt_cfg_get__onu_state_stub(_, _)) |
| 892 | .WillOnce(DoAll(SetArg1ToBcmOltOnuCfg(onu_cfg), Return(onu_cfg_get_stub_res))); |
| 893 | ON_CALL(balMock, bcmolt_cfg_get(_, _)).WillByDefault(Return(onu_cfg_get_res)); |
| 894 | |
| 895 | Status status = ActivateOnu_(pon_id, onu_id, vendor_id.c_str(), vendor_specific.c_str(), pir); |
| 896 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 897 | } |
| 898 | |
| 899 | //////////////////////////////////////////////////////////////////////////// |
| 900 | // For testing DeactivateOnu functionality |
| 901 | //////////////////////////////////////////////////////////////////////////// |
| 902 | |
| 903 | class TestDeactivateOnu : public Test { |
| 904 | protected: |
| 905 | uint32_t pon_id = 0; |
| 906 | uint32_t onu_id = 1; |
| 907 | std::string vendor_id = "TWSH"; |
| 908 | std::string vendor_specific = "80808080"; |
| 909 | NiceMock<BalMocker> balMock; |
| 910 | |
| 911 | virtual void SetUp() { |
| 912 | } |
| 913 | |
| 914 | virtual void TearDown() { |
| 915 | } |
| 916 | }; |
| 917 | |
| 918 | // Test 1 - DeactivateOnu success case |
| 919 | TEST_F(TestDeactivateOnu, DeactivateOnuSuccess) { |
| 920 | bcmos_errno onu_cfg_get_stub_res = BCM_ERR_OK; |
| 921 | bcmos_errno onu_oper_sub_res = BCM_ERR_OK; |
| 922 | |
| 923 | bcmolt_onu_cfg onu_cfg; |
| 924 | bcmolt_onu_key onu_key; |
| 925 | BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key); |
| 926 | onu_cfg.data.onu_state = BCMOLT_ONU_STATE_ACTIVE; |
| 927 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__onu_state_stub, bcmolt_cfg_get__onu_state_stub(_, _)) |
| 928 | .WillOnce(DoAll(SetArg1ToBcmOltOnuCfg(onu_cfg), Return(onu_cfg_get_stub_res))); |
| 929 | |
| 930 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(onu_oper_sub_res)); |
| 931 | |
| 932 | Status status = DeactivateOnu_(pon_id, onu_id, vendor_id.c_str(), vendor_specific.c_str()); |
| 933 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 934 | } |
| 935 | |
| 936 | // Test 2 - DeactivateOnu failure case |
| 937 | TEST_F(TestDeactivateOnu, DeactivateOnuFailure) { |
| 938 | bcmos_errno onu_cfg_get_stub_res = BCM_ERR_OK; |
| 939 | bcmos_errno onu_oper_sub_res = BCM_ERR_INTERNAL; |
| 940 | |
| 941 | bcmolt_onu_cfg onu_cfg; |
| 942 | bcmolt_onu_key onu_key; |
| 943 | BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key); |
| 944 | onu_cfg.data.onu_state = BCMOLT_ONU_STATE_ACTIVE; |
| 945 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__onu_state_stub, bcmolt_cfg_get__onu_state_stub(_, _)) |
| 946 | .WillOnce(DoAll(SetArg1ToBcmOltOnuCfg(onu_cfg), Return(onu_cfg_get_stub_res))); |
| 947 | |
| 948 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(onu_oper_sub_res)); |
| 949 | |
| 950 | Status status = DeactivateOnu_(pon_id, onu_id, vendor_id.c_str(), vendor_specific.c_str()); |
| 951 | ASSERT_FALSE( status.error_message() == Status::OK.error_message() ); |
| 952 | } |
| 953 | |
| 954 | //////////////////////////////////////////////////////////////////////////// |
| 955 | // For testing DeleteOnu functionality |
| 956 | //////////////////////////////////////////////////////////////////////////// |
| 957 | |
| 958 | class TestDeleteOnu : public Test { |
| 959 | protected: |
| 960 | uint32_t pon_id = 0; |
| 961 | uint32_t onu_id = 1; |
| 962 | std::string vendor_id = "TWSH"; |
| 963 | std::string vendor_specific = "80808080"; |
| 964 | NiceMock<BalMocker> balMock; |
| 965 | |
| 966 | virtual void SetUp() { |
| 967 | } |
| 968 | |
| 969 | virtual void TearDown() { |
| 970 | } |
| 971 | }; |
| 972 | |
| 973 | // Test 1 - DeleteOnu success case |
| 974 | TEST_F(TestDeleteOnu, DeleteOnuSuccess) { |
| 975 | bcmos_errno onu_cfg_get_stub_res = BCM_ERR_OK; |
| 976 | bcmos_errno onu_oper_sub_res = BCM_ERR_OK; |
| 977 | bcmos_errno onu_cfg_clear_res = BCM_ERR_OK; |
| 978 | |
| 979 | bcmolt_onu_cfg onu_cfg; |
| 980 | bcmolt_onu_key onu_key; |
| 981 | BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key); |
| 982 | onu_cfg.data.onu_state = BCMOLT_ONU_STATE_ACTIVE; |
| 983 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__onu_state_stub, bcmolt_cfg_get__onu_state_stub(_, _)) |
| 984 | .WillOnce(DoAll(SetArg1ToBcmOltOnuCfg(onu_cfg), Return(onu_cfg_get_stub_res))); |
| 985 | |
| 986 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(onu_oper_sub_res)); |
| 987 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(onu_cfg_clear_res)); |
| 988 | |
| 989 | Status status = DeleteOnu_(pon_id, onu_id, vendor_id.c_str(), vendor_specific.c_str()); |
| 990 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 991 | } |
| 992 | |
| 993 | // Test 2 - DeleteOnu failure case |
| 994 | TEST_F(TestDeleteOnu, DeleteOnuFailure) { |
| 995 | bcmos_errno onu_cfg_get_stub_res = BCM_ERR_OK; |
| 996 | bcmos_errno onu_oper_sub_res = BCM_ERR_OK; |
| 997 | bcmos_errno onu_cfg_clear_res = BCM_ERR_INTERNAL; |
| 998 | |
| 999 | bcmolt_onu_cfg onu_cfg; |
| 1000 | bcmolt_onu_key onu_key; |
| 1001 | BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key); |
| 1002 | onu_cfg.data.onu_state = BCMOLT_ONU_STATE_ACTIVE; |
| 1003 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__onu_state_stub, bcmolt_cfg_get__onu_state_stub(_, _)) |
| 1004 | .WillOnce(DoAll(SetArg1ToBcmOltOnuCfg(onu_cfg), Return(onu_cfg_get_stub_res))); |
| 1005 | |
| 1006 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(onu_oper_sub_res)); |
| 1007 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(onu_cfg_clear_res)); |
| 1008 | |
| 1009 | Status status = DeleteOnu_(pon_id, onu_id, vendor_id.c_str(), vendor_specific.c_str()); |
| 1010 | ASSERT_FALSE( status.error_message() == Status::OK.error_message() ); |
| 1011 | } |
| 1012 | |
| 1013 | //////////////////////////////////////////////////////////////////////////// |
| 1014 | // For testing OmciMsgOut functionality |
| 1015 | //////////////////////////////////////////////////////////////////////////// |
| 1016 | |
| 1017 | class TestOmciMsgOut : public Test { |
| 1018 | protected: |
| 1019 | uint32_t pon_id = 0; |
| 1020 | uint32_t onu_id = 1; |
| 1021 | std::string pkt = "omci-pkt"; |
| 1022 | NiceMock<BalMocker> balMock; |
| 1023 | |
| 1024 | virtual void SetUp() { |
| 1025 | } |
| 1026 | |
| 1027 | virtual void TearDown() { |
| 1028 | } |
| 1029 | }; |
| 1030 | |
| 1031 | // Test 1 - OmciMsgOut success case |
| 1032 | TEST_F(TestOmciMsgOut, OmciMsgOutSuccess) { |
| 1033 | bcmos_errno onu_oper_sub_res = BCM_ERR_OK; |
| 1034 | |
| 1035 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(onu_oper_sub_res)); |
| 1036 | |
| 1037 | Status status = OmciMsgOut_(pon_id, onu_id, pkt); |
| 1038 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1039 | } |
| 1040 | |
| 1041 | // Test 1 - OmciMsgOut failure case |
| 1042 | TEST_F(TestOmciMsgOut, OmciMsgOutFailure) { |
| 1043 | bcmos_errno onu_oper_sub_res = BCM_ERR_INTERNAL; |
| 1044 | |
| 1045 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(onu_oper_sub_res)); |
| 1046 | |
| 1047 | Status status = OmciMsgOut_(pon_id, onu_id, pkt); |
| 1048 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1049 | } |
| 1050 | |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 1051 | #if 0 |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 1052 | //////////////////////////////////////////////////////////////////////////// |
Thiyagarajan Subramani | 81c5611 | 2019-12-19 08:29:55 -0500 | [diff] [blame] | 1053 | // For testing FlowAdd functionality |
| 1054 | //////////////////////////////////////////////////////////////////////////// |
| 1055 | |
| 1056 | class TestFlowAdd : public Test { |
| 1057 | protected: |
| 1058 | int32_t access_intf_id = 0; |
| 1059 | int32_t onu_id = 1; |
| 1060 | int32_t uni_id = 0; |
| 1061 | uint32_t port_no = 16; |
| 1062 | uint32_t flow_id = 1; |
| 1063 | std::string flow_type = "upstream"; |
| 1064 | int32_t alloc_id = 1024; |
| 1065 | int32_t network_intf_id = 0; |
| 1066 | int32_t gemport_id = 1024; |
| 1067 | int32_t priority_value = 0; |
| 1068 | uint64_t cookie = 0; |
| 1069 | |
| 1070 | NiceMock<BalMocker> balMock; |
| 1071 | openolt::Flow* flow; |
| 1072 | openolt::Classifier* classifier; |
| 1073 | openolt::Action* action; |
| 1074 | openolt::ActionCmd* cmd; |
| 1075 | |
| 1076 | bcmolt_flow_key flow_key; |
| 1077 | bcmolt_flow_cfg flow_cfg; |
| 1078 | |
| 1079 | tech_profile::TrafficQueues* traffic_queues; |
| 1080 | tech_profile::TrafficQueue* traffic_queue_1; |
| 1081 | tech_profile::TrafficQueue* traffic_queue_2; |
| 1082 | tech_profile::DiscardConfig* discard_config_1; |
| 1083 | tech_profile::DiscardConfig* discard_config_2; |
| 1084 | tech_profile::TailDropDiscardConfig* tail_drop_discard_config_1; |
| 1085 | tech_profile::TailDropDiscardConfig* tail_drop_discard_config_2; |
| 1086 | |
| 1087 | |
| 1088 | virtual void SetUp() { |
| 1089 | classifier = new openolt::Classifier; |
| 1090 | action = new openolt::Action; |
| 1091 | cmd = new openolt::ActionCmd; |
| 1092 | |
| 1093 | classifier->set_o_tpid(0); |
| 1094 | classifier->set_o_vid(7); |
| 1095 | classifier->set_i_tpid(0); |
| 1096 | classifier->set_i_vid(0); |
| 1097 | classifier->set_o_pbits(0); |
| 1098 | classifier->set_i_pbits(0); |
| 1099 | classifier->set_eth_type(0); |
| 1100 | classifier->set_ip_proto(0); |
| 1101 | classifier->set_src_port(0); |
| 1102 | classifier->set_dst_port(0); |
| 1103 | classifier->set_pkt_tag_type("single_tag"); |
| 1104 | |
| 1105 | action->set_o_vid(12); |
| 1106 | action->set_o_pbits(0); |
| 1107 | action->set_o_tpid(0); |
| 1108 | action->set_i_vid(0); |
| 1109 | action->set_i_pbits(0); |
| 1110 | action->set_i_tpid(0); |
| 1111 | |
| 1112 | cmd->set_add_outer_tag(true); |
| 1113 | cmd->set_remove_outer_tag(false); |
| 1114 | cmd->set_trap_to_host(false); |
| 1115 | action->set_allocated_cmd(cmd); |
| 1116 | |
| 1117 | flow_key.flow_id = 1; |
| 1118 | flow_key.flow_type = BCMOLT_FLOW_TYPE_UPSTREAM; |
| 1119 | BCMOLT_CFG_INIT(&flow_cfg, flow, flow_key); |
| 1120 | flow_cfg.data.onu_id=1; |
| 1121 | flow_cfg.key.flow_type = BCMOLT_FLOW_TYPE_UPSTREAM; |
| 1122 | flow_cfg.data.svc_port_id=1024; |
| 1123 | flow_cfg.data.priority=0; |
| 1124 | flow_cfg.data.cookie=0; |
| 1125 | flow_cfg.data.ingress_intf.intf_type=BCMOLT_FLOW_INTERFACE_TYPE_PON; |
| 1126 | flow_cfg.data.egress_intf.intf_type=BCMOLT_FLOW_INTERFACE_TYPE_NNI; |
| 1127 | flow_cfg.data.ingress_intf.intf_id=0; |
| 1128 | flow_cfg.data.egress_intf.intf_id=0; |
| 1129 | flow_cfg.data.classifier.o_vid=7; |
| 1130 | flow_cfg.data.classifier.o_pbits=0; |
| 1131 | flow_cfg.data.classifier.i_vid=0; |
| 1132 | flow_cfg.data.classifier.i_pbits=0; |
| 1133 | flow_cfg.data.classifier.ether_type=0; |
| 1134 | flow_cfg.data.classifier.ip_proto=0; |
| 1135 | flow_cfg.data.classifier.src_port=0; |
| 1136 | flow_cfg.data.classifier.dst_port=0; |
| 1137 | flow_cfg.data.classifier.pkt_tag_type=BCMOLT_PKT_TAG_TYPE_SINGLE_TAG; |
| 1138 | flow_cfg.data.egress_qos.type=BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE; |
| 1139 | flow_cfg.data.egress_qos.u.fixed_queue.queue_id=0; |
| 1140 | flow_cfg.data.egress_qos.tm_sched.id=1020; |
| 1141 | flow_cfg.data.action.cmds_bitmask=BCMOLT_ACTION_CMD_ID_ADD_OUTER_TAG; |
| 1142 | flow_cfg.data.action.o_vid=12; |
| 1143 | flow_cfg.data.action.o_pbits=0; |
| 1144 | flow_cfg.data.action.i_vid=0; |
| 1145 | flow_cfg.data.action.i_pbits=0; |
| 1146 | flow_cfg.data.state=BCMOLT_FLOW_STATE_ENABLE; |
| 1147 | |
| 1148 | traffic_queues = new tech_profile::TrafficQueues; |
| 1149 | traffic_queues->set_intf_id(0); |
| 1150 | traffic_queues->set_onu_id(2); |
| 1151 | traffic_queue_1 = traffic_queues->add_traffic_queues(); |
| 1152 | traffic_queue_1->set_gemport_id(1024); |
| 1153 | traffic_queue_1->set_pbit_map("0b00000101"); |
| 1154 | traffic_queue_1->set_aes_encryption(true); |
| 1155 | traffic_queue_1->set_sched_policy(tech_profile::SchedulingPolicy::StrictPriority); |
| 1156 | traffic_queue_1->set_priority(0); |
| 1157 | traffic_queue_1->set_weight(0); |
| 1158 | traffic_queue_1->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 1159 | discard_config_1 = new tech_profile::DiscardConfig; |
| 1160 | discard_config_1->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 1161 | tail_drop_discard_config_1 = new tech_profile::TailDropDiscardConfig; |
| 1162 | tail_drop_discard_config_1->set_queue_size(8); |
| 1163 | discard_config_1->set_allocated_tail_drop_discard_config(tail_drop_discard_config_1); |
| 1164 | traffic_queue_1->set_allocated_discard_config(discard_config_1); |
| 1165 | |
| 1166 | traffic_queues->set_uni_id(0); |
| 1167 | traffic_queues->set_port_no(16); |
| 1168 | |
| 1169 | traffic_queue_2 = traffic_queues->add_traffic_queues(); |
| 1170 | traffic_queue_2->set_gemport_id(1025); |
| 1171 | traffic_queue_2->set_pbit_map("0b00001010"); |
| 1172 | traffic_queue_2->set_aes_encryption(true); |
| 1173 | traffic_queue_2->set_sched_policy(tech_profile::SchedulingPolicy::StrictPriority); |
| 1174 | traffic_queue_2->set_priority(1); |
| 1175 | traffic_queue_2->set_weight(0); |
| 1176 | traffic_queue_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 1177 | discard_config_2 = new tech_profile::DiscardConfig; |
| 1178 | discard_config_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 1179 | tail_drop_discard_config_2 = new tech_profile::TailDropDiscardConfig; |
| 1180 | tail_drop_discard_config_2->set_queue_size(8); |
| 1181 | discard_config_2->set_allocated_tail_drop_discard_config(tail_drop_discard_config_2); |
| 1182 | traffic_queue_2->set_allocated_discard_config(discard_config_2); |
| 1183 | } |
| 1184 | |
| 1185 | virtual void TearDown() { |
| 1186 | } |
| 1187 | }; |
| 1188 | |
| 1189 | // Test 1 - FlowAdd - success case(HSIA-upstream FixedQueue) |
| 1190 | TEST_F(TestFlowAdd, FlowAddHsiaFixedQueueUpstreamSuccess) { |
| 1191 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1192 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1193 | |
| 1194 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1195 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1196 | } |
| 1197 | |
| 1198 | // Test 2 - FlowAdd - Duplicate Flow case |
| 1199 | TEST_F(TestFlowAdd, FlowAddHsiaFixedQueueUpstreamDuplicate) { |
| 1200 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1201 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1202 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1203 | |
| 1204 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1205 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1206 | } |
| 1207 | |
| 1208 | // Test 3 - FlowAdd - Failure case(bcmolt_cfg_set returns error) |
| 1209 | TEST_F(TestFlowAdd, FlowAddHsiaFixedQueueUpstreamFailure) { |
| 1210 | gemport_id = 1025; |
| 1211 | |
| 1212 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1213 | bcmos_errno olt_cfg_set_res = BCM_ERR_INTERNAL; |
| 1214 | |
| 1215 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1216 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1217 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1218 | |
| 1219 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1220 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1221 | } |
| 1222 | |
| 1223 | // Test 4 - FlowAdd - Failure case(Invalid flow direction) |
| 1224 | TEST_F(TestFlowAdd, FlowAddFailureInvalidFlowDirection) { |
| 1225 | flow_type = "bidirectional"; |
| 1226 | |
| 1227 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1228 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1229 | } |
| 1230 | |
| 1231 | // Test 5 - FlowAdd - Failure case(Invalid network setting) |
| 1232 | TEST_F(TestFlowAdd, FlowAddFailureInvalidNWCfg) { |
| 1233 | network_intf_id = -1; |
| 1234 | |
| 1235 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1236 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1237 | } |
| 1238 | |
| 1239 | // Test 6 - FlowAdd - Success case(Single tag & EAP Ether type) |
| 1240 | TEST_F(TestFlowAdd, FlowAddEapEtherTypeSuccess) { |
| 1241 | flow_id = 2; |
| 1242 | |
| 1243 | classifier->set_eth_type(34958); |
| 1244 | cmd->set_add_outer_tag(false); |
| 1245 | cmd->set_trap_to_host(true); |
| 1246 | action->set_allocated_cmd(cmd); |
| 1247 | |
| 1248 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1249 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1250 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1251 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1252 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1253 | |
| 1254 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1255 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1256 | } |
| 1257 | |
| 1258 | // Test 7 - FlowAdd - Success case(Single tag & DHCP flow) |
| 1259 | TEST_F(TestFlowAdd, FlowAddDhcpSuccess) { |
| 1260 | flow_id = 3; |
| 1261 | gemport_id = 1025; |
| 1262 | |
| 1263 | classifier->set_ip_proto(17); |
| 1264 | classifier->set_src_port(68); |
| 1265 | classifier->set_dst_port(67); |
| 1266 | cmd->set_add_outer_tag(false); |
| 1267 | cmd->set_trap_to_host(true); |
| 1268 | action->set_allocated_cmd(cmd); |
| 1269 | |
| 1270 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1271 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1272 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1273 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1274 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1275 | |
| 1276 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1277 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1278 | } |
| 1279 | |
| 1280 | // Test 8 - FlowAdd - success case(HSIA-downstream FixedQueue) |
| 1281 | TEST_F(TestFlowAdd, FlowAddHsiaFixedQueueDownstreamSuccess) { |
| 1282 | flow_id = 4; |
| 1283 | flow_type = "downstream"; |
| 1284 | |
| 1285 | classifier->set_o_vid(12); |
| 1286 | classifier->set_i_vid(7); |
| 1287 | classifier->set_pkt_tag_type("double_tag"); |
| 1288 | action->set_o_vid(0); |
| 1289 | cmd->set_add_outer_tag(false); |
| 1290 | cmd->set_remove_outer_tag(true); |
| 1291 | action->set_allocated_cmd(cmd); |
| 1292 | |
| 1293 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1294 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1295 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1296 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1297 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1298 | |
| 1299 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1300 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1301 | } |
| 1302 | |
| 1303 | // Test 9 - FlowAdd - success case(HSIA-upstream PriorityQueue) |
| 1304 | TEST_F(TestFlowAdd, FlowAddHsiaPriorityQueueUpstreamSuccess) { |
| 1305 | onu_id = 2; |
| 1306 | flow_id = 5; |
| 1307 | alloc_id = 1025; |
| 1308 | |
| 1309 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 1310 | traffic_queue_2->set_direction(tech_profile::Direction::UPSTREAM); |
| 1311 | |
| 1312 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1313 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1314 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1315 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1316 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1317 | CreateTrafficQueues_(traffic_queues); |
| 1318 | |
| 1319 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1320 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1321 | } |
| 1322 | |
| 1323 | // Test 10 - FlowAdd - success case(HSIA-downstream PriorityQueue) |
| 1324 | TEST_F(TestFlowAdd, FlowAddHsiaPriorityQueueDownstreamSuccess) { |
| 1325 | onu_id = 2; |
| 1326 | flow_id = 6; |
| 1327 | flow_type = "downstream"; |
| 1328 | alloc_id = 1025; |
| 1329 | |
| 1330 | classifier->set_o_vid(12); |
| 1331 | classifier->set_i_vid(7); |
| 1332 | classifier->set_pkt_tag_type("double_tag"); |
| 1333 | action->set_o_vid(0); |
| 1334 | cmd->set_add_outer_tag(false); |
| 1335 | cmd->set_remove_outer_tag(true); |
| 1336 | action->set_allocated_cmd(cmd); |
| 1337 | |
| 1338 | traffic_queue_1->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 1339 | traffic_queue_2->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 1340 | |
| 1341 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1342 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1343 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1344 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1345 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1346 | CreateTrafficQueues_(traffic_queues); |
| 1347 | |
| 1348 | Status status = FlowAdd_(access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type, alloc_id, network_intf_id, gemport_id, *classifier, *action, priority_value, cookie); |
| 1349 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1350 | } |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 1351 | #endif |
Thiyagarajan Subramani | 81c5611 | 2019-12-19 08:29:55 -0500 | [diff] [blame] | 1352 | |
| 1353 | //////////////////////////////////////////////////////////////////////////// |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 1354 | // For testing OnuPacketOut functionality |
| 1355 | //////////////////////////////////////////////////////////////////////////// |
| 1356 | |
| 1357 | class TestOnuPacketOut : public Test { |
| 1358 | protected: |
| 1359 | uint32_t pon_id = 0; |
| 1360 | uint32_t onu_id = 1; |
| 1361 | std::string pkt = "omci-pkt"; |
| 1362 | NiceMock<BalMocker> balMock; |
| 1363 | |
| 1364 | virtual void SetUp() { |
| 1365 | } |
| 1366 | |
| 1367 | virtual void TearDown() { |
| 1368 | } |
| 1369 | }; |
| 1370 | |
| 1371 | // Test 1 - OnuPacketOut success case |
| 1372 | TEST_F(TestOnuPacketOut, OnuPacketOutSuccess) { |
| 1373 | uint32_t port_no = 16; |
| 1374 | uint32_t gemport_id = 1024; |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 1375 | |
Thiyagarajan Subramani | 81c5611 | 2019-12-19 08:29:55 -0500 | [diff] [blame] | 1376 | bcmos_errno onu_oper_sub_res = BCM_ERR_OK; |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 1377 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(onu_oper_sub_res)); |
| 1378 | |
| 1379 | Status status = OnuPacketOut_(pon_id, onu_id, port_no, gemport_id, pkt); |
| 1380 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1381 | } |
| 1382 | |
| 1383 | // Test 2 - OnuPacketOut Port number as 0 case |
| 1384 | TEST_F(TestOnuPacketOut, OnuPacketOutPortNo0) { |
| 1385 | uint32_t port_no = 0; |
| 1386 | uint32_t gemport_id = 1024; |
| 1387 | |
| 1388 | Status status = OnuPacketOut_(pon_id, onu_id, port_no, gemport_id, pkt); |
| 1389 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1390 | } |
| 1391 | |
Thiyagarajan Subramani | 81c5611 | 2019-12-19 08:29:55 -0500 | [diff] [blame] | 1392 | // Test 3 - OnuPacketOut success, Finding Flow ID from port no and Gem from Flow ID case |
| 1393 | TEST_F(TestOnuPacketOut, OnuPacketOutFindGemFromFlowSuccess) { |
| 1394 | uint32_t port_no = 16; |
| 1395 | uint32_t gemport_id = 0; |
| 1396 | |
| 1397 | bcmos_errno onu_oper_sub_res = BCM_ERR_OK; |
| 1398 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(onu_oper_sub_res)); |
| 1399 | |
| 1400 | Status status = OnuPacketOut_(pon_id, onu_id, port_no, gemport_id, pkt); |
| 1401 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1402 | } |
| 1403 | |
| 1404 | // Test 4 - OnuPacketOut success, Failure in finding Gem port case |
| 1405 | TEST_F(TestOnuPacketOut, OnuPacketOutFindGemFromFlowFailure) { |
| 1406 | uint32_t port_no = 64; |
| 1407 | uint32_t gemport_id = 0; |
| 1408 | |
| 1409 | bcmos_errno onu_oper_sub_res = BCM_ERR_OK; |
| 1410 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(onu_oper_sub_res)); |
| 1411 | |
| 1412 | Status status = OnuPacketOut_(pon_id, onu_id, port_no, gemport_id, pkt); |
| 1413 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1414 | } |
| 1415 | |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 1416 | #if 0 |
Thiyagarajan Subramani | 81c5611 | 2019-12-19 08:29:55 -0500 | [diff] [blame] | 1417 | //////////////////////////////////////////////////////////////////////////// |
| 1418 | // For testing FlowRemove functionality |
| 1419 | //////////////////////////////////////////////////////////////////////////// |
| 1420 | |
| 1421 | class TestFlowRemove : public Test { |
| 1422 | protected: |
| 1423 | NiceMock<BalMocker> balMock; |
| 1424 | |
| 1425 | virtual void SetUp() { |
| 1426 | } |
| 1427 | |
| 1428 | virtual void TearDown() { |
| 1429 | } |
| 1430 | }; |
| 1431 | |
| 1432 | // Test 1 - FlowRemove - Failure case |
| 1433 | TEST_F(TestFlowRemove, FlowRemoveFailure) { |
| 1434 | bcmos_errno olt_cfg_clear_res = BCM_ERR_INTERNAL; |
| 1435 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 1436 | |
| 1437 | Status status = FlowRemove_(1, "upstream"); |
| 1438 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1439 | } |
| 1440 | |
| 1441 | // Test 2 - FlowRemove - success case |
| 1442 | TEST_F(TestFlowRemove, FlowRemoveSuccess) { |
| 1443 | bcmos_errno olt_cfg_clear_res = BCM_ERR_OK; |
| 1444 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 1445 | |
| 1446 | Status status = FlowRemove_(1, "upstream"); |
| 1447 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1448 | } |
| 1449 | |
| 1450 | //////////////////////////////////////////////////////////////////////////// |
| 1451 | // For testing UplinkPacketOut functionality |
| 1452 | //////////////////////////////////////////////////////////////////////////// |
| 1453 | |
| 1454 | class TestUplinkPacketOut : public Test { |
| 1455 | protected: |
| 1456 | uint32_t pon_id = 0; |
| 1457 | std::string pkt = "omci-pkt"; |
| 1458 | NiceMock<BalMocker> balMock; |
| 1459 | |
| 1460 | bcmolt_flow_key flow_key; |
| 1461 | bcmolt_flow_cfg flow_cfg; |
| 1462 | |
| 1463 | virtual void SetUp() { |
| 1464 | flow_key.flow_id = 1; |
| 1465 | flow_key.flow_type = BCMOLT_FLOW_TYPE_UPSTREAM; |
| 1466 | BCMOLT_CFG_INIT(&flow_cfg, flow, flow_key); |
| 1467 | flow_cfg.data.onu_id=1; |
| 1468 | flow_cfg.key.flow_type = BCMOLT_FLOW_TYPE_UPSTREAM; |
| 1469 | flow_cfg.data.svc_port_id=1024; |
| 1470 | flow_cfg.data.priority=0; |
| 1471 | flow_cfg.data.cookie=0; |
| 1472 | flow_cfg.data.ingress_intf.intf_type=BCMOLT_FLOW_INTERFACE_TYPE_PON; |
| 1473 | flow_cfg.data.egress_intf.intf_type=BCMOLT_FLOW_INTERFACE_TYPE_NNI; |
| 1474 | flow_cfg.data.ingress_intf.intf_id=0; |
| 1475 | flow_cfg.data.egress_intf.intf_id=0; |
| 1476 | flow_cfg.data.classifier.o_vid=7; |
| 1477 | flow_cfg.data.classifier.o_pbits=0; |
| 1478 | flow_cfg.data.classifier.i_vid=0; |
| 1479 | flow_cfg.data.classifier.i_pbits=0; |
| 1480 | flow_cfg.data.classifier.ether_type=0; |
| 1481 | flow_cfg.data.classifier.ip_proto=0; |
| 1482 | flow_cfg.data.classifier.src_port=0; |
| 1483 | flow_cfg.data.classifier.dst_port=0; |
| 1484 | flow_cfg.data.classifier.pkt_tag_type=BCMOLT_PKT_TAG_TYPE_SINGLE_TAG; |
| 1485 | flow_cfg.data.egress_qos.type=BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE; |
| 1486 | flow_cfg.data.egress_qos.u.fixed_queue.queue_id=0; |
| 1487 | flow_cfg.data.egress_qos.tm_sched.id=1020; |
| 1488 | flow_cfg.data.action.cmds_bitmask=BCMOLT_ACTION_CMD_ID_ADD_OUTER_TAG; |
| 1489 | flow_cfg.data.action.o_vid=12; |
| 1490 | flow_cfg.data.action.o_pbits=0; |
| 1491 | flow_cfg.data.action.i_vid=0; |
| 1492 | flow_cfg.data.action.i_pbits=0; |
| 1493 | flow_cfg.data.state=BCMOLT_FLOW_STATE_ENABLE; |
| 1494 | } |
| 1495 | |
| 1496 | virtual void TearDown() { |
| 1497 | } |
| 1498 | }; |
| 1499 | |
| 1500 | // Test 1 - UplinkPacketOut success case |
| 1501 | TEST_F(TestUplinkPacketOut, UplinkPacketOutSuccess) { |
| 1502 | bcmos_errno send_eth_oper_sub_res = BCM_ERR_OK; |
| 1503 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(send_eth_oper_sub_res)); |
| 1504 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1505 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1506 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1507 | |
| 1508 | Status status = UplinkPacketOut_(pon_id, pkt); |
| 1509 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1510 | } |
| 1511 | |
| 1512 | // Test 2 - UplinkPacketOut Failure case |
| 1513 | TEST_F(TestUplinkPacketOut, UplinkPacketOutFailure) { |
| 1514 | bcmos_errno send_eth_oper_sub_res = BCM_ERR_INTERNAL; |
| 1515 | ON_CALL(balMock, bcmolt_oper_submit(_, _)).WillByDefault(Return(send_eth_oper_sub_res)); |
| 1516 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1517 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1518 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1519 | |
| 1520 | Status status = UplinkPacketOut_(pon_id, pkt); |
| 1521 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1522 | } |
| 1523 | |
| 1524 | // Test 3 - UplinkPacketOut No matching flow id found for Uplink Packetout case |
| 1525 | TEST_F(TestUplinkPacketOut, UplinkPacketOutFailureNoFlowIdFound) { |
| 1526 | flow_cfg.key.flow_type = BCMOLT_FLOW_TYPE_DOWNSTREAM; |
| 1527 | |
| 1528 | FlowRemove_(2, "upstream"); |
| 1529 | FlowRemove_(3, "upstream"); |
| 1530 | FlowRemove_(4, "downstream"); |
| 1531 | FlowRemove_(5, "upstream"); |
| 1532 | FlowRemove_(6, "downstream"); |
| 1533 | |
| 1534 | bcmos_errno flow_cfg_get_stub_res = BCM_ERR_OK; |
| 1535 | EXPECT_GLOBAL_CALL(bcmolt_cfg_get__flow_stub, bcmolt_cfg_get__flow_stub(_, _)) |
| 1536 | .WillRepeatedly(DoAll(SetArg1ToBcmOltFlowCfg(flow_cfg), Return(flow_cfg_get_stub_res))); |
| 1537 | |
| 1538 | Status status = UplinkPacketOut_(pon_id, pkt); |
| 1539 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1540 | } |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 1541 | #endif |
Thiyagarajan Subramani | 81c5611 | 2019-12-19 08:29:55 -0500 | [diff] [blame] | 1542 | |
Thiyagarajan Subramani | 6dc2005 | 2019-12-05 09:06:36 -0500 | [diff] [blame] | 1543 | //////////////////////////////////////////////////////////////////////////// |
| 1544 | // For testing CreateTrafficSchedulers functionality |
| 1545 | //////////////////////////////////////////////////////////////////////////// |
| 1546 | |
| 1547 | class TestCreateTrafficSchedulers : public Test { |
| 1548 | protected: |
| 1549 | NiceMock<BalMocker> balMock; |
| 1550 | tech_profile::TrafficSchedulers* traffic_scheds; |
| 1551 | tech_profile::TrafficScheduler* traffic_sched; |
| 1552 | tech_profile::SchedulerConfig* scheduler; |
| 1553 | tech_profile::TrafficShapingInfo* traffic_shaping_info; |
| 1554 | |
| 1555 | virtual void SetUp() { |
| 1556 | traffic_scheds = new tech_profile::TrafficSchedulers; |
| 1557 | traffic_scheds->set_intf_id(0); |
| 1558 | traffic_scheds->set_onu_id(1); |
| 1559 | traffic_scheds->set_uni_id(0); |
| 1560 | traffic_scheds->set_port_no(16); |
| 1561 | traffic_sched = traffic_scheds->add_traffic_scheds(); |
| 1562 | traffic_sched->set_alloc_id(1024); |
| 1563 | scheduler = new tech_profile::SchedulerConfig; |
| 1564 | scheduler->set_priority(0); |
| 1565 | scheduler->set_weight(0); |
| 1566 | scheduler->set_sched_policy(tech_profile::SchedulingPolicy::StrictPriority); |
| 1567 | traffic_shaping_info = new tech_profile::TrafficShapingInfo; |
| 1568 | traffic_shaping_info->set_cbs(60536); |
| 1569 | traffic_shaping_info->set_pbs(65536); |
| 1570 | traffic_shaping_info->set_gir(10000); |
| 1571 | } |
| 1572 | |
| 1573 | virtual void TearDown() { |
| 1574 | } |
| 1575 | |
| 1576 | public: |
| 1577 | static void PushAllocCfgResult(AllocObjectState state, AllocCfgStatus status) { |
| 1578 | if(ALLOC_CFG_FLAG) { |
| 1579 | alloc_cfg_compltd_key k(0, 1024); |
| 1580 | alloc_cfg_complete_result res; |
| 1581 | res.pon_intf_id = 0; |
| 1582 | res.alloc_id = 1024; |
| 1583 | res.state = state; |
| 1584 | res.status = status; |
| 1585 | |
| 1586 | bcmos_fastlock_lock(&alloc_cfg_wait_lock); |
| 1587 | std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(k); |
| 1588 | if (it == alloc_cfg_compltd_map.end()) { |
| 1589 | OPENOLT_LOG(ERROR, openolt_log_id, "alloc config key not found for alloc_id = %u, pon_intf = %u\n", 1024, 0); |
| 1590 | } else { |
| 1591 | it->second->push(res); |
| 1592 | OPENOLT_LOG(INFO, openolt_log_id, "Pushed mocked alloc cfg result\n"); |
| 1593 | } |
| 1594 | bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0); |
| 1595 | } else { |
| 1596 | PushAllocCfgResult(state, status); |
| 1597 | } |
| 1598 | } |
| 1599 | }; |
| 1600 | |
| 1601 | // Test 1 - CreateTrafficSchedulers-Upstream success case |
| 1602 | TEST_F(TestCreateTrafficSchedulers, CreateTrafficSchedulersUpstreamSuccess) { |
| 1603 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1604 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1605 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1606 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1607 | traffic_shaping_info->set_cir(64000); |
| 1608 | traffic_shaping_info->set_pir(128000); |
| 1609 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1610 | |
| 1611 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1612 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1613 | |
| 1614 | future<Status> future_res = async(launch::async, CreateTrafficSchedulers_, traffic_scheds); |
| 1615 | async(launch::async, TestCreateTrafficSchedulers::PushAllocCfgResult, ALLOC_OBJECT_STATE_ACTIVE, ALLOC_CFG_STATUS_SUCCESS); |
| 1616 | |
| 1617 | Status status = future_res.get(); |
| 1618 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1619 | } |
| 1620 | |
| 1621 | // Test 2 - CreateTrafficSchedulers-Upstream failure case(timeout waiting for alloc cfg indication) |
| 1622 | TEST_F(TestCreateTrafficSchedulers, UpstreamAllocCfgTimeout) { |
| 1623 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1624 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1625 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1626 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1627 | traffic_shaping_info->set_cir(64000); |
| 1628 | traffic_shaping_info->set_pir(128000); |
| 1629 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1630 | |
| 1631 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1632 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1633 | |
| 1634 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1635 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1636 | } |
| 1637 | |
| 1638 | // Test 3 - CreateTrafficSchedulers-Upstream failure case(error processing alloc cfg request) |
| 1639 | TEST_F(TestCreateTrafficSchedulers, UpstreamErrorProcessingAllocCfg) { |
| 1640 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1641 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1642 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1643 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1644 | traffic_shaping_info->set_cir(64000); |
| 1645 | traffic_shaping_info->set_pir(128000); |
| 1646 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1647 | |
| 1648 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1649 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1650 | |
| 1651 | future<Status> future_res = async(launch::async, CreateTrafficSchedulers_, traffic_scheds); |
| 1652 | async(launch::async, TestCreateTrafficSchedulers::PushAllocCfgResult, ALLOC_OBJECT_STATE_ACTIVE, ALLOC_CFG_STATUS_FAIL); |
| 1653 | |
| 1654 | Status status = future_res.get(); |
| 1655 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1656 | } |
| 1657 | |
| 1658 | // Test 4 - CreateTrafficSchedulers-Upstream failure case(alloc object not in active state) |
| 1659 | TEST_F(TestCreateTrafficSchedulers, UpstreamAllocObjNotinActiveState) { |
| 1660 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1661 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1662 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1663 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1664 | traffic_shaping_info->set_cir(64000); |
| 1665 | traffic_shaping_info->set_pir(128000); |
| 1666 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1667 | |
| 1668 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1669 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1670 | |
| 1671 | future<Status> future_res = async(launch::async, CreateTrafficSchedulers_, traffic_scheds); |
| 1672 | async(launch::async, TestCreateTrafficSchedulers::PushAllocCfgResult, ALLOC_OBJECT_STATE_INACTIVE, ALLOC_CFG_STATUS_SUCCESS); |
| 1673 | |
| 1674 | Status status = future_res.get(); |
| 1675 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1676 | } |
| 1677 | |
| 1678 | // Test 5 - CreateTrafficSchedulers-Upstream Failure case |
| 1679 | TEST_F(TestCreateTrafficSchedulers, CreateTrafficSchedulersUpstreamFailure) { |
| 1680 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1681 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1682 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1683 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1684 | traffic_shaping_info->set_cir(64000); |
| 1685 | traffic_shaping_info->set_pir(128000); |
| 1686 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1687 | |
| 1688 | bcmos_errno olt_cfg_set_res = BCM_ERR_INTERNAL; |
| 1689 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1690 | |
| 1691 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1692 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1693 | } |
| 1694 | |
| 1695 | // Test 6 - CreateTrafficSchedulers-Upstream Failure (AdditionalBW_BestEffort-Max BW set to 0) case |
| 1696 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_BestEffortMaxBWZeroFailure) { |
| 1697 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1698 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1699 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1700 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1701 | traffic_shaping_info->set_cir(64000); |
| 1702 | traffic_shaping_info->set_pir(0); |
| 1703 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1704 | |
| 1705 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1706 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1707 | } |
| 1708 | |
| 1709 | // Test 7 - CreateTrafficSchedulers-Upstream Failure (AdditionalBW_BestEffort-Max BW < Guaranteed BW) case |
| 1710 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_BestEffortMaxBWLtGuaranteedBwFailure) { |
| 1711 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1712 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1713 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1714 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1715 | traffic_shaping_info->set_cir(64000); |
| 1716 | traffic_shaping_info->set_pir(32000); |
| 1717 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1718 | |
| 1719 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1720 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1721 | } |
| 1722 | |
| 1723 | // Test 8 - CreateTrafficSchedulers-Upstream Failure (AdditionalBW_BestEffort-Max BW = Guaranteed BW) case |
| 1724 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_BestEffortMaxBWEqGuaranteedBwFailure) { |
| 1725 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1726 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1727 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1728 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1729 | traffic_shaping_info->set_cir(64000); |
| 1730 | traffic_shaping_info->set_pir(64000); |
| 1731 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1732 | |
| 1733 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1734 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1735 | } |
| 1736 | |
| 1737 | // Test 9 - CreateTrafficSchedulers-Upstream Failure (AdditionalBW_NA-Max BW set to 0) case |
| 1738 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_NAMaxBWZeroFailure) { |
| 1739 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1740 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_NA); |
| 1741 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1742 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1743 | traffic_shaping_info->set_cir(64000); |
| 1744 | traffic_shaping_info->set_pir(0); |
| 1745 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1746 | |
| 1747 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1748 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1749 | } |
| 1750 | |
| 1751 | // Test 10 - CreateTrafficSchedulers-Upstream Failure (AdditionalBW_NA-Guaranteed BW set to 0) case |
| 1752 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_NAGuaranteedBwZeroFailure) { |
| 1753 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1754 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_NA); |
| 1755 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1756 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1757 | traffic_shaping_info->set_cir(0); |
| 1758 | traffic_shaping_info->set_pir(32000); |
| 1759 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1760 | |
| 1761 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1762 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1763 | } |
| 1764 | |
| 1765 | // Test 11 - CreateTrafficSchedulers-Upstream Failure (AdditionalBW_NA-Max BW < Guaranteed BW) case |
| 1766 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_NAMaxBWLtGuaranteedBwFailure) { |
| 1767 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1768 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_NA); |
| 1769 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1770 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1771 | traffic_shaping_info->set_cir(64000); |
| 1772 | traffic_shaping_info->set_pir(32000); |
| 1773 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1774 | |
| 1775 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1776 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1777 | } |
| 1778 | |
| 1779 | // Test 12 - CreateTrafficSchedulers-Upstream Failure (AdditionalBW_NA-Max BW = Guaranteed BW) case |
| 1780 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_NAMaxBWEqGuaranteedBwFailure) { |
| 1781 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1782 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_NA); |
| 1783 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1784 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1785 | traffic_shaping_info->set_cir(64000); |
| 1786 | traffic_shaping_info->set_pir(64000); |
| 1787 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1788 | |
| 1789 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1790 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1791 | } |
| 1792 | |
| 1793 | // Test 13 - CreateTrafficSchedulers-Upstream Failure (AdditionalBW_None-Max BW set to 0) case |
| 1794 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_NoneMaxBWZeroFailure) { |
| 1795 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1796 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_None); |
| 1797 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1798 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1799 | traffic_shaping_info->set_cir(64000); |
| 1800 | traffic_shaping_info->set_pir(0); |
| 1801 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1802 | |
| 1803 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1804 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1805 | } |
| 1806 | |
| 1807 | // Test 14 - CreateTrafficSchedulers-Upstream Failure (AdditionalBW_None-Guaranteed BW set to 0) case |
| 1808 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_NoneGuaranteedBwZeroFailure) { |
| 1809 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1810 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_None); |
| 1811 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1812 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1813 | traffic_shaping_info->set_cir(0); |
| 1814 | traffic_shaping_info->set_pir(32000); |
| 1815 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1816 | |
| 1817 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1818 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1819 | } |
| 1820 | |
| 1821 | // Test 15 - CreateTrafficSchedulers-Upstream Success (AdditionalBW_None-Max BW > Guaranteed BW) case |
| 1822 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_NoneMaxBWGtGuaranteedBwSuccess) { |
| 1823 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1824 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_None); |
| 1825 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1826 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1827 | traffic_shaping_info->set_cir(64000); |
| 1828 | traffic_shaping_info->set_pir(128000); |
| 1829 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1830 | |
| 1831 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1832 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1833 | |
| 1834 | future<Status> future_res = async(launch::async, CreateTrafficSchedulers_, traffic_scheds); |
| 1835 | async(launch::async, TestCreateTrafficSchedulers::PushAllocCfgResult, ALLOC_OBJECT_STATE_ACTIVE, ALLOC_CFG_STATUS_SUCCESS); |
| 1836 | |
| 1837 | Status status = future_res.get(); |
| 1838 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1839 | } |
| 1840 | |
| 1841 | // Test 16 - CreateTrafficSchedulers-Upstream Success (AdditionalBW_None-Max BW < Guaranteed BW) case |
| 1842 | TEST_F(TestCreateTrafficSchedulers, AdditionalBW_NoneMaxBWLtGuaranteedBwSuccess) { |
| 1843 | scheduler->set_direction(tech_profile::Direction::UPSTREAM); |
| 1844 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_None); |
| 1845 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1846 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1847 | traffic_shaping_info->set_cir(64000); |
| 1848 | traffic_shaping_info->set_pir(32000); |
| 1849 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1850 | |
| 1851 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1852 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1853 | |
| 1854 | future<Status> future_res = async(launch::async, CreateTrafficSchedulers_, traffic_scheds); |
| 1855 | async(launch::async, TestCreateTrafficSchedulers::PushAllocCfgResult, ALLOC_OBJECT_STATE_ACTIVE, ALLOC_CFG_STATUS_SUCCESS); |
| 1856 | |
| 1857 | Status status = future_res.get(); |
| 1858 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1859 | } |
| 1860 | |
| 1861 | // Test 17 - CreateTrafficSchedulers-Downstream success case |
| 1862 | TEST_F(TestCreateTrafficSchedulers, CreateTrafficSchedulersDownstreamSuccess) { |
| 1863 | scheduler->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 1864 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1865 | traffic_sched->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 1866 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1867 | traffic_shaping_info->set_cir(64000); |
| 1868 | traffic_shaping_info->set_pir(128000); |
| 1869 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1870 | |
| 1871 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1872 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1873 | |
| 1874 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1875 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1876 | } |
| 1877 | |
| 1878 | // Test 18 - CreateTrafficSchedulers-Downstream Failure case |
| 1879 | TEST_F(TestCreateTrafficSchedulers, CreateTrafficSchedulersDownstreamFailure) { |
| 1880 | scheduler->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 1881 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1882 | traffic_sched->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 1883 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1884 | traffic_shaping_info->set_cir(64000); |
| 1885 | traffic_shaping_info->set_pir(128000); |
| 1886 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1887 | |
| 1888 | bcmos_errno olt_cfg_set_res = BCM_ERR_INTERNAL; |
| 1889 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1890 | |
| 1891 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1892 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1893 | } |
| 1894 | |
| 1895 | // Test 19 - CreateTrafficSchedulers-Invalid direction Failure case |
| 1896 | TEST_F(TestCreateTrafficSchedulers, CreateTrafficSchedulersInvalidDirectionFailure) { |
| 1897 | scheduler->set_direction(tech_profile::Direction::BIDIRECTIONAL); |
| 1898 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1899 | traffic_sched->set_direction(tech_profile::Direction::BIDIRECTIONAL); |
| 1900 | traffic_sched->set_allocated_scheduler(scheduler); |
| 1901 | traffic_shaping_info->set_cir(64000); |
| 1902 | traffic_shaping_info->set_pir(128000); |
| 1903 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1904 | |
| 1905 | Status status = CreateTrafficSchedulers_(traffic_scheds); |
| 1906 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1907 | } |
| 1908 | |
| 1909 | //////////////////////////////////////////////////////////////////////////// |
| 1910 | // For testing RemoveTrafficSchedulers functionality |
| 1911 | //////////////////////////////////////////////////////////////////////////// |
| 1912 | |
| 1913 | class TestRemoveTrafficSchedulers : public Test { |
| 1914 | protected: |
| 1915 | NiceMock<BalMocker> balMock; |
| 1916 | tech_profile::TrafficSchedulers* traffic_scheds; |
| 1917 | tech_profile::TrafficScheduler* traffic_sched; |
| 1918 | tech_profile::SchedulerConfig* scheduler; |
| 1919 | tech_profile::TrafficShapingInfo* traffic_shaping_info; |
| 1920 | alloc_cfg_complete_result res; |
| 1921 | |
| 1922 | virtual void SetUp() { |
| 1923 | traffic_scheds = new tech_profile::TrafficSchedulers; |
| 1924 | traffic_scheds->set_intf_id(0); |
| 1925 | traffic_scheds->set_onu_id(1); |
| 1926 | traffic_scheds->set_uni_id(0); |
| 1927 | traffic_scheds->set_port_no(16); |
| 1928 | traffic_sched = traffic_scheds->add_traffic_scheds(); |
| 1929 | traffic_sched->set_alloc_id(1025); |
| 1930 | scheduler = new tech_profile::SchedulerConfig; |
| 1931 | scheduler->set_priority(0); |
| 1932 | scheduler->set_weight(0); |
| 1933 | scheduler->set_sched_policy(tech_profile::SchedulingPolicy::StrictPriority); |
| 1934 | scheduler->set_additional_bw(tech_profile::AdditionalBW::AdditionalBW_BestEffort); |
| 1935 | traffic_shaping_info = new tech_profile::TrafficShapingInfo; |
| 1936 | traffic_shaping_info->set_cir(64000); |
| 1937 | traffic_shaping_info->set_pir(128000); |
| 1938 | traffic_shaping_info->set_cbs(60536); |
| 1939 | traffic_shaping_info->set_pbs(65536); |
| 1940 | traffic_shaping_info->set_gir(10000); |
| 1941 | traffic_sched->set_allocated_traffic_shaping_info(traffic_shaping_info); |
| 1942 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 1943 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 1944 | } |
| 1945 | |
| 1946 | virtual void TearDown() { |
| 1947 | } |
| 1948 | |
| 1949 | public: |
| 1950 | static void PushAllocCfgResult(AllocObjectState state, AllocCfgStatus status) { |
| 1951 | if(ALLOC_CFG_FLAG) { |
| 1952 | alloc_cfg_compltd_key k(0, 1025); |
| 1953 | alloc_cfg_complete_result res; |
| 1954 | res.pon_intf_id = 0; |
| 1955 | res.alloc_id = 1025; |
| 1956 | res.state = state; |
| 1957 | res.status = status; |
| 1958 | |
| 1959 | bcmos_fastlock_lock(&alloc_cfg_wait_lock); |
| 1960 | std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(k); |
| 1961 | if (it == alloc_cfg_compltd_map.end()) { |
| 1962 | OPENOLT_LOG(ERROR, openolt_log_id, "alloc config key not found for alloc_id = %u, pon_intf = %u\n", 1025, 0); |
| 1963 | } else { |
| 1964 | it->second->push(res); |
| 1965 | OPENOLT_LOG(INFO, openolt_log_id, "Pushed mocked alloc cfg result\n"); |
| 1966 | } |
| 1967 | bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0); |
| 1968 | } else { |
| 1969 | PushAllocCfgResult(state, status); |
| 1970 | } |
| 1971 | } |
| 1972 | }; |
| 1973 | |
| 1974 | // Test 1 - RemoveTrafficSchedulers-Upstream success case |
| 1975 | TEST_F(TestRemoveTrafficSchedulers, RemoveTrafficSchedulersUpstreamSuccess) { |
| 1976 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1977 | bcmos_errno olt_cfg_clear_res = BCM_ERR_OK; |
| 1978 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 1979 | |
| 1980 | future<Status> future_res = async(launch::async, RemoveTrafficSchedulers_, traffic_scheds); |
| 1981 | async(launch::async, TestRemoveTrafficSchedulers::PushAllocCfgResult, ALLOC_OBJECT_STATE_NOT_CONFIGURED, ALLOC_CFG_STATUS_SUCCESS); |
| 1982 | |
| 1983 | Status status = future_res.get(); |
| 1984 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 1985 | } |
| 1986 | |
| 1987 | // Test 2 - RemoveTrafficSchedulers-Upstream success case(alloc object is not reset) |
| 1988 | TEST_F(TestRemoveTrafficSchedulers, UpstreamAllocObjNotReset) { |
| 1989 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 1990 | bcmos_errno olt_cfg_clear_res = BCM_ERR_OK; |
| 1991 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 1992 | |
| 1993 | future<Status> future_res = async(launch::async, RemoveTrafficSchedulers_, traffic_scheds); |
| 1994 | async(launch::async, TestRemoveTrafficSchedulers::PushAllocCfgResult, ALLOC_OBJECT_STATE_INACTIVE, ALLOC_CFG_STATUS_SUCCESS); |
| 1995 | |
| 1996 | Status status = future_res.get(); |
| 1997 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 1998 | } |
| 1999 | |
| 2000 | // Test 3 - RemoveTrafficSchedulers-Upstream Failure case |
| 2001 | TEST_F(TestRemoveTrafficSchedulers, RemoveTrafficSchedulersUpstreamFailure) { |
| 2002 | traffic_sched->set_direction(tech_profile::Direction::UPSTREAM); |
| 2003 | |
| 2004 | bcmos_errno olt_cfg_clear_res = BCM_ERR_INTERNAL; |
| 2005 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 2006 | |
| 2007 | Status status = RemoveTrafficSchedulers_(traffic_scheds); |
| 2008 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 2009 | } |
| 2010 | |
| 2011 | // Test 4 - RemoveTrafficSchedulers-Downstream Failure case |
| 2012 | TEST_F(TestRemoveTrafficSchedulers, RemoveTrafficSchedulersDownstreamFailure) { |
| 2013 | //Create Scheduler |
| 2014 | scheduler->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2015 | traffic_sched->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2016 | traffic_sched->set_allocated_scheduler(scheduler); |
| 2017 | CreateTrafficSchedulers_(traffic_scheds); |
| 2018 | |
| 2019 | bcmos_errno olt_cfg_clear_res = BCM_ERR_INTERNAL; |
| 2020 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 2021 | |
| 2022 | Status status = RemoveTrafficSchedulers_(traffic_scheds); |
| 2023 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 2024 | } |
| 2025 | |
| 2026 | // Test 5 - RemoveTrafficSchedulers-Downstream success case |
| 2027 | TEST_F(TestRemoveTrafficSchedulers, RemoveTrafficSchedulersDownstreamSuccess) { |
| 2028 | //Create Scheduler |
| 2029 | scheduler->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2030 | traffic_sched->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2031 | traffic_sched->set_allocated_scheduler(scheduler); |
| 2032 | CreateTrafficSchedulers_(traffic_scheds); |
| 2033 | |
| 2034 | bcmos_errno olt_cfg_clear_res = BCM_ERR_OK; |
| 2035 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 2036 | |
| 2037 | Status status = RemoveTrafficSchedulers_(traffic_scheds); |
| 2038 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2039 | } |
| 2040 | |
| 2041 | // Test 6 - RemoveTrafficSchedulers-Downstream Scheduler not present case |
| 2042 | TEST_F(TestRemoveTrafficSchedulers, RemoveTrafficSchedulersDownstreamSchedNotpresent) { |
| 2043 | traffic_sched->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2044 | |
| 2045 | Status status = RemoveTrafficSchedulers_(traffic_scheds); |
| 2046 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2047 | } |
| 2048 | |
| 2049 | //////////////////////////////////////////////////////////////////////////// |
| 2050 | // For testing CreateTrafficQueues functionality |
| 2051 | //////////////////////////////////////////////////////////////////////////// |
| 2052 | |
| 2053 | class TestCreateTrafficQueues : public Test { |
| 2054 | protected: |
| 2055 | NiceMock<BalMocker> balMock; |
| 2056 | tech_profile::TrafficQueues* traffic_queues; |
| 2057 | tech_profile::TrafficQueue* traffic_queue_1; |
| 2058 | tech_profile::TrafficQueue* traffic_queue_2; |
| 2059 | tech_profile::DiscardConfig* discard_config_1; |
| 2060 | tech_profile::DiscardConfig* discard_config_2; |
| 2061 | tech_profile::TailDropDiscardConfig* tail_drop_discard_config_1; |
| 2062 | tech_profile::TailDropDiscardConfig* tail_drop_discard_config_2; |
| 2063 | |
| 2064 | virtual void SetUp() { |
| 2065 | traffic_queues = new tech_profile::TrafficQueues; |
| 2066 | traffic_queues->set_intf_id(0); |
| 2067 | traffic_queues->set_onu_id(1); |
| 2068 | traffic_queue_1 = traffic_queues->add_traffic_queues(); |
| 2069 | traffic_queue_1->set_gemport_id(1024); |
| 2070 | traffic_queue_1->set_pbit_map("0b00000101"); |
| 2071 | traffic_queue_1->set_aes_encryption(true); |
| 2072 | traffic_queue_1->set_sched_policy(tech_profile::SchedulingPolicy::StrictPriority); |
| 2073 | traffic_queue_1->set_priority(0); |
| 2074 | traffic_queue_1->set_weight(0); |
| 2075 | traffic_queue_1->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2076 | discard_config_1 = new tech_profile::DiscardConfig; |
| 2077 | discard_config_1->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2078 | tail_drop_discard_config_1 = new tech_profile::TailDropDiscardConfig; |
| 2079 | tail_drop_discard_config_1->set_queue_size(8); |
| 2080 | discard_config_1->set_allocated_tail_drop_discard_config(tail_drop_discard_config_1); |
| 2081 | traffic_queue_1->set_allocated_discard_config(discard_config_1); |
| 2082 | } |
| 2083 | |
| 2084 | virtual void TearDown() { |
| 2085 | } |
| 2086 | }; |
| 2087 | |
| 2088 | // Test 1 - CreateTrafficQueues-Upstream/Downstream FIXED_QUEUE success case |
| 2089 | TEST_F(TestCreateTrafficQueues, CreateUpstreamDownstreamFixedQueueSuccess) { |
| 2090 | Status status; |
| 2091 | traffic_queues->set_uni_id(0); |
| 2092 | traffic_queues->set_port_no(16); |
| 2093 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2094 | |
| 2095 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 2096 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 2097 | |
| 2098 | status = CreateTrafficQueues_(traffic_queues); |
| 2099 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2100 | |
| 2101 | traffic_queue_1->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2102 | status = CreateTrafficQueues_(traffic_queues); |
| 2103 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2104 | } |
| 2105 | |
| 2106 | // Test 2 - CreateTrafficQueues-Upstream PRIORITY_TO_QUEUE success case |
| 2107 | TEST_F(TestCreateTrafficQueues, CreateUpstreamPriorityQueueSuccess) { |
| 2108 | traffic_queues->set_uni_id(1); |
| 2109 | traffic_queues->set_port_no(32); |
| 2110 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2111 | |
| 2112 | traffic_queue_2 = traffic_queues->add_traffic_queues(); |
| 2113 | traffic_queue_2->set_gemport_id(1025); |
| 2114 | traffic_queue_2->set_pbit_map("0b00001010"); |
| 2115 | traffic_queue_2->set_aes_encryption(true); |
| 2116 | traffic_queue_2->set_sched_policy(tech_profile::SchedulingPolicy::StrictPriority); |
| 2117 | traffic_queue_2->set_priority(1); |
| 2118 | traffic_queue_2->set_weight(0); |
| 2119 | traffic_queue_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2120 | discard_config_2 = new tech_profile::DiscardConfig; |
| 2121 | discard_config_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2122 | tail_drop_discard_config_2 = new tech_profile::TailDropDiscardConfig; |
| 2123 | tail_drop_discard_config_2->set_queue_size(8); |
| 2124 | discard_config_2->set_allocated_tail_drop_discard_config(tail_drop_discard_config_2); |
| 2125 | traffic_queue_2->set_allocated_discard_config(discard_config_2); |
| 2126 | traffic_queue_2->set_direction(tech_profile::Direction::UPSTREAM); |
| 2127 | |
| 2128 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 2129 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 2130 | |
| 2131 | Status status = CreateTrafficQueues_(traffic_queues); |
| 2132 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2133 | } |
| 2134 | |
| 2135 | // Test 3 - CreateTrafficQueues-Upstream create tm queue mapping profile failure case |
| 2136 | TEST_F(TestCreateTrafficQueues, CreateUpstreamPriorityQueueTMQMPCreationFailure) { |
| 2137 | traffic_queues->set_uni_id(2); |
| 2138 | traffic_queues->set_port_no(16); |
| 2139 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2140 | |
| 2141 | traffic_queue_2 = traffic_queues->add_traffic_queues(); |
| 2142 | traffic_queue_2->set_gemport_id(1025); |
| 2143 | traffic_queue_2->set_pbit_map("0b10001010"); |
| 2144 | traffic_queue_2->set_aes_encryption(true); |
| 2145 | traffic_queue_2->set_sched_policy(tech_profile::SchedulingPolicy::StrictPriority); |
| 2146 | traffic_queue_2->set_priority(1); |
| 2147 | traffic_queue_2->set_weight(0); |
| 2148 | traffic_queue_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2149 | discard_config_2 = new tech_profile::DiscardConfig; |
| 2150 | discard_config_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2151 | tail_drop_discard_config_2 = new tech_profile::TailDropDiscardConfig; |
| 2152 | tail_drop_discard_config_2->set_queue_size(8); |
| 2153 | discard_config_2->set_allocated_tail_drop_discard_config(tail_drop_discard_config_2); |
| 2154 | traffic_queue_2->set_allocated_discard_config(discard_config_2); |
| 2155 | traffic_queue_2->set_direction(tech_profile::Direction::UPSTREAM); |
| 2156 | |
| 2157 | bcmos_errno olt_cfg_set_res = BCM_ERR_INTERNAL; |
| 2158 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 2159 | |
| 2160 | Status status = CreateTrafficQueues_(traffic_queues); |
| 2161 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 2162 | } |
| 2163 | |
| 2164 | // Test 4 - CreateTrafficQueues-Upstream PRIORITY_TO_QUEUE TM QMP already present case |
| 2165 | TEST_F(TestCreateTrafficQueues, CreateUpstreamPriorityQueueTMQMPAlreadyPresent) { |
| 2166 | traffic_queues->set_uni_id(3); |
| 2167 | traffic_queues->set_port_no(16); |
| 2168 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2169 | |
| 2170 | traffic_queue_2 = traffic_queues->add_traffic_queues(); |
| 2171 | traffic_queue_2->set_gemport_id(1025); |
| 2172 | traffic_queue_2->set_pbit_map("0b00001010"); |
| 2173 | traffic_queue_2->set_aes_encryption(true); |
| 2174 | traffic_queue_2->set_sched_policy(tech_profile::SchedulingPolicy::StrictPriority); |
| 2175 | traffic_queue_2->set_priority(1); |
| 2176 | traffic_queue_2->set_weight(0); |
| 2177 | traffic_queue_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2178 | discard_config_2 = new tech_profile::DiscardConfig; |
| 2179 | discard_config_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2180 | tail_drop_discard_config_2 = new tech_profile::TailDropDiscardConfig; |
| 2181 | tail_drop_discard_config_2->set_queue_size(8); |
| 2182 | discard_config_2->set_allocated_tail_drop_discard_config(tail_drop_discard_config_2); |
| 2183 | traffic_queue_2->set_allocated_discard_config(discard_config_2); |
| 2184 | traffic_queue_2->set_direction(tech_profile::Direction::UPSTREAM); |
| 2185 | |
| 2186 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 2187 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 2188 | |
| 2189 | Status status = CreateTrafficQueues_(traffic_queues); |
| 2190 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2191 | } |
| 2192 | |
| 2193 | // Test 5 - CreateTrafficQueues-Upstream PRIORITY_TO_QUEUE TM QMP Max count reached case |
| 2194 | TEST_F(TestCreateTrafficQueues, CreateUpstreamPriorityQueueReachedMaxTMQMPCount) { |
| 2195 | int uni_ids[17] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; |
| 2196 | int port_nos[17] = {16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272}; |
| 2197 | std::string pbit_maps[17] = {"0b00001010", "0b10001010", "0b00000001", "0b00000010", "0b00000100", "0b00001000", "0b00010000", "0b00100000", "0b01000000", "0b10000000", "0b10000001", "0b10000010", "0b10000100", "0b10001000", "0b10010000", "0b10100000", "0b11000000"}; |
| 2198 | |
| 2199 | traffic_queue_2 = traffic_queues->add_traffic_queues(); |
| 2200 | for(int i=0; i<sizeof(uni_ids)/sizeof(uni_ids[0]); i++) { |
| 2201 | traffic_queues->set_uni_id(uni_ids[i]); |
| 2202 | traffic_queues->set_port_no(port_nos[i]); |
| 2203 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2204 | |
| 2205 | traffic_queue_2->set_gemport_id(1025); |
| 2206 | traffic_queue_2->set_pbit_map(pbit_maps[i]); |
| 2207 | traffic_queue_2->set_aes_encryption(true); |
| 2208 | traffic_queue_2->set_sched_policy(tech_profile::SchedulingPolicy::StrictPriority); |
| 2209 | traffic_queue_2->set_priority(1); |
| 2210 | traffic_queue_2->set_weight(0); |
| 2211 | traffic_queue_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2212 | discard_config_2 = new tech_profile::DiscardConfig; |
| 2213 | discard_config_2->set_discard_policy(tech_profile::DiscardPolicy::TailDrop); |
| 2214 | tail_drop_discard_config_2 = new tech_profile::TailDropDiscardConfig; |
| 2215 | tail_drop_discard_config_2->set_queue_size(8); |
| 2216 | discard_config_2->set_allocated_tail_drop_discard_config(tail_drop_discard_config_2); |
| 2217 | traffic_queue_2->set_allocated_discard_config(discard_config_2); |
| 2218 | traffic_queue_2->set_direction(tech_profile::Direction::UPSTREAM); |
| 2219 | |
| 2220 | bcmos_errno olt_cfg_set_res = BCM_ERR_OK; |
| 2221 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 2222 | |
| 2223 | Status status = CreateTrafficQueues_(traffic_queues); |
| 2224 | if(i==16) |
| 2225 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 2226 | else |
| 2227 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2228 | } |
| 2229 | } |
| 2230 | |
| 2231 | // Test 6 - CreateTrafficQueues-Upstream FIXED_QUEUE failure case |
| 2232 | TEST_F(TestCreateTrafficQueues, CreateUpstreamFixedQueueFailure) { |
| 2233 | traffic_queues->set_uni_id(0); |
| 2234 | traffic_queues->set_port_no(16); |
| 2235 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2236 | |
| 2237 | bcmos_errno olt_cfg_set_res = BCM_ERR_INTERNAL; |
| 2238 | ON_CALL(balMock, bcmolt_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res)); |
| 2239 | |
| 2240 | Status status = CreateTrafficQueues_(traffic_queues); |
| 2241 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 2242 | } |
| 2243 | |
| 2244 | //////////////////////////////////////////////////////////////////////////// |
| 2245 | // For testing RemoveTrafficQueues functionality |
| 2246 | //////////////////////////////////////////////////////////////////////////// |
| 2247 | |
| 2248 | class TestRemoveTrafficQueues : public Test { |
| 2249 | protected: |
| 2250 | NiceMock<BalMocker> balMock; |
| 2251 | tech_profile::TrafficQueues* traffic_queues; |
| 2252 | tech_profile::TrafficQueue* traffic_queue_1; |
| 2253 | tech_profile::TrafficQueue* traffic_queue_2; |
| 2254 | |
| 2255 | virtual void SetUp() { |
| 2256 | traffic_queues = new tech_profile::TrafficQueues; |
| 2257 | traffic_queues->set_intf_id(0); |
| 2258 | traffic_queues->set_onu_id(1); |
| 2259 | traffic_queue_1 = traffic_queues->add_traffic_queues(); |
| 2260 | traffic_queue_1->set_gemport_id(1024); |
| 2261 | traffic_queue_1->set_priority(0); |
| 2262 | } |
| 2263 | |
| 2264 | virtual void TearDown() { |
| 2265 | } |
| 2266 | }; |
| 2267 | |
| 2268 | // Test 1 - RemoveTrafficQueues-Upstream/Downstream FIXED_QUEUE success case |
| 2269 | TEST_F(TestRemoveTrafficQueues, RemoveUpstreamDownstreamFixedQueueSuccess) { |
| 2270 | Status status; |
| 2271 | traffic_queues->set_uni_id(0); |
| 2272 | traffic_queues->set_port_no(16); |
| 2273 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2274 | |
| 2275 | bcmos_errno olt_cfg_clear_res = BCM_ERR_OK; |
| 2276 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 2277 | |
| 2278 | status = RemoveTrafficQueues_(traffic_queues); |
| 2279 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2280 | |
| 2281 | traffic_queue_1->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2282 | status = RemoveTrafficQueues_(traffic_queues); |
| 2283 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2284 | } |
| 2285 | |
| 2286 | // Test 2 - RemoveTrafficQueues-Downstream FIXED_QUEUE failure case |
| 2287 | TEST_F(TestRemoveTrafficQueues, RemoveUpstreamDownstreamFixedQueueFailure) { |
| 2288 | Status status; |
| 2289 | traffic_queues->set_uni_id(0); |
| 2290 | traffic_queues->set_port_no(16); |
| 2291 | traffic_queue_1->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2292 | |
| 2293 | bcmos_errno olt_cfg_clear_res = BCM_ERR_INTERNAL; |
| 2294 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 2295 | |
| 2296 | status = RemoveTrafficQueues_(traffic_queues); |
| 2297 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 2298 | } |
| 2299 | |
| 2300 | // Test 3 - RemoveTrafficQueues-Downstream_QUEUE not present case |
| 2301 | TEST_F(TestRemoveTrafficQueues, RemoveDownstreamFixedQueueNotPresent) { |
| 2302 | //Remove scheduler so that is_tm_sched_id_present api call will return false |
| 2303 | tech_profile::TrafficSchedulers* traffic_scheds; |
| 2304 | tech_profile::TrafficScheduler* traffic_sched; |
| 2305 | traffic_scheds = new tech_profile::TrafficSchedulers; |
| 2306 | traffic_scheds->set_intf_id(0); |
| 2307 | traffic_scheds->set_onu_id(1); |
| 2308 | traffic_scheds->set_uni_id(0); |
| 2309 | traffic_scheds->set_port_no(16); |
| 2310 | traffic_sched = traffic_scheds->add_traffic_scheds(); |
| 2311 | traffic_sched->set_alloc_id(1024); |
| 2312 | traffic_sched->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2313 | |
| 2314 | bcmos_errno olt_cfg_clear_res = BCM_ERR_OK; |
| 2315 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 2316 | RemoveTrafficSchedulers_(traffic_scheds); |
| 2317 | |
| 2318 | traffic_queues->set_uni_id(0); |
| 2319 | traffic_queues->set_port_no(16); |
| 2320 | traffic_queue_1->set_direction(tech_profile::Direction::DOWNSTREAM); |
| 2321 | |
| 2322 | Status status = RemoveTrafficQueues_(traffic_queues); |
| 2323 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2324 | } |
| 2325 | |
| 2326 | /* Test 4 - RemoveTrafficQueues-Upstream PRIORITY_TO_QUEUE, not removing TM QMP |
| 2327 | as it is getting referred by some other queues case */ |
| 2328 | TEST_F(TestRemoveTrafficQueues, RemoveUpstreamPriorityQueueNotRemovingTMQMP) { |
| 2329 | traffic_queues->set_uni_id(3); |
| 2330 | traffic_queues->set_port_no(16); |
| 2331 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2332 | traffic_queue_2 = traffic_queues->add_traffic_queues(); |
| 2333 | traffic_queue_2->set_gemport_id(1025); |
| 2334 | traffic_queue_2->set_priority(1); |
| 2335 | traffic_queue_2->set_direction(tech_profile::Direction::UPSTREAM); |
| 2336 | |
| 2337 | Status status = RemoveTrafficQueues_(traffic_queues); |
| 2338 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2339 | } |
| 2340 | |
| 2341 | /* Test 5 - RemoveTrafficQueues-Upstream PRIORITY_TO_QUEUE, removing TM QMP as it |
| 2342 | is not getting referred by any other queues case */ |
| 2343 | TEST_F(TestRemoveTrafficQueues, RemoveUpstreamPriorityQueueRemovingTMQMP) { |
| 2344 | traffic_queues->set_uni_id(1); |
| 2345 | traffic_queues->set_port_no(32); |
| 2346 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2347 | traffic_queue_2 = traffic_queues->add_traffic_queues(); |
| 2348 | traffic_queue_2->set_gemport_id(1025); |
| 2349 | traffic_queue_2->set_priority(1); |
| 2350 | |
| 2351 | bcmos_errno olt_cfg_clear_res = BCM_ERR_OK; |
| 2352 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 2353 | |
| 2354 | Status status = RemoveTrafficQueues_(traffic_queues); |
| 2355 | ASSERT_TRUE( status.error_message() == Status::OK.error_message() ); |
| 2356 | } |
| 2357 | |
| 2358 | /* Test 6 - RemoveTrafficQueues-Upstream PRIORITY_TO_QUEUE, error while removing TM QMP |
| 2359 | having no reference to any other queues case */ |
| 2360 | TEST_F(TestRemoveTrafficQueues, RemoveUpstreamPriorityQueueErrorRemovingTMQMP) { |
| 2361 | traffic_queues->set_uni_id(4); |
| 2362 | traffic_queues->set_port_no(64); |
| 2363 | traffic_queue_1->set_direction(tech_profile::Direction::UPSTREAM); |
| 2364 | traffic_queue_2 = traffic_queues->add_traffic_queues(); |
| 2365 | traffic_queue_2->set_gemport_id(1025); |
| 2366 | traffic_queue_2->set_priority(1); |
| 2367 | |
| 2368 | bcmos_errno olt_cfg_clear_res = BCM_ERR_INTERNAL; |
| 2369 | ON_CALL(balMock, bcmolt_cfg_clear(_, _)).WillByDefault(Return(olt_cfg_clear_res)); |
| 2370 | |
| 2371 | Status status = RemoveTrafficQueues_(traffic_queues); |
| 2372 | ASSERT_TRUE( status.error_message() != Status::OK.error_message() ); |
| 2373 | } |