Skip to content

Commit

Permalink
Unit test to cover the issue reported in Bug #1528380
Browse files Browse the repository at this point in the history
Add unit test that checks that even if the sandesh state machine queue
watermark level is initialized to INVALID the sandesh session defer
reader callback is called.

Change-Id: Iaaf0b72f6a5145fa6f3f02bfd425fc9a331f42e7
Closes-Bug: #1550562
  • Loading branch information
Megh Bhatt committed Feb 27, 2016
1 parent 3d3a796 commit 08d4ff3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions library/cpp/test/sandesh_state_machine_test.cc
Expand Up @@ -454,6 +454,37 @@ TEST_F(SandeshServerStateMachineTest, WaterMark) {
EXPECT_FALSE(sm_->session()->IsReaderDeferred());
}

TEST_F(SandeshServerStateMachineTest, WaterMark2) {
// Set high and low watermarks with level set to INVALID
// and defer undefer also set to true. Verify that the
// session reader defer status is still set/unset
std::vector<Sandesh::QueueWaterMarkInfo> wm_info =
boost::assign::tuple_list_of
(1 * 1024, SandeshLevel::INVALID, true, true)
(512, SandeshLevel::INVALID, false, true);
for (int i = 0; i < wm_info.size(); i++) {
sm_->SetQueueWaterMarkInfo(wm_info[i]);
}
// Verify initial message drop level and the session reader defer status
EXPECT_EQ(SandeshLevel::INVALID, MessageDropLevel());
EXPECT_TRUE(sm_->session() == NULL);
// Move to ssm::SERVER_INIT
GetToState(ssm::SERVER_INIT);
// Stop the task scheduler
TaskScheduler::GetInstance()->Stop();
// Enqueue 1 message 1024 byte
EvSandeshMessageRecv();
// Verify the message drop level and the session reader defer status
EXPECT_EQ(SandeshLevel::INVALID, MessageDropLevel());
EXPECT_TRUE(sm_->session()->IsReaderDeferred());
// Start the task scheduler
TaskScheduler::GetInstance()->Start();
task_util::WaitForIdle();
// Verify the message drop level and the session reader defer status
EXPECT_EQ(SandeshLevel::INVALID, MessageDropLevel());
EXPECT_FALSE(sm_->session()->IsReaderDeferred());
}

TEST_F(SandeshServerStateMachineTest, DeferDequeue) {
// Move to ssm::SERVER_INIT
GetToState(ssm::SERVER_INIT);
Expand Down

0 comments on commit 08d4ff3

Please sign in to comment.