Skip to content

Commit e499bd3

Browse files
Sriram Ganesandaverigby
authored andcommitted
MB-28685: Expand ep_testsuite value_eviction tests to passive mode
As part of expanding the different ep_testsuite tests to work in different compression modes, this change will support the different ep_testsuite value_eviction tests to passive compression mode Change-Id: I35960c4a36b1c323764c43be87c561d843831a6c Reviewed-on: http://review.couchbase.org/95449 Well-Formed: Build Bot <[email protected]> Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 075614a commit e499bd3

File tree

4 files changed

+60
-10
lines changed

4 files changed

+60
-10
lines changed

engines/ep/CMakeLists.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ if (COUCHBASE_KV_BUILD_UNIT_TESTS)
441441
tests/mock/mock_dcp.cc)
442442
SET_TARGET_PROPERTIES(ep_testsuite PROPERTIES PREFIX "")
443443
TARGET_LINK_LIBRARIES(ep_testsuite engine_utilities mcd_util
444-
${EP_STORAGE_LIBS} dirutils JSON_checker platform
445-
xattr
444+
${EP_STORAGE_LIBS} cbcompress dirutils JSON_checker
445+
platform xattr
446446
${LIBEVENT_LIBRARIES})
447447
ADD_DEPENDENCIES(ep_testsuite engine_testapp)
448448

@@ -455,7 +455,8 @@ if (COUCHBASE_KV_BUILD_UNIT_TESTS)
455455
)
456456
SET_TARGET_PROPERTIES(ep_testsuite_basic PROPERTIES PREFIX "")
457457
TARGET_LINK_LIBRARIES(ep_testsuite_basic engine_utilities JSON_checker dirutils
458-
platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
458+
cbcompress platform ${LIBEVENT_LIBRARIES}
459+
${SNAPPY_LIBRARIES})
459460
ADD_DEPENDENCIES(ep_testsuite engine_testapp)
460461

461462
ADD_LIBRARY(ep_testsuite_dcp SHARED
@@ -475,7 +476,9 @@ if (COUCHBASE_KV_BUILD_UNIT_TESTS)
475476
tests/ep_test_apis.cc
476477
src/ext_meta_parser.cc)
477478
SET_TARGET_PROPERTIES(ep_testsuite_checkpoint PROPERTIES PREFIX "")
478-
TARGET_LINK_LIBRARIES(ep_testsuite_checkpoint engine_utilities JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
479+
TARGET_LINK_LIBRARIES(ep_testsuite_checkpoint engine_utilities JSON_checker
480+
cbcompress dirutils platform ${LIBEVENT_LIBRARIES}
481+
${SNAPPY_LIBRARIES})
479482
ADD_DEPENDENCIES(ep_testsuite_checkpoint engine_testapp)
480483

481484
ADD_LIBRARY(ep_testsuite_xdcr SHARED
@@ -495,7 +498,7 @@ if (COUCHBASE_KV_BUILD_UNIT_TESTS)
495498
tests/ep_test_apis.cc
496499
tests/mock/mock_dcp.cc)
497500
SET_TARGET_PROPERTIES(ep_perfsuite PROPERTIES PREFIX "")
498-
TARGET_LINK_LIBRARIES(ep_perfsuite engine_utilities dirutils platform)
501+
TARGET_LINK_LIBRARIES(ep_perfsuite engine_utilities cbcompress dirutils platform)
499502
ADD_DEPENDENCIES(ep_perfsuite engine_testapp)
500503

501504
#ADD_CUSTOM_COMMAND(OUTPUT
@@ -584,11 +587,14 @@ if (COUCHBASE_KV_BUILD_UNIT_TESTS)
584587
${Memcached_BINARY_DIR}/engine_testapp
585588
-E $<TARGET_FILE:ep>
586589
-T $<TARGET_FILE:${name}>)
587-
ADD_TEST(NAME ${name}.value_eviction
588-
COMMAND ${_cmdline} -v -e "dbname=./${name}.value_eviction.db")
590+
ADD_TEST(NAME ${name}.value_eviction.comp_off
591+
COMMAND ${_cmdline} -v -e "compression_mode=off$<SEMICOLON>dbname=./${name}.value_eviction.comp_off.db")
592+
ADD_TEST(NAME ${name}.value_eviction.comp_passive
593+
COMMAND ${_cmdline} -v -e "compression_mode=passive$<SEMICOLON>dbname=./${name}.value_eviction.comp_passive.db")
589594
ADD_TEST(NAME ${name}.full_eviction
590595
COMMAND ${_cmdline} -v -e "item_eviction_policy=full_eviction$<SEMICOLON>dbname=./${name}.full_eviction.db")
591-
SET_TESTS_PROPERTIES(${name}.value_eviction PROPERTIES TIMEOUT ${timeout})
596+
SET_TESTS_PROPERTIES(${name}.value_eviction.comp_off PROPERTIES TIMEOUT ${timeout})
597+
SET_TESTS_PROPERTIES(${name}.value_eviction.comp_passive PROPERTIES TIMEOUT ${timeout})
592598
SET_TESTS_PROPERTIES(${name}.full_eviction PROPERTIES TIMEOUT ${timeout})
593599

594600
IF (NOT arg_SKIP_EPHEMERAL)

engines/ep/tests/ep_testsuite.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6905,6 +6905,12 @@ static enum test_result test_mb19687_fixed(ENGINE_HANDLE* h,
69056905
"ep_warmup_thread"});
69066906
}
69076907

6908+
if (isCompressionEnabled(h, h1)) {
6909+
auto& vb0_hash_stats = statsKeys.at("hash");
6910+
vb0_hash_stats.insert(vb0_hash_stats.end(),
6911+
{"vb_0:mem_size_uncompressed"});
6912+
}
6913+
69086914
if (isPersistentBucket(h, h1)) {
69096915
// Add data_size and file_size stats to toplevel group.
69106916
auto& eng_stats = statsKeys.at("");

engines/ep/tests/ep_testsuite_common.cc

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <sys/stat.h>
2727

2828
#include <platform/cb_malloc.h>
29+
#include <platform/compress.h>
2930
#include <platform/dirutils.h>
3031

3132
const char *dbname_env = NULL;
@@ -448,8 +449,36 @@ void check_key_value(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1,
448449
uint16_t vbucket) {
449450
item_info info;
450451
check(get_item_info(h, h1, &info, key, vbucket), "checking key and value");
451-
checkeq(vlen, info.value[0].iov_len, "Value length mismatch");
452-
check(memcmp(info.value[0].iov_base, val, vlen) == 0, "Data mismatch");
452+
453+
cb::const_char_buffer payload;
454+
cb::compression::Buffer inflated;
455+
if (isCompressionEnabled(h, h1) &&
456+
(info.datatype & PROTOCOL_BINARY_DATATYPE_SNAPPY)) {
457+
cb::compression::inflate(cb::compression::Algorithm::Snappy,
458+
{static_cast<const char *>(info.value[0].iov_base),
459+
info.value[0].iov_len},
460+
inflated);
461+
payload = inflated;
462+
} else {
463+
payload = {static_cast<const char *>(info.value[0].iov_base),
464+
info.value[0].iov_len};
465+
}
466+
467+
checkeq(vlen, payload.size(), "Value length mismatch");
468+
check(memcmp(payload.data(), val, vlen) == 0, "Data mismatch");
469+
}
470+
471+
bool isCompressionEnabled(ENGINE_HANDLE* h, ENGINE_HANDLE_V1* h1) {
472+
return (isPassiveCompressionEnabled(h, h1) ||
473+
isActiveCompressionEnabled(h, h1));
474+
}
475+
476+
bool isActiveCompressionEnabled(ENGINE_HANDLE* h, ENGINE_HANDLE_V1* h1) {
477+
return get_str_stat(h, h1, "ep_compression_mode") == "active";
478+
}
479+
480+
bool isPassiveCompressionEnabled(ENGINE_HANDLE* h, ENGINE_HANDLE_V1* h1) {
481+
return get_str_stat(h, h1, "ep_compression_mode") == "passive";
453482
}
454483

455484
bool isWarmupEnabled(ENGINE_HANDLE* h, ENGINE_HANDLE_V1* h1) {

engines/ep/tests/ep_testsuite_common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,15 @@ void check_key_value(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1,
278278

279279
std::string get_dbname(const char* test_cfg);
280280

281+
// Returns true if Compression is enabled for the given engine.
282+
bool isCompressionEnabled(ENGINE_HANDLE* h, ENGINE_HANDLE_V1* h1);
283+
284+
// Returns true if passive compression is enabled for the given engine.
285+
bool isPassiveCompressionEnabled(ENGINE_HANDLE* h, ENGINE_HANDLE_V1* h1);
286+
287+
// Returns true if active compression is enabled for the given engine.
288+
bool isActiveCompressionEnabled(ENGINE_HANDLE* h, ENGINE_HANDLE_V1* h1);
289+
281290
// Returns true if Warmup is enabled for the given engine.
282291
bool isWarmupEnabled(ENGINE_HANDLE* h, ENGINE_HANDLE_V1* h1);
283292

0 commit comments

Comments
 (0)