summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-03 14:02:27 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-03 14:02:27 +0200
commit55fe06979ceebe67553135b43aa47e70d931304b (patch)
tree16b10a744879cc1872d6c07624b59ae64469ddbf /tests/storagetest.cpp
parent56fae95f49a1ca8ca614bd9f89b0ea5f872765e9 (diff)
parent288946f1694c2abe1d2c5800c87339d1e8780e4b (diff)
downloadsink-55fe06979ceebe67553135b43aa47e70d931304b.tar.gz
sink-55fe06979ceebe67553135b43aa47e70d931304b.zip
Merge branch 'develop'
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index 7202628..9e9bad9 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -487,6 +487,61 @@ private slots:
487 } 487 }
488 } 488 }
489 489
490 void testCopyTransaction()
491 {
492 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
493 {
494 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
495 transaction.openDatabase("a", nullptr, false);
496 transaction.openDatabase("b", nullptr, false);
497 transaction.openDatabase("c", nullptr, false);
498 transaction.commit();
499 }
500 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
501 for (int i = 0; i < 1000; i++) {
502 transaction.openDatabase("a", nullptr, false);
503 transaction.openDatabase("b", nullptr, false);
504 transaction.openDatabase("c", nullptr, false);
505 transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
506 }
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 }
490}; 545};
491 546
492QTEST_MAIN(StorageTest) 547QTEST_MAIN(StorageTest)