2023-11-19 02:12:44 +03:00
|
|
|
|
package TestingSystem.Common;
|
2024-10-07 14:22:52 +03:00
|
|
|
|
import Common.CommonConstants;
|
2024-10-07 00:58:29 +03:00
|
|
|
|
import Common.Utils.CommonUtils;
|
|
|
|
|
|
import Common_old.Constants;
|
|
|
|
|
|
import Common.Database.Objects.DBObject;
|
|
|
|
|
|
import _VisualDVM.Global;
|
2024-09-24 20:22:41 +03:00
|
|
|
|
import Common.Utils.TextLog;
|
2024-10-07 00:58:29 +03:00
|
|
|
|
import Common_old.Utils.Utils;
|
2023-11-19 00:25:37 +03:00
|
|
|
|
import GlobalData.Account.Account;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import ProjectData.LanguageName;
|
2024-05-16 01:26:03 +03:00
|
|
|
|
import Repository.Component.Sapfor.Sapfor;
|
2024-09-25 01:27:02 +03:00
|
|
|
|
import Repository.EmailMessage;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import Repository.RepositoryRefuseException;
|
|
|
|
|
|
import Repository.RepositoryServer;
|
2023-11-19 02:12:44 +03:00
|
|
|
|
import Repository.Server.ServerCode;
|
|
|
|
|
|
import Repository.Server.ServerExchangeUnit_2021;
|
|
|
|
|
|
import TestingSystem.Common.Group.Group;
|
2024-04-23 00:36:37 +03:00
|
|
|
|
import TestingSystem.Common.MachineProcess.MachineProcess;
|
2024-04-26 20:28:50 +03:00
|
|
|
|
import TestingSystem.Common.MachineProcess.MachineProcessSet;
|
2023-11-19 02:12:44 +03:00
|
|
|
|
import TestingSystem.Common.Test.Test;
|
|
|
|
|
|
import TestingSystem.Common.Test.TestType;
|
2023-12-15 02:34:30 +03:00
|
|
|
|
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
2023-12-13 02:26:20 +03:00
|
|
|
|
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
2024-03-22 23:08:51 +03:00
|
|
|
|
import TestingSystem.DVM.DVMPackage.DVMPackage_json;
|
2024-04-26 22:21:56 +03:00
|
|
|
|
import TestingSystem.DVM.DVMTestingChecker;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforPackage_json;
|
2023-12-06 02:43:06 +03:00
|
|
|
|
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
2023-12-16 03:57:01 +03:00
|
|
|
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
2024-09-27 22:50:47 +03:00
|
|
|
|
import TestingSystem.SAPFOR.SapforSettings.SapforSettings;
|
|
|
|
|
|
import TestingSystem.SAPFOR.SapforSettingsCommand.SapforSettingsCommand;
|
2023-12-16 03:57:01 +03:00
|
|
|
|
import TestingSystem.SAPFOR.SapforTestingPlanner;
|
2023-11-19 02:12:44 +03:00
|
|
|
|
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
2024-05-21 17:36:03 +03:00
|
|
|
|
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
|
2023-11-19 02:12:44 +03:00
|
|
|
|
import Visual_DVM_2021.Passes.All.DownloadRepository;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.All.ZipFolderPass;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.Pass_2021;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import javafx.util.Pair;
|
2023-11-19 00:25:37 +03:00
|
|
|
|
import org.apache.commons.io.FileUtils;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
2024-05-21 17:36:03 +03:00
|
|
|
|
import javax.swing.*;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import java.io.File;
|
|
|
|
|
|
import java.nio.file.Paths;
|
2024-05-21 17:36:03 +03:00
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
|
import java.util.Vector;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
public class TestingServer extends RepositoryServer<TestsDatabase> {
|
2024-04-23 22:48:02 +03:00
|
|
|
|
public String name = "?";
|
2024-05-05 23:20:12 +03:00
|
|
|
|
public static MachineProcessSet machinesProcesses = new MachineProcessSet();
|
2023-12-16 03:57:01 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
public void afterPublishAction(DBObject object) throws Exception {
|
2023-12-16 16:52:17 +03:00
|
|
|
|
if (object instanceof Test) {
|
2023-12-16 03:57:01 +03:00
|
|
|
|
Test test = (Test) object;
|
|
|
|
|
|
if (!test.unpackProjectOnServer()) {
|
|
|
|
|
|
db.Delete(test);
|
|
|
|
|
|
throw new RepositoryRefuseException(
|
|
|
|
|
|
"Не удалось прикрепить проект к тесту с id " + test.id
|
|
|
|
|
|
+ "\nТест будет удален"
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2024-09-25 01:27:02 +03:00
|
|
|
|
} else if (object instanceof DVMPackage) {
|
2023-12-16 03:57:01 +03:00
|
|
|
|
DVMPackage dvmPackage = (DVMPackage) object;
|
|
|
|
|
|
//--
|
|
|
|
|
|
Utils.CheckAndCleanDirectory(dvmPackage.getLocalWorkspace());
|
|
|
|
|
|
//--
|
|
|
|
|
|
dvmPackage.saveJson();
|
|
|
|
|
|
dvmPackage.package_json = null; // объект больше не нужен.
|
2024-04-26 20:28:50 +03:00
|
|
|
|
//--
|
2024-09-25 01:27:02 +03:00
|
|
|
|
} else if (object instanceof SapforPackage) {
|
2024-03-07 18:56:47 +03:00
|
|
|
|
((SapforPackage) object).init();
|
2023-12-16 03:57:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-14 00:18:27 +03:00
|
|
|
|
@Override
|
2023-12-16 03:57:01 +03:00
|
|
|
|
public void afterDeleteAction(DBObject object) throws Exception {
|
|
|
|
|
|
if (object instanceof Test) {
|
|
|
|
|
|
Test test = (Test) object;
|
|
|
|
|
|
Utils.forceDeleteWithCheck(test.getArchive());
|
|
|
|
|
|
Utils.forceDeleteWithCheck(test.getServerPath());
|
|
|
|
|
|
} else if (object instanceof Group) {
|
|
|
|
|
|
Group group = (Group) object;
|
|
|
|
|
|
Vector<Test> tests = new Vector<>();
|
|
|
|
|
|
for (Test group_test : db.tests.Data.values()) {
|
|
|
|
|
|
if (group_test.group_id == group.id)
|
|
|
|
|
|
tests.add(group_test);
|
|
|
|
|
|
}
|
|
|
|
|
|
for (Test group_test : tests) {
|
|
|
|
|
|
db.Delete(group_test);
|
|
|
|
|
|
Utils.forceDeleteWithCheck(group_test.getArchive());
|
|
|
|
|
|
Utils.forceDeleteWithCheck(group_test.getServerPath());
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (object instanceof ServerSapfor) {
|
|
|
|
|
|
Utils.forceDeleteWithCheck(
|
|
|
|
|
|
new File(
|
|
|
|
|
|
((ServerSapfor) object).home_path
|
|
|
|
|
|
)
|
|
|
|
|
|
);
|
2024-09-28 21:47:17 +03:00
|
|
|
|
} else if (object instanceof DVMPackage) {
|
2023-12-16 03:57:01 +03:00
|
|
|
|
DVMPackage dvmPackage = (DVMPackage) object;
|
|
|
|
|
|
File workspace = dvmPackage.getLocalWorkspace();
|
|
|
|
|
|
Utils.forceDeleteWithCheck(workspace);
|
|
|
|
|
|
} else if (object instanceof SapforPackage) {
|
|
|
|
|
|
SapforPackage sapforPackage = (SapforPackage) object;
|
|
|
|
|
|
File workspace = sapforPackage.getLocalWorkspace();
|
|
|
|
|
|
Utils.forceDeleteWithCheck(workspace);
|
2024-09-27 22:50:47 +03:00
|
|
|
|
} else if (object instanceof SapforSettings) {
|
|
|
|
|
|
SapforSettings sapforSettings = (SapforSettings) object;
|
|
|
|
|
|
Vector<SapforSettingsCommand> commands = new Vector<>();
|
|
|
|
|
|
for (SapforSettingsCommand command : db.sapforSettingsCommands.Data.values()) {
|
|
|
|
|
|
if (command.sapforsettings_id== sapforSettings.id)
|
|
|
|
|
|
commands.add(command);
|
|
|
|
|
|
}
|
|
|
|
|
|
for (SapforSettingsCommand command : commands) {
|
|
|
|
|
|
db.Delete(command);
|
|
|
|
|
|
}
|
2023-12-16 03:57:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//-->>>
|
2024-05-16 01:26:03 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
protected void beforePublishAction(DBObject object) throws Exception {
|
2024-05-21 17:36:03 +03:00
|
|
|
|
if (object instanceof ServerSapfor) {
|
|
|
|
|
|
int current_version = getSapforActualVersion();
|
2024-05-16 01:26:03 +03:00
|
|
|
|
int max_installed_version = db.getInstalledSapforMaxVersion();
|
2024-05-21 17:36:03 +03:00
|
|
|
|
if (max_installed_version == current_version)
|
|
|
|
|
|
throw new RepositoryRefuseException("Актуальная версия SAPFOR " + max_installed_version + " уже установлена");
|
2024-05-16 01:26:03 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
public TestingServer() {
|
|
|
|
|
|
super(TestsDatabase.class);
|
2024-04-23 22:48:02 +03:00
|
|
|
|
name = Utils.getDateName("testingServer");
|
2024-10-07 14:22:52 +03:00
|
|
|
|
System.out.println("ServerName=" + CommonUtils.Brackets(name));
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
//основа
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public int getPort() {
|
2024-02-16 21:44:13 +03:00
|
|
|
|
return Global.properties.TestingServerPort;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
//---
|
|
|
|
|
|
@Override
|
2023-10-03 15:07:17 +03:00
|
|
|
|
protected void startAdditionalThreads() {
|
2023-12-16 16:52:17 +03:00
|
|
|
|
testingThread.start();
|
2023-10-03 15:07:17 +03:00
|
|
|
|
}
|
2024-04-26 22:21:56 +03:00
|
|
|
|
DVMTestingChecker dvmTestingChecker = new DVMTestingChecker();
|
2024-04-26 17:57:58 +03:00
|
|
|
|
SapforTestingPlanner sapforTestingPlanner = new SapforTestingPlanner();
|
2024-04-23 00:36:37 +03:00
|
|
|
|
//--
|
2023-12-16 16:52:17 +03:00
|
|
|
|
protected Thread testingThread = new Thread(() -> {
|
2023-12-16 03:57:01 +03:00
|
|
|
|
while (true) {
|
2024-04-26 22:21:56 +03:00
|
|
|
|
dvmTestingChecker.Perform();
|
2024-04-24 22:23:50 +03:00
|
|
|
|
sapforTestingPlanner.Perform();
|
2024-04-23 00:36:37 +03:00
|
|
|
|
Utils.sleep(5000);
|
2023-12-16 03:57:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
//------>>>
|
2023-10-03 15:07:17 +03:00
|
|
|
|
public static Timer checkTimer = null;
|
|
|
|
|
|
public static void TimerOn() {
|
2023-11-13 21:07:44 +03:00
|
|
|
|
checkTimer = new Timer(Global.properties.CheckTestingIntervalSeconds * 1000, e -> {
|
2023-12-10 02:26:28 +03:00
|
|
|
|
Pass_2021.passes.get(PassCode_2021.ActualizePackages).Do();
|
2023-10-03 15:07:17 +03:00
|
|
|
|
});
|
|
|
|
|
|
checkTimer.start();
|
|
|
|
|
|
}
|
|
|
|
|
|
public static void TimerOff() {
|
|
|
|
|
|
if (checkTimer != null)
|
|
|
|
|
|
checkTimer.stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
public static void ResetTimer() {
|
|
|
|
|
|
TimerOff();
|
|
|
|
|
|
TimerOn();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-09-17 22:13:42 +03:00
|
|
|
|
protected void Session() throws Exception {
|
2023-11-17 20:19:32 +03:00
|
|
|
|
Test test;
|
|
|
|
|
|
int test_id;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
switch (code) {
|
2024-09-24 20:22:41 +03:00
|
|
|
|
case PerformAutoSapforTesting:
|
|
|
|
|
|
Print("Запустить автоматическое тестирование SAPFOR");
|
|
|
|
|
|
TextLog Log = new TextLog();
|
2024-10-03 16:21:11 +03:00
|
|
|
|
SapforPackage autoPackage = tryAutoSapforTesting(Log);
|
2024-09-24 20:22:41 +03:00
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2024-09-27 02:01:14 +03:00
|
|
|
|
EmailMessage message = Log.isEmpty() ?
|
2024-09-26 21:31:18 +03:00
|
|
|
|
new EmailMessage(
|
2024-10-03 16:21:11 +03:00
|
|
|
|
"Запущено автоматическое тестирование версии " + request.arg + " системы SAPFOR",
|
2024-10-07 14:22:52 +03:00
|
|
|
|
"Пакет "+ CommonUtils.Brackets(autoPackage.id), new Vector<>()) :
|
2024-09-26 21:31:18 +03:00
|
|
|
|
new EmailMessage(
|
2024-09-27 02:01:14 +03:00
|
|
|
|
"Не удалось запустить автоматическое тестирование версии " + request.arg + " системы SAPFOR",
|
|
|
|
|
|
Log.toString(),
|
|
|
|
|
|
new Vector<>()
|
|
|
|
|
|
);
|
2024-09-26 21:31:18 +03:00
|
|
|
|
Email(message);
|
2024-09-24 20:22:41 +03:00
|
|
|
|
break;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
case DownloadTest:
|
|
|
|
|
|
Print("Отправить клиенту тест " + request.arg);
|
2023-11-17 20:19:32 +03:00
|
|
|
|
test_id = Integer.parseInt(request.arg);
|
|
|
|
|
|
if (db.tests.containsKey(test_id)) {
|
|
|
|
|
|
test = db.tests.get(test_id);
|
2024-10-07 22:04:09 +03:00
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK, "", CommonUtils.fileToBytes(test.getArchive()));
|
2023-09-17 22:13:42 +03:00
|
|
|
|
} else
|
|
|
|
|
|
throw new RepositoryRefuseException("Теста с именем " + request.arg + " не существует");
|
|
|
|
|
|
break;
|
|
|
|
|
|
case ReceiveTestsDatabase:
|
|
|
|
|
|
Print("Получить базу данных тестов");
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2024-10-07 22:04:09 +03:00
|
|
|
|
response.object = CommonUtils.fileToBytes(db.getFile());
|
2023-09-17 22:13:42 +03:00
|
|
|
|
break;
|
2023-11-19 00:25:37 +03:00
|
|
|
|
//---
|
|
|
|
|
|
case RefreshDVMTests:
|
|
|
|
|
|
Print("Синхронизировать репозиторий тестов ");
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2023-11-26 00:30:43 +03:00
|
|
|
|
RefreshDVMTests((Account) request.object, Integer.parseInt(request.arg));
|
2023-11-19 00:25:37 +03:00
|
|
|
|
break;
|
2023-12-14 18:45:41 +03:00
|
|
|
|
case DVMPackageNeedsKill:
|
2023-12-16 03:57:01 +03:00
|
|
|
|
Print("Проверить нуждается ли пакет DVM в убийстве");
|
2023-12-14 18:45:41 +03:00
|
|
|
|
DVMPackageNeedsKill();
|
|
|
|
|
|
break;
|
2023-12-14 23:00:50 +03:00
|
|
|
|
case UpdateActiveDVMPackages:
|
|
|
|
|
|
Print("Получить данные по пакетам DVM");
|
|
|
|
|
|
UpdateActiveDVMPackages();
|
|
|
|
|
|
break;
|
2024-03-21 19:02:08 +03:00
|
|
|
|
case GetFirstActiveSapforPackages:
|
2023-12-16 03:57:01 +03:00
|
|
|
|
Print("Получить первый активный пакет задач SAPFOR");
|
2024-03-21 19:02:08 +03:00
|
|
|
|
GetFirstActiveSapforPackages();
|
2023-12-16 03:57:01 +03:00
|
|
|
|
break;
|
|
|
|
|
|
case SapforPackageNeedsKill:
|
|
|
|
|
|
Print("Проверить нуждает ли пакет SAPFOR в убийстве");
|
|
|
|
|
|
SapforPackageNeedsKill();
|
|
|
|
|
|
break;
|
|
|
|
|
|
case UpdateActiveSapforPackages:
|
|
|
|
|
|
Print("Получить данные по пакетам Sapfor");
|
|
|
|
|
|
UpdateActiveSapforPackages();
|
|
|
|
|
|
break;
|
2023-12-16 11:35:37 +03:00
|
|
|
|
case DownloadDVMPackage:
|
|
|
|
|
|
Print("Загрузить пакет DVM");
|
|
|
|
|
|
DownloadDVMPackage();
|
|
|
|
|
|
break;
|
2023-12-17 19:19:59 +03:00
|
|
|
|
case DownloadDVMPackages:
|
|
|
|
|
|
Print("Загрузить пакеты DVM");
|
|
|
|
|
|
DownloadDVMPackages();
|
|
|
|
|
|
break;
|
2023-12-18 00:04:44 +03:00
|
|
|
|
case DownloadSapforPackage:
|
|
|
|
|
|
Print("Загрузить пакет SAPFOR");
|
|
|
|
|
|
DownloadSapforPackage();
|
|
|
|
|
|
break;
|
2024-03-02 01:44:03 +03:00
|
|
|
|
case ReplaceTestCode:
|
|
|
|
|
|
Print("Заменить код теста");
|
|
|
|
|
|
ReplaceTestCode();
|
|
|
|
|
|
break;
|
2024-03-05 16:49:57 +03:00
|
|
|
|
case ReplaceTestsCodes:
|
|
|
|
|
|
Print("Заменить код тестов");
|
|
|
|
|
|
ReplaceTestsCodes();
|
|
|
|
|
|
break;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
case GetSapforPackagesJson:
|
|
|
|
|
|
Print("Получить информацию о задачах пакетов SAPFOR");
|
|
|
|
|
|
GetSapforPackagesJson();
|
|
|
|
|
|
break;
|
2024-03-22 23:08:51 +03:00
|
|
|
|
case GetDVMPackagesJson:
|
|
|
|
|
|
Print("Получить информацию о задачах пакетов DVM");
|
|
|
|
|
|
GetDVMPackagesJson();
|
|
|
|
|
|
break;
|
2024-04-13 20:09:26 +03:00
|
|
|
|
case GetFirstActiveDVMPackageForMachineURL:
|
|
|
|
|
|
Print("Получить первый активный пакет задач DVM на машине с адресом");
|
|
|
|
|
|
GetFirstActiveDVMPackageForMachineURL();
|
|
|
|
|
|
break;
|
2024-04-23 22:48:02 +03:00
|
|
|
|
case GetServerName:
|
|
|
|
|
|
Print("Получить имя сервера");
|
|
|
|
|
|
GetServerName();
|
|
|
|
|
|
break;
|
2024-04-26 17:57:58 +03:00
|
|
|
|
case StartNecessaryMachines:
|
|
|
|
|
|
Print("Проверка процессов машин");
|
2024-04-26 20:54:10 +03:00
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2024-04-26 17:57:58 +03:00
|
|
|
|
StartNecessaryMachines();
|
|
|
|
|
|
break;
|
2024-05-07 01:06:47 +03:00
|
|
|
|
case GetSapforForCompilation:
|
|
|
|
|
|
Print("Получить первую активную версию Sapfor для сборки");
|
|
|
|
|
|
GetSapforForCompilation();
|
|
|
|
|
|
break;
|
2024-05-08 01:56:17 +03:00
|
|
|
|
case GetMaxSapforVersion:
|
|
|
|
|
|
Print("Получить максимальную установленную версию Sapfor");
|
|
|
|
|
|
GetSapforMaxVersion();
|
|
|
|
|
|
break;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
default:
|
|
|
|
|
|
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-11-19 00:25:37 +03:00
|
|
|
|
//->>
|
2023-11-23 01:00:08 +03:00
|
|
|
|
Pair<Group, Vector<File>> ConvertDirectoryToGroup(File src, LanguageName languageName, TestType
|
|
|
|
|
|
testType, Account account) throws Exception {
|
2023-11-19 00:25:37 +03:00
|
|
|
|
Group object = new Group();
|
|
|
|
|
|
Vector<File> groupFiles = null; //транспорт.
|
|
|
|
|
|
//->>
|
|
|
|
|
|
object.description = src.getName();
|
|
|
|
|
|
object.language = languageName;
|
|
|
|
|
|
object.type = testType;
|
|
|
|
|
|
object.sender_name = account.name;
|
|
|
|
|
|
object.sender_address = account.email;
|
|
|
|
|
|
//-->>
|
|
|
|
|
|
File[] files = src.listFiles(pathname ->
|
|
|
|
|
|
pathname.isFile()
|
|
|
|
|
|
&& !pathname.getName().equals("settings")
|
|
|
|
|
|
&& !pathname.getName().equals("test-analyzer.sh")
|
2024-10-07 14:22:52 +03:00
|
|
|
|
&& CommonUtils.getExtension(pathname).startsWith(languageName.getDVMCompile()));
|
2023-11-19 00:25:37 +03:00
|
|
|
|
;
|
|
|
|
|
|
if (files != null) {
|
|
|
|
|
|
groupFiles = new Vector<>(Arrays.asList(files));
|
|
|
|
|
|
groupFiles.sort(Comparator.comparing(File::getName));
|
|
|
|
|
|
}
|
|
|
|
|
|
//->>
|
|
|
|
|
|
return new Pair<>(object, groupFiles);
|
|
|
|
|
|
}
|
2023-11-26 00:30:43 +03:00
|
|
|
|
public void RefreshDVMTests(Account account, int sapfor_id) throws Exception {
|
2023-11-25 16:51:35 +03:00
|
|
|
|
ServerSapfor sapfor = null;
|
|
|
|
|
|
if (!db.serverSapfors.containsKey(sapfor_id))
|
|
|
|
|
|
throw new RepositoryRefuseException("Версия SAPFOR с ключом " + sapfor_id + " не найдена.");
|
|
|
|
|
|
sapfor = db.serverSapfors.get(sapfor_id);
|
2023-11-19 00:25:37 +03:00
|
|
|
|
DownloadRepository downloadRepository = new DownloadRepository();
|
|
|
|
|
|
if (!downloadRepository.Do())
|
|
|
|
|
|
throw new RepositoryRefuseException("Не удалось обновить репозиторий");
|
|
|
|
|
|
//-->>
|
|
|
|
|
|
Vector<Pair<Group, Vector<File>>> groups = new Vector<>();
|
|
|
|
|
|
File testsSrc = Paths.get(
|
|
|
|
|
|
Global.RepoDirectory.getAbsolutePath(),
|
|
|
|
|
|
"dvm", "tools", "tester", "trunk", "test-suite").toFile();
|
|
|
|
|
|
LanguageName[] supportedLanguages = new LanguageName[]{LanguageName.fortran, LanguageName.c};
|
|
|
|
|
|
for (LanguageName languageName : supportedLanguages) {
|
|
|
|
|
|
for (TestType testType : TestType.values()) {
|
|
|
|
|
|
File groupsSrc = null;
|
|
|
|
|
|
switch (testType) {
|
|
|
|
|
|
case Correctness:
|
|
|
|
|
|
String languageSrcName = null;
|
|
|
|
|
|
switch (languageName) {
|
|
|
|
|
|
case fortran:
|
|
|
|
|
|
languageSrcName = "Fortran";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case c:
|
|
|
|
|
|
languageSrcName = "C";
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (languageSrcName != null) {
|
|
|
|
|
|
groupsSrc = Paths.get(testsSrc.getAbsolutePath(), "Correctness", languageSrcName).toFile();
|
|
|
|
|
|
File[] groupsDirs = groupsSrc.listFiles(File::isDirectory);
|
|
|
|
|
|
if (groupsDirs != null) {
|
|
|
|
|
|
for (File groupDir : groupsDirs)
|
|
|
|
|
|
groups.add(ConvertDirectoryToGroup(groupDir, languageName, testType, account));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Performance:
|
|
|
|
|
|
File groupDir = Paths.get(testsSrc.getAbsolutePath(), "Performance").toFile();
|
|
|
|
|
|
groups.add(ConvertDirectoryToGroup(groupDir, languageName, testType, account));
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
groups.sort(Comparator.comparing(o -> o.getKey().description));
|
|
|
|
|
|
//-теперь создать тесты.
|
|
|
|
|
|
//--
|
2024-04-07 21:30:11 +03:00
|
|
|
|
for (Pair<Group, Vector<File>> p : groups)
|
|
|
|
|
|
db.RefreshGroup(account, sapfor, p);
|
2023-11-19 00:25:37 +03:00
|
|
|
|
}
|
2024-03-21 19:02:08 +03:00
|
|
|
|
private void GetFirstActiveSapforPackages() throws Exception {
|
2023-12-16 03:57:01 +03:00
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2024-03-21 19:02:08 +03:00
|
|
|
|
response.object = db.getFirstActiveSapforPackagesCopies();
|
2023-12-16 03:57:01 +03:00
|
|
|
|
}
|
2024-05-16 01:26:03 +03:00
|
|
|
|
void GetSapforMaxVersion() throws Exception {
|
2024-05-08 01:56:17 +03:00
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
response.object = db.getInstalledSapforMaxVersion();
|
|
|
|
|
|
}
|
2023-12-14 23:00:50 +03:00
|
|
|
|
void UpdateActiveDVMPackages() throws Exception {
|
2023-12-15 02:34:30 +03:00
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2023-12-15 14:55:16 +03:00
|
|
|
|
Vector<Pair<Integer, Long>> keys_pairs = (Vector<Pair<Integer, Long>>) request.object;
|
2023-12-14 23:00:50 +03:00
|
|
|
|
Vector<DVMPackage> res = new Vector<>();
|
|
|
|
|
|
//--
|
2023-12-15 14:55:16 +03:00
|
|
|
|
for (Pair<Integer, Long> p : keys_pairs) {
|
2023-12-14 23:00:50 +03:00
|
|
|
|
if (db.dvmPackages.containsKey(p.getKey())) {
|
2023-12-15 14:55:16 +03:00
|
|
|
|
DVMPackage actual = db.dvmPackages.get(p.getKey());
|
|
|
|
|
|
if (actual.ChangeDate != p.getValue())
|
|
|
|
|
|
res.add(new DVMPackage(actual));
|
2023-12-14 23:00:50 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
response.object = res;
|
|
|
|
|
|
}
|
2023-12-16 03:57:01 +03:00
|
|
|
|
private void UpdateActiveSapforPackages() {
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
Vector<Pair<Integer, Long>> keys_pairs = (Vector<Pair<Integer, Long>>) request.object;
|
|
|
|
|
|
Vector<SapforPackage> res = new Vector<>();
|
|
|
|
|
|
//--
|
|
|
|
|
|
for (Pair<Integer, Long> p : keys_pairs) {
|
|
|
|
|
|
if (db.sapforPackages.containsKey(p.getKey())) {
|
|
|
|
|
|
SapforPackage actual = db.sapforPackages.get(p.getKey());
|
|
|
|
|
|
if (actual.ChangeDate != p.getValue())
|
|
|
|
|
|
res.add(new SapforPackage(actual));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
response.object = res;
|
|
|
|
|
|
}
|
2023-12-15 02:34:30 +03:00
|
|
|
|
private void DVMPackageNeedsKill() {
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2024-10-07 14:22:52 +03:00
|
|
|
|
response.object = CommonConstants.Nan;
|
2023-12-15 02:34:30 +03:00
|
|
|
|
int packageId = (int) request.object;
|
|
|
|
|
|
for (TestingPackageToKill packageToKill : db.testingPackagesToKill.Data.values()) {
|
|
|
|
|
|
if ((packageToKill.packageId == packageId) && (packageToKill.type == 0)) {
|
2023-12-18 15:44:48 +03:00
|
|
|
|
response.object = packageToKill.id;
|
2023-12-15 02:34:30 +03:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-16 03:57:01 +03:00
|
|
|
|
private void SapforPackageNeedsKill() throws Exception {
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2024-10-07 14:22:52 +03:00
|
|
|
|
response.object = CommonConstants.Nan;
|
2023-12-16 03:57:01 +03:00
|
|
|
|
int packageId = (int) request.object;
|
|
|
|
|
|
for (TestingPackageToKill packageToKill : db.testingPackagesToKill.Data.values()) {
|
|
|
|
|
|
if ((packageToKill.packageId == packageId) && (packageToKill.type == 1)) {
|
2023-12-18 15:44:48 +03:00
|
|
|
|
response.object = packageToKill.id;
|
2023-12-16 03:57:01 +03:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-16 16:52:17 +03:00
|
|
|
|
private void DownloadDVMPackage() throws Exception {
|
2023-12-16 11:35:37 +03:00
|
|
|
|
int dvmPackage_id = (int) request.object;
|
|
|
|
|
|
if (!db.dvmPackages.containsKey(dvmPackage_id))
|
2023-12-16 16:52:17 +03:00
|
|
|
|
throw new RepositoryRefuseException("Не найдено пакета тестирования DVM с ключом " + dvmPackage_id);
|
2023-12-16 11:35:37 +03:00
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
DVMPackage dvmPackage = db.dvmPackages.get(dvmPackage_id);
|
|
|
|
|
|
File workspace = dvmPackage.getLocalWorkspace();
|
2023-12-16 16:52:17 +03:00
|
|
|
|
File results_zip = new File(workspace, "results.zip");
|
2023-12-16 11:35:37 +03:00
|
|
|
|
File package_json = dvmPackage.getJsonFile();
|
2024-10-07 22:04:09 +03:00
|
|
|
|
response.object = new Pair(CommonUtils.fileToBytes(results_zip), CommonUtils.fileToBytes(package_json));
|
2023-12-16 11:35:37 +03:00
|
|
|
|
}
|
2023-12-17 19:19:59 +03:00
|
|
|
|
private void DownloadDVMPackages() throws Exception {
|
|
|
|
|
|
Vector<Integer> ids = (Vector<Integer>) request.object;
|
|
|
|
|
|
Vector<Pair<Integer, Pair<byte[], byte[]>>> res = new Vector<>();
|
|
|
|
|
|
for (int dvmPackage_id : ids) {
|
|
|
|
|
|
if (!db.dvmPackages.containsKey(dvmPackage_id))
|
|
|
|
|
|
throw new RepositoryRefuseException("Не найдено пакета тестирования DVM с ключом " + dvmPackage_id);
|
|
|
|
|
|
DVMPackage dvmPackage = db.dvmPackages.get(dvmPackage_id);
|
|
|
|
|
|
File workspace = dvmPackage.getLocalWorkspace();
|
|
|
|
|
|
File results_zip = new File(workspace, "results.zip");
|
|
|
|
|
|
File package_json = dvmPackage.getJsonFile();
|
2024-10-07 22:04:09 +03:00
|
|
|
|
res.add(new Pair<>(dvmPackage_id, new Pair(CommonUtils.fileToBytes(results_zip), CommonUtils.fileToBytes(package_json))));
|
2023-12-17 19:19:59 +03:00
|
|
|
|
}
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
response.object = res;
|
|
|
|
|
|
}
|
2023-12-18 00:04:44 +03:00
|
|
|
|
private void DownloadSapforPackage() throws Exception {
|
|
|
|
|
|
int sapforPackage_id = (int) request.object;
|
|
|
|
|
|
if (!db.sapforPackages.containsKey(sapforPackage_id))
|
|
|
|
|
|
throw new RepositoryRefuseException("Не найдено пакета тестирования SAPFOR с ключом " + sapforPackage_id);
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
SapforPackage sapforPackage = db.sapforPackages.get(sapforPackage_id);
|
|
|
|
|
|
File workspace = sapforPackage.getLocalWorkspace();
|
|
|
|
|
|
File results_zip = Utils.getTempFileName("results");
|
|
|
|
|
|
ZipFolderPass zipFolderPass = new ZipFolderPass();
|
|
|
|
|
|
zipFolderPass.Do(workspace.getAbsolutePath(), results_zip.getAbsolutePath());
|
|
|
|
|
|
if (results_zip.exists())
|
2024-10-07 22:04:09 +03:00
|
|
|
|
response.object = CommonUtils.fileToBytes(results_zip);
|
2023-12-18 15:44:48 +03:00
|
|
|
|
else
|
|
|
|
|
|
throw new RepositoryRefuseException("Не удалось заархивировать пакет тестирования SAPFOR с ключом " + sapforPackage_id);
|
2023-12-18 00:04:44 +03:00
|
|
|
|
}
|
2024-03-02 01:44:03 +03:00
|
|
|
|
private void ReplaceTestCode() throws Exception {
|
|
|
|
|
|
Test test = (Test) request.object;
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
//---
|
|
|
|
|
|
if (!test.unpackProjectOnServer()) {
|
|
|
|
|
|
db.Delete(test);
|
|
|
|
|
|
throw new RepositoryRefuseException(
|
|
|
|
|
|
"Не удалось прикрепить проект к тесту с id " + test.id
|
|
|
|
|
|
+ "\nТест будет удален"
|
|
|
|
|
|
);
|
2024-03-02 22:32:42 +03:00
|
|
|
|
} else db.Update(test); //обновить список файлов и размерность.
|
|
|
|
|
|
}
|
2024-03-05 16:49:57 +03:00
|
|
|
|
private void ReplaceTestsCodes() throws Exception {
|
|
|
|
|
|
Vector<Test> tests = (Vector<Test>) request.object;
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2024-03-07 18:56:47 +03:00
|
|
|
|
for (Test test : tests) {
|
2024-03-05 16:49:57 +03:00
|
|
|
|
if (!test.unpackProjectOnServer()) {
|
|
|
|
|
|
db.Delete(test);
|
|
|
|
|
|
throw new RepositoryRefuseException(
|
|
|
|
|
|
"Не удалось прикрепить проект к тесту с id " + test.id
|
|
|
|
|
|
+ "\nТест будет удален"
|
|
|
|
|
|
);
|
|
|
|
|
|
} else db.Update(test); //обновить список файлов и размерность.
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-04-23 00:36:37 +03:00
|
|
|
|
private void GetDVMPackagesJson() throws Exception {
|
2024-03-22 23:08:51 +03:00
|
|
|
|
Vector<Integer> packages_ids = (Vector<Integer>) request.object;
|
|
|
|
|
|
Vector<DVMPackage_json> jsons = new Vector<>();
|
|
|
|
|
|
for (int package_id : packages_ids) {
|
|
|
|
|
|
if (!db.dvmPackages.containsKey(package_id))
|
2024-10-07 14:22:52 +03:00
|
|
|
|
throw new RepositoryRefuseException("Пакета задач DVM " + CommonUtils.Brackets(package_id) + " не существует.");
|
2024-03-22 23:08:51 +03:00
|
|
|
|
DVMPackage dvmPackage = db.dvmPackages.get(package_id);
|
|
|
|
|
|
File json = dvmPackage.getJsonFile();
|
|
|
|
|
|
if (!json.exists())
|
2024-10-07 14:22:52 +03:00
|
|
|
|
throw new RepositoryRefuseException("Не найден JSON файл для пакета задач DVM " + CommonUtils.Brackets(package_id));
|
2024-10-07 00:58:29 +03:00
|
|
|
|
jsons.add((DVMPackage_json) CommonUtils.jsonFromFile(json, DVMPackage_json.class));
|
2024-03-22 23:08:51 +03:00
|
|
|
|
}
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
response.object = jsons;
|
|
|
|
|
|
}
|
2024-03-08 01:17:54 +03:00
|
|
|
|
private void GetSapforPackagesJson() throws Exception {
|
|
|
|
|
|
Vector<Integer> packages_ids = (Vector<Integer>) request.object;
|
|
|
|
|
|
Vector<SapforPackage_json> jsons = new Vector<>();
|
|
|
|
|
|
for (int package_id : packages_ids) {
|
|
|
|
|
|
if (!db.sapforPackages.containsKey(package_id))
|
2024-10-07 14:22:52 +03:00
|
|
|
|
throw new RepositoryRefuseException("Пакета задач SAPFOR " + CommonUtils.Brackets(package_id) + " не существует.");
|
2024-03-08 01:17:54 +03:00
|
|
|
|
SapforPackage sapforPackage = db.sapforPackages.get(package_id);
|
|
|
|
|
|
File json = sapforPackage.getJsonFile();
|
|
|
|
|
|
if (!json.exists())
|
2024-10-07 14:22:52 +03:00
|
|
|
|
throw new RepositoryRefuseException("Не найден JSON файл для пакета задач SAPFOR " + CommonUtils.Brackets(package_id));
|
2024-10-07 00:58:29 +03:00
|
|
|
|
jsons.add((SapforPackage_json) CommonUtils.jsonFromFile(json, SapforPackage_json.class));
|
2024-03-08 01:17:54 +03:00
|
|
|
|
}
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
response.object = jsons;
|
|
|
|
|
|
}
|
2024-04-23 22:48:02 +03:00
|
|
|
|
private void GetServerName() throws Exception {
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
response.object = name;
|
|
|
|
|
|
}
|
2024-04-15 22:09:10 +03:00
|
|
|
|
//--
|
|
|
|
|
|
private void GetFirstActiveDVMPackageForMachineURL() {
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
response.object = db.getFirstActiveDVMPackageCopyForMachineURL(request.arg);
|
|
|
|
|
|
}
|
2024-05-05 23:20:12 +03:00
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-16 01:26:03 +03:00
|
|
|
|
void GetSapforActualVersion() throws Exception {
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
2024-05-21 17:36:03 +03:00
|
|
|
|
File versionFile = new File(Global.TempDirectory, "version.h");
|
2024-05-16 01:26:03 +03:00
|
|
|
|
if (versionFile.exists())
|
|
|
|
|
|
FileUtils.forceDelete(versionFile);
|
|
|
|
|
|
//1. Получить версию из репозитория.
|
|
|
|
|
|
Utils.startScript(Global.TempDirectory,
|
|
|
|
|
|
Global.TempDirectory,
|
|
|
|
|
|
"get_version",
|
|
|
|
|
|
"wget --user dvmhuser --password dvmh2013 -P " +
|
2024-10-07 14:22:52 +03:00
|
|
|
|
CommonUtils.DQuotes(Global.TempDirectory.getAbsolutePath()) +
|
2024-05-16 01:26:03 +03:00
|
|
|
|
" http://svn.dvm-system.org/svn/dvmhrepo/sapfor/experts/Sapfor_2017/_src/Utils/version.h"
|
|
|
|
|
|
).waitFor();
|
|
|
|
|
|
if (!versionFile.exists())
|
|
|
|
|
|
throw new RepositoryRefuseException("Не удалось загрузить текущую версию SAPFOR из репозитория!");
|
|
|
|
|
|
int current_version = Sapfor.readVersionFromCode(versionFile);
|
|
|
|
|
|
int max_installed_version = db.getInstalledSapforMaxVersion();
|
2024-05-21 17:36:03 +03:00
|
|
|
|
if (max_installed_version == current_version)
|
|
|
|
|
|
throw new RepositoryRefuseException("Версия " + max_installed_version + " уже установлена");
|
|
|
|
|
|
}
|
|
|
|
|
|
//---
|
|
|
|
|
|
int getSapforActualVersion() throws Exception {
|
|
|
|
|
|
File versionFile = new File(Global.TempDirectory, "version.h");
|
|
|
|
|
|
if (versionFile.exists())
|
|
|
|
|
|
FileUtils.forceDelete(versionFile);
|
|
|
|
|
|
//1. Получить версию из репозитория.
|
|
|
|
|
|
Utils.startScript(Global.TempDirectory,
|
|
|
|
|
|
Global.TempDirectory,
|
|
|
|
|
|
"get_version",
|
|
|
|
|
|
"wget --user dvmhuser --password dvmh2013 -P " +
|
2024-10-07 14:22:52 +03:00
|
|
|
|
CommonUtils.DQuotes(Global.TempDirectory.getAbsolutePath()) +
|
2024-05-21 17:36:03 +03:00
|
|
|
|
" http://svn.dvm-system.org/svn/dvmhrepo/sapfor/experts/Sapfor_2017/_src/Utils/version.h"
|
|
|
|
|
|
).waitFor();
|
|
|
|
|
|
if (!versionFile.exists())
|
|
|
|
|
|
throw new RepositoryRefuseException("Не удалось загрузить текущую версию SAPFOR из репозитория!");
|
|
|
|
|
|
return Sapfor.readVersionFromCode(versionFile);
|
|
|
|
|
|
}
|
|
|
|
|
|
void GetSapforForCompilation() throws Exception {
|
|
|
|
|
|
//1. Проверить наличие заказов от пользователя
|
|
|
|
|
|
ServerSapfor serverSapfor = db.getSapforCopyForCompilation();
|
|
|
|
|
|
if (serverSapfor == null) {
|
|
|
|
|
|
//2 если нет. проверить есть ли свежие версии.
|
|
|
|
|
|
int max_version = db.getInstalledSapforMaxVersion();
|
|
|
|
|
|
int current_version = getSapforActualVersion();
|
|
|
|
|
|
if (current_version > max_version) {
|
|
|
|
|
|
serverSapfor = new ServerSapfor();
|
|
|
|
|
|
serverSapfor.sender_name = "server";
|
|
|
|
|
|
serverSapfor.sender_address = Constants.MailAddress;
|
|
|
|
|
|
serverSapfor.state = ServerSapforState.Queued;
|
|
|
|
|
|
db.Insert(serverSapfor);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
|
|
|
|
response.object = serverSapfor;
|
2024-05-16 01:26:03 +03:00
|
|
|
|
}
|
2024-10-03 16:21:11 +03:00
|
|
|
|
SapforPackage tryAutoSapforTesting(TextLog Log) throws Exception {
|
2024-09-24 20:22:41 +03:00
|
|
|
|
//--
|
|
|
|
|
|
Account account = new Account();
|
2024-09-25 01:27:02 +03:00
|
|
|
|
account.name = "server";
|
|
|
|
|
|
account.email = Constants.MailAddress;
|
2024-09-24 20:22:41 +03:00
|
|
|
|
//-
|
|
|
|
|
|
int sapforId = Integer.parseInt(request.arg);
|
2024-10-01 17:33:08 +03:00
|
|
|
|
System.out.println("Sapfor_id = "+request.arg);
|
|
|
|
|
|
|
2024-09-25 01:27:02 +03:00
|
|
|
|
if (!db.serverSapfors.containsKey(sapforId)) {
|
|
|
|
|
|
Log.Writeln_("Версия SAPFOR " + sapforId + " не существует.");
|
2024-10-03 16:21:11 +03:00
|
|
|
|
return null;
|
2024-09-24 20:22:41 +03:00
|
|
|
|
}
|
|
|
|
|
|
ServerSapfor sapfor = db.serverSapfors.get(sapforId);
|
2024-09-25 01:27:02 +03:00
|
|
|
|
if (!sapfor.state.equals(ServerSapforState.Done)) {
|
|
|
|
|
|
Log.Writeln_("Выбранная версия SAPFOR " + sapforId + " не собрана!");
|
2024-10-03 16:21:11 +03:00
|
|
|
|
return null;
|
2024-09-24 20:22:41 +03:00
|
|
|
|
}
|
2024-09-25 01:27:02 +03:00
|
|
|
|
Vector<SapforConfiguration> configurations = db.sapforConfigurations.getAutoConfigurations();
|
|
|
|
|
|
if (configurations.isEmpty()) {
|
|
|
|
|
|
Log.Writeln_("Не найдено конфигураций для автоматического тестирования!");
|
2024-10-03 16:21:11 +03:00
|
|
|
|
return null;
|
2024-09-24 20:22:41 +03:00
|
|
|
|
}
|
|
|
|
|
|
SapforPackage target = new SapforPackage(account,
|
|
|
|
|
|
sapfor,
|
|
|
|
|
|
configurations,
|
|
|
|
|
|
1,
|
|
|
|
|
|
Log);
|
|
|
|
|
|
//-
|
2024-09-25 01:27:02 +03:00
|
|
|
|
if (target.tasksCount == 0) {
|
|
|
|
|
|
Log.Writeln_("Не сформировано ни одной новой задачи.");
|
2024-10-03 16:21:11 +03:00
|
|
|
|
return null;
|
2024-09-25 01:27:02 +03:00
|
|
|
|
}
|
2024-09-24 20:22:41 +03:00
|
|
|
|
beforePublishAction(target);
|
|
|
|
|
|
db.InsertS(target);
|
|
|
|
|
|
afterPublishAction(target);
|
|
|
|
|
|
//--
|
2024-10-03 16:21:11 +03:00
|
|
|
|
return target;
|
2024-09-24 20:22:41 +03:00
|
|
|
|
}
|
2024-09-27 22:50:47 +03:00
|
|
|
|
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
2024-03-02 22:32:42 +03:00
|
|
|
|
|