Lancelot: Add configurable client filtering to baseline server
(cherry picked from commit d499f7ca995e40f7a75f913ff0f07d9a73fa3559)
This commit is contained in:
parent
c3ce002a54
commit
c890bf88a7
@ -60,6 +60,7 @@ const QString PI_CreationDate(QLS("CreationDate"));
|
|||||||
|
|
||||||
QString BaselineServer::storage;
|
QString BaselineServer::storage;
|
||||||
QString BaselineServer::url;
|
QString BaselineServer::url;
|
||||||
|
QString BaselineServer::settingsFile;
|
||||||
|
|
||||||
BaselineServer::BaselineServer(QObject *parent)
|
BaselineServer::BaselineServer(QObject *parent)
|
||||||
: QTcpServer(parent), lastRunIdIdx(0)
|
: QTcpServer(parent), lastRunIdIdx(0)
|
||||||
@ -91,6 +92,15 @@ QString BaselineServer::baseUrl()
|
|||||||
return url;
|
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)
|
void BaselineServer::incomingConnection(int socketDescriptor)
|
||||||
{
|
{
|
||||||
QString runId = QDateTime::currentDateTime().toString(QLS("MMMdd-hhmmss"));
|
QString runId = QDateTime::currentDateTime().toString(QLS("MMMdd-hhmmss"));
|
||||||
@ -144,6 +154,8 @@ void BaselineThread::run()
|
|||||||
BaselineHandler::BaselineHandler(const QString &runId, int socketDescriptor)
|
BaselineHandler::BaselineHandler(const QString &runId, int socketDescriptor)
|
||||||
: QObject(), runId(runId), connectionEstablished(false)
|
: QObject(), runId(runId), connectionEstablished(false)
|
||||||
{
|
{
|
||||||
|
settings = new QSettings(BaselineServer::settingsFilePath(), QSettings::IniFormat, this);
|
||||||
|
|
||||||
if (socketDescriptor == -1)
|
if (socketDescriptor == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -174,17 +186,23 @@ bool BaselineHandler::establishConnection()
|
|||||||
qDebug() << runId << logtime() << "Connection established with" << plat.value(PI_HostName)
|
qDebug() << runId << logtime() << "Connection established with" << plat.value(PI_HostName)
|
||||||
<< "[" << qPrintable(plat.value(PI_HostAddress)) << "]" << logMsg;
|
<< "[" << qPrintable(plat.value(PI_HostAddress)) << "]" << logMsg;
|
||||||
|
|
||||||
// Filter on branch
|
settings->beginGroup("ClientFilters");
|
||||||
QString branch = plat.value(PI_PulseGitBranch);
|
if (!settings->childKeys().isEmpty()) {
|
||||||
if (branch.isEmpty()) {
|
// Abort if client does not match the filters
|
||||||
// Not run by Pulse, i.e. ad hoc run: Ok.
|
foreach(QString filterKey, settings->childKeys()) {
|
||||||
}
|
QString filter = settings->value(filterKey).toString();
|
||||||
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"))) {
|
QString platVal = plat.value(filterKey);
|
||||||
qDebug() << runId << logtime() << "Did not pass branch/staging repo filter, disconnecting.";
|
if (filter.isEmpty() || platVal.isEmpty())
|
||||||
proto.sendBlock(BaselineProtocol::Abort, QByteArray("This branch/staging repo is not assigned to be tested."));
|
continue; // tbd: add a syntax for specifying a "value-must-be-present" filter
|
||||||
proto.socket.disconnectFromHost();
|
if (!platVal.contains(filter)) {
|
||||||
return false;
|
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());
|
proto.sendBlock(BaselineProtocol::Ack, QByteArray());
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include "baselineprotocol.h"
|
#include "baselineprotocol.h"
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
@ -65,6 +66,7 @@ public:
|
|||||||
|
|
||||||
static QString storagePath();
|
static QString storagePath();
|
||||||
static QString baseUrl();
|
static QString baseUrl();
|
||||||
|
static QString settingsFilePath();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void incomingConnection(int socketDescriptor);
|
void incomingConnection(int socketDescriptor);
|
||||||
@ -79,6 +81,7 @@ private:
|
|||||||
int lastRunIdIdx;
|
int lastRunIdIdx;
|
||||||
static QString storage;
|
static QString storage;
|
||||||
static QString url;
|
static QString url;
|
||||||
|
static QString settingsFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -132,6 +135,7 @@ private:
|
|||||||
QString runId;
|
QString runId;
|
||||||
bool connectionEstablished;
|
bool connectionEstablished;
|
||||||
Report report;
|
Report report;
|
||||||
|
QSettings *settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASELINESERVER_H
|
#endif // BASELINESERVER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user