промежуточный. изменен механизм формирования задач для тестирования SAPFOR. Теперь они создаются на стадии черновика, при публикации только обновляются ссылки на родительский пакет. При добавлении задач в пакет идет проверка по ключам на их существование.

This commit is contained in:
2024-03-07 18:56:47 +03:00
parent 2b9cfc3af1
commit e7c8810291
11 changed files with 168 additions and 108 deletions

13
.idea/workspace.xml generated
View File

@@ -8,8 +8,17 @@
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/GlobalData/Account/Account.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GlobalData/Account/Account.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/DeleteServerSapfor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/DeleteServerSapfor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TaskThread.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TaskThread.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/Json/SapforPackage_json.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforPackage_json.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforTestingSet_json.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforTestingSet_json.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/PackageModeSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/PackageModeSupervisor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/PerformSapforTask.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/PerformSapforTask.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforPackage/SapforPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforPackage/SapforPackage.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AddTasksToSapforPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AddTasksToSapforPackage.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CompareDVMRunTasks.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CompareDVMRunTasks.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CompareSapforPackages.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CompareSapforPackages.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -7,18 +7,11 @@ import TestingSystem.SAPFOR.SapforTask.SapforTask;
import java.io.File;
public class TaskThread extends Thread {
public SapforTask task = null;
public TaskThread(SapforTask task_, File sapfor_drv,
SapforTestingSet_json set_json,
SapforConfiguration_json configuration_json) {
public TaskThread(SapforTask task_, File sapfor_drv) {
super(() -> {
while (!task_.state.isComplete()) {
task_.Reset();
new PerformSapforTask().Do(
sapfor_drv,
set_json,
configuration_json,
task_
);
new PerformSapforTask().Do(task_,sapfor_drv);
}
});
task = task_;

View File

@@ -69,12 +69,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
dvmPackage.saveJson();
dvmPackage.package_json = null; // объект больше не нужен.
} else if (object instanceof SapforPackage) {
SapforPackage sapforPackage = (SapforPackage) object;
//--
Utils.CheckAndCleanDirectory(sapforPackage.getLocalWorkspace());
//--
sapforPackage.saveJson();
sapforPackage.package_json = null; // объект больше не нужен.
((SapforPackage) object).init();
}
}
@Override
@@ -603,7 +598,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
private void ReplaceTestsCodes() throws Exception {
Vector<Test> tests = (Vector<Test>) request.object;
response = new ServerExchangeUnit_2021(ServerCode.OK);
for (Test test: tests){
for (Test test : tests) {
if (!test.unpackProjectOnServer()) {
db.Delete(test);
throw new RepositoryRefuseException(

View File

@@ -25,9 +25,41 @@ public class SapforPackage_json implements Serializable {
public int getMaxSetId() {
return max_set_id++;
}
@Expose
public int max_task_id = 0;
public int getMaxTaskId() {
return max_task_id++;
}
//--
@Expose
public List<SapforTestingSet_json> testingSets = new Vector<>(); //сет = конфигурации + тесты.
@Expose
public List<SapforTask> tasks = new Vector<>();
//--
public Vector<String> getTasksKeys() {
Vector<String> keys = new Vector<>();
for (SapforTask task : tasks) {
String key = task.getUniqueKey();
if (!keys.contains(key))
keys.add(key);
}
return keys;
}
public Vector<String> getTestsNames() {
Vector<String> names = new Vector<>();
for (SapforTask task : tasks) {
if (!names.contains(task.test_description))
names.add(task.test_description);
}
names.sort(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o1.compareTo(o2);
}
});
return names;
}
//--
public boolean hasConfiguration(int configuration_id) {
for (SapforTestingSet_json set : testingSets) {
for (SapforConfiguration_json configuration : set.configurations) {
@@ -38,9 +70,6 @@ public class SapforPackage_json implements Serializable {
return false;
}
//--
@Expose
public List<SapforTask> tasks = new Vector<>();
//---
public void sortTasks() {
tasks.sort(new Comparator<SapforTask>() {
@Override

View File

@@ -1,5 +1,7 @@
package TestingSystem.SAPFOR.Json;
import Common.Constants;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import Visual_DVM_2021.Passes.PassCode_2021;
import com.google.gson.annotations.Expose;
import java.io.Serializable;
@@ -12,4 +14,30 @@ public class SapforTestingSet_json implements Serializable {
public List<SapforTest_json> tests = new Vector<>();
@Expose
public List<SapforConfiguration_json> configurations = new Vector<>();
public Vector<SapforTask> createTasks() {
Vector<SapforTask> tasks = new Vector<>();
//-
for (SapforConfiguration_json sapforConfiguration_json : configurations) {
for (SapforTest_json test : tests) {
SapforTask task = new SapforTask();
//--
task.id = Constants.Nan;
task.sapfortaskspackage_id = Constants.Nan;
//-- unique key--
task.group_description = test.group_description;
task.test_description = test.description;
task.sapfor_configuration_id = sapforConfiguration_json.id;
//---------------
task.flags = sapforConfiguration_json.flags;
task.set_id = id;
tasks.add(task);
Vector<String> codes_s = new Vector<>();
for (PassCode_2021 code : sapforConfiguration_json.codes)
codes_s.add(code.toString());
task.codes = String.join(" ", codes_s);
}
}
//-
return tasks;
}
}

View File

@@ -36,34 +36,8 @@ public class PackageModeSupervisor extends ThreadsPlanner {
FileUtils.writeStringToFile(started, String.valueOf(startDate));
//формирование списка задач.
setMaxKernels(package_json.kernels);
int max_rask_id = 0;
for (SapforTestingSet_json set_json : package_json.testingSets) {
for (SapforConfiguration_json sapforConfiguration_json : set_json.configurations) {
for (SapforTest_json test : set_json.tests) {
//--- чтобы было можно на нее сослаться после выполнения всех нитей.
SapforTask task = new SapforTask();
task.id = max_rask_id++;
task.group_description = test.group_description;
task.test_description = test.description;
task.flags = sapforConfiguration_json.flags;
task.set_id = set_json.id;
task.sapfor_configuration_id = sapforConfiguration_json.id;
task.sapfortaskspackage_id = Integer.parseInt(new File(Global.Home).getName());
package_json.tasks.add(task);
Vector<String> codes_s = new Vector<>();
for (PassCode_2021 code : sapforConfiguration_json.codes) {
codes_s.add(code.toString());
}
task.codes = String.join(" ", codes_s);
//---
addThread(new TaskThread(task,
sapfor_drv,
set_json,
sapforConfiguration_json)
);
}
}
}
for (SapforTask task: package_json.tasks)
addThread(new TaskThread(task,sapfor_drv));
interruptThread.start();
}
@Override

View File

@@ -29,8 +29,6 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
}
//--
File sapfor_drv;
SapforTestingSet_json set_json;
SapforConfiguration_json configuration_json;
SapforVersion_json version_json;
//-----
File root;
@@ -39,17 +37,17 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
//-----
@Override
protected boolean canStart(Object... args) throws Exception {
sapfor_drv = (File) args[0];
set_json = (SapforTestingSet_json) args[1];
configuration_json = (SapforConfiguration_json) args[2];
target = (SapforTask) args[3];
//--
target = (SapforTask) args[0];
sapfor_drv = (File) args[1];
//--
version_json = null;
//--->>
parentTask = Paths.get(Global.Home,
String.valueOf(set_json.id),
String.valueOf(configuration_json.id),
String.valueOf(target.set_id),
String.valueOf(target.sapfor_configuration_id),
target.test_description).toFile();
root = Paths.get(Global.Home, String.valueOf(set_json.id), String.valueOf(configuration_json.id)).toFile();
root = Paths.get(Global.Home, String.valueOf(target.set_id), String.valueOf(target.sapfor_configuration_id)).toFile();
task = null;
//--->>
return true;
@@ -115,7 +113,10 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
protected void body() throws Exception {
target.StartDate = new Date().getTime();
target.versions.add(version_json = new SapforVersion_json(target.test_description, "исходная"));
for (PassCode_2021 code : configuration_json.codes) {
String [] data = target.codes.split(" ");
for (String code_s: data){
PassCode_2021 code = PassCode_2021.valueOf(code_s);
//--
if (parse()) {
if (code.equals(PassCode_2021.CreateParallelVariants))
variants();
@@ -123,6 +124,7 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
break;
} else
break;
//--
}
target.ChangeDate = new Date().getTime();
}

View File

@@ -2,8 +2,10 @@ package TestingSystem.SAPFOR.SapforPackage;
import Common.Constants;
import Common.Database.DBObject;
import Common.Global;
import Common.Utils.Utils;
import TestingSystem.Common.TestingPackage.TestingPackage;
import TestingSystem.SAPFOR.Json.SapforPackage_json;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import com.sun.org.glassfish.gmbal.Description;
import java.io.File;
@@ -12,8 +14,7 @@ public class SapforPackage extends TestingPackage<SapforPackage_json> {
public String testsNames = "";//имена тестов через ; для отображения
//---
public int sapforId = Constants.Nan; // так как сапфор на машине.
public SapforPackage(){
public SapforPackage() {
}
public SapforPackage(SapforPackage sapforPackage) {
SynchronizeFields(sapforPackage);
@@ -33,4 +34,12 @@ public class SapforPackage extends TestingPackage<SapforPackage_json> {
public File getHomeDirectory() {
return Global.SapforPackagesDirectory;
}
//--
public void init() throws Exception {
for (SapforTask task : package_json.tasks)
task.sapfortaskspackage_id = id;
Utils.CheckAndCleanDirectory(getLocalWorkspace());
saveJson();
package_json = null; // объект больше не нужен.
}
}

View File

@@ -15,6 +15,7 @@ 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 Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
@@ -24,13 +25,14 @@ import java.util.Vector;
public class AddTasksToSapforPackage extends Pass_2021<SapforPackage> {
SapforTestingSet_json testing_set; //то, что добавляем.
//--
protected int setTasksCount = 0;
protected LinkedHashMap<Integer, Vector<Integer>> groupsTests = null;
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/AddTasks.png";
@@ -79,10 +81,6 @@ public class AddTasksToSapforPackage extends Pass_2021<SapforPackage> {
//--
//--
public boolean checkConfigurationCommands(SapforConfiguration sapforConfiguration) {
if (target.package_json.hasConfiguration(sapforConfiguration.id)){
Log.Writeln_("Конфигурация "+sapforConfiguration.id+" уже присутствует в пакете. Повторение конфигураций запрещено!");
return false;
}
//1. получить список всех команд.
Vector<PassCode_2021> codes = new Vector<>();
//-- счетчик завершающих команд.
@@ -180,7 +178,6 @@ public class AddTasksToSapforPackage extends Pass_2021<SapforPackage> {
return false;
}
//---
setTasksCount = 0;
groupsTests = new LinkedHashMap<>();
testsNames_lower = new Vector<>();
testsByDescriptions = new LinkedHashMap<>();
@@ -218,52 +215,68 @@ public class AddTasksToSapforPackage extends Pass_2021<SapforPackage> {
return false;
}
//--
for (int i = 0; i < Global.testingServer.db.sapforConfigurations.getCheckedCount(); ++i) {
for (Vector<Integer> tests : groupsTests.values())
setTasksCount += tests.size();
testing_set = new SapforTestingSet_json();
testing_set.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;
testing_set.tests.add(test_json);
}
return UI.Question("Будет добавлено " + setTasksCount + " задач. Продолжить");
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems()) {
//--
SapforConfiguration_json configuration_json = new SapforConfiguration_json();
configuration_json.id = configuration.id;
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);
//--->>
testing_set.configurations.add(configuration_json);
//-->>
}
Vector<SapforTask> possible_tasks = testing_set.createTasks();
Vector<String> keys = target.package_json.getTasksKeys();
new_tasks = new Vector<>();
for (SapforTask task : possible_tasks) {
String key = task.getUniqueKey();
if (!keys.contains(key)) {
keys.add(key);
new_tasks.add(task);
}
}
if (new_tasks.size()==0){
Log.Writeln_("Не сформировано ни одной новой задачи.\n" +
"Задачи уже присутствуют в пакете, или не отмечено ни одного теста.");
return false;
}
return UI.Question("Будет добавлено " + new_tasks.size() + " задач. Продолжить");
}
//
return false;
}
@Override
protected void body() throws Exception {
testing_set = new SapforTestingSet_json();
testing_set.id = target.package_json.getMaxSetId();
Vector<String> testsNames = new Vector<>();
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;
testing_set.tests.add(test_json);
//-
testsNames.add(test.description);
}
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems()) {
//--
SapforConfiguration_json configuration_json = new SapforConfiguration_json();
configuration_json.id = configuration.id;
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);
//--->>
testing_set.configurations.add(configuration_json);
//-->>
}
//-->>
target.package_json.testingSets.add(testing_set);
target.tasksCount += setTasksCount;
target.testsNames += String.join(";", testsNames) + ";";
for (SapforTask task: new_tasks){
task.id = target.package_json.getMaxTaskId();
target.package_json.tasks.add(task);
}
target.tasksCount += new_tasks.size();
target.testsNames = String.join(";", target.package_json.getTestsNames());
Global.testingServer.db.Update(target);
}
@Override
protected void showDone() throws Exception {
Global.testingServer.db.sapforPackages.ShowUI(target.id);
//----
Utils.CheckAndCleanDirectory(target.getLocalWorkspace());
target.saveJson();
//---
}
}

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
@@ -36,12 +37,15 @@ public class CompareDVMRunTasks extends Pass_2021<Vector<DVMRunTask>> {
} else if (target.size() == 1) {
master = target.get(0);
slave = null;
return UI.Question("Отобразить задачу " + Utils.Brackets(target.get(0).getPK()));
} else if (target.size() != 2) {
Log.Writeln_("Для сравнения требуется отметить две задачи.\nДля отображения требуется отметить одну задачу");
return UI.Question("Отобразить задачу " + Utils.Brackets(master.getPK()));
} else if ((target.size() == 0) && (Current.HasDVMRunTask())) {
master = Current.getDVMRunTask();
slave = null;
return UI.Question("Отобразить задачу " + Utils.Brackets(master.getPK()));
} else {
Log.Writeln_("Для сравнения требуется отметить две задачи.\nДля отображения требуется отметить одну задачу,или выделить её.");
return false;
}
return true;
}
@Override
protected void body() throws Exception {

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
@@ -36,12 +37,15 @@ public class CompareSapforPackages extends Pass_2021<Vector<SapforPackage>> {
} else if (target.size() == 1) {
master = target.get(0);
slave = null;
return UI.Question("Отобразить пакет " + Utils.Brackets(target.get(0).getPK()));
} else if (target.size() != 2) {
Log.Writeln_("Для сравнения требуется отметить два пакета.\nДля отображения требуется отметить один пакет");
return UI.Question("Отобразить пакет " + Utils.Brackets(master.getPK()));
} else if ((target.size() == 0) && (Current.HasSapforPackage())) {
master = Current.getSapforPackage();
slave = null;
return UI.Question("Отобразить пакет " + Utils.Brackets(master.getPK()));
} else {
Log.Writeln_("Для сравнения требуется отметить два пакета.\nДля отображения требуется отметить один пакет,или выделить его");
return false;
}
return true;
}
@Override
protected void body() throws Exception {