Skip to content

Commit

Permalink
Add some unit tests for loading partial snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
gnufied committed Feb 18, 2015
1 parent 78a6767 commit 221e8e3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/zeromq-4.0.4/autom4te.cache/
RbkitClient.pro.user.3.2-pre1
RbkitClient.pro.user.3.3-pre1
/.ruby-version
9 changes: 9 additions & 0 deletions rbkit-lib/model/objectstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,12 @@ QHash<QString, quint64> RBKit::ObjectStore::generationStats(int begin, int end)

return stats;
}
QHash<quint64, RBKit::ObjectDetailPtr> RBKit::ObjectStore::getSnapShotStore() const
{
return snapShotStore;
}

quint64 RBKit::ObjectStore::getLoadedMessages() const
{
return loadedMessages;
}
4 changes: 4 additions & 0 deletions rbkit-lib/model/objectstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ namespace RBKit {
}
ObjectStore();

quint64 getLoadedMessages() const;

QHash<quint64, RBKit::ObjectDetailPtr> getSnapShotStore() const;
private:
// follows half-open series convention: [begin, end)
QHash<QString, quint64> generationStats(int begin, int end) const;
// Store mapping between object-id and detail
QHash<quint64, RBKit::ObjectDetailPtr> objectStore;
ObjectAggregator aggregator;
// A temporary store for holding snapshot data as it comes
QHash<quint64, RBKit::ObjectDetailPtr> snapShotStore;
quint64 loadedMessages;
};
Expand Down
15 changes: 15 additions & 0 deletions tests/testobjectdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,18 @@ void TestObjectDump::testBenchmarkProcessObjectsWhenObjectSpaceIsFull()
store.updateFromSnapshot(event->objects);
}
}

void TestObjectDump::testLoadingSplitSnapshots()
{
qDebug() << "Total objects : " << event->completeObjectCount;
qDebug() << "Objects in this event" << event->objectCount;
qDebug() << "Total number of actual objects" << event->objects.size();

ObjectStore store;
QVERIFY(store.getLoadedMessages() == 0);
QVERIFY2(store.getSnapShotStore().isEmpty(), "is not empty");

store.loadPartialSnapshot(event->objects, event->completeObjectCount);
QVERIFY(store.getLoadedMessages() == 1000);
QVERIFY(store.getSnapShotStore().size() == 1000);
}
1 change: 1 addition & 0 deletions tests/testobjectdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ private slots:
void testBenchmarkParseObjectDump();
void testBenchmarkProcessObjectsWhenObjectSpaceIsEmpty();
void testBenchmarkProcessObjectsWhenObjectSpaceIsFull();
void testLoadingSplitSnapshots();

private:
QByteArray objectDump;
Expand Down

0 comments on commit 221e8e3

Please sign in to comment.