summaryrefslogtreecommitdiffstats
path: root/storage/src/tests/persistence/diskmoveoperationhandlertest.cpp
blob: 0dd3285e5f390c5e776ae18aeed5428aa9fe8acd (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/storage/persistence/diskmoveoperationhandler.h>
#include <vespa/storage/persistence/messages.h>
#include <tests/persistence/persistencetestutils.h>
#include <vespa/document/test/make_document_bucket.h>

using document::test::makeDocumentBucket;
using namespace ::testing;

namespace storage {

struct DiskMoveOperationHandlerTest : PersistenceTestUtils {};

TEST_F(DiskMoveOperationHandlerTest, simple) {
    setupDisks(10);

    // Create bucket 16, 4 on disk 3.
    {
        StorBucketDatabase::WrappedEntry entry(
                createBucket(document::BucketId(16, 4)));
        entry->disk = 3;
        entry.write();
    }

    for (uint32_t i = 0; i < 10; i++) {
        doPutOnDisk(3, 4, spi::Timestamp(1000 + i));
    }

    DiskMoveOperationHandler diskMoveHandler(
            getEnv(3),
            getPersistenceProvider());
    BucketDiskMoveCommand move(makeDocumentBucket(document::BucketId(16, 4)), 3, 4);

    spi::Context context(documentapi::LoadType::DEFAULT, 0, 0);
    diskMoveHandler.handleBucketDiskMove(move, context);

    EXPECT_EQ("BucketId(0x4000000000000004): 10,4",
              getBucketStatus(document::BucketId(16,4)));
}

}