Skip to content

Commit 29e81ae

Browse files
committed
Move MockDcpConsumer defns to .cc
Move large method definitions of MockDcpConsumer to their own .cc file. Change-Id: Idda8ff95a3040450158f57083310db4940723e7d Reviewed-on: http://review.couchbase.org/113437 Tested-by: Build Bot <[email protected]> Reviewed-by: James Harrison <[email protected]>
1 parent 97b606f commit 29e81ae

File tree

10 files changed

+77
-29
lines changed

10 files changed

+77
-29
lines changed

engines/ep/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ if (NOT EP_BYPASS_TESTS)
317317

318318
add_library(ep_mocks OBJECT
319319
tests/mock/mock_dcp_conn_map.cc
320+
tests/mock/mock_dcp_consumer.cc
320321
tests/mock/mock_dcp_producer.cc
321322
tests/mock/mock_ep_bucket.cc
322323
tests/mock/mock_ephemeral_bucket.cc
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2+
/*
3+
* Copyright 2019 Couchbase, Inc
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "mock_dcp_consumer.h"
19+
#include "dcp/response.h"
20+
#include "mock_stream.h"
21+
22+
MockDcpConsumer::MockDcpConsumer(EventuallyPersistentEngine& theEngine,
23+
const void* cookie,
24+
const std::string& name,
25+
const std::string& consumerName)
26+
: DcpConsumer(theEngine, cookie, name, consumerName) {
27+
}
28+
29+
std::shared_ptr<PassiveStream> MockDcpConsumer::makePassiveStream(
30+
EventuallyPersistentEngine& e,
31+
std::shared_ptr<DcpConsumer> consumer,
32+
const std::string& name,
33+
uint32_t flags,
34+
uint32_t opaque,
35+
Vbid vb,
36+
uint64_t start_seqno,
37+
uint64_t end_seqno,
38+
uint64_t vb_uuid,
39+
uint64_t snap_start_seqno,
40+
uint64_t snap_end_seqno,
41+
uint64_t vb_high_seqno,
42+
const Collections::ManifestUid vb_manifest_uid) {
43+
return std::make_shared<MockPassiveStream>(e,
44+
consumer,
45+
name,
46+
flags,
47+
opaque,
48+
vb,
49+
start_seqno,
50+
end_seqno,
51+
vb_uuid,
52+
snap_start_seqno,
53+
snap_end_seqno,
54+
vb_high_seqno,
55+
vb_manifest_uid);
56+
}
57+
58+
boost::optional<uint32_t> MockDcpConsumer::getStreamOpaque(uint32_t opaque) {
59+
for (const auto& pair : opaqueMap_) {
60+
if (pair.second.first == opaque) {
61+
return pair.first;
62+
}
63+
}
64+
return {};
65+
}

engines/ep/tests/mock/mock_dcp_consumer.h

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
#pragma once
1919

2020
#include "dcp/consumer.h"
21-
#include "mock_stream.h"
2221

23-
#include <boost/optional.hpp>
22+
#include <boost/optional/optional_fwd.hpp>
2423

2524
/*
2625
* Mock of the DcpConsumer class. Wraps the real DcpConsumer class
@@ -31,9 +30,7 @@ class MockDcpConsumer: public DcpConsumer {
3130
MockDcpConsumer(EventuallyPersistentEngine& theEngine,
3231
const void* cookie,
3332
const std::string& name,
34-
const std::string& consumerName = {})
35-
: DcpConsumer(theEngine, cookie, name, consumerName) {
36-
}
33+
const std::string& consumerName = {});
3734

3835
void setPendingAddStream(bool value) {
3936
// The unit tests was written before memcached marked the
@@ -94,21 +91,7 @@ class MockDcpConsumer: public DcpConsumer {
9491
uint64_t snap_start_seqno,
9592
uint64_t snap_end_seqno,
9693
uint64_t vb_high_seqno,
97-
const Collections::ManifestUid vb_manifest_uid) override {
98-
return std::make_shared<MockPassiveStream>(e,
99-
consumer,
100-
name,
101-
flags,
102-
opaque,
103-
vb,
104-
start_seqno,
105-
end_seqno,
106-
vb_uuid,
107-
snap_start_seqno,
108-
snap_end_seqno,
109-
vb_high_seqno,
110-
vb_manifest_uid);
111-
}
94+
const Collections::ManifestUid vb_manifest_uid) override;
11295

11396
/**
11497
* @return the opaque sent to the Producer as part of the DCP_CONTROL
@@ -149,14 +132,7 @@ class MockDcpConsumer: public DcpConsumer {
149132
* the value that will be used for the opaque of a given stream, use this
150133
* map to get the correct value.
151134
*/
152-
boost::optional<uint32_t> getStreamOpaque(uint32_t opaque) {
153-
for (const auto& pair : opaqueMap_) {
154-
if (pair.second.first == opaque) {
155-
return pair.first;
156-
}
157-
}
158-
return {};
159-
}
135+
boost::optional<uint32_t> getStreamOpaque(uint32_t opaque);
160136

161137
void public_streamAccepted(uint32_t opaque,
162138
cb::mcbp::Status status,

engines/ep/tests/module_tests/checkpoint_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "../mock/mock_checkpoint_manager.h"
3333
#include "../mock/mock_dcp_consumer.h"
34+
#include "../mock/mock_stream.h"
3435
#include "../mock/mock_synchronous_ep_engine.h"
3536

3637
#include <folly/portability/GMock.h>

engines/ep/tests/module_tests/collections/evp_store_collections_dcp_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "tests/mock/mock_dcp_consumer.h"
3030
#include "tests/mock/mock_dcp_producer.h"
3131
#include "tests/mock/mock_global_task.h"
32+
#include "tests/mock/mock_stream.h"
3233
#include "tests/mock/mock_synchronous_ep_engine.h"
3334
#include "tests/module_tests/collections/collections_dcp_test.h"
3435
#include "tests/module_tests/collections/test_manifest.h"

engines/ep/tests/module_tests/dcp_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "../mock/mock_dcp_conn_map.h"
2929
#include "../mock/mock_dcp_consumer.h"
3030
#include "../mock/mock_dcp_producer.h"
31+
#include "../mock/mock_stream.h"
3132
#include "../mock/mock_synchronous_ep_engine.h"
3233
#include "checkpoint.h"
3334
#include "checkpoint_manager.h"

engines/ep/tests/module_tests/ephemeral_bucket_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
#include "../mock/mock_checkpoint_manager.h"
2828
#include "../mock/mock_dcp_consumer.h"
29+
#include "../mock/mock_dcp_producer.h"
30+
#include "../mock/mock_stream.h"
2931
#include "../mock/mock_synchronous_ep_engine.h"
3032

3133
/*

engines/ep/tests/module_tests/evp_store_rollback_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "tests/mock/mock_checkpoint_manager.h"
3535
#include "tests/mock/mock_dcp.h"
3636
#include "tests/mock/mock_dcp_consumer.h"
37+
#include "tests/mock/mock_stream.h"
3738
#include "tests/mock/mock_synchronous_ep_engine.h"
3839
#include "tests/module_tests/collections/test_manifest.h"
3940
#include "tests/module_tests/test_helpers.h"

engines/ep/tests/module_tests/evp_store_test.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
#pragma once
2525

26-
#include "ep_bucket.h"
2726
#include "kv_bucket_test.h"
2827

2928
/**

engines/ep/tests/module_tests/kv_bucket_test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#pragma once
2727

2828
#include "callbacks.h"
29+
#include "ep_types.h"
2930

3031
#include <folly/portability/GTest.h>
3132
#include <memcached/protocol_binary.h>

0 commit comments

Comments
 (0)