постепенный перевод на сервер механизма тестирования.
This commit is contained in:
@@ -7,8 +7,8 @@ import Common.Utils.Utils;
|
||||
import ProjectData.LanguageName;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import SapforTestingSystem.Json.SapforPackage_json;
|
||||
import SapforTestingSystem.Json.SapforScenario_json;
|
||||
import SapforTestingSystem.Json.SapforConfiguration_json;
|
||||
import SapforTestingSystem.Json.PackageModeScenario_json;
|
||||
import SapforTestingSystem.SapforConfiguration.SapforConfiguration;
|
||||
import SapforTestingSystem.SapforConfiguration.SapforConfigurationInterface;
|
||||
import SapforTestingSystem.SapforConfigurationCommand.SapforConfigurationCommand;
|
||||
@@ -233,7 +233,7 @@ public class StartSapforTests extends Pass_2021<SapforScenario> {
|
||||
Utils.jsonToFile(properties, new File(target.workspace, "properties"));
|
||||
//----
|
||||
File scenarioFile = new File(target.workspace, "scenario");
|
||||
SapforScenario_json scenario_json = new SapforScenario_json();
|
||||
PackageModeScenario_json scenario_json = new PackageModeScenario_json();
|
||||
scenario_json.sapfor_drv = sapfor.getName();
|
||||
scenario_json.tests.addAll(allTests.keySet());
|
||||
//----
|
||||
@@ -271,7 +271,7 @@ public class StartSapforTests extends Pass_2021<SapforScenario> {
|
||||
}
|
||||
Global.db.Update(sapforTasksPackage);
|
||||
//--->>
|
||||
SapforPackage_json package_json = new SapforPackage_json();
|
||||
SapforConfiguration_json package_json = new SapforConfiguration_json();
|
||||
package_json.id = String.valueOf(sapforTasksPackage.id);
|
||||
package_json.flags = sapforTasksPackage.flags;
|
||||
package_json.codes.addAll(codes);
|
||||
|
||||
189
src/Visual_DVM_2021/Passes/All/StartSapforTestsOnServer.java
Normal file
189
src/Visual_DVM_2021/Passes/All/StartSapforTestsOnServer.java
Normal file
@@ -0,0 +1,189 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import ProjectData.LanguageName;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import SapforTestingSystem.SapforServerScenario_info;
|
||||
import SapforTestingSystem.SapforConfiguration.SapforConfiguration;
|
||||
import SapforTestingSystem.SapforConfigurationCommand.SapforConfigurationCommand;
|
||||
import TestingSystem.Group.Group;
|
||||
import TestingSystem.Test.Test;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.TestingSystemPass;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class StartSapforTestsOnServer extends TestingSystemPass<SapforServerScenario_info> {
|
||||
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;
|
||||
}
|
||||
public boolean getConfigurationCommands(SapforConfiguration sapforConfiguration) {
|
||||
//1. получить список всех команд.
|
||||
Vector<PassCode_2021> codes = new Vector<>();
|
||||
int v = 0;
|
||||
for (SapforConfigurationCommand command : Global.testingServer.db.sapforConfigurationCommands.Data.values()) {
|
||||
if (command.sapforconfiguration_id.equals(sapforConfiguration.id)) {
|
||||
codes.add(command.passCode);
|
||||
if (command.passCode.equals(PassCode_2021.CreateParallelVariants))
|
||||
v++;
|
||||
}
|
||||
}
|
||||
//--
|
||||
if (codes.size() == 0) {
|
||||
Log.Writeln_("Пустая конфигурация:" + sapforConfiguration.id);
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
if (v > 2) {
|
||||
Log.Writeln_("Неверная конфигурация:" + sapforConfiguration.id + ": построение параллельных вариантов возможно единожды.");
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
if ((v == 1) && codes.size() > 1) {
|
||||
if (!codes.lastElement().equals(PassCode_2021.CreateParallelVariants)) {
|
||||
Log.Writeln_("Неверная конфигурация:" + sapforConfiguration.id + ": построение параллельных вариантов может быть только завершающей командой!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
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<>();
|
||||
//проверка стартовых условий.
|
||||
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 {
|
||||
target = new SapforServerScenario_info();
|
||||
target.sapforId = Current.getServerSapfor().id;
|
||||
for (Test test : allTests.values())
|
||||
target.testsIds.add(test.id);
|
||||
//--
|
||||
ShowMessage1("Создание рабочих пространств...");
|
||||
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems())
|
||||
target.configurationsIds.add(configuration.id);
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.StartSapforTests, "", target));
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
super.performFinish();
|
||||
// passes.get(PassCode_2021.SynchronizeTests).Do();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user