From 624fb3718b5063f29644b69a8082ef9f84a55ec5 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 8 Oct 2017 16:18:07 +0200 Subject: Benchmark cleanup --- tests/dummyresourcebenchmark.cpp | 3 +- tests/dummyresourcewritebenchmark.cpp | 9 +-- tests/maildirsyncbenchmark.cpp | 105 ---------------------------------- 3 files changed, 5 insertions(+), 112 deletions(-) delete mode 100644 tests/maildirsyncbenchmark.cpp diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index a2de316..79c0c96 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp @@ -14,6 +14,7 @@ #include "notification_generated.h" #include "test.h" #include "testutils.h" +#include "adaptorfactoryregistry.h" #include "hawd/dataset.h" #include "hawd/formatter.h" @@ -150,7 +151,7 @@ private slots: QTime time; time.start(); - DummyResource resource(Sink::ResourceContext{"sink.dummy.instance1", "test"}); + DummyResource resource(Sink::ResourceContext{"sink.dummy.instance1", "sink.dummy", Sink::AdaptorFactoryRegistry::instance().getFactories("sink.dummy")}); flatbuffers::FlatBufferBuilder eventFbb; eventFbb.Clear(); diff --git a/tests/dummyresourcewritebenchmark.cpp b/tests/dummyresourcewritebenchmark.cpp index 397e5de..c350b1a 100644 --- a/tests/dummyresourcewritebenchmark.cpp +++ b/tests/dummyresourcewritebenchmark.cpp @@ -113,12 +113,7 @@ class DummyResourceWriteBenchmark : public QObject QTime time; time.start(); - - auto factory = new ::DummyResourceFactory; - factory->registerFacades("dummy", Sink::FacadeFactory::instance()); - factory->registerAdaptorFactories("dummy", Sink::AdaptorFactoryRegistry::instance()); - - ::DummyResource resource(Sink::ResourceContext{"sink.dummy.instance1", "dummy", Sink::AdaptorFactoryRegistry::instance().getFactories("dummy")}); + DummyResource resource(Sink::ResourceContext{"sink.dummy.instance1", "sink.dummy", Sink::AdaptorFactoryRegistry::instance().getFactories("sink.dummy")}); int bufferSize = 0; auto command = createEntityBuffer(bufferSize); @@ -184,6 +179,8 @@ private slots: void initTestCase() { Sink::Log::setDebugOutputLevel(Sink::Log::Warning); + auto factory = Sink::ResourceFactory::load("sink.dummy"); + QVERIFY(factory); } void cleanup() diff --git a/tests/maildirsyncbenchmark.cpp b/tests/maildirsyncbenchmark.cpp deleted file mode 100644 index ab09395..0000000 --- a/tests/maildirsyncbenchmark.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include -#include - -#include "hawd/dataset.h" -#include "hawd/formatter.h" - -#include "maildirresource/maildirresource.h" -#include "store.h" -#include "resourcecontrol.h" -#include "commands.h" -#include "entitybuffer.h" -#include "resourceconfig.h" -#include "modelresult.h" -#include "pipeline.h" -#include "log.h" - - -static bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath) -{ - QFileInfo srcFileInfo(srcFilePath); - if (srcFileInfo.isDir()) { - QDir targetDir(tgtFilePath); - targetDir.cdUp(); - if (!targetDir.mkdir(QFileInfo(srcFilePath).fileName())) { - qWarning() << "Failed to create directory " << tgtFilePath; - return false; - } - QDir sourceDir(srcFilePath); - QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); - foreach (const QString &fileName, fileNames) { - const QString newSrcFilePath = srcFilePath + QLatin1Char('/') + fileName; - const QString newTgtFilePath = tgtFilePath + QLatin1Char('/') + fileName; - if (!copyRecursively(newSrcFilePath, newTgtFilePath)) - return false; - } - } else { - if (!QFile::copy(srcFilePath, tgtFilePath)) { - qWarning() << "Failed to copy file " << srcFilePath << tgtFilePath; - return false; - } - } - return true; -} - -/** - * Test of complete system using the maildir resource. - * - * This test requires the maildir resource installed. - */ -class MaildirSyncBenchmark : public QObject -{ - Q_OBJECT - - QTemporaryDir tempDir; - QString targetPath; - HAWD::State mHawdState; - -private slots: - void initTestCase() - { - targetPath = tempDir.path() + "/maildir1"; - - MaildirResource::removeFromDisk("sink.maildir.test1"); - Sink::ApplicationDomain::SinkResource resource; - resource.setProperty("identifier", "sink.maildir.test1"); - resource.setProperty("type", "sink.maildir"); - resource.setProperty("path", targetPath); - Sink::Store::create(resource).exec().waitForFinished(); - } - - void cleanup() - { - MaildirResource::removeFromDisk("sink.maildir.test1"); - QDir dir(targetPath); - dir.removeRecursively(); - } - - void init() - { - copyRecursively(TESTDATAPATH "/maildir1", targetPath); - } - - void testbench() - { - auto pipeline = QSharedPointer::create("sink.maildir.test1"); - MaildirResource resource("sink.maildir.test1", pipeline); - QTime time; - time.start(); - resource.Sink::GenericResource::synchronizeWithSource(Sink::QueryBase()).exec().waitForFinished(); - std::cout << "Sync took " << time.elapsed() << std::endl; - resource.processAllMessages().exec().waitForFinished(); - const auto allProcessedTime = time.elapsed(); - std::cout << "All done " << allProcessedTime << std::endl; - - // HAWD::Dataset dataset("maildir_sync", mHawdState); - // HAWD::Dataset::Row row = dataset.row(); - // row.setValue("totalTime", allProcessedTime); - // dataset.insertRow(row); - // HAWD::Formatter::print(dataset); - } -}; - -QTEST_MAIN(MaildirSyncBenchmark) -#include "maildirsyncbenchmark.moc" -- cgit v1.2.3