|
|
|
|
@@ -38,43 +38,7 @@ import java.nio.file.Paths;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|
|
|
|
public String name = "?";
|
|
|
|
|
public static MachineProcessSet machinesProcesses= new MachineProcessSet();
|
|
|
|
|
void StartNecessaryMachines() {
|
|
|
|
|
try {
|
|
|
|
|
Vector<String> aborted = new Vector<>();
|
|
|
|
|
for (MachineProcess process : machinesProcesses.Data.values()) {
|
|
|
|
|
if (process.isAborted()) {
|
|
|
|
|
aborted.add(process.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
for (String key : aborted) {
|
|
|
|
|
machinesProcesses.Data.remove(key);
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
LinkedHashMap<String, MachineProcess> processes_to_start = new LinkedHashMap<>();
|
|
|
|
|
//1. Получить список всех пакетов, которые активны, и взять из них машины.
|
|
|
|
|
for (DVMPackage dvmPackage : db.dvmPackages.Data.values()) {
|
|
|
|
|
if (dvmPackage.state.isActive()) {
|
|
|
|
|
//-
|
|
|
|
|
if (!machinesProcesses.hasProcessForPackage(dvmPackage)) {
|
|
|
|
|
MachineProcess new_process = new MachineProcess(dvmPackage);
|
|
|
|
|
processes_to_start.put(new_process.getUniqueKey(), new_process);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//запуск.
|
|
|
|
|
for (MachineProcess process : processes_to_start.values()) {
|
|
|
|
|
process.Start();
|
|
|
|
|
if (Utils.checkFileCreation(process.getStartedFile())) {
|
|
|
|
|
machinesProcesses.Data.put(process.id, process);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static MachineProcessSet machinesProcesses = new MachineProcessSet();
|
|
|
|
|
@Override
|
|
|
|
|
public void afterPublishAction(DBObject object) throws Exception {
|
|
|
|
|
if (object instanceof Test) {
|
|
|
|
|
@@ -94,7 +58,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|
|
|
|
dvmPackage.saveJson();
|
|
|
|
|
dvmPackage.package_json = null; // объект больше не нужен.
|
|
|
|
|
//--
|
|
|
|
|
|
|
|
|
|
} else if (object instanceof SapforPackage) {
|
|
|
|
|
((SapforPackage) object).init();
|
|
|
|
|
}
|
|
|
|
|
@@ -159,7 +122,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|
|
|
|
protected void startAdditionalThreads() {
|
|
|
|
|
testingThread.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DVMTestingChecker dvmTestingChecker = new DVMTestingChecker();
|
|
|
|
|
SapforTestingPlanner sapforTestingPlanner = new SapforTestingPlanner();
|
|
|
|
|
//--
|
|
|
|
|
@@ -473,6 +435,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|
|
|
|
File repo = new File(testingSystemHome, "Repo");
|
|
|
|
|
File repoSapforHome = Paths.get(repo.getAbsolutePath(), Constants.SAPFOR_REPOSITORY_BIN).toFile();
|
|
|
|
|
File repo_bin = new File(repoSapforHome, "Sapfor_F");
|
|
|
|
|
File repo_out = new File(repoSapforHome, Constants.out_file);
|
|
|
|
|
File repo_err = new File(repoSapforHome, Constants.err_file);
|
|
|
|
|
//--
|
|
|
|
|
System.out.println("Синхронизация ветви DVM...");
|
|
|
|
|
Utils.startScript(repo, repo, "dvm_checkout",
|
|
|
|
|
@@ -513,18 +477,40 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|
|
|
|
//--
|
|
|
|
|
System.out.println("Сборка SAPFOR...");
|
|
|
|
|
Utils.startScript(repoSapforHome, repoSapforHome, "build_sapfor",
|
|
|
|
|
"cmake ../ 1>out.txt 2>err.txt\nmake -j 14 1>>out.txt 2>>err.txt\n").waitFor();
|
|
|
|
|
"cmake ../ 1>" +
|
|
|
|
|
Constants.out_file +
|
|
|
|
|
" 2>" +
|
|
|
|
|
Constants.err_file +
|
|
|
|
|
"\nmake -j 14 1>>" +
|
|
|
|
|
Constants.out_file +
|
|
|
|
|
" 2>>" +
|
|
|
|
|
Constants.err_file +
|
|
|
|
|
"\n").waitFor();
|
|
|
|
|
//--
|
|
|
|
|
System.out.println("DONE");
|
|
|
|
|
File repoSapfor = new File(repoSapforHome, "Sapfor_F");
|
|
|
|
|
System.out.println("Result file is " + Utils.Brackets(repoSapfor.getAbsolutePath()));
|
|
|
|
|
//---
|
|
|
|
|
File sapforsDirectory = new File(testingSystemHome, "Sapfors");
|
|
|
|
|
File sapforHome = new File(sapforsDirectory, Utils.getDateName("sapfor"));
|
|
|
|
|
sapforHome.mkdir();
|
|
|
|
|
File sapforOut = new File(sapforHome, Constants.out_file);
|
|
|
|
|
File sapforErr = new File(sapforHome, Constants.err_file);
|
|
|
|
|
//--
|
|
|
|
|
System.out.println(repoSapfor.getAbsolutePath());
|
|
|
|
|
System.out.println(repo_out.getAbsolutePath());
|
|
|
|
|
System.out.println(repo_err.getAbsolutePath());
|
|
|
|
|
System.out.println("====================");
|
|
|
|
|
//--
|
|
|
|
|
if (repo_out.exists())
|
|
|
|
|
FileUtils.copyFile(repo_out, sapforOut);
|
|
|
|
|
if (repo_err.exists())
|
|
|
|
|
FileUtils.copyFile(repo_err, sapforErr);
|
|
|
|
|
//--
|
|
|
|
|
if (repoSapfor.exists()) {
|
|
|
|
|
System.out.println("assembly found!");
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
File sapforsDirectory = new File(testingSystemHome, "Sapfors");
|
|
|
|
|
//создать папку. Для того чтобы скопировать из репозитория.
|
|
|
|
|
File sapforHome = new File(sapforsDirectory, Utils.getDateName("sapfor"));
|
|
|
|
|
sapforHome.mkdir();
|
|
|
|
|
File sapforBin = new File(sapforHome, "Sapfor_F");
|
|
|
|
|
FileUtils.copyFile(repo_bin, sapforBin);
|
|
|
|
|
sapforBin.setExecutable(true, false);
|
|
|
|
|
@@ -537,7 +523,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|
|
|
|
response.object = serverSapfor;
|
|
|
|
|
serverSapfor.version = String.valueOf(current_version);
|
|
|
|
|
//---
|
|
|
|
|
EmailSapforAssembly(current_version, true);
|
|
|
|
|
// EmailSapforAssembly(current_version, true);
|
|
|
|
|
//---
|
|
|
|
|
} else {
|
|
|
|
|
//---
|
|
|
|
|
@@ -625,7 +611,40 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
response.object = db.getFirstActiveDVMPackageCopyForMachineURL(request.arg);
|
|
|
|
|
}
|
|
|
|
|
//-----
|
|
|
|
|
|
|
|
|
|
void StartNecessaryMachines() {
|
|
|
|
|
try {
|
|
|
|
|
Vector<String> aborted = new Vector<>();
|
|
|
|
|
for (MachineProcess process : machinesProcesses.Data.values()) {
|
|
|
|
|
if (process.isAborted()) {
|
|
|
|
|
aborted.add(process.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
for (String key : aborted) {
|
|
|
|
|
machinesProcesses.Data.remove(key);
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
LinkedHashMap<String, MachineProcess> processes_to_start = new LinkedHashMap<>();
|
|
|
|
|
//1. Получить список всех пакетов, которые активны, и взять из них машины.
|
|
|
|
|
for (DVMPackage dvmPackage : db.dvmPackages.Data.values()) {
|
|
|
|
|
if (dvmPackage.state.isActive()) {
|
|
|
|
|
//-
|
|
|
|
|
if (!machinesProcesses.hasProcessForPackage(dvmPackage)) {
|
|
|
|
|
MachineProcess new_process = new MachineProcess(dvmPackage);
|
|
|
|
|
processes_to_start.put(new_process.getUniqueKey(), new_process);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//запуск.
|
|
|
|
|
for (MachineProcess process : processes_to_start.values()) {
|
|
|
|
|
process.Start();
|
|
|
|
|
if (Utils.checkFileCreation(process.getStartedFile())) {
|
|
|
|
|
machinesProcesses.Data.put(process.id, process);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|