blob: 5e50fff8f94a9eca8aa038235f4e34d4bc422e26 (
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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <tests/testhelper.h>
#include <vespa/storage/storageserver/distributornode.h>
#include <vespa/storage/storageserver/servicelayernode.h>
#include <vespa/storageserver/app/distributorprocess.h>
#include <vespa/storageserver/app/dummyservicelayerprocess.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/log/log.h>
LOG_SETUP(".storageservertest");
namespace storage {
struct StorageServerTest : public ::testing::Test {
std::unique_ptr<mbus::Slobrok> slobrok;
std::unique_ptr<vdstestlib::DirConfig> distConfig;
std::unique_ptr<vdstestlib::DirConfig> storConfig;
StorageServerTest();
~StorageServerTest();
void SetUp() override;
void TearDown() override;
};
StorageServerTest::StorageServerTest() = default;
StorageServerTest::~StorageServerTest() = default;
namespace {
struct Node {
virtual ~Node() {}
virtual StorageNode& getNode() = 0;
virtual StorageNodeContext& getContext() = 0;
};
struct Distributor : public Node {
DistributorProcess _process;
Distributor(vdstestlib::DirConfig& config);
~Distributor();
virtual StorageNode& getNode() override { return _process.getNode(); }
virtual StorageNodeContext& getContext() override { return _process.getContext(); }
};
struct Storage : public Node {
DummyServiceLayerProcess _process;
StorageComponent::UP _component;
Storage(vdstestlib::DirConfig& config);
~Storage();
virtual StorageNode& getNode() override { return _process.getNode(); }
virtual StorageNodeContext& getContext() override { return _process.getContext(); }
};
Distributor::Distributor(vdstestlib::DirConfig& config)
: _process(config.getConfigId())
{
_process.setupConfig(60000);
_process.createNode();
}
Distributor::~Distributor() = default;
Storage::Storage(vdstestlib::DirConfig& config)
: _process(config.getConfigId())
{
_process.setupConfig(60000);
_process.createNode();
_component.reset(new StorageComponent(
getContext().getComponentRegister(), "test"));
}
Storage::~Storage() = default;
}
void
StorageServerTest::SetUp()
{
[[maybe_unused]] int systemResult = system("chmod -R 755 vdsroot");
systemResult = system("rm -rf vdsroot*");
slobrok.reset(new mbus::Slobrok);
distConfig.reset(new vdstestlib::DirConfig(getStandardConfig(false)));
storConfig.reset(new vdstestlib::DirConfig(getStandardConfig(true)));
addSlobrokConfig(*distConfig, *slobrok);
addSlobrokConfig(*storConfig, *slobrok);
storConfig->getConfig("stor-filestor").set("fail_disk_after_error_count", "1");
systemResult = system("mkdir -p vdsroot/disks/d0");
systemResult = system("mkdir -p vdsroot.distributor");
}
void
StorageServerTest::TearDown()
{
storConfig.reset(nullptr);
distConfig.reset(nullptr);
slobrok.reset(nullptr);
}
TEST_F(StorageServerTest, distributor_server_can_be_instantiated)
{
Distributor distServer(*distConfig);
}
TEST_F(StorageServerTest, storage_server_can_be_instantiated)
{
Storage storServer(*storConfig);
}
}
|