aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/tests/persistence/filestorage/singlebucketjointest.cpp
blob: 28e82149b3779d21e4cbd9aff130ea4eda0259d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/log/log.h>
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/storageapi/message/bucket.h>
#include <vespa/storageapi/message/bucketsplitting.h>
#include <tests/persistence/common/persistenceproviderwrapper.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>

LOG_SETUP(".singlebucketjointest");

namespace storage {

class SingleBucketJoinTest : public FileStorTestFixture
{
public:
    void testPersistenceCanHandleSingleBucketJoin();

    CPPUNIT_TEST_SUITE(SingleBucketJoinTest);
    CPPUNIT_TEST(testPersistenceCanHandleSingleBucketJoin);
    CPPUNIT_TEST_SUITE_END();
};

CPPUNIT_TEST_SUITE_REGISTRATION(SingleBucketJoinTest);

void
SingleBucketJoinTest::testPersistenceCanHandleSingleBucketJoin()
{
    TestFileStorComponents c(*this, "testPersistenceCanHandleSingleBucketJoin");
    document::BucketId targetBucket(16, 1);
    document::BucketId sourceBucket(17, 1);

    createBucket(sourceBucket);
    // Make sure it's not empty
    c.sendPut(sourceBucket, DocumentIndex(0), PutTimestamp(1000));
    expectOkReply<api::PutReply>(c.top);
    c.top.getRepliesOnce();

    auto cmd = std::make_shared<api::JoinBucketsCommand>(targetBucket);
    cmd->getSourceBuckets().push_back(sourceBucket);
    cmd->getSourceBuckets().push_back(sourceBucket);

    c.top.sendDown(cmd);
    // If single bucket join locking is not working properly, this
    // will hang forever.
    expectOkReply<api::JoinBucketsReply>(c.top);
}

} // namespace storage