diff options
author | aavit <qt-info@nokia.com> | 2011-04-27 10:37:19 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2011-05-03 11:30:56 (GMT) |
commit | d499f7ca995e40f7a75f913ff0f07d9a73fa3559 (patch) | |
tree | 9d3a196049a8dcf1a063bcb0fbc74ac4b0c0f127 /tests | |
parent | 9d75ff6fa8f8844ff6599b68618821cd8c501757 (diff) | |
download | Qt-d499f7ca995e40f7a75f913ff0f07d9a73fa3559.zip Qt-d499f7ca995e40f7a75f913ff0f07d9a73fa3559.tar.gz Qt-d499f7ca995e40f7a75f913ff0f07d9a73fa3559.tar.bz2 |
Lancelot: Add configurable client filtering to baseline server
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.cpp | 38 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.h | 4 |
2 files changed, 32 insertions, 10 deletions
diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index c22d1f8..9c30638 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -60,6 +60,7 @@ const QString PI_CreationDate(QLS("CreationDate")); QString BaselineServer::storage; QString BaselineServer::url; +QString BaselineServer::settingsFile; BaselineServer::BaselineServer(QObject *parent) : QTcpServer(parent), lastRunIdIdx(0) @@ -91,6 +92,15 @@ QString BaselineServer::baseUrl() return url; } +QString BaselineServer::settingsFilePath() +{ + if (settingsFile.isEmpty()) { + QString exeName = QCoreApplication::applicationFilePath().section(QLC('/'), -1); + settingsFile = storagePath() + QLC('/') + exeName + QLS(".ini"); + } + return settingsFile; +} + void BaselineServer::incomingConnection(int socketDescriptor) { QString runId = QDateTime::currentDateTime().toString(QLS("MMMdd-hhmmss")); @@ -144,6 +154,8 @@ void BaselineThread::run() BaselineHandler::BaselineHandler(const QString &runId, int socketDescriptor) : QObject(), runId(runId), connectionEstablished(false) { + settings = new QSettings(BaselineServer::settingsFilePath(), QSettings::IniFormat, this); + if (socketDescriptor == -1) return; @@ -174,17 +186,23 @@ bool BaselineHandler::establishConnection() qDebug() << runId << logtime() << "Connection established with" << plat.value(PI_HostName) << "[" << qPrintable(plat.value(PI_HostAddress)) << "]" << logMsg; - // Filter on branch - QString branch = plat.value(PI_PulseGitBranch); - if (branch.isEmpty()) { - // Not run by Pulse, i.e. ad hoc run: Ok. - } - else if (branch != QLS("master-integration") || !plat.value(PI_GitCommit).contains(QLS("Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration"))) { - qDebug() << runId << logtime() << "Did not pass branch/staging repo filter, disconnecting."; - proto.sendBlock(BaselineProtocol::Abort, QByteArray("This branch/staging repo is not assigned to be tested.")); - proto.socket.disconnectFromHost(); - return false; + settings->beginGroup("ClientFilters"); + if (!settings->childKeys().isEmpty()) { + // Abort if client does not match the filters + foreach(QString filterKey, settings->childKeys()) { + QString filter = settings->value(filterKey).toString(); + QString platVal = plat.value(filterKey); + if (filter.isEmpty() || platVal.isEmpty()) + continue; // tbd: add a syntax for specifying a "value-must-be-present" filter + if (!platVal.contains(filter)) { + qDebug() << runId << logtime() << "Did not pass client filter on" << filterKey << "; disconnecting."; + proto.sendBlock(BaselineProtocol::Abort, QByteArray("Configured to not do testing for this client or repo, ref. ") + BaselineServer::settingsFilePath().toLatin1()); + proto.socket.disconnectFromHost(); + return false; + } + } } + settings->endGroup(); proto.sendBlock(BaselineProtocol::Ack, QByteArray()); diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index cae490f..0dcd4ea 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -48,6 +48,7 @@ #include <QScopedPointer> #include <QTimer> #include <QDateTime> +#include <QSettings> #include "baselineprotocol.h" #include "report.h" @@ -65,6 +66,7 @@ public: static QString storagePath(); static QString baseUrl(); + static QString settingsFilePath(); protected: void incomingConnection(int socketDescriptor); @@ -79,6 +81,7 @@ private: int lastRunIdIdx; static QString storage; static QString url; + static QString settingsFile; }; @@ -132,6 +135,7 @@ private: QString runId; bool connectionEstablished; Report report; + QSettings *settings; }; #endif // BASELINESERVER_H |