Skip to content

Commit 645f02e

Browse files
committed
MB-47318: [BP] Add disabled tests for the issue
Note: The original commit that the new tests were part of was reverted due to a flaw in the accompanying fix. This back-ported commit skips the flawed fix and just includes the unit tests and supporting test code. Change-Id: Iec0f35e37377280961b8f7d923c99c797ab2fdb8 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/166226 Well-Formed: Restriction Checker Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 08f5eb9 commit 645f02e

File tree

7 files changed

+406
-19
lines changed

7 files changed

+406
-19
lines changed

protocol/connection/client_connection.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,8 @@ void MemcachedConnection::recvDcpBufferAck(uint32_t expected) {
16251625
cb::mcbp::ClientOpcode::DcpBufferAcknowledgement) {
16261626
throw std::logic_error(
16271627
"MemcachedConnection::recvDcpBufferAck not a buffer ack "
1628-
"opcode");
1628+
"opcode request:" +
1629+
request->toJSON(request->isValid()).dump());
16291630
}
16301631
auto* dcpBufferAck =
16311632
reinterpret_cast<const cb::mcbp::request::DcpBufferAckPayload*>(

tests/testapp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ set(memcached_testapp_SOURCES
3636
testapp_cmd_timers.cc
3737
testapp_collections.cc
3838
testapp_dcp.cc
39+
testapp_dcp_consumer.cc
3940
testapp_durability.cc
4041
testapp_environment.cc
4142
testapp_environment.h

tests/testapp/testapp.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ std::string to_string(ClientSnappySupport snappy) {
134134
std::to_string(int(snappy)));
135135
}
136136

137-
void TestappTest::CreateTestBucket() {
137+
void TestappTest::CreateTestBucket(const std::string& bucketConf) {
138138
auto& conn = connectionMap.getConnection(false);
139139

140140
// Reconnect to the server so we know we're on a "fresh" connection
@@ -143,7 +143,7 @@ void TestappTest::CreateTestBucket() {
143143
conn.reconnect();
144144
conn.authenticate("@admin", "password", "PLAIN");
145145

146-
mcd_env->getTestBucket().setUpBucket(bucketName, "", conn);
146+
mcd_env->getTestBucket().setUpBucket(bucketName, bucketConf, conn);
147147

148148
// Reconnect the object to avoid others to reuse the admin creds
149149
conn.reconnect();
@@ -168,8 +168,13 @@ TestBucketImpl& TestappTest::GetTestBucket() {
168168
// Per-test-case set-up.
169169
// Called before the first test in this test case.
170170
void TestappTest::SetUpTestCase() {
171+
doSetUpTestCaseWithConfiguration(generate_config(0));
172+
}
173+
174+
void TestappTest::doSetUpTestCaseWithConfiguration(
175+
nlohmann::json config, const std::string& bucketConf) {
171176
token = 0xdeadbeef;
172-
memcached_cfg = generate_config(0);
177+
memcached_cfg = std::move(config);
173178
start_memcached_server();
174179

175180
if (HasFailure()) {
@@ -178,7 +183,7 @@ void TestappTest::SetUpTestCase() {
178183

179184
exit(EXIT_FAILURE);
180185
} else {
181-
CreateTestBucket();
186+
CreateTestBucket(bucketConf);
182187
}
183188
}
184189

tests/testapp/testapp.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ class TestappTest : public ::testing::Test {
9696
static cb::mcbp::Status sasl_auth(const char* username,
9797
const char* password);
9898

99+
/// Do the per-test-case set up with the provided configuration
100+
/// (start the server with the provided configuration and define the
101+
/// default bucket and terminate the process if we fail to do so)
102+
static void doSetUpTestCaseWithConfiguration(
103+
nlohmann::json config, const std::string& bucketConf = "");
104+
99105
/// Helper which which returns true if the specified value is correctly
100106
/// encoded as JSON.
101107
static bool isJSON(cb::const_char_buffer value);
@@ -203,7 +209,7 @@ class TestappTest : public ::testing::Test {
203209
static void stop_memcached_server();
204210

205211
// Create the bucket used for testing
206-
static void CreateTestBucket();
212+
static void CreateTestBucket(const std::string& bucketConf = "");
207213

208214
// Delete the bucket used for testing.
209215
static void DeleteTestBucket();

tests/testapp/testapp_client_test.cc

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ MemcachedConnection& TestappClientTest::getConnection() {
3535

3636
void TestappXattrClientTest::setBodyAndXattr(
3737
const std::string& startValue,
38-
std::initializer_list<std::pair<std::string, std::string>> xattrList,
38+
std::initializer_list<std::pair<const std::string, std::string>>
39+
xattrList,
3940
bool compressValue) {
4041
document.info.flags = 0xcaffee;
4142
document.info.id = name;
@@ -45,17 +46,10 @@ void TestappXattrClientTest::setBodyAndXattr(
4546
// Combine the body and Extended Attribute into a single value -
4647
// this allows us to store already compressed documents which
4748
// have XATTRs.
48-
cb::xattr::Blob xattrs;
49-
for (auto& kv : xattrList) {
50-
xattrs.set(kv.first, kv.second);
51-
}
52-
auto encoded = xattrs.finalize();
53-
ASSERT_TRUE(cb::xattr::validate(encoded)) << "Invalid xattr encoding";
5449
document.info.cas = 10; // withMeta requires a non-zero CAS.
5550
document.info.datatype = cb::mcbp::Datatype::Xattr;
56-
document.value = {reinterpret_cast<char*>(encoded.data()),
57-
encoded.size()};
58-
document.value.append(startValue);
51+
document.value =
52+
cb::xattr::make_wire_encoded_string(startValue, xattrList);
5953
if (compressValue) {
6054
// Compress the complete body.
6155
document.compress();
@@ -95,7 +89,8 @@ void TestappXattrClientTest::setBodyAndXattr(
9589

9690
void TestappXattrClientTest::setBodyAndXattr(
9791
const std::string& value,
98-
std::initializer_list<std::pair<std::string, std::string>> xattrList) {
92+
std::initializer_list<std::pair<const std::string, std::string>>
93+
xattrList) {
9994
setBodyAndXattr(
10095
value, xattrList, hasSnappySupport() == ClientSnappySupport::Yes);
10196
}

tests/testapp/testapp_client_test.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class TestappXattrClientTest : public TestappTest,
114114
*/
115115
void setBodyAndXattr(
116116
const std::string& startValue,
117-
std::initializer_list<std::pair<std::string, std::string>>
117+
std::initializer_list<std::pair<const std::string, std::string>>
118118
xattrList,
119119
bool compressValue);
120120

@@ -127,7 +127,7 @@ class TestappXattrClientTest : public TestappTest,
127127
*/
128128
void setBodyAndXattr(
129129
const std::string& value,
130-
std::initializer_list<std::pair<std::string, std::string>>
130+
std::initializer_list<std::pair<const std::string, std::string>>
131131
xattrList);
132132

133133
void setClusterSessionToken(uint64_t new_value);

0 commit comments

Comments
 (0)