// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include #include #include #include #include #include #include #include LOG_SETUP(".storageservertest"); using namespace std::chrono_literals; namespace storage { struct StorageServerTest : public ::testing::Test { std::unique_ptr slobrok; std::unique_ptr distConfig; std::unique_ptr storConfig; StorageServerTest(); ~StorageServerTest() override; void SetUp() override; void TearDown() override; }; StorageServerTest::StorageServerTest() = default; StorageServerTest::~StorageServerTest() = default; namespace { struct Node { virtual ~Node() = default; virtual StorageNode& getNode() = 0; virtual StorageNodeContext& getContext() = 0; }; struct Distributor : public Node { DistributorProcess _process; explicit Distributor(vdstestlib::DirConfig& config); ~Distributor() override; StorageNode& getNode() override { return _process.getNode(); } StorageNodeContext& getContext() override { return _process.getContext(); } }; struct Storage : public Node { DummyServiceLayerProcess _process; StorageComponent::UP _component; explicit Storage(vdstestlib::DirConfig& config); ~Storage() override; StorageNode& getNode() override { return _process.getNode(); } StorageNodeContext& getContext() override { return _process.getContext(); } }; Distributor::Distributor(vdstestlib::DirConfig& config) : _process(config::ConfigUri(config.getConfigId())) { _process.setupConfig(60000ms); _process.createNode(); } Distributor::~Distributor() = default; Storage::Storage(vdstestlib::DirConfig& config) : _process(config::ConfigUri(config.getConfigId())) { _process.setupConfig(60000ms); _process.createNode(); _component = std::make_unique(getContext().getComponentRegister(), "test"); } Storage::~Storage() = default; } void StorageServerTest::SetUp() { [[maybe_unused]] int systemResult = system("chmod -R 755 vdsroot"); systemResult = system("rm -rf vdsroot*"); slobrok = std::make_unique(); distConfig = std::make_unique(getStandardConfig(false)); storConfig = std::make_unique(getStandardConfig(true)); addSlobrokConfig(*distConfig, *slobrok); addSlobrokConfig(*storConfig, *slobrok); systemResult = system("mkdir -p vdsroot/disks/d0"); systemResult = system("mkdir -p vdsroot.distributor"); } void StorageServerTest::TearDown() { // TODO wipe temp dirs 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); } }