lte/gateway/c/session_manager/test/test_session_state.cpp
/**
 * Check that rule scheduling and installation works from the perspective of
 * tracking in SessionState
 */
Check that rule scheduling and installation works from the perspective of
tracking in SessionState
Check that rule scheduling and installation works from the perspective of tracking in SessionState
TEST_F(SessionStateTest, test_rule_scheduling) {
  schedule_rule(1, "m1", "rule1", DYNAMIC, 0, 0);
  EXPECT_EQ(0, session_state->total_monitored_rules_count());
  EXPECT_FALSE(session_state->is_dynamic_rule_installed("rule1"));
  schedule_rule(2, "m2", "rule2", STATIC, 0, 0);
  EXPECT_EQ(0, session_state->total_monitored_rules_count());
  EXPECT_FALSE(session_state->is_static_rule_installed("rule2"));
  PolicyRule rule;
  session_state->remove_scheduled_dynamic_rule("rule1", &rule, nullptr);
  session_state->insert_dynamic_rule(
      rule, session_state->get_rule_lifetime("rule1"), nullptr);
  EXPECT_EQ(1, session_state->total_monitored_rules_count());
  EXPECT_TRUE(session_state->is_dynamic_rule_installed("rule1"));
  session_state->activate_static_rule(
      "rule2", session_state->get_rule_lifetime("rule2"), nullptr);
  EXPECT_EQ(2, session_state->total_monitored_rules_count());
  EXPECT_TRUE(session_state->is_static_rule_installed("rule2"));
  EXPECT_EQ(session_state->get_current_rule_version("rule1"), 1);
  EXPECT_EQ(session_state->get_current_rule_version("rule2"), 1);
}
TEST_F ( SessionStateTest , test_rule_scheduling ) { schedule_rule ( 1 , " " , " " , DYNAMIC , 0 , 0 ) ; EXPECT_EQ ( 0 , session_state -> total_monitored_rules_count ( ) ) ; EXPECT_FALSE ( session_state -> is_dynamic_rule_installed ( " " ) ) ; schedule_rule ( 2 , " " , " " , STATIC , 0 , 0 ) ; EXPECT_EQ ( 0 , session_state -> total_monitored_rules_count ( ) ) ; EXPECT_FALSE ( session_state -> is_static_rule_installed ( " " ) ) ; PolicyRule rule ; session_state -> remove_scheduled_dynamic_rule ( " " , & rule , nullptr ) ; session_state -> insert_dynamic_rule ( rule , session_state -> get_rule_lifetime ( " " ) , nullptr ) ; EXPECT_EQ ( 1 , session_state -> total_monitored_rules_count ( ) ) ; EXPECT_TRUE ( session_state -> is_dynamic_rule_installed ( " " ) ) ; session_state -> activate_static_rule ( " " , session_state -> get_rule_lifetime ( " " ) , nullptr ) ; EXPECT_EQ ( 2 , session_state -> total_monitored_rules_count ( ) ) ; EXPECT_TRUE ( session_state -> is_static_rule_installed ( " " ) ) ; EXPECT_EQ ( session_state -> get_current_rule_version ( " " ) , 1 ) ; EXPECT_EQ ( session_state -> get_current_rule_version ( " " ) , 1 ) ; }
Check that rule scheduling and installation works from the perspective of
 tracking in SessionState
Check that rule scheduling and installation works from the perspective of tracking in SessionState
// First schedule a dynamic and static rule. They are treated as inactive. // Now suppose some time has passed, and it's time to mark scheduled rules // as active. The responsibility is given to the session owner to make // these calls