summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-07 11:27:40 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-07 11:27:40 +0200
commit3657dcd309f30b704801dcaf3e43b71ef703c0de (patch)
treef7b1cadf66c19b39c3eee9b34573bb965b7db2dd /tests/storagetest.cpp
parentf52ed4fd64994985f1061c5fcd20dccaa61fbc67 (diff)
downloadsink-3657dcd309f30b704801dcaf3e43b71ef703c0de.tar.gz
sink-3657dcd309f30b704801dcaf3e43b71ef703c0de.zip
Somewhat useless stress test...
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index dfb91ec..9e9bad9 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -505,6 +505,43 @@ private slots:
505 transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly); 505 transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
506 } 506 }
507 } 507 }
508
509 /*
510 * This test is meant to find problems with the multi-process architecture and initial database creation.
511 * If we create named databases dynamically (not all up front), it is possilbe that we violate the rule
512 * that mdb_open_dbi may only be used by a single thread at a time.
513 * This test is meant to stress that condition.
514 *
515 * However, it yields absolutely nothing.
516 */
517 void testReadDuringExternalProcessWrite()
518 {
519 QSKIP("Not running multiprocess test");
520
521 QList<QFuture<void>> futures;
522 for (int i = 0; i < 5; i++) {
523 futures << QtConcurrent::run([&]() {
524 QTRY_VERIFY(Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly).exists());
525 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly);
526 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
527 for (int i = 0; i < 100000; i++) {
528 transaction.openDatabase("a", nullptr, false);
529 transaction.openDatabase("b", nullptr, false);
530 transaction.openDatabase("c", nullptr, false);
531 transaction.openDatabase("p", nullptr, false);
532 transaction.openDatabase("q", nullptr, false);
533 }
534 });
535 }
536
537 //Start writing to the db from a separate process
538 QVERIFY(QProcess::startDetached(QCoreApplication::applicationDirPath() + "/dbwriter", QStringList() << testDataPath << dbName << QString::number(100000)));
539
540 for (auto future : futures) {
541 future.waitForFinished();
542 }
543
544 }
508}; 545};
509 546
510QTEST_MAIN(StorageTest) 547QTEST_MAIN(StorageTest)