Kills running processes (assignment clients, domain server and sand box) prior to installation

Runs server processes
Runs interface with the top-level recursive test script.
This commit is contained in:
NissimHadar 2018-09-04 13:31:31 -07:00
parent 06ad3903c4
commit 33f3552cba
2 changed files with 45 additions and 8 deletions

View file

@ -9,6 +9,7 @@
// //
#include "TestRunner.h" #include "TestRunner.h"
#include <QThread>
#include <QtWidgets/QMessageBox> #include <QtWidgets/QMessageBox>
#include <QtWidgets/QFileDialog> #include <QtWidgets/QFileDialog>
@ -30,15 +31,18 @@ void TestRunner::run() {
autoTester->downloadFiles(urls, _tempFolder, filenames, (void *)this); autoTester->downloadFiles(urls, _tempFolder, filenames, (void *)this);
// installerDownloadComplete will run after download complete // After download has finished, `installerDownloadComplete` will run after download complete
} }
void TestRunner::installerDownloadComplete() { void TestRunner::installerDownloadComplete() {
runInstaller(); runInstaller();
createSnapshotFolder(); createSnapshotFolder();
killProcesses(); killProcesses();
startLocalServerProcesses();
runInterfaceWithTestScript();
restoreHighFidelityAppDataFolder(); killProcesses();
restoreHighFidelityAppDataFolder();
} }
void TestRunner::runInstaller() { void TestRunner::runInstaller() {
@ -48,7 +52,7 @@ void TestRunner::runInstaller() {
QString installerFullPath = _tempFolder + "/" + INSTALLER_FILENAME; QString installerFullPath = _tempFolder + "/" + INSTALLER_FILENAME;
QString commandLine = QDir::toNativeSeparators(installerFullPath + " /S /D=" + _tempFolder); QString commandLine = QDir::toNativeSeparators(installerFullPath) + " /S /D=" + QDir::toNativeSeparators(_tempFolder);
system(commandLine.toStdString().c_str()); system(commandLine.toStdString().c_str());
} }
@ -70,8 +74,6 @@ void TestRunner::saveExistingHighFidelityAppDataFolder() {
// The original folder is saved in a unique name // The original folder is saved in a unique name
_savedAppDataFolder = dataDirectory + "/" + UNIQUE_FOLDER_NAME; _savedAppDataFolder = dataDirectory + "/" + UNIQUE_FOLDER_NAME;
_appDataFolder.rename(_appDataFolder.path(), _savedAppDataFolder.path()); _appDataFolder.rename(_appDataFolder.path(), _savedAppDataFolder.path());
QDir().mkdir(_appDataFolder.path());
} }
void TestRunner::restoreHighFidelityAppDataFolder() { void TestRunner::restoreHighFidelityAppDataFolder() {
@ -98,7 +100,8 @@ void TestRunner::selectTemporaryFolder() {
} }
void TestRunner::createSnapshotFolder() { void TestRunner::createSnapshotFolder() {
QDir().mkdir(_tempFolder + "/" + SNAPSHOT_FOLDER_NAME); _snapshotFolder = _tempFolder + "/" + SNAPSHOT_FOLDER_NAME;
QDir().mkdir(_snapshotFolder);
} }
void TestRunner::killProcesses() { void TestRunner::killProcesses() {
killProcessByName("assignment-client.exe"); killProcessByName("assignment-client.exe");
@ -111,4 +114,34 @@ void TestRunner::killProcessByName(QString processName) {
QString commandLine = "taskkill /im " + processName + " /f >nul"; QString commandLine = "taskkill /im " + processName + " /f >nul";
system(commandLine.toStdString().c_str()); system(commandLine.toStdString().c_str());
#endif #endif
} }
void TestRunner::startLocalServerProcesses() {
QDir::setCurrent(_tempFolder);
#ifdef Q_OS_WIN
QString commandLine;
commandLine = "start \"domain-server.exe\" domain-server.exe";
system(commandLine.toStdString().c_str());
commandLine = "start \"assignment-client.exe\" assignment-client.exe -n 6";
system(commandLine.toStdString().c_str());
#endif
// Give server processes time to stabilize
QThread::sleep(8);
}
void TestRunner::runInterfaceWithTestScript() {
QDir::setCurrent(_tempFolder);
QString branch = autoTester->getSelectedBranch();
QString user = autoTester->getSelectedUser();
#ifdef Q_OS_WIN
QString commandLine = "interface.exe --url hifi://localhost --testScript https://raw.githubusercontent.com/" + user +
"/hifi_tests/" + branch + "/tests/testRecursive.js quitWhenFinished --testResultsLocation " +
_snapshotFolder;
system(commandLine.toStdString().c_str());
#endif
}

View file

@ -13,6 +13,7 @@
#include <QObject> #include <QObject>
#include <QDir> #include <QDir>
#include <QProcess>
#include "Downloader.h" #include "Downloader.h"
#include "ui/BusyWindow.h" #include "ui/BusyWindow.h"
@ -32,12 +33,15 @@ public:
void createSnapshotFolder(); void createSnapshotFolder();
void killProcesses(); void killProcesses();
void killProcessByName(QString processName); void killProcessByName(QString processName);
void startLocalServerProcesses();
void runInterfaceWithTestScript();
private: private:
QDir _appDataFolder; QDir _appDataFolder;
QDir _savedAppDataFolder; QDir _savedAppDataFolder;
QString _tempFolder; QString _tempFolder;
QString _snapshotFolder;
Downloader* _downloader; Downloader* _downloader;