Skip to content

Commit ba5d4f2

Browse files
BenHuddlestondaverigby
authored andcommitted
MB-41719: Make mb_24424 tests ST
Change-Id: Icd2f2fb8ad422994d1d51e42f121cc881cfb1029 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/137659 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 6ff8fee commit ba5d4f2

File tree

2 files changed

+115
-101
lines changed

2 files changed

+115
-101
lines changed

engines/ep/tests/module_tests/dcp_single_threaded_test.cc

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,121 @@ TEST_P(STDcpTest, test_consumer_add_stream) {
751751
EXPECT_TRUE(connMap.isDeadConnectionsEmpty());
752752
}
753753

754+
// Tests that the MutationResponse created for the deletion response is of the
755+
// correct size.
756+
TEST_P(STDcpTest, test_mb24424_deleteResponse) {
757+
setVBucketStateAndRunPersistTask(vbid, vbucket_state_replica);
758+
const void* cookie = create_mock_cookie(engine.get());
759+
Vbid vbid = Vbid(0);
760+
761+
auto& connMap = static_cast<MockDcpConnMap&>(engine->getDcpConnMap());
762+
auto consumer =
763+
std::make_shared<MockDcpConsumer>(*engine, cookie, "test_consumer");
764+
connMap.addConn(cookie, consumer);
765+
766+
ASSERT_EQ(ENGINE_SUCCESS,
767+
consumer->addStream(/*opaque*/ 0,
768+
vbid,
769+
/*flags*/ 0));
770+
771+
MockPassiveStream* stream = static_cast<MockPassiveStream*>(
772+
(consumer->getVbucketStream(vbid)).get());
773+
ASSERT_TRUE(stream->isActive());
774+
775+
std::string key = "key";
776+
const DocKey docKey{reinterpret_cast<const uint8_t*>(key.data()),
777+
key.size(),
778+
DocKeyEncodesCollectionId::No};
779+
std::array<uint8_t, 1> extMeta;
780+
extMeta[0] = uint8_t(PROTOCOL_BINARY_DATATYPE_JSON);
781+
cb::const_byte_buffer meta{extMeta.data(), extMeta.size()};
782+
783+
consumer->deletion(/*opaque*/ 1,
784+
/*key*/ docKey,
785+
/*value*/ {},
786+
/*priv_bytes*/ 0,
787+
/*datatype*/ PROTOCOL_BINARY_RAW_BYTES,
788+
/*cas*/ 0,
789+
/*vbucket*/ vbid,
790+
/*bySeqno*/ 1,
791+
/*revSeqno*/ 0,
792+
/*meta*/ meta);
793+
794+
auto messageSize = MutationResponse::deletionBaseMsgBytes + key.size() +
795+
sizeof(extMeta);
796+
797+
EXPECT_EQ(messageSize, stream->responseMessageSize);
798+
799+
/* Close stream before deleting the connection */
800+
ASSERT_EQ(ENGINE_SUCCESS, consumer->closeStream(/*opaque*/ 0, vbid));
801+
802+
connMap.disconnect(cookie);
803+
EXPECT_FALSE(connMap.isDeadConnectionsEmpty());
804+
connMap.manageConnections();
805+
EXPECT_TRUE(connMap.isDeadConnectionsEmpty());
806+
}
807+
808+
// Tests that the MutationResponse created for the mutation response is of the
809+
// correct size.
810+
TEST_P(STDcpTest, test_mb24424_mutationResponse) {
811+
setVBucketStateAndRunPersistTask(vbid, vbucket_state_replica);
812+
const void* cookie = create_mock_cookie(engine.get());
813+
Vbid vbid = Vbid(0);
814+
815+
auto& connMap = static_cast<MockDcpConnMap&>(engine->getDcpConnMap());
816+
auto consumer =
817+
std::make_shared<MockDcpConsumer>(*engine, cookie, "test_consumer");
818+
connMap.addConn(cookie, consumer);
819+
820+
ASSERT_EQ(ENGINE_SUCCESS,
821+
consumer->addStream(/*opaque*/ 0,
822+
vbid,
823+
/*flags*/ 0));
824+
825+
MockPassiveStream* stream = static_cast<MockPassiveStream*>(
826+
(consumer->getVbucketStream(vbid)).get());
827+
ASSERT_TRUE(stream->isActive());
828+
829+
std::string key = "key";
830+
std::string data = R"({"json":"yes"})";
831+
const DocKey docKey{reinterpret_cast<const uint8_t*>(key.data()),
832+
key.size(),
833+
DocKeyEncodesCollectionId::No};
834+
cb::const_byte_buffer value{reinterpret_cast<const uint8_t*>(data.data()),
835+
data.size()};
836+
std::array<uint8_t, 1> extMeta;
837+
extMeta[0] = uint8_t(PROTOCOL_BINARY_DATATYPE_JSON);
838+
cb::const_byte_buffer meta{extMeta.data(), extMeta.size()};
839+
840+
consumer->mutation(/*opaque*/ 1,
841+
/*key*/ docKey,
842+
/*values*/ value,
843+
/*priv_bytes*/ 0,
844+
/*datatype*/ PROTOCOL_BINARY_DATATYPE_JSON,
845+
/*cas*/ 0,
846+
/*vbucket*/ vbid,
847+
/*flags*/ 0,
848+
/*bySeqno*/ 1,
849+
/*revSeqno*/ 0,
850+
/*exptime*/ 0,
851+
/*lock_time*/ 0,
852+
/*meta*/ meta,
853+
/*nru*/ 0);
854+
855+
auto messageSize = MutationResponse::mutationBaseMsgBytes + key.size() +
856+
data.size() + sizeof(extMeta);
857+
858+
EXPECT_EQ(messageSize, stream->responseMessageSize);
859+
860+
/* Close stream before deleting the connection */
861+
ASSERT_EQ(ENGINE_SUCCESS, consumer->closeStream(/*opaque*/ 0, vbid));
862+
863+
connMap.disconnect(cookie);
864+
EXPECT_FALSE(connMap.isDeadConnectionsEmpty());
865+
connMap.manageConnections();
866+
EXPECT_TRUE(connMap.isDeadConnectionsEmpty());
867+
}
868+
754869
void STDcpTest::sendConsumerMutationsNearThreshold(bool beyondThreshold) {
755870
setVBucketStateAndRunPersistTask(vbid, vbucket_state_replica);
756871

engines/ep/tests/module_tests/dcp_test.cc

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,107 +2285,6 @@ TEST_F(NotifyTest, test_mb19503_connmap_notify_paused) {
22852285
EXPECT_EQ(1, notifyTest.getCallbacks());
22862286
}
22872287

2288-
// Tests that the MutationResponse created for the deletion response is of the
2289-
// correct size.
2290-
TEST_P(ConnectionTest, test_mb24424_deleteResponse) {
2291-
const void* cookie = create_mock_cookie(engine);
2292-
Vbid vbid = Vbid(0);
2293-
2294-
auto consumer =
2295-
std::make_shared<MockDcpConsumer>(*engine, cookie, "test_consumer");
2296-
2297-
ASSERT_EQ(ENGINE_SUCCESS, set_vb_state(vbid, vbucket_state_replica));
2298-
ASSERT_EQ(ENGINE_SUCCESS, consumer->addStream(/*opaque*/0, vbid,
2299-
/*flags*/0));
2300-
2301-
MockPassiveStream *stream = static_cast<MockPassiveStream*>
2302-
((consumer->
2303-
getVbucketStream(vbid)).get());
2304-
ASSERT_TRUE(stream->isActive());
2305-
2306-
std::string key = "key";
2307-
const DocKey docKey{reinterpret_cast<const uint8_t*>(key.data()),
2308-
key.size(),
2309-
DocKeyEncodesCollectionId::No};
2310-
uint8_t extMeta[1] = {uint8_t(PROTOCOL_BINARY_DATATYPE_JSON)};
2311-
cb::const_byte_buffer meta{extMeta, sizeof(uint8_t)};
2312-
2313-
consumer->deletion(/*opaque*/ 1,
2314-
/*key*/ docKey,
2315-
/*value*/ {},
2316-
/*priv_bytes*/ 0,
2317-
/*datatype*/ PROTOCOL_BINARY_RAW_BYTES,
2318-
/*cas*/ 0,
2319-
/*vbucket*/ vbid,
2320-
/*bySeqno*/ 1,
2321-
/*revSeqno*/ 0,
2322-
/*meta*/ meta);
2323-
2324-
auto messageSize = MutationResponse::deletionBaseMsgBytes + key.size() +
2325-
sizeof(extMeta);
2326-
2327-
EXPECT_EQ(messageSize, stream->responseMessageSize);
2328-
2329-
/* Close stream before deleting the connection */
2330-
ASSERT_EQ(ENGINE_SUCCESS, consumer->closeStream(/*opaque*/0, vbid));
2331-
2332-
destroy_mock_cookie(cookie);
2333-
}
2334-
2335-
// Tests that the MutationResponse created for the mutation response is of the
2336-
// correct size.
2337-
TEST_P(ConnectionTest, test_mb24424_mutationResponse) {
2338-
const void* cookie = create_mock_cookie(engine);
2339-
Vbid vbid = Vbid(0);
2340-
2341-
auto consumer =
2342-
std::make_shared<MockDcpConsumer>(*engine, cookie, "test_consumer");
2343-
2344-
ASSERT_EQ(ENGINE_SUCCESS, set_vb_state(vbid, vbucket_state_replica));
2345-
ASSERT_EQ(ENGINE_SUCCESS, consumer->addStream(/*opaque*/0, vbid,
2346-
/*flags*/0));
2347-
2348-
MockPassiveStream *stream = static_cast<MockPassiveStream*>
2349-
((consumer->
2350-
getVbucketStream(vbid)).get());
2351-
ASSERT_TRUE(stream->isActive());
2352-
2353-
std::string key = "key";
2354-
std::string data = R"({"json":"yes"})";
2355-
const DocKey docKey{reinterpret_cast<const uint8_t*>(key.data()),
2356-
key.size(),
2357-
DocKeyEncodesCollectionId::No};
2358-
cb::const_byte_buffer value{reinterpret_cast<const uint8_t*>(data.data()),
2359-
data.size()};
2360-
uint8_t extMeta[1] = {uint8_t(PROTOCOL_BINARY_DATATYPE_JSON)};
2361-
cb::const_byte_buffer meta{extMeta, sizeof(uint8_t)};
2362-
2363-
consumer->mutation(/*opaque*/1,
2364-
/*key*/docKey,
2365-
/*values*/value,
2366-
/*priv_bytes*/0,
2367-
/*datatype*/PROTOCOL_BINARY_DATATYPE_JSON,
2368-
/*cas*/0,
2369-
/*vbucket*/vbid,
2370-
/*flags*/0,
2371-
/*bySeqno*/1,
2372-
/*revSeqno*/0,
2373-
/*exptime*/0,
2374-
/*lock_time*/0,
2375-
/*meta*/meta,
2376-
/*nru*/0);
2377-
2378-
auto messageSize = MutationResponse::mutationBaseMsgBytes +
2379-
key.size() + data.size() + sizeof(extMeta);
2380-
2381-
EXPECT_EQ(messageSize, stream->responseMessageSize);
2382-
2383-
/* Close stream before deleting the connection */
2384-
ASSERT_EQ(ENGINE_SUCCESS, consumer->closeStream(/*opaque*/0, vbid));
2385-
2386-
destroy_mock_cookie(cookie);
2387-
}
2388-
23892288
TEST_P(ConnectionTest, ProducerEnablesDeleteXattr) {
23902289
const void* cookie = create_mock_cookie();
23912290

0 commit comments

Comments
 (0)