Skip to content

Commit 7d59b44

Browse files
BenHuddlestondaverigby
authored andcommitted
MB-41719: Make test_consumer_add_stream ST
Change-Id: Ic4c3b7901a42f4d8064076bdc9b03e3ef638808d Reviewed-on: http://review.couchbase.org/c/kv_engine/+/137658 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent cf814b3 commit 7d59b44

File tree

2 files changed

+46
-33
lines changed

2 files changed

+46
-33
lines changed

engines/ep/tests/module_tests/dcp_single_threaded_test.cc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,52 @@ TEST_P(STDcpTest, test_producer_no_stream_end_on_client_close_stream) {
705705
connMap.manageConnections();
706706
}
707707

708+
TEST_P(STDcpTest, test_consumer_add_stream) {
709+
setVBucketStateAndRunPersistTask(vbid, vbucket_state_replica);
710+
711+
auto& connMap = static_cast<MockDcpConnMap&>(engine->getDcpConnMap());
712+
713+
const void* cookie = create_mock_cookie(engine.get());
714+
Vbid vbid = Vbid(0);
715+
716+
/* Create a Mock Dcp consumer */
717+
auto consumer =
718+
std::make_shared<MockDcpConsumer>(*engine, cookie, "test_consumer");
719+
connMap.addConn(cookie, consumer);
720+
721+
ASSERT_EQ(ENGINE_SUCCESS,
722+
consumer->addStream(/*opaque*/ 0,
723+
vbid,
724+
/*flags*/ 0));
725+
726+
/* Set the passive to dead state. Note that we want to set the stream to
727+
dead state but not erase it from the streams map in the consumer
728+
connection*/
729+
MockPassiveStream* stream = static_cast<MockPassiveStream*>(
730+
(consumer->getVbucketStream(vbid)).get());
731+
732+
stream->transitionStateToDead();
733+
734+
/* Add a passive stream on the same vb */
735+
ASSERT_EQ(ENGINE_SUCCESS,
736+
consumer->addStream(/*opaque*/ 0,
737+
vbid,
738+
/*flags*/ 0));
739+
740+
/* Expected the newly added stream to be in active state */
741+
stream = static_cast<MockPassiveStream*>(
742+
(consumer->getVbucketStream(vbid)).get());
743+
ASSERT_TRUE(stream->isActive());
744+
745+
/* Close stream before deleting the connection */
746+
ASSERT_EQ(ENGINE_SUCCESS, consumer->closeStream(/*opaque*/ 0, vbid));
747+
748+
connMap.disconnect(cookie);
749+
EXPECT_FALSE(connMap.isDeadConnectionsEmpty());
750+
connMap.manageConnections();
751+
EXPECT_TRUE(connMap.isDeadConnectionsEmpty());
752+
}
753+
708754
void STDcpTest::sendConsumerMutationsNearThreshold(bool beyondThreshold) {
709755
setVBucketStateAndRunPersistTask(vbid, vbucket_state_replica);
710756

engines/ep/tests/module_tests/dcp_test.cc

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,40 +1278,7 @@ TEST_P(ConnectionTest, test_update_of_last_message_time_in_consumer) {
12781278
destroy_mock_cookie(cookie);
12791279
}
12801280

1281-
TEST_P(ConnectionTest, test_consumer_add_stream) {
1282-
const void* cookie = create_mock_cookie(engine);
1283-
Vbid vbid = Vbid(0);
1284-
1285-
/* Create a Mock Dcp consumer */
1286-
auto consumer =
1287-
std::make_shared<MockDcpConsumer>(*engine, cookie, "test_consumer");
1288-
1289-
ASSERT_EQ(ENGINE_SUCCESS, set_vb_state(vbid, vbucket_state_replica));
1290-
ASSERT_EQ(ENGINE_SUCCESS, consumer->addStream(/*opaque*/0, vbid,
1291-
/*flags*/0));
1292-
1293-
/* Set the passive to dead state. Note that we want to set the stream to
1294-
dead state but not erase it from the streams map in the consumer
1295-
connection*/
1296-
MockPassiveStream *stream = static_cast<MockPassiveStream*>
1297-
((consumer->getVbucketStream(vbid)).get());
12981281

1299-
stream->transitionStateToDead();
1300-
1301-
/* Add a passive stream on the same vb */
1302-
ASSERT_EQ(ENGINE_SUCCESS, consumer->addStream(/*opaque*/0, vbid,
1303-
/*flags*/0));
1304-
1305-
/* Expected the newly added stream to be in active state */
1306-
stream = static_cast<MockPassiveStream*>
1307-
((consumer->getVbucketStream(vbid)).get());
1308-
ASSERT_TRUE(stream->isActive());
1309-
1310-
/* Close stream before deleting the connection */
1311-
ASSERT_EQ(ENGINE_SUCCESS, consumer->closeStream(/*opaque*/0, vbid));
1312-
1313-
destroy_mock_cookie(cookie);
1314-
}
13151282

13161283
TEST_P(ConnectionTest, consumer_waits_for_add_stream) {
13171284
const void* cookie = create_mock_cookie(engine);

0 commit comments

Comments
 (0)