diff options
Diffstat (limited to 'tests/maildirsyncbenchmark.cpp')
-rw-r--r-- | tests/maildirsyncbenchmark.cpp | 105 |
1 files changed, 0 insertions, 105 deletions
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 @@ | |||
1 | #include <QtTest> | ||
2 | #include <QString> | ||
3 | #include <iostream> | ||
4 | |||
5 | #include "hawd/dataset.h" | ||
6 | #include "hawd/formatter.h" | ||
7 | |||
8 | #include "maildirresource/maildirresource.h" | ||
9 | #include "store.h" | ||
10 | #include "resourcecontrol.h" | ||
11 | #include "commands.h" | ||
12 | #include "entitybuffer.h" | ||
13 | #include "resourceconfig.h" | ||
14 | #include "modelresult.h" | ||
15 | #include "pipeline.h" | ||
16 | #include "log.h" | ||
17 | |||
18 | |||
19 | static bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath) | ||
20 | { | ||
21 | QFileInfo srcFileInfo(srcFilePath); | ||
22 | if (srcFileInfo.isDir()) { | ||
23 | QDir targetDir(tgtFilePath); | ||
24 | targetDir.cdUp(); | ||
25 | if (!targetDir.mkdir(QFileInfo(srcFilePath).fileName())) { | ||
26 | qWarning() << "Failed to create directory " << tgtFilePath; | ||
27 | return false; | ||
28 | } | ||
29 | QDir sourceDir(srcFilePath); | ||
30 | QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); | ||
31 | foreach (const QString &fileName, fileNames) { | ||
32 | const QString newSrcFilePath = srcFilePath + QLatin1Char('/') + fileName; | ||
33 | const QString newTgtFilePath = tgtFilePath + QLatin1Char('/') + fileName; | ||
34 | if (!copyRecursively(newSrcFilePath, newTgtFilePath)) | ||
35 | return false; | ||
36 | } | ||
37 | } else { | ||
38 | if (!QFile::copy(srcFilePath, tgtFilePath)) { | ||
39 | qWarning() << "Failed to copy file " << srcFilePath << tgtFilePath; | ||
40 | return false; | ||
41 | } | ||
42 | } | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * Test of complete system using the maildir resource. | ||
48 | * | ||
49 | * This test requires the maildir resource installed. | ||
50 | */ | ||
51 | class MaildirSyncBenchmark : public QObject | ||
52 | { | ||
53 | Q_OBJECT | ||
54 | |||
55 | QTemporaryDir tempDir; | ||
56 | QString targetPath; | ||
57 | HAWD::State mHawdState; | ||
58 | |||
59 | private slots: | ||
60 | void initTestCase() | ||
61 | { | ||
62 | targetPath = tempDir.path() + "/maildir1"; | ||
63 | |||
64 | MaildirResource::removeFromDisk("sink.maildir.test1"); | ||
65 | Sink::ApplicationDomain::SinkResource resource; | ||
66 | resource.setProperty("identifier", "sink.maildir.test1"); | ||
67 | resource.setProperty("type", "sink.maildir"); | ||
68 | resource.setProperty("path", targetPath); | ||
69 | Sink::Store::create(resource).exec().waitForFinished(); | ||
70 | } | ||
71 | |||
72 | void cleanup() | ||
73 | { | ||
74 | MaildirResource::removeFromDisk("sink.maildir.test1"); | ||
75 | QDir dir(targetPath); | ||
76 | dir.removeRecursively(); | ||
77 | } | ||
78 | |||
79 | void init() | ||
80 | { | ||
81 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); | ||
82 | } | ||
83 | |||
84 | void testbench() | ||
85 | { | ||
86 | auto pipeline = QSharedPointer<Sink::Pipeline>::create("sink.maildir.test1"); | ||
87 | MaildirResource resource("sink.maildir.test1", pipeline); | ||
88 | QTime time; | ||
89 | time.start(); | ||
90 | resource.Sink::GenericResource::synchronizeWithSource(Sink::QueryBase()).exec().waitForFinished(); | ||
91 | std::cout << "Sync took " << time.elapsed() << std::endl; | ||
92 | resource.processAllMessages().exec().waitForFinished(); | ||
93 | const auto allProcessedTime = time.elapsed(); | ||
94 | std::cout << "All done " << allProcessedTime << std::endl; | ||
95 | |||
96 | // HAWD::Dataset dataset("maildir_sync", mHawdState); | ||
97 | // HAWD::Dataset::Row row = dataset.row(); | ||
98 | // row.setValue("totalTime", allProcessedTime); | ||
99 | // dataset.insertRow(row); | ||
100 | // HAWD::Formatter::print(dataset); | ||
101 | } | ||
102 | }; | ||
103 | |||
104 | QTEST_MAIN(MaildirSyncBenchmark) | ||
105 | #include "maildirsyncbenchmark.moc" | ||