2023-10-04 00:25:36 +03:00
|
|
|
|
package Visual_DVM_2021.Passes.All;
|
2023-10-17 17:33:34 +03:00
|
|
|
|
import Common.Constants;
|
2023-10-04 00:25:36 +03:00
|
|
|
|
import Common.Current;
|
|
|
|
|
|
import Common.Global;
|
|
|
|
|
|
import Common.UI.UI;
|
2023-10-17 17:33:34 +03:00
|
|
|
|
import Common.Utils.Index;
|
2023-10-04 00:25:36 +03:00
|
|
|
|
import ProjectData.LanguageName;
|
|
|
|
|
|
import Repository.Server.ServerCode;
|
|
|
|
|
|
import Repository.Server.ServerExchangeUnit_2021;
|
|
|
|
|
|
import SapforTestingSystem.SapforConfiguration.SapforConfiguration;
|
|
|
|
|
|
import SapforTestingSystem.SapforConfigurationCommand.SapforConfigurationCommand;
|
2023-10-15 20:20:07 +03:00
|
|
|
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
2023-10-04 00:25:36 +03:00
|
|
|
|
import TestingSystem.Group.Group;
|
2023-10-15 20:20:07 +03:00
|
|
|
|
import TestingSystem.TasksPackage.TasksPackageState;
|
2023-10-04 00:25:36 +03:00
|
|
|
|
import TestingSystem.Test.Test;
|
2023-10-12 21:48:22 +03:00
|
|
|
|
import TestingSystem.TestingServer;
|
2023-10-04 00:25:36 +03:00
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.TestingSystemPass;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
2023-10-15 20:20:07 +03:00
|
|
|
|
import java.util.Date;
|
2023-10-04 00:25:36 +03:00
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
|
import java.util.Vector;
|
2023-10-15 20:20:07 +03:00
|
|
|
|
public class StartSapforTests extends TestingSystemPass<SapforTasksPackage> {
|
2023-10-04 00:25:36 +03:00
|
|
|
|
protected int allTasksCount = 0;
|
|
|
|
|
|
//--
|
|
|
|
|
|
protected LinkedHashMap<String, Vector<String>> groupsTests = null;
|
|
|
|
|
|
//--
|
|
|
|
|
|
protected LinkedHashMap<String, Test> allTests = null;
|
|
|
|
|
|
protected Vector<String> testsNames_lower = null; //все тесты что участвуют здесь
|
|
|
|
|
|
protected Vector<LanguageName> groupsLanguages = null;
|
|
|
|
|
|
protected File sapfor = null;
|
|
|
|
|
|
//---
|
|
|
|
|
|
//---
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
|
return "/icons/Start.png";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getButtonText() {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean needsAnimation() {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
protected boolean checkTestName(Test test) {
|
|
|
|
|
|
String name = test.description.toLowerCase();
|
|
|
|
|
|
if (testsNames_lower.contains(name)) {
|
|
|
|
|
|
Log.Writeln_("В пакет не могут входить тесты с одинаковыми именами (без учета регистра):" + test.description.toLowerCase());
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
testsNames_lower.add(name);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
protected boolean getGroupTests(String groupId) {
|
|
|
|
|
|
Vector<String> groupTests = new Vector<>();
|
|
|
|
|
|
Vector<String> selectedGroupTests = new Vector<>();
|
|
|
|
|
|
//---
|
|
|
|
|
|
for (Test test : Global.testingServer.db.tests.Data.values()) {
|
|
|
|
|
|
if (test.group_id.equals(groupId)) {
|
|
|
|
|
|
groupTests.add(test.id);
|
|
|
|
|
|
if (test.isSelected())
|
|
|
|
|
|
selectedGroupTests.add(test.id);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!groupTests.isEmpty() && !selectedGroupTests.isEmpty())
|
|
|
|
|
|
groupTests = selectedGroupTests;
|
|
|
|
|
|
//---
|
|
|
|
|
|
if (groupTests.isEmpty()) {
|
|
|
|
|
|
Log.Writeln_("Пустая группа тестов: " + groupId);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
for (String testId : groupTests) {
|
|
|
|
|
|
Test test = Global.testingServer.db.tests.get(testId);
|
|
|
|
|
|
if (!checkTestName(test))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
else
|
|
|
|
|
|
allTests.put(test.description, test);
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
groupsTests.put(groupId, groupTests);
|
|
|
|
|
|
//--
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2023-10-17 17:33:34 +03:00
|
|
|
|
boolean checkTerminalCode(SapforConfiguration sapforConfiguration, PassCode_2021 code, int count, Vector<PassCode_2021> codes) {
|
|
|
|
|
|
if (count > 2) {
|
|
|
|
|
|
Log.Writeln_("Неверная конфигурация:" + sapforConfiguration.id + ": " +
|
|
|
|
|
|
code.getDescription() +
|
|
|
|
|
|
" возможно только один раз.");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
if ((count == 1) && codes.size() > 1) {
|
|
|
|
|
|
if (!codes.lastElement().equals(code)) {
|
|
|
|
|
|
Log.Writeln_("Неверная конфигурация:" + sapforConfiguration.id + ": " +
|
|
|
|
|
|
code.getDescription() +
|
|
|
|
|
|
" может быть только завершающей командой!");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2023-10-04 00:25:36 +03:00
|
|
|
|
public boolean getConfigurationCommands(SapforConfiguration sapforConfiguration) {
|
|
|
|
|
|
//1. получить список всех команд.
|
|
|
|
|
|
Vector<PassCode_2021> codes = new Vector<>();
|
2023-10-17 17:33:34 +03:00
|
|
|
|
//-- счетчик завершающих команд.
|
|
|
|
|
|
LinkedHashMap<PassCode_2021, Index> terminalCodesCount = new LinkedHashMap<>();
|
|
|
|
|
|
for (PassCode_2021 code : Constants.terminalSapforTestingCodes)
|
|
|
|
|
|
terminalCodesCount.put(code, new Index());
|
|
|
|
|
|
//--
|
2023-10-04 00:25:36 +03:00
|
|
|
|
for (SapforConfigurationCommand command : Global.testingServer.db.sapforConfigurationCommands.Data.values()) {
|
|
|
|
|
|
if (command.sapforconfiguration_id.equals(sapforConfiguration.id)) {
|
|
|
|
|
|
codes.add(command.passCode);
|
2023-10-17 17:33:34 +03:00
|
|
|
|
//---
|
|
|
|
|
|
for (PassCode_2021 t_code : Constants.terminalSapforTestingCodes) {
|
|
|
|
|
|
if (command.passCode.equals(t_code))
|
|
|
|
|
|
terminalCodesCount.get(t_code).Inc();
|
|
|
|
|
|
}
|
|
|
|
|
|
//---
|
2023-10-04 00:25:36 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
if (codes.size() == 0) {
|
|
|
|
|
|
Log.Writeln_("Пустая конфигурация:" + sapforConfiguration.id);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2023-10-17 17:33:34 +03:00
|
|
|
|
for (PassCode_2021 t_code : Constants.terminalSapforTestingCodes) {
|
|
|
|
|
|
if (!checkTerminalCode(sapforConfiguration, t_code,
|
|
|
|
|
|
terminalCodesCount.get(t_code).getValue(), codes
|
|
|
|
|
|
))
|
2023-10-04 00:25:36 +03:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2023-10-17 17:33:34 +03:00
|
|
|
|
//--
|
2023-10-04 00:25:36 +03:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
|
//--
|
|
|
|
|
|
allTasksCount = 0;
|
|
|
|
|
|
target = null;
|
|
|
|
|
|
//--
|
|
|
|
|
|
groupsTests = new LinkedHashMap<>();
|
|
|
|
|
|
//--->>
|
|
|
|
|
|
testsNames_lower = new Vector<>();
|
|
|
|
|
|
allTests = new LinkedHashMap<>();
|
|
|
|
|
|
groupsLanguages = new Vector<>();
|
2023-10-08 23:07:41 +03:00
|
|
|
|
//-->>
|
|
|
|
|
|
if (!Current.getAccount().CheckRegistered(Log)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2023-10-04 00:25:36 +03:00
|
|
|
|
//проверка стартовых условий.
|
|
|
|
|
|
if (!Current.Check(Log, Current.ServerSapfor))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
//--->>
|
|
|
|
|
|
if (Global.testingServer.db.sapforConfigurations.getCheckedCount() == 0) {
|
|
|
|
|
|
Log.Writeln_("Не отмечено ни одной конфигурации SAPFOR.");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//-
|
|
|
|
|
|
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems()) {
|
|
|
|
|
|
if (!getConfigurationCommands(configuration))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
if (Global.testingServer.db.groups.getCheckedCount() == 0) {
|
|
|
|
|
|
Log.Writeln_("Не отмечено ни одной группы тестов");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
for (Group group : Global.testingServer.db.groups.getCheckedItems()) {
|
|
|
|
|
|
//---
|
|
|
|
|
|
if (!groupsLanguages.contains(group.language))
|
|
|
|
|
|
groupsLanguages.add(group.language);
|
|
|
|
|
|
//-
|
|
|
|
|
|
if (groupsLanguages.get(0) != LanguageName.fortran) {
|
|
|
|
|
|
Log.Writeln_("Поддерживается пакетный режим только для языка Fortran!");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (groupsLanguages.size() > 1) {
|
|
|
|
|
|
Log.Writeln_("Запуск тестов на разных языках в рамках одного пакета запрещен!");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//---
|
|
|
|
|
|
if (!getGroupTests(group.id))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
for (int i = 0; i < Global.testingServer.db.sapforConfigurations.getCheckedCount(); ++i) {
|
|
|
|
|
|
for (Vector<String> tests : groupsTests.values())
|
|
|
|
|
|
allTasksCount += tests.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
return (UI.Question("Будет запущено:\n"
|
|
|
|
|
|
+ allTasksCount + " задач\n" +
|
|
|
|
|
|
"Продолжить"));
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void ServerAction() throws Exception {
|
2023-10-15 20:20:07 +03:00
|
|
|
|
target = new SapforTasksPackage();
|
|
|
|
|
|
target.genName();
|
|
|
|
|
|
//--
|
|
|
|
|
|
Vector<String> testsIds = new Vector<>();
|
|
|
|
|
|
Vector<String> configurationsIds = new Vector<>();
|
2023-10-04 00:25:36 +03:00
|
|
|
|
for (Test test : allTests.values())
|
2023-10-15 20:20:07 +03:00
|
|
|
|
testsIds.add(test.id);
|
2023-10-04 00:25:36 +03:00
|
|
|
|
//--
|
|
|
|
|
|
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems())
|
2023-10-15 20:20:07 +03:00
|
|
|
|
configurationsIds.add(configuration.id);
|
|
|
|
|
|
//--
|
2023-10-15 22:06:34 +03:00
|
|
|
|
target.tasksCount = allTasksCount;
|
2023-10-15 20:20:07 +03:00
|
|
|
|
target.testsIds = String.join("\n", testsIds);
|
|
|
|
|
|
target.configurationsIds = String.join("\n", configurationsIds);
|
|
|
|
|
|
//--
|
|
|
|
|
|
target.sapforId = Current.getServerSapfor().id;
|
|
|
|
|
|
target.sapfor_drv = Current.getServerSapfor().call_command;
|
|
|
|
|
|
target.sapfor_version = Current.getServerSapfor().version;
|
|
|
|
|
|
target.sapfor_build_date = Current.getServerSapfor().buildDate;
|
|
|
|
|
|
//--
|
|
|
|
|
|
target.testsNames = String.join(";", testsNames_lower);
|
|
|
|
|
|
target.StartDate = new Date().getTime();
|
|
|
|
|
|
target.kernels = TestingServer.kernels;
|
|
|
|
|
|
target.state = TasksPackageState.Queued;
|
2023-10-17 22:53:38 +03:00
|
|
|
|
target.needsEmail = TestingServer.email ? 1 : 0;
|
2023-10-15 20:20:07 +03:00
|
|
|
|
//---
|
|
|
|
|
|
Vector<SapforTasksPackage> packages = new Vector<>();
|
|
|
|
|
|
packages.add(target);
|
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.PublishAccountObjects, Current.getAccount().email, packages));
|
2023-10-04 00:25:36 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-10-10 16:53:29 +03:00
|
|
|
|
protected void performDone() throws Exception {
|
|
|
|
|
|
passes.get(PassCode_2021.SynchronizeTestsTasks).Do();
|
2023-10-17 01:38:47 +03:00
|
|
|
|
/*
|
2023-10-10 16:53:29 +03:00
|
|
|
|
if (!TestingServer.checkTasks)
|
|
|
|
|
|
TestingServer.TimerOn();
|
2023-10-17 01:38:47 +03:00
|
|
|
|
*/
|
2023-10-04 00:25:36 +03:00
|
|
|
|
}
|
2023-10-15 21:58:23 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
protected void showDone() throws Exception {
|
|
|
|
|
|
server.account_db.sapforTasksPackages.ui_.Select(target.id);
|
2023-10-17 17:33:34 +03:00
|
|
|
|
// UI.getMainWindow().getTestingWindow().ShowAutoActualizeTestsState();
|
2023-10-15 21:58:23 +03:00
|
|
|
|
}
|
2023-10-04 00:25:36 +03:00
|
|
|
|
}
|