Add shared statistics and Prometheus metrics
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "Types.h"
|
||||
#include "Metrics.h"
|
||||
|
||||
#include <QTemporaryDir>
|
||||
#include <QTest>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
@@ -11,6 +13,7 @@ class TypesTest final : public QObject {
|
||||
void parsesShareUrl();
|
||||
void rejectsNonShareUrl();
|
||||
void plansByChecksum();
|
||||
void persistsStatisticsAcrossInstances();
|
||||
};
|
||||
|
||||
void TypesTest::parsesShareUrl()
|
||||
@@ -46,5 +49,30 @@ void TypesTest::plansByChecksum()
|
||||
QCOMPARE(plan.rightToLeft.front().id, u"5"_s);
|
||||
}
|
||||
|
||||
void TypesTest::persistsStatisticsAcrossInstances()
|
||||
{
|
||||
QTemporaryDir directory;
|
||||
QVERIFY(directory.isValid());
|
||||
const QString path = directory.filePath(u"stats.json"_s);
|
||||
|
||||
Metrics first{path};
|
||||
first.synchronizationStarted();
|
||||
first.assetFinished(u"IMAGE"_s, true, 1'024);
|
||||
first.synchronizationFinished(true);
|
||||
|
||||
Metrics second{path};
|
||||
second.assetFinished(u"VIDEO"_s, true, 2'048);
|
||||
second.assetFinished(u"IMAGE"_s, false, 512);
|
||||
|
||||
const QJsonObject statistics = first.statistics();
|
||||
QCOMPARE(statistics.value(u"syncs"_s).toInteger(), 1);
|
||||
QCOMPARE(statistics.value(u"assets"_s).toInteger(), 2);
|
||||
QCOMPARE(statistics.value(u"images"_s).toInteger(), 1);
|
||||
QCOMPARE(statistics.value(u"videos"_s).toInteger(), 1);
|
||||
QCOMPARE(statistics.value(u"other"_s).toInteger(), 0);
|
||||
QCOMPARE(statistics.value(u"bytes"_s).toInteger(), 3'072);
|
||||
QVERIFY(second.prometheus().contains("immich_sync_lifetime_synchronizations_total 1"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(TypesTest)
|
||||
#include "TypesTest.moc"
|
||||
|
||||
Reference in New Issue
Block a user