обновление конфигураций для тестирования сапфора. нужно будет еще проверить и рефакторить.

This commit is contained in:
2024-09-19 17:37:34 +03:00
parent 54d86d6e4d
commit 25cd097445
12 changed files with 379 additions and 203 deletions

View File

@@ -1,92 +0,0 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants;
import Common.Current;
import Common.Database.Database;
import Common.Global;
import GlobalData.Compiler.CompilerType;
import GlobalData.Machine.MachineType;
import GlobalData.User.UserState;
import TestingSystem.Common.TasksPackageState;
import TestingSystem.Common.TestingServer;
import TestingSystem.DVM.DVMPackage.DVMPackage;
import TestingSystem.DVM.DVMPackage.DVMPackage_json;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Server.PublishServerObject;
public class AddDVMPackage extends PublishServerObject<TestingServer, DVMPackage> {
public AddDVMPackage() {
super(Global.testingServer, DVMPackage.class);
}
@Override
public String getIconPath() {
return "/icons/CreateProject.png";
}
@Override
protected Database getDb() {
return Global.testingServer.db;
}
@Override
protected boolean canStart(Object... args) throws Exception {
if (!Current.getAccount().CheckRegistered(Log)) {
return false;
}
if (Current.Check(Log, Current.Machine, Current.User, Current.Compiler)) {
if (!Current.getMachine().type.equals(MachineType.Server)) {
Log.Writeln_("Тестирование поддерживается только на одиночном удалённом сервере.");
return false;
}
if (!Current.getUser().state.equals(UserState.ready_to_work)) {
Log.Writeln_("Пользователь не готов к работе. Выполните инициализацию пользователя!");
return false;
}
if (!Current.getCompiler().type.equals(CompilerType.dvm)) {
Log.Writeln_("Тестирование поддерживается только для DVM компиляторов.");
return false;
}
if (!Current.getCompiler().versionLoaded)
passes.get(PassCode_2021.ShowCompilerVersion).Do(Current.getCompiler(), false);
//-
/*
for (DVMPackage dvmPackage: Global.testingServer.db.dvmPackages.Data.values()){
if (dvmPackage.state.equals(TasksPackageState.Draft)){
Log.Writeln_("Может существовать только один пакет, готовящийся к публикации.");
return false;
}
}
*/
//--
target = new DVMPackage();
target.id = Constants.Nan;
//-
target.sender_name = Current.getAccount().name;
target.sender_address = Current.getAccount().email;
//-
target.machine_name = Current.getMachine().name;
target.machine_address = Current.getMachine().address;
target.machine_port = Current.getMachine().port;
//-
target.user_name = Current.getUser().login;
target.user_password = Current.getUser().password;
target.user_workspace = Current.getUser().workspace;
target.drv = Current.getCompiler().call_command;
target.version = Current.getCompiler().getVersionInfo();
target.kernels = Global.properties.TestingKernels;
target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
//--
target.package_json = new DVMPackage_json();
target.state = TasksPackageState.Inactive;
return true;
}
return false;
}
/*
@Override
protected void body() throws Exception {
Global.testingServer.db.dvmPackages.Data.put(target.id, target);
}
*/
@Override
protected void showDone() throws Exception {
super.showDone();
Global.testingServer.db.dvmRunTasks.ShowDVMPackage(target);
}
}

View File

@@ -260,8 +260,6 @@ public class AddTasksToSapforPackage extends Pass_2021<SapforPackage> {
target.package_json.tasks.add(task);
}
target.tasksCount += new_tasks.size();
target.testsNames = String.join(";", target.package_json.getTestsNames());
target.configurationsNames = String.join(";", target.package_json.getConfigurationsNames());
}
@Override
protected void showDone() throws Exception {

View File

@@ -165,8 +165,10 @@ public class CloneSapforPackage extends AddObjectPass<SapforPackage> {
task.id = target.package_json.getMaxTaskId();
}
target.tasksCount = target.package_json.tasks.size();
/*
target.testsNames = String.join(";", target.package_json.getTestsNames());
target.configurationsNames = String.join(";", target.package_json.getConfigurationsNames());
*/
//--
return inexistingTests.isEmpty() && inexistingConfigurations.isEmpty() ||
UI.Question(

View File

@@ -30,7 +30,6 @@ public class StartSelectedDVMConfigurations extends PublishServerObject<TestingS
public StartSelectedDVMConfigurations() {
super(Global.testingServer, DVMPackage.class);
}
//пока пусть будет одна конфигурация и один пакет.
@Override
public String getIconPath() {
return "/icons/Start.png";
@@ -110,71 +109,68 @@ public class StartSelectedDVMConfigurations extends PublishServerObject<TestingS
tests = new Vector<>();
testByGroups = new LinkedHashMap<>();
tasks = new Vector<>();
tasks_count=0;
tasks_count = 0;
//---
if (!Current.getAccount().CheckRegistered(Log)) {
return false;
}
if (configurations.isEmpty()){
if (configurations.isEmpty()) {
Log.Writeln_("Не отмечено ни одной конфигурации, или отсутствует текущая конфигурация.");
return false;
}
if (Current.Check(Log, Current.Machine, Current.User, Current.Compiler)) {
if (!Current.getMachine().type.equals(MachineType.Server)) {
Log.Writeln_("Тестирование поддерживается только на одиночном удалённом сервере.");
return false;
if (!Current.Check(Log, Current.Machine, Current.User, Current.Compiler))
return false;
if (!Current.getMachine().type.equals(MachineType.Server)) {
Log.Writeln_("Тестирование поддерживается только на одиночном удалённом сервере.");
return false;
}
if (!Current.getUser().state.equals(UserState.ready_to_work)) {
Log.Writeln_("Пользователь не готов к работе. Выполните инициализацию пользователя!");
return false;
}
if (!Current.getCompiler().type.equals(CompilerType.dvm)) {
Log.Writeln_("Тестирование поддерживается только для DVM компиляторов.");
return false;
}
if (!Current.getCompiler().versionLoaded)
passes.get(PassCode_2021.ShowCompilerVersion).Do(Current.getCompiler(), false);
//--
target = new DVMPackage(
Current.getAccount(),
Current.getMachine(),
Current.getUser(),
Current.getCompiler()
);
//----
for (DVMConfiguration configuration : configurations) {
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(configuration);
groups = cache.getGroups();
tests = cache.getTests();
//-
for (Group group : groups) {
Vector<Test> groupTests = new Vector<>();
for (Test test : tests) {
if (test.group_id == group.id)
groupTests.add(test);
}
testByGroups.put(group.id, groupTests);
}
if (!Current.getUser().state.equals(UserState.ready_to_work)) {
Log.Writeln_("Пользователь не готов к работе. Выполните инициализацию пользователя!");
return false;
}
if (!Current.getCompiler().type.equals(CompilerType.dvm)) {
Log.Writeln_("Тестирование поддерживается только для DVM компиляторов.");
return false;
}
if (!Current.getCompiler().versionLoaded)
passes.get(PassCode_2021.ShowCompilerVersion).Do(Current.getCompiler(), false);
//--
target = new DVMPackage(
Current.getAccount(),
Current.getMachine(),
Current.getUser(),
Current.getCompiler()
);
//----
for (DVMConfiguration configuration: configurations) {
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(configuration);
groups = cache.getGroups();
tests = cache.getTests();
//-
for (Group group: groups){
Vector<Test> groupTests = new Vector<>();
for (Test test: tests){
if (test.group_id==group.id)
groupTests.add(test);
}
testByGroups.put(group.id, groupTests);
}
//--
for (Group group : groups) {
Vector<Test> groupTests = testByGroups.get(group.id);
for (Test test : groupTests)
tasks.addAll(createTasksCGT(configuration, group, test));
}
for (Group group : groups) {
Vector<Test> groupTests = testByGroups.get(group.id);
for (Test test : groupTests)
tasks.addAll(createTasksCGT(configuration, group, test));
}
if (tasks_count==0){
Log.Writeln_("Задач не найдено.");
return false;
}
return UI.Question("Будет запущено " + tasks_count + " задач. Продолжить");
}
if (tasks_count == 0) {
Log.Writeln_("Задач не найдено.");
return false;
}
if (UI.Question("Будет запущено " + tasks_count + " задач. Продолжить")){
target.saveConfigurationsAsJson(configurations);
target.saveTasks(tasks, tasks_count);
return true;
}
return false;
}
@Override
protected void ServerAction() throws Exception {
//занесение информации об участвующих конфигурациях
target.saveConfigurationsAsJson(configurations);
target.saveTasks(tasks, tasks_count);
super.ServerAction();
}
}

View File

@@ -0,0 +1,265 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.UI.VisualCache.ConfigurationCache;
import Common.UI.VisualCache.VisualCaches;
import Common.Utils.Index;
import ProjectData.LanguageName;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.TestingServer;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.Json.SapforTest_json;
import TestingSystem.SAPFOR.Json.SapforTestingSet_json;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Server.PublishServerObject;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.Vector;
public class StartSelectedSAPFORConfigurations extends PublishServerObject<TestingServer, SapforPackage> {
Vector<SapforConfiguration> configurations;
Vector<Group> groups;
Vector<Test> tests;
SapforTestingSet_json testingSet; //то, что добавляем.
//--
protected LinkedHashMap<String, Test> testsByDescriptions = null;
protected Vector<String> testsNames_lower = null; //все тесты что участвуют здесь
protected Vector<LanguageName> groupsLanguages = null;
protected File sapfor = null;
//--
protected Vector<SapforTask> new_tasks = null;
@Override
public String getIconPath() {
return "/icons/Start.png";
}
//--
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;
}
boolean checkStartingCode(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.firstElement().equals(code)) {
Log.Writeln_("Неверная конфигурация:" + sapforConfiguration.id + ": " +
code.getDescription() +
" может быть только первой командой!");
return false;
}
}
return true;
}
//--
//--
public boolean checkConfigurationCommands(SapforConfiguration sapforConfiguration) {
//1. получить список всех команд.
Vector<PassCode_2021> codes = new Vector<>();
//-- счетчик завершающих команд.
LinkedHashMap<PassCode_2021, Index> terminalCodesCount = new LinkedHashMap<>();
for (PassCode_2021 code : Constants.terminalSapforTestingCodes)
terminalCodesCount.put(code, new Index());
//--
LinkedHashMap<PassCode_2021, Index> startingCodesCount = new LinkedHashMap<>();
for (PassCode_2021 code : Constants.startingSapforTestingCodes)
startingCodesCount.put(code, new Index());
//--
for (SapforConfigurationCommand command : Global.testingServer.db.sapforConfigurationCommands.Data.values()) {
if (command.sapforconfiguration_id == sapforConfiguration.id) {
codes.add(command.passCode);
//---
for (PassCode_2021 t_code : Constants.terminalSapforTestingCodes) {
if (command.passCode.equals(t_code))
terminalCodesCount.get(t_code).Inc();
}
//---
for (PassCode_2021 s_code : Constants.startingSapforTestingCodes) {
if (command.passCode.equals(s_code))
startingCodesCount.get(s_code).Inc();
}
}
}
//--
if (codes.size() == 0) {
Log.Writeln_("Пустая конфигурация:" + sapforConfiguration.id);
return false;
}
for (PassCode_2021 t_code : Constants.terminalSapforTestingCodes) {
if (!checkTerminalCode(sapforConfiguration, t_code,
terminalCodesCount.get(t_code).getValue(), codes
))
return false;
}
//-
for (PassCode_2021 s_code : Constants.startingSapforTestingCodes) {
if (!checkStartingCode(sapforConfiguration, s_code,
startingCodesCount.get(s_code).getValue(), codes
))
return false;
}
//--
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 checkTestsDescriptions(int groupId, Vector<Test> groupTests) {
if (groupTests.isEmpty()) {
Log.Writeln_("Пустая группа тестов: " + groupId);
return false;
}
for (Test test : groupTests) {
if (!checkTestName(test))
return false;
else
testsByDescriptions.put(test.description, test);
}
return true;
}
//--
public StartSelectedSAPFORConfigurations() {
super(Global.testingServer, SapforPackage.class);
}
@Override
protected boolean canStart(Object... args) throws Exception {
//--
groups = new Vector<>();
tests = new Vector<>();
//--
testsNames_lower = new Vector<>();
testsByDescriptions = new LinkedHashMap<>();
groupsLanguages = new Vector<>();
//--
new_tasks= new Vector<>();
//--
if (!Current.getAccount().CheckRegistered(Log)) {
return false;
}
if (!Current.Check(Log, Current.ServerSapfor)) {
return false;
}
if (!Current.getServerSapfor().state.equals(ServerSapforState.Done)) {
Log.Writeln_("Выбранная версия SAPFOR не собрана!");
return false;
}
//--
configurations = Global.testingServer.db.sapforConfigurations.getCheckedOrCurrent();
if (configurations.isEmpty()) {
Log.Writeln_("Не отмечено ни одной конфигурации, или отсутствует текущая конфигурация.");
return false;
}
for (SapforConfiguration configuration : configurations) {
if (!checkConfigurationCommands(configuration))
return false;
//-
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(configuration);
//--
groups = cache.getGroups();
tests = cache.getTests();
//--
for (Group group : groups) {
//-
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;
}
//---
Vector<Test> groupTests = new Vector<>();
for (Test test : tests) {
if (test.group_id == group.id)
groupTests.add(test);
}
//---
if (!checkTestsDescriptions(group.id,groupTests))
return false;
//-
}
}
target = new SapforPackage(Current.getAccount(), Current.getServerSapfor());
//--
testingSet = new SapforTestingSet_json();
testingSet.id = target.package_json.getMaxSetId();
for (Test test : testsByDescriptions.values()) {
SapforTest_json test_json = new SapforTest_json();
test_json.id = test.id;
test_json.description = test.description;
test_json.group_description = Global.testingServer.db.groups.get(test.group_id).description;
testingSet.tests.add(test_json);
}
for (SapforConfiguration configuration : configurations) {
//--
SapforConfiguration_json configuration_json = new SapforConfiguration_json();
configuration_json.id = configuration.id;
configuration_json.name = configuration.description;
configuration_json.flags = configuration.getFlags();
Vector<PassCode_2021> codes = configuration.getPassCodes();
//--- коррекцию кода нельзя вызвать если инклуды есть. в общем случае.
if (!codes.firstElement().equals(PassCode_2021.SPF_InsertIncludesPass))
configuration_json.codes.add(PassCode_2021.SPF_CorrectCodeStylePass); //всегда добавляется.
//--
configuration_json.codes.addAll(codes);
//--->>
testingSet.configurations.add(configuration_json);
//-->>
}
new_tasks = target.getActualTestingSetTasks(testingSet);
if (new_tasks.size() == 0) {
Log.Writeln_("Не сформировано ни одной новой задачи.\n" +
"Задачи уже присутствуют в пакете, или не отмечено ни одного теста.");
return false;
}
if (UI.Question("Будет добавлено " + new_tasks.size() + " задач. Продолжить")){
target.saveConfigurationsAsJson(configurations);
target.package_json.testingSets.add(testingSet);
for (SapforTask task : new_tasks) {
task.id = target.package_json.getMaxTaskId();
target.package_json.tasks.add(task);
}
target.tasksCount += new_tasks.size();
return true;
}
//
return false;
}
}

View File

@@ -298,7 +298,6 @@ public enum PassCode_2021 {
ActualizeSapforPackages,
ActualizePackages,
//->
AddDVMPackage,
DeleteDVMPackage,
AbortDVMPackage,
//->
@@ -346,13 +345,16 @@ public enum PassCode_2021 {
StartSelectedDVMConfigurations,
//--
ShowCurrentSAPFORConfigurationTests,
SaveCurrentSAPFORConfiguration
SaveCurrentSAPFORConfiguration,
StartSelectedSAPFORConfigurations,
;
//--
public String getDescription() {
switch (this) {
case Undefined:
return "?";
case StartSelectedSAPFORConfigurations:
return "Запустить отмеченные конфигурации тестирования системы SAPFOR";
case SaveCurrentSAPFORConfiguration:
return "Сохранить тесты текущей конфигурации системы SAPFOR";
case ShowCurrentSAPFORConfigurationTests:
@@ -436,8 +438,6 @@ public enum PassCode_2021 {
return "Удалить пакет задач DVM";
case DownloadDVMPackage:
return "Скачать пакет задач DVM";
case AddDVMPackage:
return "Создать пустой пакет";
case ActualizePackages:
return "Обновить пакеты задач";
case ActualizeDVMPackages: