aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2022-06-02 16:35:21 +0200
committerTor Egge <Tor.Egge@online.no>2022-06-02 19:22:21 +0200
commit914317d3db05758483eaea09a60ef8bfa3981948 (patch)
tree7b94d14f6215b8b66becb869e1b08c59d81a05e6 /searchcore/src/tests
parenta51340034f1b4bc98096613af8f5736a2c974c96 (diff)
Remove most use of vespalib::rmdir in searchcore.
Diffstat (limited to 'searchcore/src/tests')
-rw-r--r--searchcore/src/tests/index/disk_indexes/disk_indexes_test.cpp8
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_directory/attribute_directory_test.cpp27
-rw-r--r--searchcore/src/tests/proton/attribute/attributeflush_test.cpp10
-rw-r--r--searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp12
-rw-r--r--searchcore/src/tests/proton/documentdb/documentdb_test.cpp11
-rw-r--r--searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp4
-rw-r--r--searchcore/src/tests/proton/index/indexmanager_test.cpp4
-rw-r--r--searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp7
8 files changed, 41 insertions, 42 deletions
diff --git a/searchcore/src/tests/index/disk_indexes/disk_indexes_test.cpp b/searchcore/src/tests/index/disk_indexes/disk_indexes_test.cpp
index d22ad499316..6151fcaf1ca 100644
--- a/searchcore/src/tests/index/disk_indexes/disk_indexes_test.cpp
+++ b/searchcore/src/tests/index/disk_indexes/disk_indexes_test.cpp
@@ -3,9 +3,9 @@
#include <vespa/searchcorespi/index/disk_indexes.h>
#include <vespa/searchcorespi/index/index_disk_dir.h>
#include <vespa/searchcorespi/index/indexdisklayout.h>
-#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/gtest/gtest.h>
+#include <filesystem>
#include <fstream>
namespace {
@@ -149,7 +149,7 @@ TEST_F(DiskIndexesTest, get_transient_size_during_ongoing_fusion)
assert_transient_size(0, fusion1);
}
auto dir = base_dir + "/index.fusion.2";
- vespalib::mkdir(dir, true);
+ std::filesystem::create_directories(std::filesystem::path(dir));
{
/*
* Fusion started, but no files written yet.
@@ -188,9 +188,9 @@ TEST_F(DiskIndexesTest, get_transient_size_during_ongoing_fusion)
int
main(int argc, char* argv[])
{
- vespalib::rmdir(base_dir, true);
+ std::filesystem::remove_all(std::filesystem::path(base_dir));
::testing::InitGoogleTest(&argc, argv);
auto result = RUN_ALL_TESTS();
- vespalib::rmdir(base_dir, true);
+ std::filesystem::remove_all(std::filesystem::path(base_dir));
return result;
}
diff --git a/searchcore/src/tests/proton/attribute/attribute_directory/attribute_directory_test.cpp b/searchcore/src/tests/proton/attribute/attribute_directory/attribute_directory_test.cpp
index ee2904d736c..55de4caed80 100644
--- a/searchcore/src/tests/proton/attribute/attribute_directory/attribute_directory_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_directory/attribute_directory_test.cpp
@@ -3,10 +3,10 @@
#include <vespa/searchcore/proton/attribute/attribute_directory.h>
#include <vespa/searchcore/proton/attribute/attributedisklayout.h>
#include <vespa/searchlib/test/directory_handler.h>
-#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/testkit/testapp.h>
+#include <filesystem>
#include <vespa/log/log.h>
LOG_SETUP("attribute_directory_test");
@@ -65,9 +65,7 @@ struct Fixture : public DirectoryHandler
vespalib::string getAttrDir(const vespalib::string &name) { return getDir() + "/" + name; }
void assertDiskDir(const vespalib::string &name) {
- auto fileinfo = vespalib::stat(name);
- EXPECT_TRUE(static_cast<bool>(fileinfo));
- EXPECT_TRUE(fileinfo->_directory);
+ EXPECT_TRUE(std::filesystem::is_directory(std::filesystem::path(name)));
}
void assertAttributeDiskDir(const vespalib::string &name) {
@@ -75,8 +73,7 @@ struct Fixture : public DirectoryHandler
}
void assertNotDiskDir(const vespalib::string &name) {
- auto fileinfo = vespalib::stat(name);
- EXPECT_FALSE(static_cast<bool>(fileinfo));
+ EXPECT_FALSE(std::filesystem::exists(std::filesystem::path(name)));
}
void assertNotAttributeDiskDir(const vespalib::string &name) {
@@ -137,7 +134,7 @@ struct Fixture : public DirectoryHandler
EXPECT_TRUE(hasAttributeDir(dir));
auto writer = dir->getWriter();
writer->createInvalidSnapshot(serialNum);
- vespalib::mkdir(writer->getSnapshotDir(serialNum), false);
+ std::filesystem::create_directory(std::filesystem::path(writer->getSnapshotDir(serialNum)));
writer->markValidSnapshot(serialNum);
TEST_DO(assertAttributeDiskDir("foo"));
}
@@ -163,7 +160,7 @@ struct Fixture : public DirectoryHandler
auto dir = createFooAttrDir();
auto writer = dir->getWriter();
writer->createInvalidSnapshot(serialNum);
- vespalib::mkdir(writer->getSnapshotDir(serialNum), false);
+ std::filesystem::create_directory(std::filesystem::path(writer->getSnapshotDir(serialNum)));
writer->markValidSnapshot(serialNum);
}
@@ -210,10 +207,10 @@ TEST_F("Test that we can prune attribute snapshots", Fixture)
TEST_DO(f.assertNotAttributeDiskDir("foo"));
auto writer = dir->getWriter();
writer->createInvalidSnapshot(2);
- vespalib::mkdir(writer->getSnapshotDir(2), false);
+ std::filesystem::create_directory(std::filesystem::path(writer->getSnapshotDir(2)));
writer->markValidSnapshot(2);
writer->createInvalidSnapshot(4);
- vespalib::mkdir(writer->getSnapshotDir(4), false);
+ std::filesystem::create_directory(std::filesystem::path(writer->getSnapshotDir(4)));
writer->markValidSnapshot(4);
writer.reset();
TEST_DO(f.assertAttributeDiskDir("foo"));
@@ -264,9 +261,9 @@ TEST_F("Test that attribute directory is not removed due to pruning but disk dir
TEST("Test that initial state tracks disk layout")
{
- vespalib::mkdir("attributes");
- vespalib::mkdir("attributes/foo");
- vespalib::mkdir("attributes/bar");
+ std::filesystem::create_directory(std::filesystem::path("attributes"));
+ std::filesystem::create_directory(std::filesystem::path("attributes/foo"));
+ std::filesystem::create_directory(std::filesystem::path("attributes/bar"));
IndexMetaInfo fooInfo("attributes/foo");
IndexMetaInfo barInfo("attributes/bar");
fooInfo.addSnapshot({true, 4, "snapshot-4"});
@@ -292,8 +289,8 @@ TEST("Test that initial state tracks disk layout")
TEST_F("Test that snapshot removal removes correct snapshot directory", Fixture)
{
TEST_DO(f.setupFooSnapshots(5));
- vespalib::mkdir(f.getSnapshotDir("foo", 5));
- vespalib::mkdir(f.getSnapshotDir("foo", 6));
+ std::filesystem::create_directory(std::filesystem::path(f.getSnapshotDir("foo", 5)));
+ std::filesystem::create_directory(std::filesystem::path(f.getSnapshotDir("foo", 6)));
TEST_DO(f.assertSnapshotDir("foo", 5));
TEST_DO(f.assertSnapshotDir("foo", 6));
TEST_DO(f.invalidateFooSnapshots(false));
diff --git a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
index ab7a0db5e7b..6d581f6e6f9 100644
--- a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
@@ -15,13 +15,13 @@
#include <vespa/searchlib/test/directory_handler.h>
#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/datastore/datastorebase.h>
-#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/foreground_thread_executor.h>
#include <vespa/vespalib/util/foregroundtaskexecutor.h>
#include <vespa/vespalib/util/idestructorcallback.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
+#include <filesystem>
#include <thread>
#include <vespa/log/log.h>
@@ -436,9 +436,9 @@ Test::requireThatCleanUpIsPerformedAfterFlush()
std::string base = "flush/a6";
std::string snap10 = "flush/a6/snapshot-10";
std::string snap20 = "flush/a6/snapshot-20";
- vespalib::mkdir(base, false);
- vespalib::mkdir(snap10, false);
- vespalib::mkdir(snap20, false);
+ std::filesystem::create_directory(std::filesystem::path(base));
+ std::filesystem::create_directory(std::filesystem::path(snap10));
+ std::filesystem::create_directory(std::filesystem::path(snap20));
IndexMetaInfo info("flush/a6");
info.addSnapshot(IndexMetaInfo::Snapshot(true, 10, "snapshot-10"));
info.addSnapshot(IndexMetaInfo::Snapshot(false, 20, "snapshot-20"));
@@ -662,7 +662,7 @@ Test::Main()
if (_argc > 0) {
DummyFileHeaderContext::setCreator(_argv[0]);
}
- vespalib::rmdir(test_dir, true);
+ std::filesystem::remove_all(std::filesystem::path(test_dir));
TEST_DO(requireThatUpdaterAndFlusherCanRunConcurrently());
TEST_DO(requireThatFlushableAttributeReportsMemoryUsage());
TEST_DO(requireThatFlushableAttributeManagesSyncTokenInfo());
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp
index 948c9cfe25e..b57ff052e82 100644
--- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp
@@ -26,10 +26,10 @@
#include <vespa/searchlib/attribute/interlock.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/transactionlog/nosyncproxy.h>
-#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/testclock.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
+#include <filesystem>
using namespace config;
using namespace document;
@@ -173,8 +173,8 @@ Fixture::Fixture()
_resolver(),
_configurer()
{
- vespalib::rmdir(BASE_DIR, true);
- vespalib::mkdir(BASE_DIR);
+ std::filesystem::remove_all(std::filesystem::path(BASE_DIR));
+ std::filesystem::create_directory(std::filesystem::path(BASE_DIR));
initViewSet(_views);
_configurer = std::make_unique<Configurer>(_views._summaryMgr, _views.searchView, _views.feedView, _queryLimiter,
_constantValueRepo, _clock.clock(), "test", 0);
@@ -284,8 +284,8 @@ struct FastAccessFixture
_view(_service.write()),
_configurer(_view._feedView, std::make_unique<AttributeWriterFactory>(), "test")
{
- vespalib::rmdir(BASE_DIR, true);
- vespalib::mkdir(BASE_DIR);
+ std::filesystem::remove_all(std::filesystem::path(BASE_DIR));
+ std::filesystem::create_directory(std::filesystem::path(BASE_DIR));
}
~FastAccessFixture() {
_service.shutdown();
@@ -692,5 +692,5 @@ TEST("require that subdbs should change if relevant config changed")
TEST_MAIN()
{
TEST_RUN_ALL();
- vespalib::rmdir(BASE_DIR, true);
+ std::filesystem::remove_all(std::filesystem::path(BASE_DIR));
}
diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp
index a9f923833e5..916f3106923 100644
--- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp
@@ -36,6 +36,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/size_literals.h>
+#include <filesystem>
#include <iostream>
using namespace cloud::config::filedistribution;
@@ -62,10 +63,10 @@ namespace {
void
cleanup_dirs(bool file_config)
{
- vespalib::rmdir("typea", true);
- vespalib::rmdir("tmp", true);
+ std::filesystem::remove_all(std::filesystem::path("typea"));
+ std::filesystem::remove_all(std::filesystem::path("tmp"));
if (file_config) {
- vespalib::rmdir("config", true);
+ std::filesystem::remove_all(std::filesystem::path("config"));
}
}
@@ -105,7 +106,7 @@ FixtureBase::FixtureBase(bool file_config)
: _cleanup(true),
_file_config(file_config)
{
- vespalib::mkdir("typea");
+ std::filesystem::create_directory(std::filesystem::path("typea"));
}
@@ -352,7 +353,7 @@ TEST("require that resume after interrupted save config works")
std::cout << "Best config serial is " << best_config_snapshot.syncToken << std::endl;
auto old_config_subdir = config_subdir(best_config_snapshot.syncToken);
auto new_config_subdir = config_subdir(serialNum + 1);
- vespalib::mkdir(new_config_subdir);
+ std::filesystem::create_directories(std::filesystem::path(new_config_subdir));
auto config_files = vespalib::listDirectory(old_config_subdir);
for (auto &config_file : config_files) {
vespalib::copy(old_config_subdir + "/" + config_file, new_config_subdir + "/" + config_file, false, false);
diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
index 8ef2742b6d8..f9518cb1b5e 100644
--- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
@@ -35,7 +35,7 @@
#include <vespa/vespalib/util/lambdatask.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/size_literals.h>
-#include <vespa/vespalib/io/fileutil.h>
+#include <filesystem>
#include <vespa/log/log.h>
LOG_SETUP("feedhandler_test");
@@ -784,5 +784,5 @@ TEST_MAIN()
{
DummyFileHeaderContext::setCreator("feedhandler_test");
TEST_RUN_ALL();
- vespalib::rmdir("mytlsdir", true);
+ std::filesystem::remove_all(std::filesystem::path("mytlsdir"));
}
diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp
index 60864019419..0bc11e64df8 100644
--- a/searchcore/src/tests/proton/index/indexmanager_test.cpp
+++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp
@@ -19,13 +19,13 @@
#include <vespa/searchlib/queryeval/isourceselector.h>
#include <vespa/searchlib/test/index/mock_field_length_inspector.h>
#include <vespa/vespalib/gtest/gtest.h>
-#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/destructor_callbacks.h>
#include <vespa/vespalib/util/gate.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/time.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/fastos/file.h>
+#include <filesystem>
#include <set>
#include <thread>
@@ -122,7 +122,7 @@ struct IndexManagerTest : public ::testing::Test {
_builder(_schema)
{
removeTestData();
- vespalib::mkdir(index_dir, false);
+ std::filesystem::create_directory(std::filesystem::path(index_dir));
resetIndexManager();
}
diff --git a/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp b/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp
index 05d993a33e0..3d087808e44 100644
--- a/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp
+++ b/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp
@@ -10,6 +10,7 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/test/insertion_operators.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <filesystem>
using search::index::DummyFileHeaderContext;
using search::transactionlog::client::TransLogClient;
@@ -25,8 +26,8 @@ static const vespalib::string documentsDir(baseDir + "/documents");
struct FixtureBase
{
- FixtureBase() { vespalib::rmdir(baseDir, true); }
- ~FixtureBase() { vespalib::rmdir(baseDir, true); }
+ FixtureBase() { std::filesystem::remove_all(std::filesystem::path(baseDir)); }
+ ~FixtureBase() { std::filesystem::remove_all(std::filesystem::path(baseDir)); }
};
struct DiskLayoutFixture {
@@ -41,7 +42,7 @@ struct DiskLayoutFixture {
void createDirs(const std::set<vespalib::string> &dirs) {
for (const auto &dir : dirs) {
- vespalib::mkdir(documentsDir + "/" + dir, false);
+ std::filesystem::create_directory(std::filesystem::path(documentsDir + "/" + dir));
}
}
void createDomains(const std::set<vespalib::string> &domains) {