|
|
|
|
@@ -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);
|
|
|
|
|
|