mirror of https://github.com/qt/qtgrpc.git
Make ServerProcRunner logs more explicit
Move QThead include to .cpp. Add missing QVERIFY in the server stream Valid() test. Modify MessageLatencyThreshold to work better with Windows. Pick-to: 6.6 Change-Id: I791d0ffdf3018ce9db4f062d9c0e7f0e466a6530 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
c94e5f7a5b
commit
e7e733aecb
|
|
@ -59,6 +59,8 @@ void QtGrpcClientServerStreamTest::Valid()
|
|||
QVERIFY(streamErrorSpy.isValid());
|
||||
|
||||
QSignalSpy streamFinishedSpy(stream.get(), &QGrpcServerStream::finished);
|
||||
QVERIFY(streamFinishedSpy.isValid());
|
||||
|
||||
QObject::connect(stream.get(), &QGrpcServerStream::messageReceived, this, [&result, stream] {
|
||||
SimpleStringMessage ret = stream->read<SimpleStringMessage>();
|
||||
result.setTestFieldString(result.testFieldString() + ret.testFieldString());
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
#include <QThread>
|
||||
|
||||
#include "testservice.grpc.pb.h"
|
||||
#include <message_latency_defs.h>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#ifndef TEST_SERVER_H
|
||||
#define TEST_SERVER_H
|
||||
|
||||
#include <QThread>
|
||||
|
||||
class SecureTestServer
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -8,7 +8,11 @@
|
|||
#endif
|
||||
|
||||
constexpr int MessageLatency = QT_GRPC_TEST_MESSAGE_LATENCY;
|
||||
#ifdef Q_OS_WINDOWS
|
||||
constexpr int MessageLatencyThreshold = MessageLatency;
|
||||
#else
|
||||
constexpr int MessageLatencyThreshold = MessageLatency / 5;
|
||||
#endif
|
||||
constexpr int MessageLatencyWithThreshold = MessageLatency + MessageLatencyThreshold;
|
||||
constexpr int FailTimeout = QT_GRPC_TEST_MESSAGE_LATENCY * 5;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QTimer>
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
|
@ -34,25 +35,34 @@ private:
|
|||
void start()
|
||||
{
|
||||
if (serverPath.isEmpty()) {
|
||||
qInfo() << "testserver binary is missing";
|
||||
qInfo() << "testserver binary is missing.";
|
||||
return;
|
||||
}
|
||||
serverProc = std::make_unique<QProcess>();
|
||||
QObject::connect(serverProc.get(), &QProcess::readyReadStandardOutput, this,
|
||||
[this] { qInfo() << serverProc->readAllStandardOutput(); });
|
||||
|
||||
serverProc->start(serverPath);
|
||||
serverProc->waitForStarted(waitForServerLatency.count());
|
||||
if (!serverProc->waitForStarted(waitForServerLatency.count())) {
|
||||
qInfo() << "Failed to start the server" << serverPath
|
||||
<< QString::number(serverProc->exitCode(), 16);
|
||||
return;
|
||||
}
|
||||
// Wait for the 'Server listening' log from the server
|
||||
serverProc->waitForReadyRead(waitForServerRead.count());
|
||||
if (!serverProc->waitForReadyRead(waitForServerRead.count())) {
|
||||
qInfo() << "Could not wait for ready read from the server" << serverPath;
|
||||
return;
|
||||
}
|
||||
auto serverData = serverProc->readAllStandardError();
|
||||
if (!serverData.startsWith("Server listening")) {
|
||||
qInfo() << "The server was not ready within the deadline.";
|
||||
qInfo() << "The server was not ready within the deadline" << serverPath;
|
||||
return;
|
||||
}
|
||||
|
||||
// Connect remaining error logs to the server
|
||||
QObject::connect(serverProc.get(), &QProcess::readyReadStandardError, this,
|
||||
[this] { qInfo() << serverProc->readAllStandardError(); });
|
||||
qInfo() << "Testserver started" << serverPath;
|
||||
}
|
||||
void stop()
|
||||
{
|
||||
|
|
@ -60,6 +70,7 @@ private:
|
|||
serverProc->kill();
|
||||
serverProc->waitForFinished(waitForServerLatency.count());
|
||||
}
|
||||
qInfo() << "Testserver stopped" << serverPath;
|
||||
}
|
||||
|
||||
const QString serverPath;
|
||||
|
|
|
|||
Loading…
Reference in New Issue