summaryrefslogtreecommitdiffstats
path: root/filedistribution/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'filedistribution/src/tests')
-rw-r--r--filedistribution/src/tests/.gitignore2
-rw-r--r--filedistribution/src/tests/common/.gitignore1
-rw-r--r--filedistribution/src/tests/common/CMakeLists.txt13
-rw-r--r--filedistribution/src/tests/common/testCommon.cpp41
-rw-r--r--filedistribution/src/tests/filedbmodelimpl/.gitignore1
-rw-r--r--filedistribution/src/tests/filedbmodelimpl/CMakeLists.txt16
-rw-r--r--filedistribution/src/tests/filedbmodelimpl/test-filedistributionmodelimpl.cpp51
-rw-r--r--filedistribution/src/tests/filedownloader/.gitignore1
-rw-r--r--filedistribution/src/tests/filedownloader/CMakeLists.txt15
-rw-r--r--filedistribution/src/tests/filedownloader/testfiledownloader.cpp143
-rw-r--r--filedistribution/src/tests/lib/CMakeLists.txt6
-rw-r--r--filedistribution/src/tests/lib/mock-zookeeper.cpp327
-rw-r--r--filedistribution/src/tests/rpc/.gitignore1
-rw-r--r--filedistribution/src/tests/rpc/CMakeLists.txt15
-rw-r--r--filedistribution/src/tests/rpc/mockfileprovider.h49
-rw-r--r--filedistribution/src/tests/rpc/testfileprovider.cpp66
-rw-r--r--filedistribution/src/tests/scheduler/.gitignore1
-rw-r--r--filedistribution/src/tests/scheduler/CMakeLists.txt16
-rw-r--r--filedistribution/src/tests/scheduler/test-scheduler.cpp109
-rw-r--r--filedistribution/src/tests/status/.gitignore1
-rw-r--r--filedistribution/src/tests/status/CMakeLists.txt15
-rw-r--r--filedistribution/src/tests/status/test-status.cpp16
-rw-r--r--filedistribution/src/tests/zkfacade/.gitignore1
-rw-r--r--filedistribution/src/tests/zkfacade/CMakeLists.txt15
-rw-r--r--filedistribution/src/tests/zkfacade/test-zkfacade.cpp228
-rw-r--r--filedistribution/src/tests/zkfiledbmodel/.gitignore1
-rw-r--r--filedistribution/src/tests/zkfiledbmodel/CMakeLists.txt16
-rw-r--r--filedistribution/src/tests/zkfiledbmodel/test-zkfiledbmodel.cpp88
28 files changed, 0 insertions, 1255 deletions
diff --git a/filedistribution/src/tests/.gitignore b/filedistribution/src/tests/.gitignore
deleted file mode 100644
index ee50e13466c..00000000000
--- a/filedistribution/src/tests/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-*_test
diff --git a/filedistribution/src/tests/common/.gitignore b/filedistribution/src/tests/common/.gitignore
deleted file mode 100644
index 060721ea295..00000000000
--- a/filedistribution/src/tests/common/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-filedistribution_common_test_app
diff --git a/filedistribution/src/tests/common/CMakeLists.txt b/filedistribution/src/tests/common/CMakeLists.txt
deleted file mode 100644
index 9f142eec9e7..00000000000
--- a/filedistribution/src/tests/common/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(filedistribution_common_test_app TEST
- SOURCES
- testCommon.cpp
- DEPENDS
-)
-target_compile_options(filedistribution_common_test_app PRIVATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_DHT -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED)
-vespa_add_target_system_dependency(filedistribution_common_test_app boost boost_system${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_common_test_app boost boost_thread${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_common_test_app boost boost_program_options${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_common_test_app boost boost_filesystem${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_common_test_app boost boost_unit_test_framework${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_test(NAME filedistribution_common_test_app NO_VALGRIND COMMAND filedistribution_common_test_app)
diff --git a/filedistribution/src/tests/common/testCommon.cpp b/filedistribution/src/tests/common/testCommon.cpp
deleted file mode 100644
index 8ad17b6b7ce..00000000000
--- a/filedistribution/src/tests/common/testCommon.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2017 Yahoo Holdings. 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
-
-#include <vespa/filedistribution/common/buffer.h>
-
-#include <boost/test/unit_test.hpp>
-#include <string>
-
-namespace fd = filedistribution;
-
-const size_t bufferCapacity = 10;
-
-fd::Buffer
-getBuffer() {
- const char* test = "test";
- fd::Buffer buffer(test, test + strlen(test));
- buffer.reserve(bufferCapacity);
- buffer.push_back(0);
- return buffer;
-}
-
-BOOST_AUTO_TEST_CASE(bufferTest) {
- fd::Buffer buffer(getBuffer());
- BOOST_CHECK(buffer.begin() != 0);
- BOOST_CHECK_EQUAL(bufferCapacity, buffer.capacity());
- BOOST_CHECK_EQUAL(5u, buffer.size());
- BOOST_CHECK_EQUAL(std::string("test"), buffer.begin());
-}
-
-struct Callback {
- bool* _called;
- Callback(bool *called)
- :_called(called)
- {}
-
- void operator()(const std::string& str) {
- BOOST_CHECK_EQUAL("abcd", str);
- *_called = true;
- }
-};
diff --git a/filedistribution/src/tests/filedbmodelimpl/.gitignore b/filedistribution/src/tests/filedbmodelimpl/.gitignore
deleted file mode 100644
index 05a25df1258..00000000000
--- a/filedistribution/src/tests/filedbmodelimpl/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-filedistribution_filedbmodelimpl_test_app
diff --git a/filedistribution/src/tests/filedbmodelimpl/CMakeLists.txt b/filedistribution/src/tests/filedbmodelimpl/CMakeLists.txt
deleted file mode 100644
index a97cc9e4c7a..00000000000
--- a/filedistribution/src/tests/filedbmodelimpl/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(filedistribution_filedbmodelimpl_test_app TEST
- SOURCES
- test-filedistributionmodelimpl.cpp
- DEPENDS
- filedistribution_filedistributionmodel
- filedistribution_common
- filedistribution_mocks
-)
-target_compile_options(filedistribution_filedbmodelimpl_test_app PRIVATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_DHT -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED)
-vespa_add_target_system_dependency(filedistribution_filedbmodelimpl_test_app boost boost_system${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_filedbmodelimpl_test_app boost boost_thread${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_filedbmodelimpl_test_app boost boost_program_options${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_filedbmodelimpl_test_app boost boost_filesystem${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_filedbmodelimpl_test_app boost boost_unit_test_framework${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_test(NAME filedistribution_filedbmodelimpl_test_app NO_VALGRIND COMMAND filedistribution_filedbmodelimpl_test_app)
diff --git a/filedistribution/src/tests/filedbmodelimpl/test-filedistributionmodelimpl.cpp b/filedistribution/src/tests/filedbmodelimpl/test-filedistributionmodelimpl.cpp
deleted file mode 100644
index 1de7fc817ae..00000000000
--- a/filedistribution/src/tests/filedbmodelimpl/test-filedistributionmodelimpl.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2017 Yahoo Holdings. 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()
diff --git a/filedistribution/src/tests/filedownloader/.gitignore b/filedistribution/src/tests/filedownloader/.gitignore
deleted file mode 100644
index f7bb72b4791..00000000000
--- a/filedistribution/src/tests/filedownloader/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-filedistribution_filedownloader_test_app
diff --git a/filedistribution/src/tests/filedownloader/CMakeLists.txt b/filedistribution/src/tests/filedownloader/CMakeLists.txt
deleted file mode 100644
index 7bdfeda3525..00000000000
--- a/filedistribution/src/tests/filedownloader/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(filedistribution_filedownloader_test_app TEST
- SOURCES
- testfiledownloader.cpp
- DEPENDS
- filedistribution_filedistributionmodel
- filedistribution_common
-)
-target_compile_options(filedistribution_filedownloader_test_app PRIVATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_DHT -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED)
-vespa_add_target_system_dependency(filedistribution_filedownloader_test_app boost boost_system${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_filedownloader_test_app boost boost_thread${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_filedownloader_test_app boost boost_program_options${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_filedownloader_test_app boost boost_filesystem${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_filedownloader_test_app boost boost_unit_test_framework${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_test(NAME filedistribution_filedownloader_test_app NO_VALGRIND COMMAND filedistribution_filedownloader_test_app)
diff --git a/filedistribution/src/tests/filedownloader/testfiledownloader.cpp b/filedistribution/src/tests/filedownloader/testfiledownloader.cpp
deleted file mode 100644
index c03c6ca5e6c..00000000000
--- a/filedistribution/src/tests/filedownloader/testfiledownloader.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright 2017 Yahoo Holdings. 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
-
-#include <vespa/filedistribution/distributor/filedownloader.h>
-#include <vespa/filedistribution/distributor/filedistributortrackerimpl.h>
-
-#include <fstream>
-
-#include <boost/test/unit_test.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/filesystem/fstream.hpp>
-
-#include <vespa/filedistribution/manager/createtorrent.h>
-#include <vespa/filedistribution/common/componentsdeleter.h>
-
-namespace fs = boost::filesystem;
-
-using namespace filedistribution;
-
-namespace {
-const std::string localHost("localhost");
-const int uploaderPort = 9113;
-const int downloaderPort = 9112;
-
-#if 0
-std::shared_ptr<FileDownloader>
-createDownloader(ComponentsDeleter& deleter,
- int port, const fs::path& downloaderPath,
- const std::shared_ptr<FileDistributionModel>& model)
-{
- std::shared_ptr<FileDistributorTrackerImpl> tracker(deleter.track(new FileDistributorTrackerImpl(model)));
- std::shared_ptr<FileDownloader> downloader(deleter.track(new FileDownloader(tracker,
- localHost, port, downloaderPath)));
-
- tracker->setDownloader(downloader);
- return downloader;
-}
-#endif
-
-} //anonymous namespace
-
-class MockFileDistributionModel : public FileDistributionModel {
- FileDBModel& getFileDBModel() override {
- abort();
- }
-
- std::set<std::string> getFilesToDownload() override {
- return std::set<std::string>();
- }
-
- PeerEntries getPeers(const std::string& , size_t) override {
- PeerEntries peers(2);
- peers[0].ip = localHost;
- peers[0].port = uploaderPort;
-
- peers[1].ip = localHost;
- peers[1].port = downloaderPort;
-
- return peers;
- }
-
- void addPeer(const std::string&) override {}
- void removePeer(const std::string&) override {}
- void peerFinished(const std::string&) override {}
-};
-
-
-#if 0
-BOOST_AUTO_TEST_CASE(fileDownloaderTest) {
- fs::path testPath = "/tmp/filedownloadertest";
- fs::remove_all(testPath);
-
- fs::path downloaderPath = testPath / "downloader";
- fs::path uploaderPath = testPath / "uploader";
-
- const std::string fileReference = "0123456789012345678901234567890123456789";
- const std::string fileToSend = "filetosend.txt";
-
- fs::create_directories(downloaderPath);
- fs::create_directories(uploaderPath / fileReference);
-
- fs::path fileToUploadPath = uploaderPath / fileReference / "filetosend.txt";
-
- {
- fs::ofstream stream(fileToUploadPath);
- stream <<"Hello, world!" <<std::endl;
- }
-
- CreateTorrent createTorrent(fileToUploadPath);
- Buffer buffer(createTorrent.bencode());
-
- ComponentsDeleter deleter;
-
- std::shared_ptr<FileDistributionModel> model(deleter.track(new MockFileDistributionModel()));
- std::shared_ptr<FileDownloader> downloader =
- createDownloader(deleter, downloaderPort, downloaderPath, model);
-
- std::shared_ptr<FileDownloader> uploader =
- createDownloader(deleter, uploaderPort, uploaderPath, model);
-
- std::thread uploaderThread( [uploader] () { uploader->runEventLoop(); });
- std::thread downloaderThread( [downloader] () { downloader->runEventLoop(); });
-
- uploader->addTorrent(fileReference, buffer);
- downloader->addTorrent(fileReference, buffer);
-
- sleep(5);
- BOOST_CHECK(fs::exists(downloaderPath / fileReference / fileToSend));
-
- uploaderThread.interrupt();
- uploaderThread.join();
-
- downloaderThread.interrupt();
- downloaderThread.join();
-
- fs::remove_all(testPath);
-}
-#endif
-
-//TODO: cleanup
-libtorrent::sha1_hash
-toInfoHash(const std::string& fileReference) {
- assert (fileReference.size() == 40);
- std::istringstream s(fileReference);
-
- libtorrent::sha1_hash infoHash;
- s >> infoHash;
- return infoHash;
-}
-
-BOOST_AUTO_TEST_CASE(test_filereference_infohash_conversion) {
- const std::string fileReference = "3a281c905c9b6ebe4d969037a198454fedefbdf3";
-
- libtorrent::sha1_hash infoHash = toInfoHash(fileReference);
-
- std::ostringstream fileReferenceString;
- fileReferenceString <<infoHash;
-
- BOOST_CHECK(fileReference == fileReferenceString.str());
-
- std::cout <<fileReference <<std::endl <<fileReferenceString.str() <<std::endl;
-}
diff --git a/filedistribution/src/tests/lib/CMakeLists.txt b/filedistribution/src/tests/lib/CMakeLists.txt
deleted file mode 100644
index 735a735e1ba..00000000000
--- a/filedistribution/src/tests/lib/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_library(filedistribution_mocks STATIC
- SOURCES
- mock-zookeeper.cpp
- DEPENDS
-)
diff --git a/filedistribution/src/tests/lib/mock-zookeeper.cpp b/filedistribution/src/tests/lib/mock-zookeeper.cpp
deleted file mode 100644
index 5416afdc1fe..00000000000
--- a/filedistribution/src/tests/lib/mock-zookeeper.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <zookeeper/zookeeper.h>
-
-#include <string>
-#include <map>
-#include <cassert>
-#include <cstring>
-#include <vector>
-
-#include <thread>
-#include <atomic>
-#include <boost/lexical_cast.hpp>
-
-#include <iostream>
-
-#include <vespa/filedistribution/common/concurrentqueue.h>
-
-using std::map;
-using std::string;
-using std::vector;
-using std::pair;
-using std::make_pair;
-using filedistribution::ConcurrentQueue;
-
-namespace {
-std::pair<string, string> parentPathAndChildName(const string& childPath)
-{
- if (childPath.empty()) {
- return std::make_pair("", "");
- } else {
- assert (childPath[0] == '/');
-
- size_t index = childPath.find_last_of("/");
- return std::make_pair(childPath.substr(0, index), childPath.substr(index + 1));
- }
-}
-
-struct Node {
- typedef map<string, Node> Children;
- Children children;
- bool exists;
- bool ephemeral;
- vector<char> buffer;
- vector<pair<watcher_fn, void*> > watchers;
-
- Node()
- :exists(false),
- ephemeral(false)
- {}
-
- void addWatcher(watcher_fn fn, void* context) {
- if (fn)
- watchers.push_back(make_pair(fn, context));
- }
-
- void triggerWatches(zhandle_t* zh, const std::string& path);
-};
-
-std::shared_ptr<Node> sharedRoot;
-
-void doNothing() { }
-
-struct ZHandle {
- struct Worker {
- ZHandle& zhandle;
-
- Worker(ZHandle* parent) : zhandle(*parent) {}
-
- void operator()();
- };
-
- int sequence;
-
- std::shared_ptr<Node> root;
- std::atomic<bool> _closed;
- std::thread _watchersThread;
- vector<string> ephemeralNodes;
-
- typedef std::function<void (void)> InvokeWatcherFun;
- ConcurrentQueue<InvokeWatcherFun> watcherInvocations;
-
- Node& getNode(const string& path);
-
- Node& getParent(const string& path);
-
- void ephemeralNode(const string&path) {
- ephemeralNodes.push_back(path);
- }
-
- ZHandle() : sequence(0), _closed(false), _watchersThread(Worker(this)) {
- if (!sharedRoot)
- sharedRoot.reset(new Node());
-
- root = sharedRoot;
- }
-
- ~ZHandle() {
- std::for_each(ephemeralNodes.begin(), ephemeralNodes.end(),
- [this] (const string & s) { zoo_delete((zhandle_t*)this, s.c_str(), 0); });
- close();
- _watchersThread.join();
- }
- void close() {
- _closed.store(true);
- watcherInvocations.push(std::ref(doNothing));
- }
-};
-
-void
-ZHandle::Worker::operator()()
-{
- while (! zhandle._closed.load()) {
- InvokeWatcherFun fun = zhandle.watcherInvocations.pop();
- fun();
- }
-}
-
-Node& ZHandle::getNode(const string& path) {
- auto splittedPath = parentPathAndChildName(path);
- if (splittedPath.second.empty()) {
- return *root;
- } else {
- return getNode(splittedPath.first).children[splittedPath.second];
- }
-}
-
-Node&
-ZHandle::getParent(const string& childPath)
-{
- auto splittedPath = parentPathAndChildName(childPath);
- if (splittedPath.second.empty()) {
- throw "Can't get parent of root.";
- } else {
- return getNode(splittedPath.first);
- }
-}
-
-void
-Node::triggerWatches(zhandle_t* zh, const std::string& path) {
- for (auto i = watchers.begin(); i != watchers.end(); ++i) {
- ((ZHandle*)zh)->watcherInvocations.push([zh, i, path] () { i->first(zh, 0, 0, path.c_str(), i->second); });
- }
- watchers.clear();
-}
-
-} //anonymous namespace
-
-extern "C" {
-
-ZOOAPI void zoo_set_debug_level(ZooLogLevel) {}
-ZOOAPI zhandle_t *zookeeper_init(const char * host, watcher_fn fn,
- int recv_timeout, const clientid_t *clientid, void *context, int flags)
-{
- (void)host;
- (void)fn;
- (void)recv_timeout;
- (void)clientid;
- (void)context;
- (void)flags;
-
- return (zhandle_t*)new ZHandle;
-}
-
-ZOOAPI int zookeeper_close(zhandle_t *zh)
-{
- delete (ZHandle*)zh;
- return 0;
-}
-
-ZOOAPI int zoo_create(zhandle_t *zh, const char *pathOrPrefix, const char *value,
- int valuelen, const struct ACL_vector *, int flags,
- char *path_buffer, int path_buffer_len)
-{
- std::string path = pathOrPrefix;
- if (flags & ZOO_SEQUENCE)
- path += boost::lexical_cast<std::string>(((ZHandle*)zh)->sequence++);
-
- strncpy(path_buffer, path.c_str(), path_buffer_len);
- Node& node = ((ZHandle*)zh)->getNode(path);
- node.exists = true;
-
- if (flags & ZOO_EPHEMERAL)
- ((ZHandle*)zh)->ephemeralNode(path);
-
- node.buffer.resize(valuelen);
- std::copy(value, value + valuelen, node.buffer.begin());
-
-
- node.triggerWatches(zh, path);
- ((ZHandle*)zh)->getParent(path).triggerWatches(zh,
- parentPathAndChildName(path).first);
-
- return 0;
-}
-
-
-ZOOAPI int zoo_set(zhandle_t *zh, const char *path, const char *buffer,
- int buflen, int version) {
- (void)version;
-
- Node& node = ((ZHandle*)zh)->getNode(path);
- if (!node.exists)
- return ZNONODE;
-
-
- node.buffer.resize(buflen);
- std::copy(buffer, buffer + buflen, node.buffer.begin());
-
- node.triggerWatches(zh, path);
- return 0;
-}
-
-
-
-ZOOAPI int zoo_get_children(zhandle_t *zh, const char *path, int watch,
- struct String_vector *strings)
-{
- (void)watch;
- return zoo_wget_children(zh, path,
- 0, 0,
- strings);
-}
-
-ZOOAPI int zoo_wget_children(zhandle_t *zh, const char *path,
- watcher_fn watcher, void* watcherCtx,
- struct String_vector *strings)
-{
- Node& node = ((ZHandle*)zh)->getNode(path);
- strings->count = node.children.size();
- strings->data = new char*[strings->count];
-
- int index = 0;
- for (auto i = node.children.begin(); i != node.children.end(); ++i) {
- strings->data[index] = new char[i->first.length() + 1];
- std::strcpy(strings->data[index], &*i->first.begin());
- ++index;
- }
-
- node.addWatcher(watcher, watcherCtx);
-
- return 0;
-}
-
-
-
-
-ZOOAPI int zoo_delete(zhandle_t *zh, const char *path, int version)
-{
- (void)version;
-
- std::string pathStr = path;
- int index = pathStr.find_last_of("/");
-
- if (pathStr.length() == 1)
- throw "Can't delete root";
-
- Node& parent = ((ZHandle*)zh)->getNode(pathStr.substr(0, index));
- parent.children.erase(pathStr.substr(index + 1));
-
- ((ZHandle*)zh)->getParent(path).triggerWatches(zh,
- parentPathAndChildName(path).first);
-
- return 0;
-}
-
-void zoo_set_log_stream(FILE*) {}
-
-int deallocate_String_vector(struct String_vector *v) {
- for (int i=0; i< v->count; ++i) {
- delete[] v->data[i];
- }
- delete[] v->data;
- return 0;
-}
-
-
-ZOOAPI int zoo_get(zhandle_t *zh, const char *path, int watch, char *buffer,
- int* buffer_len, struct Stat *stat)
-{
- (void)watch;
-
- return zoo_wget(zh, path,
- 0, 0,
- buffer, buffer_len, stat);
-
-}
-
-ZOOAPI int zoo_wget(zhandle_t *zh, const char *path,
- watcher_fn watcher, void* watcherCtx,
- char *buffer, int* buffer_len, struct Stat *)
-{
- Node& node = ((ZHandle*)zh)->getNode(path);
- std::copy(node.buffer.begin(), node.buffer.end(), buffer);
- *buffer_len = node.buffer.size();
-
- node.addWatcher(watcher, watcherCtx);
- return 0;
-}
-
-ZOOAPI int zoo_wexists(zhandle_t *zh, const char *path,
- watcher_fn watcher, void* watcherCtx, struct Stat *)
-{
- Node& node = ((ZHandle*)zh)->getNode(path);
-
- node.addWatcher(watcher, watcherCtx);
- return node.exists ? ZOK : ZNONODE;
-}
-
-ZOOAPI int zoo_exists(zhandle_t *zh, const char *path, int watch, struct Stat *stat)
-{
- (void)watch;
- return zoo_wexists(zh, path,
- 0, 0,
- stat);
-}
-
-
-
-
-ZOOAPI ACL_vector ZOO_OPEN_ACL_UNSAFE;
-
-ZOOAPI const int ZOO_SEQUENCE = 1;
-ZOOAPI const int ZOO_EPHEMERAL = 2;
-ZOOAPI const int ZOO_SESSION_EVENT = 3;
-ZOOAPI const int ZOO_EXPIRED_SESSION_STATE = 4;
-ZOOAPI const int ZOO_AUTH_FAILED_STATE = 5;
-}
diff --git a/filedistribution/src/tests/rpc/.gitignore b/filedistribution/src/tests/rpc/.gitignore
deleted file mode 100644
index b29a47efd87..00000000000
--- a/filedistribution/src/tests/rpc/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-filedistribution_rpc_test_app
diff --git a/filedistribution/src/tests/rpc/CMakeLists.txt b/filedistribution/src/tests/rpc/CMakeLists.txt
deleted file mode 100644
index 1882959f94f..00000000000
--- a/filedistribution/src/tests/rpc/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(filedistribution_rpc_test_app TEST
- SOURCES
- testfileprovider.cpp
- DEPENDS
- filedistribution_filedistributorrpc
- filedistribution_common
-)
-target_compile_options(filedistribution_rpc_test_app PRIVATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_DHT -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED)
-vespa_add_target_system_dependency(filedistribution_rpc_test_app boost boost_system${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_rpc_test_app boost boost_thread${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_rpc_test_app boost boost_program_options${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_rpc_test_app boost boost_filesystem${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_rpc_test_app boost boost_unit_test_framework${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_test(NAME filedistribution_rpc_test_app NO_VALGRIND COMMAND filedistribution_rpc_test_app)
diff --git a/filedistribution/src/tests/rpc/mockfileprovider.h b/filedistribution/src/tests/rpc/mockfileprovider.h
deleted file mode 100644
index be0a6100165..00000000000
--- a/filedistribution/src/tests/rpc/mockfileprovider.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#pragma once
-
-#include <vespa/filedistribution/rpc/fileprovider.h>
-#include <boost/thread/barrier.hpp>
-
-namespace filedistribution {
-
-class MockFileProvider : public FileProvider {
- DownloadCompletedSignal _downloadCompleted;
- DownloadFailedSignal _downloadFailed;
-public:
- static const std::string _queueForeverFileReference;
-
- boost::barrier _queueForeverBarrier;
-
- boost::optional<Path> getPath(const std::string& fileReference) override {
- if (fileReference == "dd") {
- return Path("direct/result/path");
- } else {
- return boost::optional<Path>();
- }
- }
-
- void downloadFile(const std::string& fileReference) override {
- if (fileReference == _queueForeverFileReference) {
- _queueForeverBarrier.wait();
- return;
- }
-
- sleep(1);
- downloadCompleted()(fileReference, "downloaded/path/" + fileReference);
- }
-
- DownloadCompletedSignal& downloadCompleted() override {
- return _downloadCompleted;
- }
-
- DownloadFailedSignal& downloadFailed() override {
- return _downloadFailed;
- }
-
- MockFileProvider()
- :_queueForeverBarrier(2)
- {}
-};
-
-} //namespace filedistribution
-
diff --git a/filedistribution/src/tests/rpc/testfileprovider.cpp b/filedistribution/src/tests/rpc/testfileprovider.cpp
deleted file mode 100644
index 2879258272a..00000000000
--- a/filedistribution/src/tests/rpc/testfileprovider.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2017 Yahoo Holdings. 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
-
-#include "mockfileprovider.h"
-#include <vespa/filedistribution/rpc/filedistributorrpc.h>
-#include <vespa/frtstream/frtclientstream.h>
-#include <vespa/fnet/frt/rpcrequest.h>
-#include <vespa/fnet/frt/target.h>
-#include <boost/test/unit_test.hpp>
-
-namespace fd = filedistribution;
-
-using fd::MockFileProvider;
-
-const std::string MockFileProvider::_queueForeverFileReference("queue-forever");
-
-BOOST_AUTO_TEST_CASE(fileDistributionRPCTest) {
- const std::string spec("tcp/localhost:9111");
- fd::FileProvider::SP provider(new fd::MockFileProvider());
- fd::FileDistributorRPC::SP fileDistributorRPC(new fd::FileDistributorRPC(spec, provider));
- fileDistributorRPC->start();
-
- frtstream::FrtClientStream rpc(spec);
- frtstream::Method method("waitFor");
-
- std::string path;
- rpc <<method <<"dd";
- rpc >> path;
- BOOST_CHECK_EQUAL("direct/result/path", path);
-
- rpc <<method <<"0123456789abcdef";
- rpc >> path;
- BOOST_CHECK_EQUAL("downloaded/path/0123456789abcdef", path);
-}
-
-//must be run through valgrind
-BOOST_AUTO_TEST_CASE(require_that_queued_requests_does_not_leak_memory) {
- const std::string spec("tcp/localhost:9111");
- std::shared_ptr<MockFileProvider> provider(new MockFileProvider());
- fd::FileDistributorRPC::SP fileDistributorRPC(new fd::FileDistributorRPC(spec, provider));
- fileDistributorRPC->start();
-
- FRT_Supervisor supervisor;
-
- supervisor.Start();
- FRT_Target *target = supervisor.GetTarget(spec.c_str());
-
- FRT_RPCRequest* request = supervisor.AllocRPCRequest();
- request->SetMethodName("waitFor");
- request->GetParams()->AddString(MockFileProvider::_queueForeverFileReference.c_str());
- target->InvokeVoid(request);
-
- provider->_queueForeverBarrier.wait(); //the request has been enqueued.
- fileDistributorRPC.reset();
-
- target->SubRef();
- supervisor.ShutDown(true);
-
-}
-
-BOOST_AUTO_TEST_CASE(require_that_port_can_be_extracted_from_connection_spec) {
- BOOST_CHECK_EQUAL(9056, fd::FileDistributorRPC::get_port("tcp/host:9056"));
- BOOST_CHECK_EQUAL(9056, fd::FileDistributorRPC::get_port("tcp/9056"));
- BOOST_CHECK_EQUAL(9056, fd::FileDistributorRPC::get_port("9056"));
-}
diff --git a/filedistribution/src/tests/scheduler/.gitignore b/filedistribution/src/tests/scheduler/.gitignore
deleted file mode 100644
index b1976d1c516..00000000000
--- a/filedistribution/src/tests/scheduler/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-filedistribution_scheduler_test_app
diff --git a/filedistribution/src/tests/scheduler/CMakeLists.txt b/filedistribution/src/tests/scheduler/CMakeLists.txt
deleted file mode 100644
index 763d87cfc64..00000000000
--- a/filedistribution/src/tests/scheduler/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(filedistribution_scheduler_test_app TEST
- SOURCES
- test-scheduler.cpp
- DEPENDS
- filedistribution_distributor
- filedistribution_filedistributionmodel
- filedistribution_common
-)
-target_compile_options(filedistribution_scheduler_test_app PRIVATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_DHT -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED)
-vespa_add_target_system_dependency(filedistribution_scheduler_test_app boost boost_system${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_scheduler_test_app boost boost_thread${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_scheduler_test_app boost boost_program_options${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_scheduler_test_app boost boost_filesystem${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_scheduler_test_app boost boost_unit_test_framework${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_test(NAME filedistribution_scheduler_test_app NO_VALGRIND COMMAND filedistribution_scheduler_test_app)
diff --git a/filedistribution/src/tests/scheduler/test-scheduler.cpp b/filedistribution/src/tests/scheduler/test-scheduler.cpp
deleted file mode 100644
index d5afe7e4b11..00000000000
--- a/filedistribution/src/tests/scheduler/test-scheduler.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2017 Yahoo Holdings. 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
-
-#include <boost/test/unit_test.hpp>
-
-#include <vespa/filedistribution/distributor/scheduler.h>
-
-#include <iostream>
-
-#include <boost/thread/barrier.hpp>
-
-using filedistribution::Scheduler;
-using namespace std::literals;
-
-namespace asio = boost::asio;
-
-class TestException {};
-
-
-struct CallRun {
- volatile bool _caughtException;
-
- CallRun()
- :_caughtException(false)
- {}
-
- void operator()(asio::io_service& ioService) {
- try {
- //No reset needed after handling exceptions.
- ioService.run();
- } catch(const TestException& e ) {
- _caughtException = true;
- }
- }
-};
-
-struct Fixture {
- CallRun callRun;
- Scheduler scheduler;
-
- Fixture()
- : scheduler(std::ref(callRun))
- {}
-};
-
-
-BOOST_FIXTURE_TEST_SUITE(SchedulerTest, Fixture)
-
-
-struct RepeatedTask : Scheduler::Task {
- void doHandle() override {
- std::cout <<"RepeatedTask::doHandle " <<std::endl;
- schedule(boost::posix_time::seconds(1));
- }
-
- RepeatedTask(Scheduler& scheduler) : Task(scheduler) {}
-};
-
-BOOST_AUTO_TEST_CASE(require_tasks_does_not_keep_scheduler_alive) {
- RepeatedTask::SP task(new RepeatedTask(scheduler));
- task->schedule(boost::posix_time::hours(10));
-}
-
-struct EnsureInvokedTask : Scheduler::Task {
- boost::barrier& _barrier;
-
- void doHandle() override {
- _barrier.wait();
- }
-
- EnsureInvokedTask(Scheduler& scheduler, boost::barrier& barrier) :
- Task(scheduler),
- _barrier(barrier)
- {}
-};
-
-
-BOOST_AUTO_TEST_CASE(require_task_invoked) {
- boost::barrier barrier(2);
-
- EnsureInvokedTask::SP task(new EnsureInvokedTask(scheduler, barrier));
- task->schedule(boost::posix_time::milliseconds(50));
-
- barrier.wait();
-}
-
-struct ThrowExceptionTask : Scheduler::Task {
- void doHandle() override {
- throw TestException();
- }
-
- ThrowExceptionTask(Scheduler& scheduler) :
- Task(scheduler)
- {}
-};
-
-BOOST_AUTO_TEST_CASE(require_exception_from_tasks_can_be_caught) {
- ThrowExceptionTask::SP task(new ThrowExceptionTask(scheduler));
- task->scheduleNow();
-
- for (int i=0; i<200 && !callRun._caughtException; ++i) {
- std::this_thread::sleep_for(100ms);
- }
-
- BOOST_CHECK(callRun._caughtException);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/filedistribution/src/tests/status/.gitignore b/filedistribution/src/tests/status/.gitignore
deleted file mode 100644
index 3da528fcd45..00000000000
--- a/filedistribution/src/tests/status/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-filedistribution_status_test_app
diff --git a/filedistribution/src/tests/status/CMakeLists.txt b/filedistribution/src/tests/status/CMakeLists.txt
deleted file mode 100644
index 646cc1351a9..00000000000
--- a/filedistribution/src/tests/status/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(filedistribution_status_test_app TEST
- SOURCES
- test-status.cpp
- DEPENDS
- filedistribution_filedistributionmodel
- filedistribution_common
-)
-target_compile_options(filedistribution_status_test_app PRIVATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_DHT -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED)
-vespa_add_target_system_dependency(filedistribution_status_test_app boost boost_system${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_status_test_app boost boost_thread${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_status_test_app boost boost_program_options${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_status_test_app boost boost_filesystem${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_status_test_app boost boost_unit_test_framework${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_test(NAME filedistribution_status_test_app NO_VALGRIND COMMAND filedistribution_status_test_app)
diff --git a/filedistribution/src/tests/status/test-status.cpp b/filedistribution/src/tests/status/test-status.cpp
deleted file mode 100644
index f50626aabdc..00000000000
--- a/filedistribution/src/tests/status/test-status.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 Yahoo Holdings. 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
-#include <boost/test/unit_test.hpp>
-
-#include <vespa/filedistribution/model/zkfacade.h>
-#include <vespa/filedistribution/model/filedistributionmodel.h>
-#include <vespa/filedistribution/model/filedistributionmodelimpl.h>
-
-using namespace filedistribution;
-
-
-BOOST_AUTO_TEST_CASE(test_retrieve_status) {
- // TODO:
-}
-
diff --git a/filedistribution/src/tests/zkfacade/.gitignore b/filedistribution/src/tests/zkfacade/.gitignore
deleted file mode 100644
index 6ffef2339b1..00000000000
--- a/filedistribution/src/tests/zkfacade/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-filedistribution_zkfacade_test_app
diff --git a/filedistribution/src/tests/zkfacade/CMakeLists.txt b/filedistribution/src/tests/zkfacade/CMakeLists.txt
deleted file mode 100644
index 18dc8121049..00000000000
--- a/filedistribution/src/tests/zkfacade/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(filedistribution_zkfacade_test_app
- SOURCES
- test-zkfacade.cpp
- DEPENDS
- filedistribution_filedistributionmodel
- filedistribution_common
- filedistribution_mocks
-)
-target_compile_options(filedistribution_zkfacade_test_app PRIVATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_DHT -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED)
-vespa_add_target_system_dependency(filedistribution_zkfacade_test_app boost boost_system${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_zkfacade_test_app boost boost_thread${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_zkfacade_test_app boost boost_program_options${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_zkfacade_test_app boost boost_filesystem${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_zkfacade_test_app boost boost_unit_test_framework${VESPA_BOOST_LIB_SUFFIX})
diff --git a/filedistribution/src/tests/zkfacade/test-zkfacade.cpp b/filedistribution/src/tests/zkfacade/test-zkfacade.cpp
deleted file mode 100644
index de4be087432..00000000000
--- a/filedistribution/src/tests/zkfacade/test-zkfacade.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-// Copyright 2017 Yahoo Holdings. 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 zkfacade test
-
-#include <boost/test/unit_test.hpp>
-#include <iostream>
-#include <boost/thread/barrier.hpp>
-#include <vespa/filedistribution/common/componentsdeleter.h>
-#include <vespa/filedistribution/model/zkfacade.h>
-
-#include <zookeeper/zookeeper.h>
-
-
-using namespace std::literals;
-using namespace filedistribution;
-
-namespace {
-
-
-struct Watcher : public ZKFacade::NodeChangedWatcher {
- boost::barrier _barrier;
-
- Watcher() :
- _barrier(2) {}
-
- void operator()() override {
- _barrier.wait();
- }
-};
-
-struct Fixture {
- ComponentsDeleter _componentsDeleter;
- std::shared_ptr<ZKFacade> zk;
- Path testNode;
-
- Fixture() {
- zoo_set_debug_level(ZOO_LOG_LEVEL_WARN);
- zk = _componentsDeleter.track(new ZKFacade("test1-tonyv:2181", false));
-
- testNode = "/test-node";
- zk->removeIfExists(testNode);
- }
-
- ~Fixture() {
- if (zk) {
- zk->removeIfExists(testNode);
- }
- }
-};
-
-} //anonymous namespace
-
-
-BOOST_FIXTURE_TEST_SUITE(ZKFacadeTests, Fixture)
-
-BOOST_AUTO_TEST_CASE(hasNode)
-{
- zk->setData(testNode, "", 0);
- BOOST_CHECK(zk->hasNode(testNode));
-
- zk->remove(testNode);
- BOOST_CHECK(!zk->hasNode(testNode));
-}
-
-BOOST_AUTO_TEST_CASE(getValidZKServers)
-{
- BOOST_CHECK_EQUAL("localhost:22", ZKFacade::getValidZKServers("localhost:22", false));
- BOOST_CHECK_EQUAL("localhost:22", ZKFacade::getValidZKServers("localhost:22", true));
- BOOST_CHECK_EQUAL("idonotexist:22", ZKFacade::getValidZKServers("idonotexist:22", false));
- BOOST_CHECK_EQUAL("", ZKFacade::getValidZKServers("idonotexist:22", true));
- BOOST_CHECK_EQUAL("localhost:22,idonotexist:22", ZKFacade::getValidZKServers("localhost:22,idonotexist:22", false));
- BOOST_CHECK_EQUAL("localhost:22", ZKFacade::getValidZKServers("localhost:22,idonotexist:22", true));
- BOOST_CHECK_EQUAL("idonotexist:22,localhost:22", ZKFacade::getValidZKServers("idonotexist:22,localhost:22", false));
- BOOST_CHECK_EQUAL("localhost:22", ZKFacade::getValidZKServers("idonotexist:22,localhost:22", true));
-}
-
-BOOST_AUTO_TEST_CASE(hasNodeNotification)
-{
- std::shared_ptr<Watcher> watcher(new Watcher);
-
- zk->hasNode(testNode, watcher);
- zk->setData(testNode, "", 0);
- watcher->_barrier.wait();
-
- //after the notification has returned, the watcher must no longer reside in watchers map.
- for (int i=0; i<20 && !watcher.unique(); ++i) {
- std::this_thread::sleep_for(100ms);
- }
- BOOST_CHECK(watcher.unique());
-}
-
-BOOST_AUTO_TEST_CASE(getAndSetData)
-{
- std::string inputString = "test data.";
- Buffer inputBuffer(inputString.begin(), inputString.end());
-
- zk->setData(testNode, inputBuffer);
-
- Buffer outputBuffer(zk->getData(testNode));
- std::string outputString(outputBuffer.begin(), outputBuffer.end());
-
- BOOST_CHECK(outputString == inputString);
-
- outputString = zk->getString(testNode);
- BOOST_CHECK(outputString == inputString);
-}
-
-BOOST_AUTO_TEST_CASE(setDataMustExist)
-{
- bool mustExist = true;
- BOOST_REQUIRE_THROW(zk->setData(testNode, "", 0, mustExist), ZKNodeDoesNotExistsException);
-}
-
-BOOST_AUTO_TEST_CASE(createSequenceNode)
-{
- zk->setData(testNode, "", 0);
-
- Path prefix = testNode / "prefix";
- zk->createSequenceNode(prefix, "test", 4);
- zk->createSequenceNode(prefix, "test", 4);
- zk->createSequenceNode(prefix, "test", 4);
-
- std::vector<std::string> children = zk->getChildren(testNode);
- BOOST_CHECK(children.size() == 3);
- BOOST_CHECK(children.begin()->substr(0,6) == "prefix");
-
- Buffer buffer(zk->getData(testNode / *children.begin()));
- std::string bufferContent(buffer.begin(), buffer.end());
-
- BOOST_CHECK(bufferContent == "test");
-}
-
-BOOST_AUTO_TEST_CASE(retainOnly)
-{
- zk->setData(testNode, "", 0);
-
- zk->setData(testNode / "a", "", 0);
- zk->setData(testNode / "b", "", 0);
- zk->setData(testNode / "c", "", 0);
- zk->setData(testNode / "d", "", 0);
-
- std::vector<std::string> toRetain;
- toRetain.push_back("a");
- toRetain.push_back("c");
-
- zk->retainOnly(testNode, toRetain);
- std::vector<std::string> children = zk->getChildren(testNode);
-
- std::sort(children.begin(), children.end());
- BOOST_CHECK(children == toRetain);
-}
-
-
-
-BOOST_AUTO_TEST_CASE(addEphemeralNode)
-{
- Path ephemeralNode = "/test-ephemeral-node";
- zk->removeIfExists(ephemeralNode);
-
- //Checked deleter is ok here since we're not installing any watchers
- ZKFacade::SP zk2(new ZKFacade("test1-tonyv:2181", false), boost::checked_deleter<ZKFacade>());
- zk2->addEphemeralNode(ephemeralNode);
-
- BOOST_CHECK(zk->hasNode(ephemeralNode));
- zk2.reset();
- BOOST_CHECK(!zk->hasNode(ephemeralNode));
-}
-
-
-
-BOOST_AUTO_TEST_CASE(dataChangedNotification)
-{
- std::shared_ptr<Watcher> watcher(new Watcher);
-
- zk->setData(testNode, "", 0);
- Buffer buffer(zk->getData(testNode, watcher));
- BOOST_CHECK(buffer.size() == 0);
-
- bool mustExist = true;
- zk->setData(testNode, "test", 4, mustExist);
- watcher->_barrier.wait();
-}
-
-BOOST_AUTO_TEST_CASE(getChildrenNotification)
-{
- std::shared_ptr<Watcher> watcher(new Watcher);
-
- zk->setData(testNode, "", 0);
- zk->getChildren(testNode, watcher);
-
- zk->setData(testNode / "child", "", 0);
- watcher->_barrier.wait();
-}
-
-BOOST_AUTO_TEST_CASE(require_that_zkfacade_can_be_deleted_from_callback)
-{
- struct DeleteZKFacadeWatcher : public Watcher {
- std::shared_ptr<ZKFacade> _zk;
-
- DeleteZKFacadeWatcher(const std::shared_ptr<ZKFacade>& zk)
- :_zk(zk)
- {}
-
- void operator()() override {
- BOOST_CHECK(_zk.use_count() == 2);
- _zk.reset();
- Watcher::operator()();
- }
- };
-
- std::shared_ptr<Watcher> watcher((Watcher*)new DeleteZKFacadeWatcher(zk));
-
- zk->setData(testNode, "", 0);
- zk->getData(testNode, watcher);
-
- ZKFacade* unprotectedZk = zk.get();
- zk.reset();
-
- unprotectedZk->setData(testNode, "t", 1);
- watcher->_barrier.wait();
-
- //Must wait longer than the zookeeper_close timeout to catch
- //problems due to closing zookeeper in a zookeeper watcher thread.
- sleep(3);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/filedistribution/src/tests/zkfiledbmodel/.gitignore b/filedistribution/src/tests/zkfiledbmodel/.gitignore
deleted file mode 100644
index 18c14c47c56..00000000000
--- a/filedistribution/src/tests/zkfiledbmodel/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-filedistribution_zkfiledbmodel_test_app
diff --git a/filedistribution/src/tests/zkfiledbmodel/CMakeLists.txt b/filedistribution/src/tests/zkfiledbmodel/CMakeLists.txt
deleted file mode 100644
index e21d0bacf6e..00000000000
--- a/filedistribution/src/tests/zkfiledbmodel/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(filedistribution_zkfiledbmodel_test_app TEST
- SOURCES
- test-zkfiledbmodel.cpp
- DEPENDS
- filedistribution_filedistributionmodel
- filedistribution_common
- filedistribution_mocks
-)
-target_compile_options(filedistribution_zkfiledbmodel_test_app PRIVATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_DHT -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED)
-vespa_add_target_system_dependency(filedistribution_zkfiledbmodel_test_app boost boost_system${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_zkfiledbmodel_test_app boost boost_thread${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_zkfiledbmodel_test_app boost boost_program_options${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_zkfiledbmodel_test_app boost boost_filesystem${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_target_system_dependency(filedistribution_zkfiledbmodel_test_app boost boost_unit_test_framework${VESPA_BOOST_LIB_SUFFIX})
-vespa_add_test(NAME filedistribution_zkfiledbmodel_test_app NO_VALGRIND COMMAND filedistribution_zkfiledbmodel_test_app)
diff --git a/filedistribution/src/tests/zkfiledbmodel/test-zkfiledbmodel.cpp b/filedistribution/src/tests/zkfiledbmodel/test-zkfiledbmodel.cpp
deleted file mode 100644
index 20fc4364dc8..00000000000
--- a/filedistribution/src/tests/zkfiledbmodel/test-zkfiledbmodel.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2017 Yahoo Holdings. 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 zkfiledbmodel test
-#include <boost/test/unit_test.hpp>
-
-#include <iostream>
-
-#include <vespa/filedistribution/common/componentsdeleter.h>
-#include <vespa/filedistribution/model/zkfacade.h>
-#include <vespa/filedistribution/model/zkfiledbmodel.h>
-
-#include <zookeeper/zookeeper.h>
-
-
-using namespace filedistribution;
-
-namespace {
-
-struct Fixture {
- ComponentsDeleter _componentsDeleter;
- std::shared_ptr<ZKFacade> zk;
- std::shared_ptr<ZKFileDBModel> model;
-
- Fixture() {
- zoo_set_debug_level(ZOO_LOG_LEVEL_WARN);
- zk = _componentsDeleter.track(new ZKFacade("test1-tonyv:2181", false));
- zk->setData("/vespa", "", 0);
-
- model = _componentsDeleter.track(new ZKFileDBModel(zk));
- }
-};
-
-} //anonymous namespace
-
-
-BOOST_FIXTURE_TEST_SUITE(ZKFileDBModelTests, Fixture)
-
-BOOST_AUTO_TEST_CASE(retainOnlyHostsForTenant)
-{
- Path path = "/vespa/filedistribution/hosts";
- std::vector<std::string> files = {"myfile"};
- BOOST_CHECK(zk->hasNode("/vespa"));
- BOOST_CHECK(zk->hasNode("/vespa/filedistribution"));
- BOOST_CHECK(zk->hasNode(path));
- model->setDeployedFilesToDownload("testhost", "myapp:so:cool", files);
- model->setDeployedFilesToDownload("testhost2", "myapp:so:cool", files);
- model->setDeployedFilesToDownload("testhost3", "myapp:so:cool", files);
- model->setDeployedFilesToDownload("testhost3", "myapp:legacyid:so:cool", files);
- model->setDeployedFilesToDownload("testhost3", "yourapp:so:cool", files);
- BOOST_CHECK(zk->getChildren(path / "testhost").size() == 1);
- BOOST_CHECK(zk->getChildren(path / "testhost2").size() == 1);
- BOOST_CHECK(zk->getChildren(path / "testhost3").size() == 3);
-
- model->cleanDeployedFilesToDownload({"testhost3"}, "yourapp:so:cool");
- model->removeDeploymentsThatHaveDifferentApplicationId({"testhost3"}, "yourapp:so:cool");
- BOOST_CHECK(zk->hasNode(path / "testhost"));
- BOOST_CHECK(zk->hasNode(path / "testhost2"));
- BOOST_CHECK(zk->hasNode(path / "testhost3"));
- BOOST_CHECK(zk->getChildren(path / "testhost").size() == 1);
- BOOST_CHECK(zk->getChildren(path / "testhost2").size() == 1);
- BOOST_CHECK(zk->getChildren(path / "testhost3").size() == 1);
-
- model->cleanDeployedFilesToDownload({"testhost"}, "myapp:not:cool");
- model->removeDeploymentsThatHaveDifferentApplicationId({"testhost"}, "myapp:not:cool");
- BOOST_CHECK(zk->hasNode(path / "testhost"));
- BOOST_CHECK(zk->hasNode(path / "testhost2"));
- BOOST_CHECK(zk->hasNode(path / "testhost3"));
- BOOST_CHECK(zk->getChildren(path / "testhost").size() == 0);
- BOOST_CHECK(zk->getChildren(path / "testhost2").size() == 1);
- BOOST_CHECK(zk->getChildren(path / "testhost3").size() == 1);
-
- model->cleanDeployedFilesToDownload({"testhost2"}, "myapp:so:cool");
- model->removeDeploymentsThatHaveDifferentApplicationId({"testhost2"}, "myapp:so:cool");
-
- BOOST_CHECK(!zk->hasNode(path / "testhost"));
- BOOST_CHECK(zk->hasNode(path / "testhost2"));
- BOOST_CHECK(zk->hasNode(path / "testhost3"));
- BOOST_CHECK(zk->getChildren(path / "testhost2").size() == 1);
- BOOST_CHECK(zk->getChildren(path / "testhost3").size() == 1);
-
- model->cleanDeployedFilesToDownload({"testhost2"}, "yourapp:so:cool");
- BOOST_CHECK(!zk->hasNode(path / "testhost"));
- BOOST_CHECK(zk->hasNode(path / "testhost2"));
- BOOST_CHECK(!zk->hasNode(path / "testhost3"));
-}
-
-BOOST_AUTO_TEST_SUITE_END()