восстановление тестирование сапфор с инкрементными ключами.

This commit is contained in:
2023-11-18 02:25:12 +03:00
parent b708f4d35d
commit f52139a8b5
9 changed files with 140 additions and 127 deletions

8
.idea/workspace.xml generated
View File

@@ -7,7 +7,15 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTasksPackage/SapforPackageData.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/Server/PublishServerAccountObject.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTasksPackage/SapforTasksPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTasksPackage/SapforTasksPackage.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTasksPackage/SapforTasksPackagesDBTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTasksPackage/SapforTasksPackagesDBTable.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTasksPackageSupervisor/SapforTasksPackageSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTasksPackageSupervisor/SapforTasksPackageSupervisor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -79,5 +79,7 @@ public enum ServerCode {
OLD,
//-
PublishAIObject, //публикация объекта с автоинкрементом.
PublishTestProject, //отправка теста на сервер в архиве.
PublishAccountAIObject,
PublishTestProject,
GetActualSapforPackageData
}

View File

@@ -24,6 +24,7 @@ import TestingSystem.DVM.Tasks.TestTask;
import TestingSystem.DVM.TasksPackage.TasksPackage;
import TestingSystem.DVM.UserConnection;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforPackageData;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import Visual_DVM_2021.Passes.All.DownloadRepository;
@@ -35,6 +36,7 @@ import javafx.util.Pair;
import javax.swing.*;
import java.io.File;
import java.io.Serializable;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.LinkedHashMap;
@@ -496,6 +498,54 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
DeleteAction(account_db.DeleteByPK(to_delete.getKey(), to_delete.getValue()));
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case PublishAccountAIObject:
Print("Опубликовать объект с автоинкрементным ключом для пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
dbObject = (DBObject) request.object;
account_db.Insert(dbObject); //проверка не нужна,АИ гарантирует что ключ уникален.
PublishAction(dbObject);
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = (Serializable) dbObject.getPK(); //чтобы пользователь знал, какой ключ.
break;
case GetActualSapforPackageData:
Print("Запросить актуальные данные пакета");
sapforTasksPackage = (SapforTasksPackage) request.object;
SapforPackageData sapforPackageData = new SapforPackageData();
Vector<String> notFoundLines = new Vector<>();
//---
String[] configurations = sapforTasksPackage.configurationsIds.split("\n");
for (String id_s : configurations) {
int id = Integer.parseInt(id_s);
if (db.sapforConfigurations.containsKey(id)) {
sapforPackageData.sapforConfigurations.put(id, db.sapforConfigurations.get(id));
} else {
notFoundLines.add("конфигурация с ключом " + id_s + " не существует");
}
}
//---
String[] tests = sapforTasksPackage.testsIds.split("\n");
for (String id_s : tests) {
int id = Integer.parseInt(id_s);
if (db.tests.containsKey(id)) { //если есть тест есть и группа.
test = db.tests.get(id);
sapforPackageData.tests.put(id, test);
sapforPackageData.groups.put(test.group_id, db.groups.get(test.group_id));
} else {
notFoundLines.add("теста с ключом " + id_s + " не существует");
}
}
//--
if (db.serverSapfors.containsKey(sapforTasksPackage.sapforId)) {
sapforPackageData.sapfor = db.serverSapfors.get(sapforTasksPackage.sapforId);
} else
notFoundLines.add("версии SAPFOR с ключом" + sapforTasksPackage.sapforId + " не существует");
//---
if (!notFoundLines.isEmpty())
sapforPackageData.notFound = String.join("\n", notFoundLines);
//---
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = sapforPackageData;
break;
default:
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
}

View File

@@ -0,0 +1,17 @@
package TestingSystem.SAPFOR.SapforTasksPackage;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import java.io.Serializable;
import java.util.LinkedHashMap;
public class SapforPackageData implements Serializable {
//--->
public LinkedHashMap<Integer, Group> groups =new LinkedHashMap<Integer, Group>();
public LinkedHashMap<Integer, Test> tests = new LinkedHashMap<>();
public LinkedHashMap<Integer, SapforConfiguration> sapforConfigurations = new LinkedHashMap<>();
public ServerSapfor sapfor = null;
//-->>
public String notFound = "";
}

View File

@@ -1,7 +1,7 @@
package TestingSystem.SAPFOR.SapforTasksPackage;
import Common.Constants;
import Common.Database.DBObject;
import Common.Database.iDBObject;
import Common.Database.riDBObject;
import Common.Global;
import Common.Utils.Utils;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
@@ -12,14 +12,12 @@ import com.sun.org.glassfish.gmbal.Description;
import java.io.File;
import java.nio.file.Paths;
import java.util.Comparator;
public class SapforTasksPackage extends iDBObject {
public class SapforTasksPackage extends riDBObject {
@Description("DEFAULT ''")
public String testsNames = "";//имена тестов через ; для отображения
//---
public int sapforId = Constants.Nan;
public String sapfor_version = "?"; //тестируемая версия SAPFOR
public long sapfor_build_date = 0;
public String sapfor_drv = "";
public String sapfor_version = "?"; //тестируемая версия SAPFOR для таблицы
public String sapfor_process_name = "";
//---
public String workspace = ""; //домашняя папка
@@ -80,7 +78,6 @@ public class SapforTasksPackage extends iDBObject {
sapforId = p.sapforId;
testsNames = p.testsNames;
sapfor_version = p.sapfor_version;
sapfor_build_date = p.sapfor_build_date;
workspace = p.workspace;
tasksCount = p.tasksCount;
StartDate = p.StartDate;

View File

@@ -30,7 +30,7 @@ public class SapforTasksPackagesDBTable extends iDBTable<SapforTasksPackage> {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
// columns.get(0).setVisible(false);
columns.get(5).setRenderer(RendererDate);
columns.get(6).setRenderer(RendererDate);
columns.get(7).setRenderer(RendererStatusEnum);

View File

@@ -5,7 +5,6 @@ import Common.Global;
import Common.GlobalProperties;
import Common.Utils.Utils;
import Repository.Server.ServerCode;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.TestingPlanner;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
@@ -15,15 +14,13 @@ import TestingSystem.SAPFOR.Json.SapforTasksResults_json;
import TestingSystem.SAPFOR.Json.SapforTest_json;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforPackageData;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import Visual_DVM_2021.Passes.PassCode_2021;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Vector;
public class SapforTasksPackageSupervisor {
protected TestingPlanner planner; //планировщик.
@@ -33,66 +30,22 @@ public class SapforTasksPackageSupervisor {
sapforTasksPackage = sapforTasksPackage_in;
}
private void TestsSynchronize() throws Exception {
Vector<String> testsIds = new Vector<>(Arrays.asList(sapforTasksPackage.testsIds.split("\n")));
Vector<String> configurationsIds = new Vector<>(Arrays.asList(sapforTasksPackage.configurationsIds.split("\n")));
Vector<Object> tests_ = (Vector<Object>) planner.ServerCommand(ServerCode.GetObjectsCopiesByPK, "", new Pair<>(Test.class, testsIds));
Vector<Object> configurations_ = (Vector<Object>) planner.ServerCommand(ServerCode.GetObjectsCopiesByPK, "", new Pair<>(SapforConfiguration.class, configurationsIds));
LinkedHashMap<Integer, Test> tests = new LinkedHashMap<>();
LinkedHashMap<Integer, SapforConfiguration> configurations = new LinkedHashMap<>();
Vector<Integer> groupsIds = new Vector<>();
LinkedHashMap<Integer, Group> groups = new LinkedHashMap<>();
//--
System.out.println(sapforTasksPackage.id + " — TestsSynchronize");
for (Object o : tests_) {
Test test = (Test) o;
tests.put(test.id, test);
if (!groupsIds.contains(test.group_id))
groupsIds.add(test.group_id);
}
//--
for (Object o : configurations_) {
SapforConfiguration sapforConfiguration = (SapforConfiguration) o;
configurations.put(sapforConfiguration.id, sapforConfiguration);
}
//---
Vector<String> badTests = new Vector<>();
for (String testId : testsIds)
if (!tests.containsKey(Integer.parseInt(testId)))
badTests.add(testId);
//--
Vector<String> badConfigurations = new Vector<>();
for (String configurationId : configurationsIds)
if (!configurations.containsKey(configurationId))
badConfigurations.add(configurationId);
//--
File sapfor_src = new File(sapforTasksPackage.sapfor_drv);
//--
Vector<String> notFound = new Vector<>();
if (!badTests.isEmpty())
notFound.add("Несуществующие тесты: " + String.join("\n", badTests));
if (!badConfigurations.isEmpty())
notFound.add("Несуществующие конфигурации: " + String.join("\n", badConfigurations));
if (!sapfor_src.exists()) {
notFound.add("Несуществующий SAPFOR: " + Utils.Brackets(sapfor_src.getAbsolutePath()));
}
if (!notFound.isEmpty()) {
sapforTasksPackage.summary = String.join("\n", notFound);
System.out.println(sapforTasksPackage.summary);
SapforPackageData data = (SapforPackageData) planner.ServerCommand(ServerCode.GetActualSapforPackageData, sapforTasksPackage);
if (!data.notFound.isEmpty()) {
sapforTasksPackage.summary = data.notFound;
sapforTasksPackage.state = TasksPackageState.Aborted;
return;
}
Vector<Object> groups_ = (Vector<Object>) planner.ServerCommand(ServerCode.GetObjectsCopiesByPK, "", new Pair<>(Group.class, groupsIds));
for (Object o : groups_) {
Group group = (Group) o;
groups.put(group.id, group);
}
//--
System.out.println(sapforTasksPackage.id + " — TestsSynchronize");
File sapfor_src = new File(data.sapfor.call_command);
//--
SapforTasksPackage_json package_json = new SapforTasksPackage_json();
package_json.kernels = sapforTasksPackage.kernels;
for (Test test : tests.values()) {
for (Test test : data.tests.values()) {
SapforTest_json test_json = new SapforTest_json();
test_json.test_description = test.description;
test_json.group_description = groups.get(test.group_id).description;
test_json.group_description = data.groups.get(test.group_id).description;
package_json.tests.add(test_json);
}
//создание рабочего пространства для пакетного режима
@@ -101,21 +54,20 @@ public class SapforTasksPackageSupervisor {
sapforTasksPackage.workspace = packageWorkspace.getAbsolutePath();
//копирование тестов по конфигурациям.
int actual_tasks_count = 0;
for (String configuration_id : configurationsIds) {
SapforConfiguration configuration = configurations.get(configuration_id);
for (SapforConfiguration configuration: data.sapforConfigurations.values()){
//--
SapforConfiguration_json configuration_json = new SapforConfiguration_json();
configuration_json.id = Integer.parseInt(configuration_id);
configuration_json.id = configuration.id;
configuration_json.flags = configuration.getFlags();
configuration_json.codes.add(PassCode_2021.SPF_CorrectCodeStylePass); //всегда добавляется.
configuration_json.codes.addAll(configuration.getPassCodes());
//--->>
package_json.configurations.add(configuration_json);
//-->>
File configurationWorkspace = new File(packageWorkspace, configuration_id);
File configurationWorkspace = new File(packageWorkspace, String.valueOf(configuration.id));
FileUtils.forceMkdir(configurationWorkspace);
//--->>>
for (Test test : tests.values()) {
for (Test test : data.tests.values()) {
File test_root = new File(configurationWorkspace, test.description);
Utils.CheckAndCleanDirectory(test_root);
FileUtils.copyDirectory(new File(Global.TestsDirectory, String.valueOf(test.id)), test_root);

View File

@@ -5,44 +5,37 @@ import Common.Global;
import Common.UI.UI;
import Common.Utils.Index;
import ProjectData.LanguageName;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.Common.Group.Group;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import TestingSystem.Common.Test.Test;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
import Visual_DVM_2021.Passes.Server.PublishServerAccountObject;
import java.io.File;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Vector;
public class StartSapforTests extends TestingSystemPass<SapforTasksPackage> {
public class StartSapforTests extends PublishServerAccountObject<SapforTasksPackage> {
protected int allTasksCount = 0;
//--
protected LinkedHashMap<Integer, Vector<Integer>> groupsTests = null;
//--
protected LinkedHashMap<String, Test> allTests = null;
protected LinkedHashMap<String, Test> testsByDescriptions = null;
protected Vector<String> testsNames_lower = null; //все тесты что участвуют здесь
protected Vector<LanguageName> groupsLanguages = null;
protected Vector<String> testsIds = null;
protected Vector<String> configurationsIds = null;
protected File sapfor = null;
//---
//--
public StartSapforTests() {
super(SapforTasksPackage.class);
}
//---
@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();
@@ -57,7 +50,7 @@ public class StartSapforTests extends TestingSystemPass<SapforTasksPackage> {
Vector<Integer> groupTests = new Vector<>();
Vector<Integer> selectedGroupTests = new Vector<>();
//---
for (Test test : Global.testingServer.db.tests.Data.values()) {
for (Test test : server.db.tests.Data.values()) {
if (test.group_id==groupId) {
groupTests.add(test.id);
if (test.isSelected())
@@ -77,7 +70,7 @@ public class StartSapforTests extends TestingSystemPass<SapforTasksPackage> {
if (!checkTestName(test))
return false;
else
allTests.put(test.description, test);
testsByDescriptions.put(test.description, test);
}
//--
groupsTests.put(groupId, groupTests);
@@ -137,16 +130,15 @@ public class StartSapforTests extends TestingSystemPass<SapforTasksPackage> {
}
//--
@Override
protected boolean canStart(Object... args) throws Exception {
public boolean fillObjectFields() throws Exception {
//--
allTasksCount = 0;
target = null;
//--
groupsTests = new LinkedHashMap<>();
//--->>
testsNames_lower = new Vector<>();
allTests = new LinkedHashMap<>();
testsByDescriptions = new LinkedHashMap<>();
groupsLanguages = new Vector<>();
testsIds =new Vector<>();
configurationsIds = new Vector<>();
//-->>
if (!Current.getAccount().CheckRegistered(Log)) {
return false;
@@ -193,19 +185,7 @@ public class StartSapforTests extends TestingSystemPass<SapforTasksPackage> {
allTasksCount += tests.size();
}
//--
return (UI.Question("Будет запущено:\n"
+ allTasksCount + " задач\n" +
"Продолжить"));
}
//--
@Override
protected void ServerAction() throws Exception {
target = new SapforTasksPackage();
//target.genName();
//--
Vector<String> testsIds = new Vector<>();
Vector<String> configurationsIds = new Vector<>();
for (Test test : allTests.values())
for (Test test : testsByDescriptions.values())
testsIds.add(String.valueOf(test.id));
//--
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems())
@@ -216,9 +196,7 @@ public class StartSapforTests extends TestingSystemPass<SapforTasksPackage> {
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();
@@ -226,21 +204,9 @@ public class StartSapforTests extends TestingSystemPass<SapforTasksPackage> {
target.state = TasksPackageState.Queued;
target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
//---
Vector<SapforTasksPackage> packages = new Vector<>();
packages.add(target);
Command(new ServerExchangeUnit_2021(ServerCode.PublishAccountObjects, Current.getAccount().email, packages));
}
@Override
protected void performDone() throws Exception {
passes.get(PassCode_2021.SynchronizeTestsTasks).Do();
/*
if (!TestingServer.checkTasks)
TestingServer.TimerOn();
*/
}
@Override
protected void showDone() throws Exception {
server.account_db.sapforTasksPackages.ui_.Select(target.id);
// UI.getMainWindow().getTestingWindow().ShowAutoActualizeTestsState();
//--
return (UI.Question("Будет запущено:\n"
+ allTasksCount + " задач\n" +
"Продолжить"));
}
}

View File

@@ -0,0 +1,21 @@
package Visual_DVM_2021.Passes.Server;
import Common.Current;
import Common.Database.Database;
import Common.Database.riDBObject;
import Common.Global;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.Common.TestingServer;
public class PublishServerAccountObject<D extends riDBObject> extends PublishServerObject<TestingServer, D> {
public PublishServerAccountObject(Class<D> d_in) {
super(Global.testingServer, d_in);
}
@Override
protected Database getDb() {
return Global.testingServer.account_db;
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.PublishAccountAIObject, Current.getAccount().email, target));
}
}