forked from qt-creator/qt-creator
SSH: Fix autotest
- Consider the case of connection sharing being disabled. - Adapt to slower environments. Change-Id: I088622034c26ea343eb78161b24c43b3286b0512 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -231,7 +231,7 @@ void SshConnection::disconnectFromHost()
|
|||||||
case Connecting:
|
case Connecting:
|
||||||
case Connected:
|
case Connected:
|
||||||
if (!d->sharingEnabled) {
|
if (!d->sharingEnabled) {
|
||||||
emitDisconnected();
|
QTimer::singleShot(0, this, &SshConnection::emitDisconnected);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->state = Disconnecting;
|
d->state = Disconnecting;
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include <ssh/sftptransfer.h>
|
#include <ssh/sftptransfer.h>
|
||||||
#include <ssh/sshconnection.h>
|
#include <ssh/sshconnection.h>
|
||||||
#include <ssh/sshremoteprocessrunner.h>
|
#include <ssh/sshremoteprocessrunner.h>
|
||||||
|
#include <ssh/sshsettings.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/temporarydirectory.h>
|
#include <utils/temporarydirectory.h>
|
||||||
|
|
||||||
@@ -171,8 +172,10 @@ void tst_Ssh::errorHandling()
|
|||||||
connection.connectToHost();
|
connection.connectToHost();
|
||||||
loop.exec();
|
loop.exec();
|
||||||
QVERIFY(timer.isActive());
|
QVERIFY(timer.isActive());
|
||||||
QCOMPARE(connection.state(), SshConnection::Unconnected);
|
const bool expectConnected = !SshSettings::connectionSharingEnabled();
|
||||||
QVERIFY(!connection.errorString().isEmpty());
|
QCOMPARE(connection.state(), expectConnected ? SshConnection::Connected
|
||||||
|
: SshConnection::Unconnected);
|
||||||
|
QCOMPARE(connection.errorString().isEmpty(), expectConnected);
|
||||||
QVERIFY(!disconnected);
|
QVERIFY(!disconnected);
|
||||||
QVERIFY2(dataReceived.isEmpty(), qPrintable(dataReceived));
|
QVERIFY2(dataReceived.isEmpty(), qPrintable(dataReceived));
|
||||||
}
|
}
|
||||||
@@ -374,7 +377,7 @@ void tst_Ssh::sftp()
|
|||||||
};
|
};
|
||||||
FilesToTransfer filesToUpload;
|
FilesToTransfer filesToUpload;
|
||||||
std::srand(QDateTime::currentDateTime().toSecsSinceEpoch());
|
std::srand(QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||||
for (int i = 0; i < 1000; ++i) {
|
for (int i = 0; i < 100; ++i) {
|
||||||
const QString fileName = "sftptestfile" + QString::number(i + 1);
|
const QString fileName = "sftptestfile" + QString::number(i + 1);
|
||||||
QFile file(dirForFilesToUpload.path() + '/' + fileName);
|
QFile file(dirForFilesToUpload.path() + '/' + fileName);
|
||||||
QVERIFY2(file.open(QIODevice::WriteOnly), qPrintable(file.errorString()));
|
QVERIFY2(file.open(QIODevice::WriteOnly), qPrintable(file.errorString()));
|
||||||
@@ -413,7 +416,7 @@ void tst_Ssh::sftp()
|
|||||||
QTimer timer;
|
QTimer timer;
|
||||||
QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
timer.setInterval((params.timeout + 5) * 1000);
|
timer.setInterval(30 * 1000);
|
||||||
timer.start();
|
timer.start();
|
||||||
upload->start();
|
upload->start();
|
||||||
loop.exec();
|
loop.exec();
|
||||||
@@ -453,7 +456,7 @@ void tst_Ssh::sftp()
|
|||||||
// Download the uploaded files to a different location
|
// Download the uploaded files to a different location
|
||||||
const QStringList allUploadedFileNames
|
const QStringList allUploadedFileNames
|
||||||
= QDir(dirForFilesToUpload.path()).entryList(QDir::Files);
|
= QDir(dirForFilesToUpload.path()).entryList(QDir::Files);
|
||||||
QCOMPARE(allUploadedFileNames.size(), 1001);
|
QCOMPARE(allUploadedFileNames.size(), 101);
|
||||||
for (const QString &fileName : allUploadedFileNames) {
|
for (const QString &fileName : allUploadedFileNames) {
|
||||||
const QString localFilePath = dirForFilesToUpload.path() + '/' + fileName;
|
const QString localFilePath = dirForFilesToUpload.path() + '/' + fileName;
|
||||||
const QString remoteFilePath = getRemoteFilePath(fileName);
|
const QString remoteFilePath = getRemoteFilePath(fileName);
|
||||||
@@ -462,7 +465,7 @@ void tst_Ssh::sftp()
|
|||||||
QVERIFY(downloadJob != SftpInvalidJob);
|
QVERIFY(downloadJob != SftpInvalidJob);
|
||||||
jobs << downloadJob;
|
jobs << downloadJob;
|
||||||
}
|
}
|
||||||
QCOMPARE(jobs.size(), 1001);
|
QCOMPARE(jobs.size(), 101);
|
||||||
loop.exec();
|
loop.exec();
|
||||||
QVERIFY(!invalidFinishedSignal);
|
QVERIFY(!invalidFinishedSignal);
|
||||||
QVERIFY2(jobError.isEmpty(), qPrintable(jobError));
|
QVERIFY2(jobError.isEmpty(), qPrintable(jobError));
|
||||||
@@ -490,6 +493,7 @@ void tst_Ssh::sftp()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove the uploaded files on the remote system
|
// Remove the uploaded files on the remote system
|
||||||
|
timer.setInterval((params.timeout + 5) * 1000);
|
||||||
for (const QString &fileName : allUploadedFileNames) {
|
for (const QString &fileName : allUploadedFileNames) {
|
||||||
const QString remoteFilePath = getRemoteFilePath(fileName);
|
const QString remoteFilePath = getRemoteFilePath(fileName);
|
||||||
const SftpJobId removeJob = sftpChannel->removeFile(remoteFilePath);
|
const SftpJobId removeJob = sftpChannel->removeFile(remoteFilePath);
|
||||||
|
Reference in New Issue
Block a user