Skip to content

Commit 575919e

Browse files
committed
MB-19672: Fix intermittent failure of 'test producer stream request (partial)'
This test was making incorrect assumptions about how / when checkpoints would be created - it wasn't taking the checkpoint period (how often we forcefully create new checkpoints) into account in it's assuptions of checkpoint layout. As such it would occasionally fail if it took longer than expected to run. Fix this by essentially disabling chk_period (setting it to an arbitrarily large value). At the same time make the tests expectations explicit and check them where possible. Change-Id: I9944f19d41a0a33064c9c43c8673c7ef9c4a3ab9 Reviewed-on: http://review.couchbase.org/69233 Reviewed-by: Manu Dhundi <manu@couchbase.com> Tested-by: buildbot <build@couchbase.com>
1 parent 1e0e8ea commit 575919e

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

tests/ep_testsuite_dcp.cc

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,36 +1533,65 @@ static enum test_result test_dcp_consumer_noop(ENGINE_HANDLE *h,
15331533

15341534
static enum test_result test_dcp_producer_stream_req_partial(ENGINE_HANDLE *h,
15351535
ENGINE_HANDLE_V1 *h1) {
1536-
const int num_items = 200;
1537-
write_items(h, h1, num_items);
15381536

1537+
// Should start at checkpoint_id 2
1538+
const auto initial_ckpt_id = get_int_stat(h, h1, "vb_0:open_checkpoint_id",
1539+
"checkpoint");
1540+
checkeq(2, initial_ckpt_id, "Expected to start at checkpoint ID 2");
1541+
1542+
// Create two 'full' checkpoints by storing exactly 2 x 'chk_max_items'
1543+
// into the VBucket.
1544+
const auto max_ckpt_items = get_int_stat(h, h1, "ep_chk_max_items");
1545+
1546+
write_items(h, h1, max_ckpt_items);
15391547
wait_for_flusher_to_settle(h, h1);
1540-
stop_persistence(h, h1);
1548+
wait_for_stat_to_be(h, h1, "ep_items_rm_from_checkpoints", max_ckpt_items);
1549+
checkeq(initial_ckpt_id + 1,
1550+
get_int_stat(h, h1, "vb_0:open_checkpoint_id", "checkpoint"),
1551+
"Expected #checkpoints to increase by 1 after storing items");
15411552

1542-
// Ensure all 200 items are removed from the checkpoint queues
1543-
// to avoid any de-duplication with the delete ops that follow
1544-
wait_for_stat_to_be(h, h1, "ep_items_rm_from_checkpoints", 200);
1553+
write_items(h, h1, max_ckpt_items, max_ckpt_items);
1554+
wait_for_flusher_to_settle(h, h1);
1555+
wait_for_stat_to_be(h, h1, "ep_items_rm_from_checkpoints", max_ckpt_items * 2);
1556+
checkeq(initial_ckpt_id + 2,
1557+
get_int_stat(h, h1, "vb_0:open_checkpoint_id", "checkpoint"),
1558+
"Expected #checkpoints to increase by 2 after storing 2x max_ckpt_items");
1559+
1560+
// Stop persistece (so the persistence cursor cannot advance into the
1561+
// deletions below, and hence de-dupe them with respect to the
1562+
// additions we just did).
1563+
stop_persistence(h, h1);
15451564

1546-
for (int j = 0; j < (num_items / 2); ++j) {
1565+
// Now delete half of the keys. Given that we have reached the
1566+
// maximum checkpoint size above, all the deletes should be in a
1567+
// subsequent checkpoint.
1568+
for (int j = 0; j < max_ckpt_items; ++j) {
15471569
std::stringstream ss;
15481570
ss << "key" << j;
15491571
checkeq(ENGINE_SUCCESS,
15501572
del(h, h1, ss.str().c_str(), 0, 0),
15511573
"Expected delete to succeed");
15521574
}
15531575

1554-
wait_for_stat_to_be(h, h1, "vb_0:num_checkpoints", 2, "checkpoint");
1555-
15561576
const void *cookie = testHarness.create_cookie();
15571577

1578+
// Verify that we recieve full checkpoints when we only ask for
1579+
// sequence numbers which lie within partial checkpoints. We
1580+
// should have the following Checkpoints in existence:
1581+
//
1582+
// { 1,100} - MUTATE(key0..key99), from disk.
1583+
// {101,200} - MUTATE(key100.key199), from disk.
1584+
// {201,300} - DELETE(key0..key99), in memory (as persistence has been stopped).
1585+
//
1586+
// We request a start and end which lie in the middle of checkpoints -
1587+
// start at 95 and end at 209. We should recieve to the end of
1588+
// complete checkpoints, i.e. from 95 all the way to 300.
15581589
DcpStreamCtx ctx;
15591590
ctx.vb_uuid = get_ull_stat(h, h1, "vb_0:0:id", "failovers");
15601591
ctx.seqno = {95, 209};
15611592
ctx.snapshot = {95, 95};
1562-
// Note that more than the expected number of items (mutations +
1563-
// deletions) will be sent, because of current design.
1564-
ctx.exp_mutations = 105;
1565-
ctx.exp_deletions = 100;
1593+
ctx.exp_mutations = 105; // 95 to 200
1594+
ctx.exp_deletions = 100; // 201 to 300
15661595
ctx.exp_markers = 2;
15671596

15681597
TestDcpConsumer tdc("unittest", cookie);
@@ -5480,7 +5509,10 @@ BaseTestCase testsuite_testcases[] = {
54805509
prepare, cleanup),
54815510
TestCase("test producer stream request (partial)",
54825511
test_dcp_producer_stream_req_partial, test_setup, teardown,
5483-
"chk_remover_stime=1;chk_max_items=100", prepare, cleanup),
5512+
/* set chk_period to essentially infinity so it won't run
5513+
during this test and create extra checkpoints we don't want.*/
5514+
"chk_remover_stime=1;chk_max_items=100;"
5515+
"chk_period=1000000", prepare, cleanup),
54845516
TestCase("test producer stream request (full)",
54855517
test_dcp_producer_stream_req_full, test_setup, teardown,
54865518
"chk_remover_stime=1;chk_max_items=100", prepare, cleanup),

0 commit comments

Comments
 (0)