diff options
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r-- | tests/storagetest.cpp | 55 |
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 | ||
492 | QTEST_MAIN(StorageTest) | 547 | QTEST_MAIN(StorageTest) |