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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/fastos/fastos.h>
#include <cppunit/extensions/HelperMacros.h>
#include <iomanip>
#include <iostream>
#include <memory>
#include <tests/common/dummystoragelink.h>
#include <vespa/storageapi/message/removelocation.h>
#include <vespa/storage/distributor/operations/external/removelocationoperation.h>
#include <tests/distributor/distributortestutil.h>
namespace storage {
namespace distributor {
class RemoveLocationOperationTest : public CppUnit::TestFixture,
public DistributorTestUtil
{
CPPUNIT_TEST_SUITE(RemoveLocationOperationTest);
CPPUNIT_TEST(testSimple);
CPPUNIT_TEST_SUITE_END();
protected:
void testSimple();
public:
std::unique_ptr<RemoveLocationOperation> op;
void setUp() {
createLinks();
};
void tearDown() {
close();
}
void sendRemoveLocation(const std::string& selection) {
std::shared_ptr<api::RemoveLocationCommand> msg(
new api::RemoveLocationCommand(selection, document::BucketId(0)));
op.reset(new RemoveLocationOperation(getExternalOperationHandler(),
msg,
getDistributor().getMetrics().
removelocations[msg->getLoadType()]));
op->start(_sender, framework::MilliSecTime(0));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(RemoveLocationOperationTest);
void
RemoveLocationOperationTest::testSimple()
{
_distributor->enableClusterState(lib::ClusterState("distributor:1 storage:3"));
addNodesToBucketDB(document::BucketId(34, 0x000001234), "0=1,1=1");
addNodesToBucketDB(document::BucketId(34, 0x100001234), "0=1,2=1");
addNodesToBucketDB(document::BucketId(34, 0x200001234), "0=1,2=1");
addNodesToBucketDB(document::BucketId(34, 0x300001234), "1=1,2=1");
sendRemoveLocation("id.user=4660");
CPPUNIT_ASSERT_EQUAL(
std::string("Remove selection(id.user=4660): BucketInfoCommand() => 0,"
"Remove selection(id.user=4660): BucketInfoCommand() => 1,"
"Remove selection(id.user=4660): BucketInfoCommand() => 0,"
"Remove selection(id.user=4660): BucketInfoCommand() => 2,"
"Remove selection(id.user=4660): BucketInfoCommand() => 0,"
"Remove selection(id.user=4660): BucketInfoCommand() => 2,"
"Remove selection(id.user=4660): BucketInfoCommand() => 1,"
"Remove selection(id.user=4660): BucketInfoCommand() => 2"),
_sender.getCommands(true, true));
for (uint32_t i = 0; i < 8; ++i) {
sendReply(*op, i);
}
CPPUNIT_ASSERT_EQUAL(
std::string("BucketInfoReply(BucketInfo(invalid)) ReturnCode(NONE)"),
_sender.getLastReply());
}
} // distributor
} // storage
|