summaryrefslogtreecommitdiffstats
path: root/filedistribution/src/tests/filedbmodelimpl/test-filedistributionmodelimpl.cpp
blob: 1ef347889589ac7c4b10ed249b158efd0a3d1091 (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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE filedbmodelimpl test
#include <boost/test/unit_test.hpp>

#include <iostream>
#include <vector>
#include <vespa/filedistribution/common/componentsdeleter.h>
#include <vespa/filedistribution/model/filedistributionmodelimpl.h>
#include <vespa/filedistribution/model/zkfacade.h>
#include <zookeeper/zookeeper.h>


using namespace filedistribution;


namespace {


struct Fixture {
    ComponentsDeleter _componentsDeleter;
    std::shared_ptr<ZKFacade> _zk;
    std::shared_ptr<FileDistributionModelImpl> _distModel;
    Fixture() {
        _zk = _componentsDeleter.track(new ZKFacade("test1-tonyv:2181", false));
        _distModel.reset(new FileDistributionModelImpl("hostname", 12345, _zk));       
     }
    ~Fixture() { }
};

} //anonymous namespace


BOOST_FIXTURE_TEST_SUITE(FileDistributionModelImplTests, Fixture)

BOOST_AUTO_TEST_CASE(configServersAsPeers)
{
    std::vector<std::string> peers;
    peers.push_back("old");
    peers.push_back("config:123");
    peers.push_back("config:567");
    peers.push_back("foo:123");
    _distModel->addConfigServersAsPeers(peers, "config,configTwo", 123);
    BOOST_CHECK(peers.size() == 5);
    BOOST_CHECK(peers[4] == "configTwo:123");
    _distModel->addConfigServersAsPeers(peers, NULL, 123);
    BOOST_CHECK(peers.size() == 5);
}

BOOST_AUTO_TEST_SUITE_END()