Switch integration test to mostly use unix sockets

By not using the same hardcoded number for every test, we can parallelize the test now.

There are several cases remaining where we can't easily use unix sockets (e.g. QSslSocket or imapauth module), for that ask kernel what port number is currently free to use. This is a bit racy though.
This commit is contained in:
Alexey Sokolov
2025-04-21 00:00:14 +01:00
parent 63d10ccb17
commit b642d92ce7
8 changed files with 152 additions and 85 deletions
+13 -10
View File
@@ -15,6 +15,7 @@
*/
#include <QRegularExpression>
#include <QProcess>
#include "znctest.h"
#ifndef ZNC_BIN_DIR
@@ -24,13 +25,15 @@
namespace znc_inttest {
void WriteConfig(QString path) {
Process p(ZNC_BIN_DIR "/znc",
QStringList() << "--debug" << "--datadir" << path << "--makeconf",
[=](QProcess* p) {
auto env = p->processEnvironment();
env.insert("ZNC_LISTEN_UNIX_SOCKET",
path + "/inttest.znc");
p->setProcessEnvironment(env);
});
// clang-format off
Process p(ZNC_BIN_DIR "/znc", QStringList() << "--debug"
<< "--datadir" << path
<< "--makeconf");
p.ReadUntil("Listen on port"); p.Write("12345");
p.ReadUntil("Listen using SSL"); p.Write();
p.ReadUntil("IPv6"); p.Write();
p.ReadUntil("Username"); p.Write("user");
p.ReadUntil("password"); p.Write("hunter2", false);
p.ReadUntil("Confirm"); p.Write("hunter2", false);
@@ -41,7 +44,7 @@ void WriteConfig(QString path) {
p.ReadUntil("Bind host"); p.Write();
p.ReadUntil("Set up a network?"); p.Write();
p.ReadUntil("Name [libera]"); p.Write("test");
p.ReadUntil("Server host (host only)"); p.Write("127.0.0.1");
p.ReadUntil("Server host (host only)"); p.Write("unix:" + path.toUtf8() + "/inttest.ircd");
p.ReadUntil("Server uses SSL?"); p.Write();
p.ReadUntil("6667"); p.Write();
p.ReadUntil("password"); p.Write();
@@ -61,7 +64,7 @@ void WriteConfig(QString path) {
void ZNCTest::SetUp() {
WriteConfig(m_dir.path());
ASSERT_TRUE(m_server.listen(QHostAddress::LocalHost, 6667))
ASSERT_TRUE(m_server.listen(m_dir.path() + "/inttest.ircd"))
<< m_server.errorString().toStdString();
}
@@ -72,8 +75,8 @@ Socket ZNCTest::ConnectIRCd() {
Socket ZNCTest::ConnectClient() {
m_clients.emplace_back();
QTcpSocket& sock = m_clients.back();
sock.connectToHost("127.0.0.1", 12345);
QLocalSocket& sock = m_clients.back();
sock.connectToServer(m_dir.path() + "/inttest.znc");
[&] {
ASSERT_TRUE(sock.waitForConnected())
<< sock.errorString().toStdString();