From 237b9ae4113e7a9f489632296941becb71afdb45 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 16 Oct 2016 14:55:20 +0200 Subject: Refactor how the storage is used. This is the initial refactoring to improve how we deal with the storage. It does a couple of things: * Rename Sink::Storage to Sink::Storage::DataStore to free up the Sink::Storage namespace * Introduce a Sink::ResourceContext to have a single object that can be passed around containing everything that is necessary to operate on a resource. This is a lot better than the multiple separate parameters that we used to pass around all over the place, while still allowing for dependency injection for tests. * Tie storage access together using the new EntityStore that directly works with ApplicationDomainTypes. This gives us a central place where main storage, indexes and buffer adaptors are tied together, which will also give us a place to implement external indexes, such as a fulltextindex using xapian. * Use ApplicationDomainTypes as the default way to pass around entities. Instead of using various ways to pass around entities (buffers, buffer adaptors, ApplicationDomainTypes), only use a single way. The old approach was confusing, and was only done as: * optimization; really shouldn't be necessary and otherwise I'm sure we can find better ways to optimize ApplicationDomainType itself. * a way to account for entities that have multiple buffers, a concept that I no longer deem relevant. While this commit does the bulk of the work to get there, the following commits will refactor more stuff to get things back to normal. --- tests/clientapitest.cpp | 6 +- .../databasepopulationandfacadequerybenchmark.cpp | 22 ++-- tests/dummyresourcebenchmark.cpp | 4 +- tests/dummyresourcetest.cpp | 9 +- tests/dummyresourcewritebenchmark.cpp | 4 +- tests/hawd/dataset.cpp | 8 +- tests/hawd/dataset.h | 4 +- tests/indextest.cpp | 6 +- tests/mailquerybenchmark.cpp | 11 +- tests/messagequeuetest.cpp | 4 +- tests/pipelinebenchmark.cpp | 11 +- tests/pipelinetest.cpp | 49 ++++---- tests/querytest.cpp | 2 +- tests/storagebenchmark.cpp | 24 ++-- tests/storagetest.cpp | 136 ++++++++++----------- tests/testimplementations.h | 10 +- 16 files changed, 155 insertions(+), 155 deletions(-) (limited to 'tests') diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index fd3d5f0..94c78a7 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp @@ -22,11 +22,13 @@ public: auto facade = std::make_shared>(); map.insert(instanceIdentifier, facade); bool alwaysReturnFacade = instanceIdentifier.isEmpty(); - Sink::FacadeFactory::instance().registerFacade>("dummyresource", [alwaysReturnFacade](const QByteArray &instanceIdentifier) { + Sink::FacadeFactory::instance().registerFacade>("dummyresource", [alwaysReturnFacade](const Sink::ResourceContext &context) { if (alwaysReturnFacade) { + Q_ASSERT(map.contains(QByteArray())); return map.value(QByteArray()); } - return map.value(instanceIdentifier); + Q_ASSERT(map.contains(context.instanceId())); + return map.value(context.instanceId()); }); return facade; } diff --git a/tests/databasepopulationandfacadequerybenchmark.cpp b/tests/databasepopulationandfacadequerybenchmark.cpp index 5efe292..4e00bd4 100644 --- a/tests/databasepopulationandfacadequerybenchmark.cpp +++ b/tests/databasepopulationandfacadequerybenchmark.cpp @@ -38,13 +38,13 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject void populateDatabase(int count) { - Sink::Storage(Sink::storageLocation(), "identifier", Sink::Storage::ReadWrite).removeFromDisk(); + Sink::Storage::DataStore(Sink::storageLocation(), "identifier", Sink::Storage::DataStore::ReadWrite).removeFromDisk(); // Setup auto domainTypeAdaptorFactory = QSharedPointer::create(); { - Sink::Storage storage(Sink::storageLocation(), identifier, Sink::Storage::ReadWrite); - auto transaction = storage.createTransaction(Sink::Storage::ReadWrite); - auto db = Sink::Storage::mainDatabase(transaction, "event"); + Sink::Storage::DataStore storage(Sink::storageLocation(), identifier, Sink::Storage::DataStore::ReadWrite); + auto transaction = storage.createTransaction(Sink::Storage::DataStore::ReadWrite); + auto db = Sink::Storage::DataStore::mainDatabase(transaction, "event"); int bufferSizeTotal = 0; int keysSizeTotal = 0; @@ -58,15 +58,15 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject flatbuffers::FlatBufferBuilder fbb; domainTypeAdaptorFactory->createBuffer(*domainObject, fbb); const auto buffer = QByteArray::fromRawData(reinterpret_cast(fbb.GetBufferPointer()), fbb.GetSize()); - const auto key = Sink::Storage::generateUid(); + const auto key = Sink::Storage::DataStore::generateUid(); db.write(key, buffer); bufferSizeTotal += buffer.size(); keysSizeTotal += key.size(); } transaction.commit(); - transaction = storage.createTransaction(Sink::Storage::ReadOnly); - db = Sink::Storage::mainDatabase(transaction, "event"); + transaction = storage.createTransaction(Sink::Storage::DataStore::ReadOnly); + db = Sink::Storage::DataStore::mainDatabase(transaction, "event"); auto dataSizeTotal = count * (QByteArray("uid").size() + QByteArray("summary").size() + attachment.size()); auto size = db.getSize(); @@ -100,7 +100,11 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject auto resultSet = QSharedPointer>::create(); auto resourceAccess = QSharedPointer::create(); - TestResourceFacade facade(identifier, resourceAccess); + + QMap factories; + Sink::ResourceContext context{identifier, "test", factories}; + context.mResourceAccess = resourceAccess; + TestResourceFacade facade(context); auto ret = facade.load(query); ret.first.exec().waitForFinished(); @@ -118,7 +122,7 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject const auto finalRss = getCurrentRSS(); const auto rssGrowth = finalRss - startingRss; // Since the database is memory mapped it is attributted to the resident set size. - const auto rssWithoutDb = finalRss - Sink::Storage(Sink::storageLocation(), identifier, Sink::Storage::ReadWrite).diskUsage(); + const auto rssWithoutDb = finalRss - Sink::Storage::DataStore(Sink::storageLocation(), identifier, Sink::Storage::DataStore::ReadWrite).diskUsage(); const auto peakRss = getPeakRSS(); // How much peak deviates from final rss in percent (should be around 0) const auto percentageRssError = static_cast(peakRss - finalRss) * 100.0 / static_cast(finalRss); diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index d0ecef7..a2de316 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp @@ -9,7 +9,6 @@ #include "resourcecontrol.h" #include "commands.h" #include "entitybuffer.h" -#include "pipeline.h" #include "log.h" #include "resourceconfig.h" #include "notification_generated.h" @@ -151,8 +150,7 @@ private slots: QTime time; time.start(); - auto pipeline = QSharedPointer::create("sink.dummy.instance1"); - DummyResource resource("sink.dummy.instance1", pipeline); + DummyResource resource(Sink::ResourceContext{"sink.dummy.instance1", "test"}); flatbuffers::FlatBufferBuilder eventFbb; eventFbb.Clear(); diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index be6e3a5..0883a13 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp @@ -13,6 +13,7 @@ #include "log.h" #include "test.h" #include "testutils.h" +#include "adaptorfactoryregistry.h" using namespace Sink; using namespace Sink::ApplicationDomain; @@ -28,6 +29,11 @@ class DummyResourceTest : public QObject QTime time; + Sink::ResourceContext getContext() + { + return Sink::ResourceContext{"sink.dummy.instance1", "sink.dummy", Sink::AdaptorFactoryRegistry::instance().getFactories("sink.dummy")}; + } + private slots: void initTestCase() { @@ -129,8 +135,7 @@ private slots: void testResourceSync() { - auto pipeline = QSharedPointer::create("sink.dummy.instance1"); - ::DummyResource resource("sink.dummy.instance1", pipeline); + ::DummyResource resource(getContext()); auto job = resource.synchronizeWithSource(); // TODO pass in optional timeout? auto future = job.exec(); diff --git a/tests/dummyresourcewritebenchmark.cpp b/tests/dummyresourcewritebenchmark.cpp index 5cd7007..facd60c 100644 --- a/tests/dummyresourcewritebenchmark.cpp +++ b/tests/dummyresourcewritebenchmark.cpp @@ -9,7 +9,6 @@ #include "store.h" #include "commands.h" #include "entitybuffer.h" -#include "pipeline.h" #include "log.h" #include "resourceconfig.h" #include "definitions.h" @@ -109,8 +108,7 @@ class DummyResourceWriteBenchmark : public QObject QTime time; time.start(); - auto pipeline = QSharedPointer::create("sink.dummy.instance1"); - DummyResource resource("sink.dummy.instance1", pipeline); + ::DummyResource resource(Sink::ResourceContext{"sink.dummy.instance1", "dummy"}); int bufferSize = 0; auto command = createEntityBuffer(bufferSize); diff --git a/tests/hawd/dataset.cpp b/tests/hawd/dataset.cpp index c023f31..fb2d7e6 100644 --- a/tests/hawd/dataset.cpp +++ b/tests/hawd/dataset.cpp @@ -215,7 +215,7 @@ QString Dataset::Row::toString(const QStringList &cols, int standardCols, const Dataset::Dataset(const QString &name, const State &state) : m_definition(state.datasetDefinition(name)), - m_storage(state.resultsPath(), name, Sink::Storage::ReadWrite), + m_storage(state.resultsPath(), name, Sink::Storage::DataStore::ReadWrite), m_transaction(m_storage.createTransaction()), m_commitHash(state.commitHash()) { @@ -270,13 +270,13 @@ void Dataset::eachRow(const std::function &resultHandler) resultHandler(row); return true; }, - Sink::Storage::basicErrorHandler()); + Sink::Storage::DataStore::basicErrorHandler()); } Dataset::Row Dataset::row(qint64 key) { if (key < 1) { - Row row(*this, Sink::Storage::maxRevision(m_transaction)); + Row row(*this, Sink::Storage::DataStore::maxRevision(m_transaction)); row.setCommitHash(m_commitHash); return row; } @@ -287,7 +287,7 @@ Dataset::Row Dataset::row(qint64 key) row.fromBinary(value); return true; }, - Sink::Storage::basicErrorHandler() + Sink::Storage::DataStore::basicErrorHandler() ); return row; } diff --git a/tests/hawd/dataset.h b/tests/hawd/dataset.h index 0fca8f0..bb2aae5 100644 --- a/tests/hawd/dataset.h +++ b/tests/hawd/dataset.h @@ -84,8 +84,8 @@ public: private: DatasetDefinition m_definition; - Sink::Storage m_storage; - Sink::Storage::Transaction m_transaction; + Sink::Storage::DataStore m_storage; + Sink::Storage::DataStore::Transaction m_transaction; QString m_commitHash; }; diff --git a/tests/indextest.cpp b/tests/indextest.cpp index 8566803..d6a28d6 100644 --- a/tests/indextest.cpp +++ b/tests/indextest.cpp @@ -16,19 +16,19 @@ class IndexTest : public QObject private slots: void initTestCase() { - Sink::Storage store("./testindex", "sink.dummy.testindex", Sink::Storage::ReadWrite); + Sink::Storage::DataStore store("./testindex", "sink.dummy.testindex", Sink::Storage::DataStore::ReadWrite); store.removeFromDisk(); } void cleanup() { - Sink::Storage store("./testindex", "sink.dummy.testindex", Sink::Storage::ReadWrite); + Sink::Storage::DataStore store("./testindex", "sink.dummy.testindex", Sink::Storage::DataStore::ReadWrite); store.removeFromDisk(); } void testIndex() { - Index index("./testindex", "sink.dummy.testindex", Sink::Storage::ReadWrite); + Index index("./testindex", "sink.dummy.testindex", Sink::Storage::DataStore::ReadWrite); // The first key is specifically a substring of the second key index.add("key", "value1"); index.add("keyFoo", "value2"); diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp index 1d96819..c44b9f6 100644 --- a/tests/mailquerybenchmark.cpp +++ b/tests/mailquerybenchmark.cpp @@ -62,8 +62,7 @@ class MailQueryBenchmark : public QObject { TestResource::removeFromDisk(resourceIdentifier); - auto pipeline = QSharedPointer::create(resourceIdentifier); - pipeline->setResourceType("test"); + auto pipeline = QSharedPointer::create(Sink::ResourceContext{resourceIdentifier, "test"}); auto indexer = QSharedPointer>::create(); @@ -94,10 +93,10 @@ class MailQueryBenchmark : public QObject // Benchmark QTime time; time.start(); - auto resultSet = QSharedPointer>::create(); - auto resourceAccess = QSharedPointer::create(); - TestMailResourceFacade facade(resourceIdentifier, resourceAccess); + Sink::ResourceContext context{resourceIdentifier, "test"}; + context.mResourceAccess = QSharedPointer::create(); + TestMailResourceFacade facade(context); auto ret = facade.load(query); ret.first.exec().waitForFinished(); @@ -115,7 +114,7 @@ class MailQueryBenchmark : public QObject const auto finalRss = getCurrentRSS(); const auto rssGrowth = finalRss - startingRss; // Since the database is memory mapped it is attributted to the resident set size. - const auto rssWithoutDb = finalRss - Sink::Storage(Sink::storageLocation(), resourceIdentifier, Sink::Storage::ReadWrite).diskUsage(); + const auto rssWithoutDb = finalRss - Sink::Storage::DataStore(Sink::storageLocation(), resourceIdentifier, Sink::Storage::DataStore::ReadWrite).diskUsage(); const auto peakRss = getPeakRSS(); // How much peak deviates from final rss in percent (should be around 0) const auto percentageRssError = static_cast(peakRss - finalRss) * 100.0 / static_cast(finalRss); diff --git a/tests/messagequeuetest.cpp b/tests/messagequeuetest.cpp index e79bba2..83fa23f 100644 --- a/tests/messagequeuetest.cpp +++ b/tests/messagequeuetest.cpp @@ -21,7 +21,7 @@ private slots: void initTestCase() { Sink::Test::initTest(); - Sink::Storage store(Sink::Store::storageLocation(), "sink.dummy.testqueue", Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(Sink::Store::storageLocation(), "sink.dummy.testqueue", Sink::Storage::DataStore::ReadWrite); store.removeFromDisk(); } @@ -31,7 +31,7 @@ private slots: void cleanup() { - Sink::Storage store(Sink::Store::storageLocation(), "sink.dummy.testqueue", Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(Sink::Store::storageLocation(), "sink.dummy.testqueue", Sink::Storage::DataStore::ReadWrite); store.removeFromDisk(); } diff --git a/tests/pipelinebenchmark.cpp b/tests/pipelinebenchmark.cpp index 0c0b9e6..16806c7 100644 --- a/tests/pipelinebenchmark.cpp +++ b/tests/pipelinebenchmark.cpp @@ -47,7 +47,7 @@ // class IndexUpdater : public Sink::Preprocessor { // public: -// void newEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE +// void newEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE // { // for (int i = 0; i < 10; i++) { // Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction); @@ -56,11 +56,11 @@ // } // // void modifiedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, const Sink::ApplicationDomain::BufferAdaptor &newEntity, -// Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE +// Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE // { // } // -// void deletedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE +// void deletedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE // { // } // }; @@ -83,9 +83,8 @@ class PipelineBenchmark : public QObject { TestResource::removeFromDisk(resourceIdentifier); - auto pipeline = QSharedPointer::create(resourceIdentifier); + auto pipeline = QSharedPointer::create(Sink::ResourceContext{resourceIdentifier, "test"}); pipeline->setPreprocessors("mail", preprocessors); - pipeline->setResourceType("test"); QTime time; time.start(); @@ -112,7 +111,7 @@ class PipelineBenchmark : public QObject // Print memory layout, RSS is what is in memory // std::system("exec pmap -x \"$PPID\""); // - std::cout << "Size: " << Sink::Storage(Sink::storageLocation(), resourceIdentifier, Sink::Storage::ReadOnly).diskUsage() / 1024 << " [kb]" << std::endl; + std::cout << "Size: " << Sink::Storage::DataStore(Sink::storageLocation(), resourceIdentifier, Sink::Storage::DataStore::ReadOnly).diskUsage() / 1024 << " [kb]" << std::endl; std::cout << "Time: " << allProcessedTime << " [ms]" << std::endl; HAWD::Dataset dataset("pipeline", mHawdState); diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp index 7216f62..112453e 100644 --- a/tests/pipelinetest.cpp +++ b/tests/pipelinetest.cpp @@ -23,14 +23,14 @@ static void removeFromDisk(const QString &name) { - Sink::Storage store(Sink::Store::storageLocation(), name, Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(Sink::Store::storageLocation(), name, Sink::Storage::DataStore::ReadWrite); store.removeFromDisk(); } static QList getKeys(const QByteArray &dbEnv, const QByteArray &name) { - Sink::Storage store(Sink::storageLocation(), dbEnv, Sink::Storage::ReadOnly); - auto transaction = store.createTransaction(Sink::Storage::ReadOnly); + Sink::Storage::DataStore store(Sink::storageLocation(), dbEnv, Sink::Storage::DataStore::ReadOnly); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly); auto db = transaction.openDatabase(name, nullptr, false); QList result; db.scan("", [&](const QByteArray &key, const QByteArray &value) { @@ -42,8 +42,8 @@ static QList getKeys(const QByteArray &dbEnv, const QByteArray &name static QByteArray getEntity(const QByteArray &dbEnv, const QByteArray &name, const QByteArray &uid) { - Sink::Storage store(Sink::storageLocation(), dbEnv, Sink::Storage::ReadOnly); - auto transaction = store.createTransaction(Sink::Storage::ReadOnly); + Sink::Storage::DataStore store(Sink::storageLocation(), dbEnv, Sink::Storage::DataStore::ReadOnly); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly); auto db = transaction.openDatabase(name, nullptr, false); QByteArray result; db.scan(uid, [&](const QByteArray &key, const QByteArray &value) { @@ -152,20 +152,20 @@ QByteArray deleteEntityCommand(const QByteArray &uid, qint64 revision) class TestProcessor : public Sink::Preprocessor { public: - void newEntity(const QByteArray &uid, qint64 revision, Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE + void newEntity(const QByteArray &uid, qint64 revision, Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE { newUids << uid; newRevisions << revision; } void modifiedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::ApplicationDomain::BufferAdaptor &newEntity, - Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE + Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE { modifiedUids << uid; modifiedRevisions << revision; } - void deletedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE + void deletedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE { deletedUids << uid; deletedRevisions << revision; @@ -203,8 +203,7 @@ private slots: flatbuffers::FlatBufferBuilder entityFbb; auto command = createEntityCommand(createEvent(entityFbb)); - Sink::Pipeline pipeline("sink.pipelinetest.instance1"); - pipeline.setResourceType("test"); + Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"}); pipeline.startTransaction(); pipeline.newEntity(command.constData(), command.size()); @@ -220,8 +219,7 @@ private slots: flatbuffers::FlatBufferBuilder entityFbb; auto command = createEntityCommand(createEvent(entityFbb, "summary", "description")); - Sink::Pipeline pipeline("sink.pipelinetest.instance1"); - pipeline.setResourceType("test"); + Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"}); auto adaptorFactory = QSharedPointer::create(); @@ -234,7 +232,7 @@ private slots: auto keys = getKeys("sink.pipelinetest.instance1", "event.main"); QCOMPARE(keys.size(), 1); const auto key = keys.first(); - const auto uid = Sink::Storage::uidFromKey(key); + const auto uid = Sink::Storage::DataStore::uidFromKey(key); // Execute the modification entityFbb.Clear(); @@ -244,7 +242,7 @@ private slots: pipeline.commit(); // Ensure we've got the new revision with the modification - auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 2)); + auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::DataStore::assembleKey(uid, 2)); QVERIFY(!buffer.isEmpty()); Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); @@ -269,8 +267,7 @@ private slots: flatbuffers::FlatBufferBuilder entityFbb; auto command = createEntityCommand(createEvent(entityFbb)); - Sink::Pipeline pipeline("sink.pipelinetest.instance1"); - pipeline.setResourceType("test"); + Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"}); auto adaptorFactory = QSharedPointer::create(); @@ -282,7 +279,7 @@ private slots: // Get uid of written entity auto keys = getKeys("sink.pipelinetest.instance1", "event.main"); QCOMPARE(keys.size(), 1); - const auto uid = Sink::Storage::uidFromKey(keys.first()); + const auto uid = Sink::Storage::DataStore::uidFromKey(keys.first()); // Create another operation inbetween @@ -302,7 +299,7 @@ private slots: pipeline.commit(); // Ensure we've got the new revision with the modification - auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 3)); + auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::DataStore::assembleKey(uid, 3)); QVERIFY(!buffer.isEmpty()); Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); @@ -313,8 +310,7 @@ private slots: { flatbuffers::FlatBufferBuilder entityFbb; auto command = createEntityCommand(createEvent(entityFbb)); - Sink::Pipeline pipeline("sink.pipelinetest.instance1"); - pipeline.setResourceType("test"); + Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"}); // Create the initial revision pipeline.startTransaction(); @@ -324,7 +320,7 @@ private slots: auto result = getKeys("sink.pipelinetest.instance1", "event.main"); QCOMPARE(result.size(), 1); - const auto uid = Sink::Storage::uidFromKey(result.first()); + const auto uid = Sink::Storage::DataStore::uidFromKey(result.first()); // Delete entity auto deleteCommand = deleteEntityCommand(uid, 1); @@ -350,8 +346,7 @@ private slots: auto testProcessor = new TestProcessor; - Sink::Pipeline pipeline("sink.pipelinetest.instance1"); - pipeline.setResourceType("test"); + Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"}); pipeline.setPreprocessors("event", QVector() << testProcessor); pipeline.startTransaction(); // pipeline.setAdaptorFactory("event", QSharedPointer::create()); @@ -363,21 +358,21 @@ private slots: QCOMPARE(testProcessor->newUids.size(), 1); QCOMPARE(testProcessor->newRevisions.size(), 1); // Key doesn't contain revision and is just the uid - QCOMPARE(testProcessor->newUids.at(0), Sink::Storage::uidFromKey(testProcessor->newUids.at(0))); + QCOMPARE(testProcessor->newUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->newUids.at(0))); } pipeline.commit(); entityFbb.Clear(); pipeline.startTransaction(); auto keys = getKeys("sink.pipelinetest.instance1", "event.main"); QCOMPARE(keys.size(), 1); - const auto uid = Sink::Storage::uidFromKey(keys.first()); + const auto uid = Sink::Storage::DataStore::uidFromKey(keys.first()); { auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1); pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); QCOMPARE(testProcessor->modifiedUids.size(), 1); QCOMPARE(testProcessor->modifiedRevisions.size(), 1); // Key doesn't contain revision and is just the uid - QCOMPARE(testProcessor->modifiedUids.at(0), Sink::Storage::uidFromKey(testProcessor->modifiedUids.at(0))); + QCOMPARE(testProcessor->modifiedUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->modifiedUids.at(0))); } pipeline.commit(); entityFbb.Clear(); @@ -389,7 +384,7 @@ private slots: QCOMPARE(testProcessor->deletedUids.size(), 1); QCOMPARE(testProcessor->deletedSummaries.size(), 1); // Key doesn't contain revision and is just the uid - QCOMPARE(testProcessor->deletedUids.at(0), Sink::Storage::uidFromKey(testProcessor->deletedUids.at(0))); + QCOMPARE(testProcessor->deletedUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->deletedUids.at(0))); QCOMPARE(testProcessor->deletedSummaries.at(0), QByteArray("summary2")); } } diff --git a/tests/querytest.cpp b/tests/querytest.cpp index c5c251a..9ae3c74 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -64,7 +64,7 @@ private slots: // Setup { Mail mail("sink.dummy.instance1"); - Sink::Store::create(mail).exec().waitForFinished(); + VERIFYEXEC(Sink::Store::create(mail)); } // Test diff --git a/tests/storagebenchmark.cpp b/tests/storagebenchmark.cpp index a1ddcc9..906844e 100644 --- a/tests/storagebenchmark.cpp +++ b/tests/storagebenchmark.cpp @@ -62,7 +62,7 @@ private slots: void cleanupTestCase() { - Sink::Storage store(testDataPath, dbName); + Sink::Storage::DataStore store(testDataPath, dbName); store.removeFromDisk(); } @@ -70,7 +70,7 @@ private slots: { auto event = createEvent(); - QScopedPointer store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadWrite)); + QScopedPointer store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite)); const char *keyPrefix = "key"; @@ -78,12 +78,12 @@ private slots: time.start(); // Test db write time { - auto transaction = store->createTransaction(Sink::Storage::ReadWrite); + auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite); for (int i = 0; i < count; i++) { transaction.openDatabase().write(keyPrefix + QByteArray::number(i), event); if ((i % 10000) == 0) { transaction.commit(); - transaction = store->createTransaction(Sink::Storage::ReadWrite); + transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite); } } transaction.commit(); @@ -105,7 +105,7 @@ private slots: // Db read time { - auto transaction = store->createTransaction(Sink::Storage::ReadOnly); + auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadOnly); auto db = transaction.openDatabase(); for (int i = 0; i < count; i++) { db.scan(keyPrefix + QByteArray::number(i), [](const QByteArray &key, const QByteArray &value) -> bool { return true; }); @@ -126,7 +126,7 @@ private slots: void testSizes() { - Sink::Storage store(testDataPath, dbName); + Sink::Storage::DataStore store(testDataPath, dbName); qDebug() << "Database size [kb]: " << store.diskUsage() / 1024; QFileInfo fileInfo(filePath); @@ -135,11 +135,11 @@ private slots: void testScan() { - QScopedPointer store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); + QScopedPointer store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly)); QBENCHMARK { int hit = 0; - store->createTransaction(Sink::Storage::ReadOnly) + store->createTransaction(Sink::Storage::DataStore::ReadOnly) .openDatabase() .scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { if (key == "key10000") { @@ -154,8 +154,8 @@ private slots: void testKeyLookup() { - QScopedPointer store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); - auto transaction = store->createTransaction(Sink::Storage::ReadOnly); + QScopedPointer store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly)); + auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadOnly); auto db = transaction.openDatabase(); QBENCHMARK { @@ -170,8 +170,8 @@ private slots: void testFindLatest() { - QScopedPointer store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); - auto transaction = store->createTransaction(Sink::Storage::ReadOnly); + QScopedPointer store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly)); + auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadOnly); auto db = transaction.openDatabase(); QBENCHMARK { diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp index aa12ec1..5a517c7 100644 --- a/tests/storagetest.cpp +++ b/tests/storagetest.cpp @@ -21,14 +21,14 @@ private: void populate(int count) { - Sink::Storage storage(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = storage.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore storage(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = storage.createTransaction(Sink::Storage::DataStore::ReadWrite); for (int i = 0; i < count; i++) { // This should perhaps become an implementation detail of the db? if (i % 10000 == 0) { if (i > 0) { transaction.commit(); - transaction = storage.createTransaction(Sink::Storage::ReadWrite); + transaction = storage.createTransaction(Sink::Storage::DataStore::ReadWrite); } } transaction.openDatabase().write(keyPrefix + QByteArray::number(i), keyPrefix + QByteArray::number(i)); @@ -36,12 +36,12 @@ private: transaction.commit(); } - bool verify(Sink::Storage &storage, int i) + bool verify(Sink::Storage::DataStore &storage, int i) { bool success = true; bool keyMatch = true; const auto reference = keyPrefix + QByteArray::number(i); - storage.createTransaction(Sink::Storage::ReadOnly) + storage.createTransaction(Sink::Storage::DataStore::ReadOnly) .openDatabase() .scan(keyPrefix + QByteArray::number(i), [&keyMatch, &reference](const QByteArray &key, const QByteArray &value) -> bool { @@ -51,7 +51,7 @@ private: } return keyMatch; }, - [&success](const Sink::Storage::Error &error) { + [&success](const Sink::Storage::DataStore::Error &error) { qDebug() << error.message; success = false; }); @@ -63,20 +63,20 @@ private slots: { testDataPath = "./testdb"; dbName = "test"; - Sink::Storage storage(testDataPath, dbName); + Sink::Storage::DataStore storage(testDataPath, dbName); storage.removeFromDisk(); } void cleanup() { - Sink::Storage storage(testDataPath, dbName); + Sink::Storage::DataStore storage(testDataPath, dbName); storage.removeFromDisk(); } void testCleanup() { populate(1); - Sink::Storage storage(testDataPath, dbName); + Sink::Storage::DataStore storage(testDataPath, dbName); storage.removeFromDisk(); QFileInfo info(testDataPath + "/" + dbName); QVERIFY(!info.exists()); @@ -90,7 +90,7 @@ private slots: // ensure we can read everything back correctly { - Sink::Storage storage(testDataPath, dbName); + Sink::Storage::DataStore storage(testDataPath, dbName); for (int i = 0; i < count; i++) { QVERIFY(verify(storage, i)); } @@ -105,8 +105,8 @@ private slots: // ensure we can scan for values { int hit = 0; - Sink::Storage store(testDataPath, dbName); - store.createTransaction(Sink::Storage::ReadOnly) + Sink::Storage::DataStore store(testDataPath, dbName); + store.createTransaction(Sink::Storage::DataStore::ReadOnly) .openDatabase() .scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { if (key == "key50") { @@ -121,8 +121,8 @@ private slots: { int hit = 0; bool foundInvalidValue = false; - Sink::Storage store(testDataPath, dbName); - store.createTransaction(Sink::Storage::ReadOnly) + Sink::Storage::DataStore store(testDataPath, dbName); + store.createTransaction(Sink::Storage::DataStore::ReadOnly) .openDatabase() .scan("key50", [&](const QByteArray &key, const QByteArray &value) -> bool { if (key != "key50") { @@ -139,10 +139,10 @@ private slots: void testNestedOperations() { populate(3); - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); transaction.openDatabase().scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { - transaction.openDatabase().remove(key, [](const Sink::Storage::Error &) { QVERIFY(false); }); + transaction.openDatabase().remove(key, [](const Sink::Storage::DataStore::Error &) { QVERIFY(false); }); return false; }); } @@ -150,11 +150,11 @@ private slots: void testNestedTransactions() { populate(3); - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - store.createTransaction(Sink::Storage::ReadOnly) + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + store.createTransaction(Sink::Storage::DataStore::ReadOnly) .openDatabase() .scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { - store.createTransaction(Sink::Storage::ReadWrite).openDatabase().remove(key, [](const Sink::Storage::Error &) { QVERIFY(false); }); + store.createTransaction(Sink::Storage::DataStore::ReadWrite).openDatabase().remove(key, [](const Sink::Storage::DataStore::Error &) { QVERIFY(false); }); return false; }); } @@ -163,9 +163,9 @@ private slots: { bool gotResult = false; bool gotError = false; - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadOnly); - auto db = transaction.openDatabase("default", [&](const Sink::Storage::Error &error) { + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly); + auto db = transaction.openDatabase("default", [&](const Sink::Storage::DataStore::Error &error) { qDebug() << error.message; gotError = true; }); @@ -174,7 +174,7 @@ private slots: gotResult = true; return false; }, - [&](const Sink::Storage::Error &error) { + [&](const Sink::Storage::DataStore::Error &error) { qDebug() << error.message; gotError = true; }); @@ -199,8 +199,8 @@ private slots: const int concurrencyLevel = 20; for (int num = 0; num < concurrencyLevel; num++) { futures << QtConcurrent::run([this, count, &error]() { - Sink::Storage storage(testDataPath, dbName, Sink::Storage::ReadOnly); - Sink::Storage storage2(testDataPath, dbName + "2", Sink::Storage::ReadOnly); + Sink::Storage::DataStore storage(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly); + Sink::Storage::DataStore storage2(testDataPath, dbName + "2", Sink::Storage::DataStore::ReadOnly); for (int i = 0; i < count; i++) { if (!verify(storage, i)) { error = true; @@ -216,9 +216,9 @@ private slots: } { - Sink::Storage storage(testDataPath, dbName); + Sink::Storage::DataStore storage(testDataPath, dbName); storage.removeFromDisk(); - Sink::Storage storage2(testDataPath, dbName + "2"); + Sink::Storage::DataStore storage2(testDataPath, dbName + "2"); storage2.removeFromDisk(); } } @@ -227,8 +227,8 @@ private slots: { bool gotResult = false; bool gotError = false; - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("default", nullptr, false); db.write("key", "value"); db.write("key", "value"); @@ -238,7 +238,7 @@ private slots: gotResult = true; return true; }, - [&](const Sink::Storage::Error &error) { + [&](const Sink::Storage::DataStore::Error &error) { qDebug() << error.message; gotError = true; }); @@ -252,8 +252,8 @@ private slots: { bool gotResult = false; bool gotError = false; - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("default", nullptr, true); db.write("key", "value1"); db.write("key", "value2"); @@ -262,7 +262,7 @@ private slots: gotResult = true; return true; }, - [&](const Sink::Storage::Error &error) { + [&](const Sink::Storage::DataStore::Error &error) { qDebug() << error.message; gotError = true; }); @@ -275,15 +275,15 @@ private slots: { bool gotResult = false; bool gotError = false; - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadOnly); - int numValues = store.createTransaction(Sink::Storage::ReadOnly) + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly); + int numValues = store.createTransaction(Sink::Storage::DataStore::ReadOnly) .openDatabase("test") .scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { gotResult = true; return false; }, - [&](const Sink::Storage::Error &error) { + [&](const Sink::Storage::DataStore::Error &error) { qDebug() << error.message; gotError = true; }); @@ -295,10 +295,10 @@ private slots: void testWriteToNamedDb() { bool gotError = false; - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - store.createTransaction(Sink::Storage::ReadWrite) + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + store.createTransaction(Sink::Storage::DataStore::ReadWrite) .openDatabase("test") - .write("key1", "value1", [&](const Sink::Storage::Error &error) { + .write("key1", "value1", [&](const Sink::Storage::DataStore::Error &error) { qDebug() << error.message; gotError = true; }); @@ -308,10 +308,10 @@ private slots: void testWriteDuplicatesToNamedDb() { bool gotError = false; - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - store.createTransaction(Sink::Storage::ReadWrite) + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + store.createTransaction(Sink::Storage::DataStore::ReadWrite) .openDatabase("test", nullptr, true) - .write("key1", "value1", [&](const Sink::Storage::Error &error) { + .write("key1", "value1", [&](const Sink::Storage::DataStore::Error &error) { qDebug() << error.message; gotError = true; }); @@ -321,8 +321,8 @@ private slots: // By default we want only exact matches void testSubstringKeys() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("test", nullptr, true); db.write("sub", "value1"); db.write("subsub", "value2"); @@ -333,8 +333,8 @@ private slots: void testFindSubstringKeys() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("test", nullptr, false); db.write("sub", "value1"); db.write("subsub", "value2"); @@ -346,8 +346,8 @@ private slots: void testFindSubstringKeysWithDuplicatesEnabled() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("test", nullptr, true); db.write("sub", "value1"); db.write("subsub", "value2"); @@ -359,8 +359,8 @@ private slots: void testKeySorting() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("test", nullptr, false); db.write("sub_2", "value2"); db.write("sub_1", "value1"); @@ -380,8 +380,8 @@ private slots: // Ensure we don't retrieve a key that is greater than the current key. We only want equal keys. void testKeyRange() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("test", nullptr, true); db.write("sub1", "value1"); int numValues = db.scan("sub", [&](const QByteArray &key, const QByteArray &value) -> bool { return true; }); @@ -391,8 +391,8 @@ private slots: void testFindLatest() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("test", nullptr, false); db.write("sub1", "value1"); db.write("sub2", "value2"); @@ -406,8 +406,8 @@ private slots: void testFindLatestInSingle() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("test", nullptr, false); db.write("sub2", "value2"); QByteArray result; @@ -418,8 +418,8 @@ private slots: void testFindLast() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); auto db = transaction.openDatabase("test", nullptr, false); db.write("sub2", "value2"); db.write("wub3", "value3"); @@ -431,23 +431,23 @@ private slots: void testRecordRevision() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); - Sink::Storage::recordRevision(transaction, 1, "uid", "type"); - QCOMPARE(Sink::Storage::getTypeFromRevision(transaction, 1), QByteArray("type")); - QCOMPARE(Sink::Storage::getUidFromRevision(transaction, 1), QByteArray("uid")); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); + Sink::Storage::DataStore::recordRevision(transaction, 1, "uid", "type"); + QCOMPARE(Sink::Storage::DataStore::getTypeFromRevision(transaction, 1), QByteArray("type")); + QCOMPARE(Sink::Storage::DataStore::getUidFromRevision(transaction, 1), QByteArray("uid")); } void testRecordRevisionSorting() { - Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); - auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite); QByteArray result; auto db = transaction.openDatabase("test", nullptr, false); const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}"; //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6) - db.write(Sink::Storage::assembleKey(uid, 6), "value1"); - db.write(Sink::Storage::assembleKey(uid, 10), "value2"); + db.write(Sink::Storage::DataStore::assembleKey(uid, 6), "value1"); + db.write(Sink::Storage::DataStore::assembleKey(uid, 10), "value2"); db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; }); QCOMPARE(result, QByteArray("value2")); } diff --git a/tests/testimplementations.h b/tests/testimplementations.h index d188c0c..cf7a3da 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h @@ -83,8 +83,8 @@ public slots: class TestResourceFacade : public Sink::GenericFacade { public: - TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer resourceAccess) - : Sink::GenericFacade(instanceIdentifier, QSharedPointer::create(), resourceAccess) + TestResourceFacade(const Sink::ResourceContext &resourceContext) + : Sink::GenericFacade(resourceContext) { } virtual ~TestResourceFacade() @@ -95,8 +95,8 @@ public: class TestMailResourceFacade : public Sink::GenericFacade { public: - TestMailResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer resourceAccess) - : Sink::GenericFacade(instanceIdentifier, QSharedPointer::create(), resourceAccess) + TestMailResourceFacade(const Sink::ResourceContext &resourceContext) + : Sink::GenericFacade(resourceContext) { } virtual ~TestMailResourceFacade() @@ -107,7 +107,7 @@ public: class TestResource : public Sink::GenericResource { public: - TestResource(const QByteArray &instanceIdentifier, QSharedPointer pipeline) : Sink::GenericResource("test", instanceIdentifier, pipeline) + TestResource(const Sink::ResourceContext &resourceContext, QSharedPointer pipeline) : Sink::GenericResource(resourceContext, pipeline) { } -- cgit v1.2.3