[VOL-2152][BAL3.0 Brigade] OpenOLT driver registers ONU Remote Defect
Indicator alarm
- Provide missing BAL API definitions required for unit test compilation
Change-Id: Ifb38a55b24413beb9f5caf864403c4513cd7be68
diff --git a/agent/test/Makefile b/agent/test/Makefile
index a32c160..1693af0 100644
--- a/agent/test/Makefile
+++ b/agent/test/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2018-present Open Networking Foundation
+ # Copyright 2018-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
TOP_DIR=`pwd`
OPENOLTDEVICE ?= asfvolt16
-OPENOLT_PROTO_VER ?= v3.3.5
+OPENOLT_PROTO_VER ?= v3.3.6
GTEST_VER ?= release-1.8.0
gtest-target = /usr/local/lib/libgtest.a
@@ -134,6 +134,11 @@
OPENOLT_API_LIB = lib/libopenoltapi.a
OPENOLT_LIB = lib/libopenolt.a
+# Set the OPENOLT_ROOT_DIR variable to "/app" folder inside the docker container, if not already set.
+ifeq ($(OPENOLT_ROOT_DIR),)
+OPENOLT_ROOT_DIR := /app
+endif
+
all: bcm_host_api_stubs $(OPENOLT_API_LIB) $(OPENOLT_LIB) build
# test
@@ -152,20 +157,15 @@
# bcm_host_api_stubs
bcm_host_api_stubs:
+ echo $(OPENOLT_ROOT_DIR); \
# TODO: This is temporary hack below to introduce the definition BAL IEs that are missing in https://github.com/balapi/bal-api-<BAL-VER>
if [ -d $(BAL_API_DIR) ]; then \
echo "$(BAL_API_DIR) exists"; \
else \
git clone https://github.com/balapi/$(BAL_API_VER).git ;\
- sed -i "\$$i #define BCMOLT_TM_QUEUE_KEY_TM_Q_SET_ID_DEFAULT 0" ./$(BAL_API_DIR)/include/bcmos_system.h; \
- sed -i "\$$i struct bcmos_mutex \{ pthread_mutex_t m; };" ./$(BAL_API_DIR)/include/bcmos_system.h; \
- sed -i "\$$i extern void* bcmos_calloc(uint32_t size);" ./$(BAL_API_DIR)/include/bcmos_common.h; \
- sed -i "\$$i #define BCMOLT_INTERFACE_TYPE_EPON_1_G 3" ./$(BAL_API_DIR)/include/bcmos_common.h; \
- sed -i "\$$i #define BCMOLT_INTERFACE_TYPE_EPON_10_G 4" ./$(BAL_API_DIR)/include/bcmos_common.h; \
- sed -i "\$$i typedef struct \{ uint64_t rdi_errors;} bcmolt_onu_itu_pon_stats_data;" ./$(BAL_API_DIR)/include/object_model/bcmolt_api_model_api_structs.h; \
- sed -i "\$$i typedef struct \{ bcmolt_onu_key key; bcmolt_onu_itu_pon_stats_data data;} bcmolt_onu_itu_pon_stats;" ./$(BAL_API_DIR)/include/object_model/bcmolt_api_model_api_structs.h; \
- sed -i "\$$i #define bcmolt_onu_stat_subgroup_itu_pon_stats BCMOLT_ONU_STAT_SUBGROUP_ITU_PON_STATS" ./$(BAL_API_DIR)/include/object_model/bcmolt_api_model_api_structs.h; \
- sed -i "\$$i #define BCMOLT_ONU_STAT_SUBGROUP_ITU_PON_STATS 0" ./$(BAL_API_DIR)/include/object_model/bcmolt_api_model_api_structs.h; \
+ sed -i "\$$i #include \"$(OPENOLT_ROOT_DIR)/agent/test/inc/bcmos_system_test.h\"" ./$(BAL_API_DIR)/include/bcmos_system.h; \
+ sed -i "\$$i #include \"$(OPENOLT_ROOT_DIR)/agent/test/inc/bcmos_common_test.h\"" ./$(BAL_API_DIR)/include/bcmos_common.h; \
+ sed -i "\$$i #include \"$(OPENOLT_ROOT_DIR)/agent/test/inc/bcmolt_api_model_api_structs_test.h\"" ./$(BAL_API_DIR)/include/object_model/bcmolt_api_model_api_structs.h; \
fi
# openoltapi
diff --git a/agent/test/inc/bal_mocker.h b/agent/test/inc/bal_mocker.h
index f60c581..8a8a9fa 100644
--- a/agent/test/inc/bal_mocker.h
+++ b/agent/test/inc/bal_mocker.h
@@ -44,6 +44,7 @@
MOCK_METHOD2(bcmolt_oper_submit, bcmos_errno(bcmolt_oltid, bcmolt_oper*));
MOCK_METHOD2(bcmolt_cfg_set, bcmos_errno(bcmolt_oltid, bcmolt_cfg*));
MOCK_METHOD2(bcmolt_cfg_clear, bcmos_errno(bcmolt_oltid, bcmolt_cfg*));
+ MOCK_METHOD2(bcmolt_stat_cfg_set, bcmos_errno(bcmolt_oltid, bcmolt_stat_cfg*));
// Add more here
};
diff --git a/agent/test/inc/bcmolt_api_model_api_structs_test.h b/agent/test/inc/bcmolt_api_model_api_structs_test.h
new file mode 100644
index 0000000..3c67a1e
--- /dev/null
+++ b/agent/test/inc/bcmolt_api_model_api_structs_test.h
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BCMOLT_API_MODEL_API_STRUCTS_TEST_H_
+#define BCMOLT_API_MODEL_API_STRUCTS_TEST_H_
+
+#include <bcmos_system.h>
+#include <bcmolt_system_types.h>
+#include "bcmolt_msg.h"
+#include "bcmolt_api_model_supporting_structs.h"
+#include "bcmolt_api_model_supporting_enums.h"
+#include "bcmolt_api_model_supporting_typedefs.h"
+
+/**
+This header file provides STUB definitions of missing BAL structs for unit test compilation
+*/
+
+
+// ITU PON Statistics
+typedef struct
+{
+ uint64_t presence_mask;
+ uint64_t rdi_errors;
+} bcmolt_onu_itu_pon_stats_data;
+
+typedef struct
+{
+ bcmolt_stat hdr;
+ bcmolt_onu_key key;
+ bcmolt_onu_itu_pon_stats_data data;
+} bcmolt_onu_itu_pon_stats;
+
+
+
+// onu_itu_pon_stats_data'
+typedef enum
+{
+ BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS = 1,
+ BCMOLT_ONU_ITU_PON_STATS_CFG_DATA_ID_BIP_ERRORS = 2
+
+ #define bcmolt_onu_itu_pon_stats_data_id_rdi_errors BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS
+ #define bcmolt_onu_itu_pon_stats_cfg_data_id_bip_errors BCMOLT_ONU_ITU_PON_STATS_CFG_DATA_ID_BIP_ERRORS
+
+} bcmolt_onu_itu_pon_stats_data_id;
+
+// onu_itu_pon_stats_cfg_data
+typedef enum
+{
+
+ BCMOLT_ONU_ITU_PON_STATS_CFG_DATA_ID_RDI_ERRORS = 1
+
+ #define bcmolt_onu_itu_pon_stats_cfg_data_id_rdi_errors BCMOLT_ONU_ITU_PON_STATS_CFG_DATA_ID_RDI_ERRORS
+
+} bcmolt_onu_itu_pon_stats_cfg_data_id;
+
+//onu_itu_pon_stats_alarm_raised_data
+typedef enum
+{
+ BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT = 0
+ #define bcmolt_onu_itu_pon_stats_alarm_raised_data_id_stat BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT
+
+} bcmolt_onu_itu_pon_stats_alarm_raised_data_id;
+
+// onu_itu_pon_stats_alarm_cleared_data
+typedef enum
+{
+ BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT = 0
+ #define bcmolt_onu_itu_pon_stats_alarm_cleared_data_id_stat BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT
+
+} bcmolt_onu_itu_pon_stats_alarm_cleared_data_id;
+
+
+/** ONU: ITU PON Statistics Alarm Raised */
+typedef struct
+{
+ bcmolt_presence_mask presence_mask;
+ bcmolt_onu_itu_pon_stats_data_id stat;
+} bcmolt_onu_itu_pon_stats_alarm_raised_data;
+
+// itu_pon_stats_alarm_raised" group of "onu" object
+typedef struct
+{
+ bcmolt_auto hdr;
+ bcmolt_onu_key key;
+ bcmolt_onu_itu_pon_stats_alarm_raised_data data;
+} bcmolt_onu_itu_pon_stats_alarm_raised;
+
+// ITU PON Statistics Alarm Cleared
+typedef struct
+{
+ uint64_t presence_mask;
+ bcmolt_onu_itu_pon_stats_data_id stat;
+} bcmolt_onu_itu_pon_stats_alarm_cleared_data;
+
+// itu_pon_stats_alarm_cleared" group of "onu" object
+typedef struct
+{
+ bcmolt_auto hdr;
+ bcmolt_onu_key key;
+ bcmolt_onu_itu_pon_stats_alarm_cleared_data data;
+} bcmolt_onu_itu_pon_stats_alarm_cleared;
+
+
+// ITU PON Statistics Configuration
+typedef struct
+{
+ uint64_t presence_mask;
+ bcmolt_stat_alarm_config rdi_errors;
+ bcmolt_stat_alarm_config bip_errors;
+
+} bcmolt_onu_itu_pon_stats_cfg_data;
+
+// itu_pon_stats_cfg" group of "onu" object
+typedef struct
+{
+ bcmolt_stat_cfg hdr;
+ bcmolt_onu_key key;
+ bcmolt_onu_itu_pon_stats_cfg_data data;
+} bcmolt_onu_itu_pon_stats_cfg;
+
+#define BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED 1
+#define BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED 2
+#define BCMOLT_ONU_STAT_SUBGROUP_ITU_PON_STATS 3
+#define BCMOLT_ONU_STAT_CFG_SUBGROUP_ITU_PON_STATS_CFG 4
+
+#define bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED
+#define bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED
+#define bcmolt_onu_stat_subgroup_itu_pon_stats BCMOLT_ONU_STAT_SUBGROUP_ITU_PON_STATS
+#define bcmolt_onu_stat_cfg_subgroup_itu_pon_stats_cfg BCMOLT_ONU_STAT_CFG_SUBGROUP_ITU_PON_STATS_CFG
+
+#endif // BCMOLT_API_MODEL_API_STRUCTS_TEST_H_
+
diff --git a/agent/test/inc/bcmos_common_test.h b/agent/test/inc/bcmos_common_test.h
new file mode 100644
index 0000000..391b444
--- /dev/null
+++ b/agent/test/inc/bcmos_common_test.h
@@ -0,0 +1,29 @@
+/*
+
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BCMOS_COMMON_TEST_H_
+#define BCMOS_COMMON_TEST_H_
+
+/**
+This header file provides missing BAL API definitions required for unit test compilation.
+*/
+
+extern void* bcmos_calloc(uint32_t size);
+#define BCMOLT_INTERFACE_TYPE_EPON_1_G 3
+#define BCMOLT_INTERFACE_TYPE_EPON_10_G 4
+
+#endif // BCMOS_COMMON_TEST_H_
diff --git a/agent/test/inc/bcmos_system_test.h b/agent/test/inc/bcmos_system_test.h
new file mode 100644
index 0000000..881a232
--- /dev/null
+++ b/agent/test/inc/bcmos_system_test.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BCMOS_SYSTEM_TEST_H_
+#define BCMOS_SYSTEM_TEST_H_
+
+#include <pthread.h>
+
+/**
+This header file provides missing BAL API definitions required for unit test compilation.
+*/
+
+#define BCMOLT_TM_QUEUE_KEY_TM_Q_SET_ID_DEFAULT 0
+struct bcmos_mutex { pthread_mutex_t m; };
+
+#endif
+
diff --git a/agent/test/src/bal_mocker.cc b/agent/test/src/bal_mocker.cc
index f59c412..72ef1d2 100644
--- a/agent/test/src/bal_mocker.cc
+++ b/agent/test/src/bal_mocker.cc
@@ -21,5 +21,6 @@
CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_oper_submit, bcmos_errno(bcmolt_oltid, bcmolt_oper*));
CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_cfg_set, bcmos_errno(bcmolt_oltid, bcmolt_cfg*));
CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_cfg_clear, bcmos_errno(bcmolt_oltid, bcmolt_cfg*));
+CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_stat_cfg_set, bcmos_errno(bcmolt_oltid, bcmolt_stat_cfg*));
}
diff --git a/agent/test/src/bal_stub.cc b/agent/test/src/bal_stub.cc
index 124b9a0..2c778ce 100644
--- a/agent/test/src/bal_stub.cc
+++ b/agent/test/src/bal_stub.cc
@@ -108,13 +108,6 @@
return BCM_ERR_OK;
}
-/* Set statistics configuration */
-bcmos_errno bcmolt_stat_cfg_set(bcmolt_oltid olt, bcmolt_stat_cfg *cfg)
-{
- printf("-- entering :stubbed %s\n", __FUNCTION__);
- return BCM_ERR_OK;
-}
-
/* Register Autonomous Indication Message Handler */
bcmos_errno bcmolt_ind_subscribe(bcmolt_oltid olt, bcmolt_rx_cfg *rx_cfg)
{
diff --git a/agent/test/src/test_core.cc b/agent/test/src/test_core.cc
index d5b4dc8..698b894 100644
--- a/agent/test/src/test_core.cc
+++ b/agent/test/src/test_core.cc
@@ -2633,3 +2633,179 @@
Status status = RemoveTrafficQueues_(traffic_queues);
ASSERT_TRUE( status.error_message() != Status::OK.error_message() );
}
+
+////////////////////////////////////////////////////////////////////////////
+// For testing OnuItuPonAlarmSet functionality
+////////////////////////////////////////////////////////////////////////////
+
+class TestOnuItuPonAlarmSet : public Test {
+ protected:
+ bcmolt_pon_ni pon_ni = 0;
+ bcmolt_onu_id onu_id = 1;
+
+ openolt::OnuItuPonAlarm *onu_itu_pon_alarm_rt;
+ openolt::OnuItuPonAlarm::RateThresholdConfig *rate_threshold_config;
+ openolt::OnuItuPonAlarm::SoakTime *soak_time_rt;
+
+ openolt::OnuItuPonAlarm *onu_itu_pon_alarm_rr;
+ openolt::OnuItuPonAlarm::RateRangeConfig *rate_range_config;
+ openolt::OnuItuPonAlarm::SoakTime *soak_time_rr;
+
+ openolt::OnuItuPonAlarm *onu_itu_pon_alarm_tc;
+ openolt::OnuItuPonAlarm::ValueThresholdConfig *value_threshold_config;
+ openolt::OnuItuPonAlarm::SoakTime *soak_time_tc;
+
+ NiceMock<BalMocker> balMock;
+
+ virtual void SetUp() {
+ onu_itu_pon_alarm_rt = new openolt::OnuItuPonAlarm;
+ rate_threshold_config = new openolt::OnuItuPonAlarm::RateThresholdConfig;
+ soak_time_rt = new openolt::OnuItuPonAlarm::SoakTime;
+ onu_itu_pon_alarm_rt->set_pon_ni(0);
+ onu_itu_pon_alarm_rt->set_onu_id(1);
+ onu_itu_pon_alarm_rt->set_alarm_id(openolt::OnuItuPonAlarm_AlarmID::OnuItuPonAlarm_AlarmID_RDI_ERRORS);
+ onu_itu_pon_alarm_rt->set_alarm_reporting_condition(openolt::OnuItuPonAlarm_AlarmReportingCondition::OnuItuPonAlarm_AlarmReportingCondition_RATE_THRESHOLD);
+ rate_threshold_config->set_rate_threshold_rising(1);
+ rate_threshold_config->set_rate_threshold_falling(4);
+ soak_time_rt->set_active_soak_time(2);
+ soak_time_rt->set_clear_soak_time(2);
+ rate_threshold_config->set_allocated_soak_time(soak_time_rt);
+ onu_itu_pon_alarm_rt->set_allocated_rate_threshold_config(rate_threshold_config);
+
+ onu_itu_pon_alarm_rr = new openolt::OnuItuPonAlarm;
+ rate_range_config = new openolt::OnuItuPonAlarm::RateRangeConfig;
+ soak_time_rr = new openolt::OnuItuPonAlarm::SoakTime;
+ onu_itu_pon_alarm_rr->set_pon_ni(0);
+ onu_itu_pon_alarm_rr->set_onu_id(1);
+ onu_itu_pon_alarm_rr->set_alarm_id(openolt::OnuItuPonAlarm_AlarmID::OnuItuPonAlarm_AlarmID_RDI_ERRORS);
+ onu_itu_pon_alarm_rr->set_alarm_reporting_condition(openolt::OnuItuPonAlarm_AlarmReportingCondition::OnuItuPonAlarm_AlarmReportingCondition_RATE_RANGE);
+ rate_range_config->set_rate_range_lower(1);
+ rate_range_config->set_rate_range_upper(4);
+ soak_time_rr->set_active_soak_time(2);
+ soak_time_rr->set_clear_soak_time(2);
+ rate_range_config->set_allocated_soak_time(soak_time_rr);
+ onu_itu_pon_alarm_rr->set_allocated_rate_range_config(rate_range_config);
+
+ onu_itu_pon_alarm_tc = new openolt::OnuItuPonAlarm;
+ value_threshold_config = new openolt::OnuItuPonAlarm::ValueThresholdConfig;
+ soak_time_tc = new openolt::OnuItuPonAlarm::SoakTime;
+ onu_itu_pon_alarm_tc->set_pon_ni(0);
+ onu_itu_pon_alarm_tc->set_onu_id(1);
+ onu_itu_pon_alarm_tc->set_alarm_id(openolt::OnuItuPonAlarm_AlarmID::OnuItuPonAlarm_AlarmID_RDI_ERRORS);
+ onu_itu_pon_alarm_tc->set_alarm_reporting_condition(openolt::OnuItuPonAlarm_AlarmReportingCondition::OnuItuPonAlarm_AlarmReportingCondition_VALUE_THRESHOLD);
+ value_threshold_config->set_threshold_limit(6);
+ soak_time_tc->set_active_soak_time(2);
+ soak_time_tc->set_clear_soak_time(2);
+ value_threshold_config->set_allocated_soak_time(soak_time_tc);
+ onu_itu_pon_alarm_tc->set_allocated_value_threshold_config(value_threshold_config);
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+// Test 1 - OnuItuPonAlarmSet-Set RDI_errors to rate threshold type success case
+// rate_threshold: The alarm is triggered if the stats delta value between samples crosses
+// the configured threshold boundary.
+TEST_F(TestOnuItuPonAlarmSet, OnuItuPonAlarmSetRdiErrorsRateThresholdTypeSuccess) {
+ bcmolt_onu_itu_pon_stats_cfg stat_cfg;
+ bcmolt_onu_key key = {};
+ BCMOLT_STAT_CFG_INIT(&stat_cfg, onu, itu_pon_stats, key);
+ stat_cfg.data.rdi_errors.trigger.type = BCMOLT_STAT_CONDITION_TYPE_RATE_THRESHOLD;
+ stat_cfg.data.rdi_errors.trigger.u.rate_threshold.rising = 50;
+ stat_cfg.data.rdi_errors.trigger.u.rate_threshold.falling = 100;
+ bcmos_errno olt_cfg_set_res = BCM_ERR_OK;
+
+ ON_CALL(balMock, bcmolt_stat_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res));
+
+ Status status = OnuItuPonAlarmSet_(onu_itu_pon_alarm_rt);
+ ASSERT_TRUE( status.error_message() == Status::OK.error_message() );
+}
+
+// Test 2 - OnuItuPonAlarmSet-Set RDI_errors to rate threshold type failure case
+// rate_threshold: The alarm is triggered if the stats delta value between samples crosses
+// the configured threshold boundary.
+TEST_F(TestOnuItuPonAlarmSet, OnuItuPonAlarmSetRdiErrorsRateThresholdTypeFailure) {
+ bcmolt_onu_itu_pon_stats_cfg stat_cfg;
+ bcmolt_onu_key key = {};
+ BCMOLT_STAT_CFG_INIT(&stat_cfg, onu, itu_pon_stats, key);
+ stat_cfg.data.rdi_errors.trigger.type = BCMOLT_STAT_CONDITION_TYPE_RATE_THRESHOLD;
+ stat_cfg.data.rdi_errors.trigger.u.rate_threshold.rising = 50;
+ stat_cfg.data.rdi_errors.trigger.u.rate_threshold.falling = 100;
+ bcmos_errno olt_cfg_set_res = BCM_ERR_INTERNAL;
+
+ ON_CALL(balMock, bcmolt_stat_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res));
+
+ Status status = OnuItuPonAlarmSet_(onu_itu_pon_alarm_rt);
+ ASSERT_TRUE( status.error_message() != Status::OK.error_message() );
+}
+
+// Test 3 - OnuItuPonAlarmSet-Set RDI_errors to rate range type success case
+// rate_range: The alarm is triggered if the stats delta value between samples deviates
+// from the configured range.
+TEST_F(TestOnuItuPonAlarmSet, OnuItuPonAlarmSetRdiErrorsRateRangeTypeSuccess) {
+ bcmolt_onu_itu_pon_stats_cfg stat_cfg;
+ bcmolt_onu_key key = {};
+ BCMOLT_STAT_CFG_INIT(&stat_cfg, onu, itu_pon_stats, key);
+ stat_cfg.data.rdi_errors.trigger.type = BCMOLT_STAT_CONDITION_TYPE_RATE_RANGE;
+ stat_cfg.data.rdi_errors.trigger.u.rate_range.upper = 100;
+ stat_cfg.data.rdi_errors.trigger.u.rate_range.lower = 50;
+ bcmos_errno olt_cfg_set_res = BCM_ERR_OK;
+
+ ON_CALL(balMock, bcmolt_stat_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res));
+
+ Status status = OnuItuPonAlarmSet_(onu_itu_pon_alarm_rr);
+ ASSERT_TRUE( status.error_message() == Status::OK.error_message() );
+}
+
+// Test 4 - OnuItuPonAlarmSet-Set RDI_errors to rate range type failure case
+// rate_range: The alarm is triggered if the stats delta value between samples deviates
+// from the configured range.
+TEST_F(TestOnuItuPonAlarmSet, OnuItuPonAlarmSetRdiErrorsRateRangeTypeFailure) {
+ bcmolt_onu_itu_pon_stats_cfg stat_cfg;
+ bcmolt_onu_key key = {};
+ BCMOLT_STAT_CFG_INIT(&stat_cfg, onu, itu_pon_stats, key);
+ stat_cfg.data.rdi_errors.trigger.type = BCMOLT_STAT_CONDITION_TYPE_RATE_RANGE;
+ stat_cfg.data.rdi_errors.trigger.u.rate_range.upper = 50;
+ stat_cfg.data.rdi_errors.trigger.u.rate_range.lower = 100;
+ bcmos_errno olt_cfg_set_res = BCM_ERR_INTERNAL;
+
+ ON_CALL(balMock, bcmolt_stat_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res));
+
+ Status status = OnuItuPonAlarmSet_(onu_itu_pon_alarm_rr);
+ ASSERT_TRUE( status.error_message() != Status::OK.error_message() );
+}
+
+// Test 5 - OnuItuPonAlarmSet-Set RDI_errors to value threshold type success case
+// value_threshold: The alarm is raised if the stats sample value becomes greater than this
+// level. The alarm is cleared when the host read the stats.
+TEST_F(TestOnuItuPonAlarmSet, OnuItuPonAlarmSetRdiErrorsValueThresholdTypeSuccess) {
+ bcmolt_onu_itu_pon_stats_cfg stat_cfg;
+ bcmolt_onu_key key = {};
+ BCMOLT_STAT_CFG_INIT(&stat_cfg, onu, itu_pon_stats, key);
+ stat_cfg.data.rdi_errors.trigger.type = BCMOLT_STAT_CONDITION_TYPE_VALUE_THRESHOLD;
+ stat_cfg.data.rdi_errors.trigger.u.value_threshold.limit = 100;
+ bcmos_errno olt_cfg_set_res = BCM_ERR_OK;
+
+ ON_CALL(balMock, bcmolt_stat_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res));
+
+ Status status = OnuItuPonAlarmSet_(onu_itu_pon_alarm_tc);
+ ASSERT_TRUE( status.error_message() == Status::OK.error_message() );
+}
+
+// Test 6 - OnuItuPonAlarmSet-Set RDI_errors to value threshold type failure case
+// value_threshold: The alarm is raised if the stats sample value becomes greater than this
+// level. The alarm is cleared when the host read the stats.
+TEST_F(TestOnuItuPonAlarmSet, OnuItuPonAlarmSetRdiErrorsValueThresholdTypeFailure) {
+ bcmolt_onu_itu_pon_stats_cfg stat_cfg;
+ bcmolt_onu_key key = {};
+ BCMOLT_STAT_CFG_INIT(&stat_cfg, onu, itu_pon_stats, key);
+ stat_cfg.data.rdi_errors.trigger.type = BCMOLT_STAT_CONDITION_TYPE_VALUE_THRESHOLD;
+ stat_cfg.data.rdi_errors.trigger.u.value_threshold.limit = -1;
+ bcmos_errno olt_cfg_set_res = BCM_ERR_INTERNAL;
+
+ ON_CALL(balMock, bcmolt_stat_cfg_set(_, _)).WillByDefault(Return(olt_cfg_set_res));
+
+ Status status = OnuItuPonAlarmSet_(onu_itu_pon_alarm_tc);
+ ASSERT_TRUE( status.error_message() != Status::OK.error_message() );
+}