запись результатов тестирования в бд
This commit is contained in:
5553
.idea/workspace.xml
generated
5553
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
@@ -25,8 +25,8 @@ public enum ServerCode {
|
|||||||
GetTestProject,
|
GetTestProject,
|
||||||
StartTests,
|
StartTests,
|
||||||
//-
|
//-
|
||||||
CompareSapforPackages,
|
|
||||||
RefreshDVMTests, //- для админа. получение тестов из репозитория.
|
RefreshDVMTests, //- для админа. получение тестов из репозитория.
|
||||||
|
PublishSapforPackageTasks,
|
||||||
//-
|
//-
|
||||||
PublishObject,
|
PublishObject,
|
||||||
CopyObjects, //использовать с осторожностью. проверять CopyAction на тему первичного ключа.
|
CopyObjects, //использовать с осторожностью. проверять CopyAction на тему первичного ключа.
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package SapforTestingSystem.Json;
|
package SapforTestingSystem.Json;
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
public class SapforVersion_json {
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
public class SapforVersion_json implements Serializable {
|
||||||
@Expose
|
@Expose
|
||||||
public String version = "";
|
public String version = "";
|
||||||
@Expose
|
@Expose
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class PackageModeSupervisor extends ThreadsPlanner {
|
|||||||
//--
|
//--
|
||||||
for (SapforTask task : results_json.tasks) {
|
for (SapforTask task : results_json.tasks) {
|
||||||
//--
|
//--
|
||||||
task.files = new Vector<>();
|
task.filesList = new Vector<>();
|
||||||
//--
|
//--
|
||||||
if (task.versions.size() > 1) {
|
if (task.versions.size() > 1) {
|
||||||
SapforVersion_json correctness = task.versions.get(1); //0 - исходная, 1 коррекция стиля кода.
|
SapforVersion_json correctness = task.versions.get(1); //0 - исходная, 1 коррекция стиля кода.
|
||||||
@@ -80,7 +80,7 @@ public class PackageModeSupervisor extends ThreadsPlanner {
|
|||||||
pf.file = file;
|
pf.file = file;
|
||||||
pf.AutoDetectProperties();
|
pf.AutoDetectProperties();
|
||||||
if (pf.fileType != FileType.forbidden)
|
if (pf.fileType != FileType.forbidden)
|
||||||
task.files.add(pf.file.getName());
|
task.filesList.add(pf.file.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
|
|||||||
parentTask = Paths.get(Global.Home, sapforConfiguration_json.id, target.test_description).toFile();
|
parentTask = Paths.get(Global.Home, sapforConfiguration_json.id, target.test_description).toFile();
|
||||||
task = null;
|
task = null;
|
||||||
//--->>
|
//--->>
|
||||||
target.root = parentTask.getAbsolutePath();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
protected static boolean checkLines(Vector<String> lines) {
|
protected static boolean checkLines(Vector<String> lines) {
|
||||||
@@ -342,7 +341,10 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
|
|||||||
//-------------------------------------------------->>
|
//-------------------------------------------------->>
|
||||||
@Override
|
@Override
|
||||||
protected void body() throws Exception {
|
protected void body() throws Exception {
|
||||||
target.versions.add(new SapforVersion_json(target.root, "исходная"));
|
target.versions.add(new SapforVersion_json(
|
||||||
|
Paths.get(Global.Home,
|
||||||
|
sapforConfiguration_json.id,
|
||||||
|
target.test_description).toFile().getAbsolutePath(), "исходная"));
|
||||||
for (PassCode_2021 code : sapforConfiguration_json.codes) {
|
for (PassCode_2021 code : sapforConfiguration_json.codes) {
|
||||||
if (parse()) {
|
if (parse()) {
|
||||||
if (code.equals(PassCode_2021.CreateParallelVariants))
|
if (code.equals(PassCode_2021.CreateParallelVariants))
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Common.Database.DBObject;
|
|||||||
import Common.Utils.Utils;
|
import Common.Utils.Utils;
|
||||||
import GlobalData.Tasks.TaskState;
|
import GlobalData.Tasks.TaskState;
|
||||||
import SapforTestingSystem.Json.SapforVersion_json;
|
import SapforTestingSystem.Json.SapforVersion_json;
|
||||||
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
import com.sun.org.glassfish.gmbal.Description;
|
import com.sun.org.glassfish.gmbal.Description;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@@ -20,6 +21,8 @@ public class SapforTask extends DBObject {
|
|||||||
@Description("DEFAULT '-1'")
|
@Description("DEFAULT '-1'")
|
||||||
@Expose
|
@Expose
|
||||||
public String sapfor_configuration_id = "";
|
public String sapfor_configuration_id = "";
|
||||||
|
@Description("DEFAULT ''")
|
||||||
|
public String sapfortaskspackage_id = "";
|
||||||
//------------------------------------->>
|
//------------------------------------->>
|
||||||
@Description("DEFAULT ''")
|
@Description("DEFAULT ''")
|
||||||
@Expose
|
@Expose
|
||||||
@@ -33,16 +36,18 @@ public class SapforTask extends DBObject {
|
|||||||
@Description("DEFAULT ''")
|
@Description("DEFAULT ''")
|
||||||
@Expose
|
@Expose
|
||||||
public String codes = "";
|
public String codes = "";
|
||||||
@Description("DEFAULT ''")
|
|
||||||
@Expose
|
|
||||||
public String root = "";
|
|
||||||
@Description("DEFAULT 'Inactive'")
|
|
||||||
@Expose
|
@Expose
|
||||||
public TaskState state = TaskState.Inactive;
|
public TaskState state = TaskState.Inactive;
|
||||||
|
//в json не выносить. это только для БД.
|
||||||
|
@Description("DEFAULT ''")
|
||||||
|
public String files = "";
|
||||||
|
@Description("DEFAULT ''")
|
||||||
|
public String versionsDescription = "";
|
||||||
|
//------
|
||||||
//-----------
|
//-----------
|
||||||
@Description("IGNORE")
|
@Description("IGNORE")
|
||||||
@Expose
|
@Expose
|
||||||
public List<String> files = new Vector<>(); //файлы проекта.Брать из коррекции стиля кода. есть первой версия
|
public List<String> filesList = new Vector<>(); //файлы проекта.Брать из коррекции стиля кода. есть первой версия
|
||||||
//-------------------------------------->>
|
//-------------------------------------->>
|
||||||
@Description("IGNORE")
|
@Description("IGNORE")
|
||||||
@Expose
|
@Expose
|
||||||
@@ -55,9 +60,8 @@ public class SapforTask extends DBObject {
|
|||||||
public SapforTask() {
|
public SapforTask() {
|
||||||
}
|
}
|
||||||
public void Reset() {
|
public void Reset() {
|
||||||
root = "";
|
|
||||||
state = TaskState.Inactive;
|
state = TaskState.Inactive;
|
||||||
files.clear();
|
filesList.clear();
|
||||||
versions.clear();
|
versions.clear();
|
||||||
variants.clear();
|
variants.clear();
|
||||||
}
|
}
|
||||||
@@ -74,14 +78,25 @@ public class SapforTask extends DBObject {
|
|||||||
SapforTask t = (SapforTask) object;
|
SapforTask t = (SapforTask) object;
|
||||||
id = t.id;
|
id = t.id;
|
||||||
sapfor_configuration_id = t.sapfor_configuration_id;
|
sapfor_configuration_id = t.sapfor_configuration_id;
|
||||||
|
sapfortaskspackage_id = t.sapfortaskspackage_id;
|
||||||
|
//-
|
||||||
test_description = t.test_description;
|
test_description = t.test_description;
|
||||||
|
group_description = t.group_description;
|
||||||
|
versionsDescription = t.versionsDescription;
|
||||||
|
//--
|
||||||
|
files = t.files;
|
||||||
|
codes = t.codes;
|
||||||
state = t.state;
|
state = t.state;
|
||||||
|
//--
|
||||||
}
|
}
|
||||||
public String getVersionsChain() {
|
public String getVersionsChain() {
|
||||||
Vector<String> versionsLines = new Vector<>();
|
Vector<String> versionsLines = new Vector<>();
|
||||||
for (int i = 1; i < versions.size(); ++i) {
|
for (int i = 1; i < versions.size(); ++i) {
|
||||||
versionsLines.add(Utils.Brackets(versions.get(i).description));
|
versionsLines.add(Utils.Brackets(versions.get(i).description));
|
||||||
}
|
}
|
||||||
|
if (!variants.isEmpty()) {
|
||||||
|
versionsLines.add(Utils.Brackets(PassCode_2021.CreateParallelVariants.getDescription()));
|
||||||
|
}
|
||||||
return String.join("→", versionsLines);
|
return String.join("→", versionsLines);
|
||||||
}
|
}
|
||||||
public static boolean compareVersionsFiles(SapforVersion_json version1, SapforVersion_json version2, List<String> files) throws Exception {
|
public static boolean compareVersionsFiles(SapforVersion_json version1, SapforVersion_json version2, List<String> files) throws Exception {
|
||||||
@@ -105,10 +120,10 @@ public class SapforTask extends DBObject {
|
|||||||
}
|
}
|
||||||
public boolean Compare(SapforTask task, Vector<String> comparisonLog) throws Exception {
|
public boolean Compare(SapforTask task, Vector<String> comparisonLog) throws Exception {
|
||||||
//1. сравнить списки файлов. без учета порядка.
|
//1. сравнить списки файлов. без учета порядка.
|
||||||
if (files.size() != task.files.size())
|
if (filesList.size() != task.filesList.size())
|
||||||
return false;
|
return false;
|
||||||
for (String file1 : files) {
|
for (String file1 : filesList) {
|
||||||
if (!task.files.contains(file1)) {
|
if (!task.filesList.contains(file1)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +139,7 @@ public class SapforTask extends DBObject {
|
|||||||
SapforVersion_json version1 = versions.get(i);
|
SapforVersion_json version1 = versions.get(i);
|
||||||
SapforVersion_json version2 = task.versions.get(i);
|
SapforVersion_json version2 = task.versions.get(i);
|
||||||
//--
|
//--
|
||||||
if (!compareVersionsFiles(version1, version2, files)) return false;
|
if (!compareVersionsFiles(version1, version2, filesList)) return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public class SapforTasksPackage extends nDBObject {
|
|||||||
public String testsIds = "";
|
public String testsIds = "";
|
||||||
@Description("DEFAULT ''")
|
@Description("DEFAULT ''")
|
||||||
public String configurationsIds = "";
|
public String configurationsIds = "";
|
||||||
|
@Description("DEFAULT ''")
|
||||||
|
public String summary = "";
|
||||||
// допустимые состояния
|
// допустимые состояния
|
||||||
//Queued
|
//Queued
|
||||||
//PackageStart
|
//PackageStart
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package SapforTestingSystem.SapforTasksPackage;
|
||||||
|
import Common.Global;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
public class SapforTasksPackageInterface {
|
||||||
|
public static File getPackageArchive(SapforTasksPackage package_in){
|
||||||
|
return new File(Global.SapforPackagesDirectory, package_in.workspace+".zip");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package SapforTestingSystem.SapforTasksPackage;
|
package SapforTestingSystem.SapforTasksPackage;
|
||||||
import Common.Current;
|
import Common.Current;
|
||||||
import Common.Database.DBTable;
|
import Common.Database.*;
|
||||||
import Common.UI.DataSetControlForm;
|
import Common.UI.DataSetControlForm;
|
||||||
|
import SapforTestingSystem.SapforTask.SapforTask;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
import static Common.UI.Tables.TableRenderers.RendererDate;
|
import static Common.UI.Tables.TableRenderers.RendererDate;
|
||||||
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
|
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
|
||||||
@@ -77,12 +79,11 @@ public class SapforTasksPackagesDBTable extends DBTable<String, SapforTasksPacka
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
|
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
|
||||||
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
|
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
|
||||||
res.put(SapforTasksPackage.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
res.put(SapforTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ import Common.Current;
|
|||||||
import Common.Global;
|
import Common.Global;
|
||||||
import Common.GlobalProperties;
|
import Common.GlobalProperties;
|
||||||
import Common.Utils.Utils;
|
import Common.Utils.Utils;
|
||||||
|
import GlobalData.Tasks.TaskState;
|
||||||
import Repository.Server.ServerCode;
|
import Repository.Server.ServerCode;
|
||||||
import SapforTestingSystem.Json.SapforConfiguration_json;
|
import SapforTestingSystem.Json.SapforConfiguration_json;
|
||||||
import SapforTestingSystem.Json.SapforTasksPackage_json;
|
import SapforTestingSystem.Json.SapforTasksPackage_json;
|
||||||
|
import SapforTestingSystem.Json.SapforTasksResults_json;
|
||||||
import SapforTestingSystem.Json.SapforTest_json;
|
import SapforTestingSystem.Json.SapforTest_json;
|
||||||
import SapforTestingSystem.SapforConfiguration.SapforConfiguration;
|
import SapforTestingSystem.SapforConfiguration.SapforConfiguration;
|
||||||
import SapforTestingSystem.SapforConfiguration.SapforConfigurationInterface;
|
import SapforTestingSystem.SapforConfiguration.SapforConfigurationInterface;
|
||||||
|
import SapforTestingSystem.SapforTask.SapforTask;
|
||||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||||
import TestingSystem.Group.Group;
|
import TestingSystem.Group.Group;
|
||||||
import TestingSystem.TasksPackage.TasksPackageState;
|
import TestingSystem.TasksPackage.TasksPackageState;
|
||||||
@@ -139,9 +142,9 @@ public class SapforTasksPackageSupervisor {
|
|||||||
File done = new File(sapforTasksPackage.workspace, Constants.DONE);
|
File done = new File(sapforTasksPackage.workspace, Constants.DONE);
|
||||||
File aborted = new File(sapforTasksPackage.workspace, Constants.ABORTED);
|
File aborted = new File(sapforTasksPackage.workspace, Constants.ABORTED);
|
||||||
if (done.exists()) {
|
if (done.exists()) {
|
||||||
sapforTasksPackage.state = TasksPackageState.Done;
|
sapforTasksPackage.state = TasksPackageState.Analysis;
|
||||||
planner.UpdateSapforPackage();
|
planner.UpdateSapforPackage();
|
||||||
System.out.println("package done");
|
System.out.println("package done, start Analysis");
|
||||||
} else if (aborted.exists()) {
|
} else if (aborted.exists()) {
|
||||||
sapforTasksPackage.state = TasksPackageState.Aborted;
|
sapforTasksPackage.state = TasksPackageState.Aborted;
|
||||||
planner.UpdateSapforPackage();
|
planner.UpdateSapforPackage();
|
||||||
@@ -171,6 +174,95 @@ public class SapforTasksPackageSupervisor {
|
|||||||
killer.waitFor();
|
killer.waitFor();
|
||||||
System.out.println("done!");
|
System.out.println("done!");
|
||||||
}
|
}
|
||||||
|
public void AnalysePackage() throws Exception {
|
||||||
|
Vector<String> summary_lines = new Vector<>();
|
||||||
|
File results_json_file = new File(sapforTasksPackage.workspace, Constants.results_json);
|
||||||
|
if (results_json_file.exists()) {
|
||||||
|
SapforTasksResults_json results_json = (SapforTasksResults_json) Utils.jsonFromFile(results_json_file, SapforTasksResults_json.class);
|
||||||
|
summary_lines.add("Всего задач: " + results_json.tasks.size());
|
||||||
|
LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> sortedTasks = new LinkedHashMap<>();
|
||||||
|
//рассортировать задачи по конфигурациям.
|
||||||
|
for (TaskState state : TaskState.values()) {
|
||||||
|
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByFlags = new LinkedHashMap<>();
|
||||||
|
sortedTasks.put(state, tasksByFlags);
|
||||||
|
//--
|
||||||
|
for (SapforTask task : results_json.tasks) {
|
||||||
|
task.sapfortaskspackage_id = sapforTasksPackage.id;
|
||||||
|
if (task.state.equals(state)) {
|
||||||
|
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = null;
|
||||||
|
if (tasksByFlags.containsKey(task.flags)) {
|
||||||
|
groups_tasks = tasksByFlags.get(task.flags);
|
||||||
|
} else {
|
||||||
|
groups_tasks = new LinkedHashMap<>();
|
||||||
|
tasksByFlags.put(task.flags, groups_tasks);
|
||||||
|
}
|
||||||
|
Vector<SapforTask> tasks = null;
|
||||||
|
if (groups_tasks.containsKey(task.group_description)) {
|
||||||
|
tasks = groups_tasks.get(task.group_description);
|
||||||
|
} else {
|
||||||
|
tasks = new Vector<>();
|
||||||
|
groups_tasks.put(task.group_description, tasks);
|
||||||
|
}
|
||||||
|
tasks.add(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
for (TaskState state : sortedTasks.keySet()) {
|
||||||
|
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByFlags = sortedTasks.get(state);
|
||||||
|
if (!tasksByFlags.isEmpty()) {
|
||||||
|
int count = 0;
|
||||||
|
if (!state.equals(TaskState.Done)) {
|
||||||
|
Vector<String> flagsLines = new Vector<>();
|
||||||
|
for (String flags : tasksByFlags.keySet()) {
|
||||||
|
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByFlags.get(flags);
|
||||||
|
for (String group : tasksByGroups.keySet()) {
|
||||||
|
Vector<SapforTask> tasks = tasksByGroups.get(group);
|
||||||
|
flagsLines.add("Группа " + group + ": " + tasks.size());
|
||||||
|
count += tasks.size();
|
||||||
|
for (SapforTask task : tasks) {
|
||||||
|
task.versionsDescription = task.getVersionsChain();
|
||||||
|
flagsLines.add(
|
||||||
|
"тест: " +
|
||||||
|
Utils.Brackets(task.test_description) + " " +
|
||||||
|
"флаги: "
|
||||||
|
+ Utils.Brackets(flags) + " " +
|
||||||
|
"версии: " +
|
||||||
|
task.versionsDescription
|
||||||
|
// + " " + "конфигурация " + task.sapfor_configuration_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
summary_lines.add(state.getDescription() + " :" + count);
|
||||||
|
summary_lines.addAll(flagsLines);
|
||||||
|
} else {
|
||||||
|
for (String flags : tasksByFlags.keySet()) {
|
||||||
|
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByFlags.get(flags);
|
||||||
|
for (String group : tasksByGroups.keySet()) {
|
||||||
|
Vector<SapforTask> tasks = tasksByGroups.get(group);
|
||||||
|
for (SapforTask task: tasks)
|
||||||
|
task.versionsDescription = task.getVersionsChain();
|
||||||
|
count += tasks.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
summary_lines.add(state.getDescription() + " :" + count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sapforTasksPackage.summary = String.join("\n", summary_lines);
|
||||||
|
for (SapforTask task : results_json.tasks) {
|
||||||
|
//--
|
||||||
|
if (!task.filesList.isEmpty())
|
||||||
|
task.files = String.join("\n", task.filesList);
|
||||||
|
//---
|
||||||
|
task.filesList = null;
|
||||||
|
task.versions = null;
|
||||||
|
task.variants = null;
|
||||||
|
}
|
||||||
|
planner.ServerCommand(ServerCode.PublishSapforPackageTasks, planner.email, new Vector<>(results_json.tasks));
|
||||||
|
}
|
||||||
|
}
|
||||||
public void Perform() throws Exception {
|
public void Perform() throws Exception {
|
||||||
if (packageNeedsKill()) {
|
if (packageNeedsKill()) {
|
||||||
System.out.println("PACKAGE " + sapforTasksPackage.id + " NEEDS TO KILL");
|
System.out.println("PACKAGE " + sapforTasksPackage.id + " NEEDS TO KILL");
|
||||||
@@ -190,6 +282,11 @@ public class SapforTasksPackageSupervisor {
|
|||||||
case RunningExecution:
|
case RunningExecution:
|
||||||
CheckPackageState();
|
CheckPackageState();
|
||||||
break;
|
break;
|
||||||
|
case Analysis:
|
||||||
|
AnalysePackage();
|
||||||
|
sapforTasksPackage.state = TasksPackageState.Done;
|
||||||
|
planner.UpdateSapforPackage();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package TestingSystem;
|
|||||||
import Common.Database.SQLITE.SQLiteDatabase;
|
import Common.Database.SQLITE.SQLiteDatabase;
|
||||||
import Common.Global;
|
import Common.Global;
|
||||||
import GlobalData.Settings.SettingName;
|
import GlobalData.Settings.SettingName;
|
||||||
|
import SapforTestingSystem.SapforTask.SapforTasksDBTable;
|
||||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackagesDBTable;
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackagesDBTable;
|
||||||
import TestingSystem.TSetting.TSetting;
|
import TestingSystem.TSetting.TSetting;
|
||||||
@@ -31,6 +32,7 @@ public class TasksDatabase extends SQLiteDatabase {
|
|||||||
PreparedStatement selectPackageRunTasks = null;
|
PreparedStatement selectPackageRunTasks = null;
|
||||||
//----------
|
//----------
|
||||||
public SapforTasksPackagesDBTable sapforTasksPackages;
|
public SapforTasksPackagesDBTable sapforTasksPackages;
|
||||||
|
public SapforTasksDBTable sapforTasks;
|
||||||
//---------
|
//---------
|
||||||
public TasksDatabase(String email) {
|
public TasksDatabase(String email) {
|
||||||
super(Paths.get(Global.DataDirectory.getAbsolutePath(), email + "_" + tests_db_name + ".sqlite").toFile());
|
super(Paths.get(Global.DataDirectory.getAbsolutePath(), email + "_" + tests_db_name + ".sqlite").toFile());
|
||||||
@@ -50,6 +52,7 @@ public class TasksDatabase extends SQLiteDatabase {
|
|||||||
addTable(packagesToKill = new TasksPackageToKillDBTable());
|
addTable(packagesToKill = new TasksPackageToKillDBTable());
|
||||||
//-----------
|
//-----------
|
||||||
addTable(sapforTasksPackages = new SapforTasksPackagesDBTable());
|
addTable(sapforTasksPackages = new SapforTasksPackagesDBTable());
|
||||||
|
addTable(sapforTasks = new SapforTasksDBTable());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void Init() throws Exception {
|
public void Init() throws Exception {
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
package TestingSystem;
|
package TestingSystem;
|
||||||
import Common.Constants;
|
|
||||||
import Common.Global;
|
import Common.Global;
|
||||||
import Common.Utils.Utils;
|
import Common.Utils.Utils;
|
||||||
import GlobalData.Machine.Machine;
|
import GlobalData.Machine.Machine;
|
||||||
import GlobalData.Tasks.TaskState;
|
|
||||||
import GlobalData.User.User;
|
import GlobalData.User.User;
|
||||||
import Repository.EmailMessage;
|
import Repository.EmailMessage;
|
||||||
import Repository.Server.ServerCode;
|
import Repository.Server.ServerCode;
|
||||||
import Repository.Server.ServerExchangeUnit_2021;
|
import Repository.Server.ServerExchangeUnit_2021;
|
||||||
import SapforTestingSystem.Json.SapforTasksResults_json;
|
|
||||||
import SapforTestingSystem.SapforTask.SapforTask;
|
|
||||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||||
import SapforTestingSystem.SapforTasksPackageSupervisor.SapforTasksPackageSupervisor;
|
import SapforTestingSystem.SapforTasksPackageSupervisor.SapforTasksPackageSupervisor;
|
||||||
import TestingSystem.Tasks.TestCompilationTask;
|
import TestingSystem.Tasks.TestCompilationTask;
|
||||||
@@ -31,7 +27,7 @@ import java.util.Vector;
|
|||||||
|
|
||||||
import static TestingSystem.TasksDatabase.tests_db_name;
|
import static TestingSystem.TasksDatabase.tests_db_name;
|
||||||
public class TestingPlanner {
|
public class TestingPlanner {
|
||||||
protected String email;
|
public String email;
|
||||||
TasksPackage tasksPackage;
|
TasksPackage tasksPackage;
|
||||||
TestsSupervisor_2022 supervisor;
|
TestsSupervisor_2022 supervisor;
|
||||||
LinkedHashMap<String, Machine> machines = new LinkedHashMap<>();
|
LinkedHashMap<String, Machine> machines = new LinkedHashMap<>();
|
||||||
@@ -227,7 +223,7 @@ public class TestingPlanner {
|
|||||||
//результаты.
|
//результаты.
|
||||||
message = new EmailMessage();
|
message = new EmailMessage();
|
||||||
message.subject = "Состояние пакета задач SAPFOR" + Utils.Brackets(sapforTasksPackage.id) + " изменилось на " + Utils.Brackets(sapforTasksPackage.state.getDescription());
|
message.subject = "Состояние пакета задач SAPFOR" + Utils.Brackets(sapforTasksPackage.id) + " изменилось на " + Utils.Brackets(sapforTasksPackage.state.getDescription());
|
||||||
message.text = PrintSapforPackageResults();
|
message.text = sapforTasksPackage.summary;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -238,81 +234,4 @@ public class TestingPlanner {
|
|||||||
ServerCommand(ServerCode.Email, message);
|
ServerCommand(ServerCode.Email, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--
|
|
||||||
public String PrintSapforPackageResults() throws Exception {
|
|
||||||
String result = "";
|
|
||||||
Vector<String> result_lines = new Vector<>();
|
|
||||||
File results_json_file = new File(sapforTasksPackage.workspace, Constants.results_json);
|
|
||||||
if (results_json_file.exists()) {
|
|
||||||
SapforTasksResults_json results_json = (SapforTasksResults_json) Utils.jsonFromFile(results_json_file, SapforTasksResults_json.class);
|
|
||||||
result_lines.add("Всего задач: " + results_json.tasks.size());
|
|
||||||
LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> sortedTasks = new LinkedHashMap<>();
|
|
||||||
//рассортировать задачи по конфигурациям.
|
|
||||||
for (TaskState state : TaskState.values()) {
|
|
||||||
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByFlags = new LinkedHashMap<>();
|
|
||||||
sortedTasks.put(state, tasksByFlags);
|
|
||||||
//--
|
|
||||||
for (SapforTask task : results_json.tasks) {
|
|
||||||
if (task.state.equals(state)) {
|
|
||||||
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = null;
|
|
||||||
if (tasksByFlags.containsKey(task.flags)) {
|
|
||||||
groups_tasks = tasksByFlags.get(task.flags);
|
|
||||||
} else {
|
|
||||||
groups_tasks = new LinkedHashMap<>();
|
|
||||||
tasksByFlags.put(task.flags, groups_tasks);
|
|
||||||
}
|
|
||||||
Vector<SapforTask> tasks = null;
|
|
||||||
if (groups_tasks.containsKey(task.group_description)) {
|
|
||||||
tasks = groups_tasks.get(task.group_description);
|
|
||||||
} else {
|
|
||||||
tasks = new Vector<>();
|
|
||||||
groups_tasks.put(task.group_description, tasks);
|
|
||||||
}
|
|
||||||
tasks.add(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//--
|
|
||||||
for (TaskState state : sortedTasks.keySet()) {
|
|
||||||
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByFlags = sortedTasks.get(state);
|
|
||||||
if (!tasksByFlags.isEmpty()) {
|
|
||||||
int count = 0;
|
|
||||||
if (!state.equals(TaskState.Done)) {
|
|
||||||
Vector<String> flagsLines = new Vector<>();
|
|
||||||
for (String flags : tasksByFlags.keySet()) {
|
|
||||||
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByFlags.get(flags);
|
|
||||||
for (String group : tasksByGroups.keySet()) {
|
|
||||||
Vector<SapforTask> tasks = tasksByGroups.get(group);
|
|
||||||
flagsLines.add("Группа " + group + ": " + tasks.size());
|
|
||||||
count += tasks.size();
|
|
||||||
for (SapforTask task : tasks)
|
|
||||||
flagsLines.add(
|
|
||||||
"тест: " +
|
|
||||||
Utils.Brackets(task.test_description) + " " +
|
|
||||||
"флаги: "
|
|
||||||
+ Utils.Brackets(flags) + " " +
|
|
||||||
"версии: " +
|
|
||||||
task.getVersionsChain() + " " +
|
|
||||||
"конфигурация " + task.sapfor_configuration_id
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result_lines.add(state.getDescription() + " :" + count);
|
|
||||||
result_lines.addAll(flagsLines);
|
|
||||||
} else {
|
|
||||||
for (String flags : tasksByFlags.keySet()) {
|
|
||||||
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByFlags.get(flags);
|
|
||||||
for (String group : tasksByGroups.keySet()) {
|
|
||||||
Vector<SapforTask> tasks = tasksByGroups.get(group);
|
|
||||||
count += tasks.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result_lines.add(state.getDescription() + " :" + count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = String.join("\n", result_lines);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import Repository.Server.ServerExchangeUnit_2021;
|
|||||||
import SapforTestingSystem.Json.SapforTasksResults_json;
|
import SapforTestingSystem.Json.SapforTasksResults_json;
|
||||||
import SapforTestingSystem.SapforTask.SapforTask;
|
import SapforTestingSystem.SapforTask.SapforTask;
|
||||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||||
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackageInterface;
|
||||||
import SapforTestingSystem.ServerSapfor.ServerSapfor;
|
import SapforTestingSystem.ServerSapfor.ServerSapfor;
|
||||||
import TestingSystem.Group.Group;
|
import TestingSystem.Group.Group;
|
||||||
import TestingSystem.Group.GroupInterface;
|
import TestingSystem.Group.GroupInterface;
|
||||||
@@ -185,11 +186,22 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else if (object instanceof SapforTasksPackage) {
|
} else if (object instanceof SapforTasksPackage) {
|
||||||
|
SapforTasksPackage sapforTasksPackage = (SapforTasksPackage) object;
|
||||||
File workspace = new File(
|
File workspace = new File(
|
||||||
((SapforTasksPackage) object).workspace
|
sapforTasksPackage.workspace
|
||||||
);
|
);
|
||||||
System.out.println(Utils.Brackets(workspace.getAbsolutePath()));
|
System.out.println(Utils.Brackets(workspace.getAbsolutePath()));
|
||||||
Utils.forceDeleteWithCheck(workspace);
|
Utils.forceDeleteWithCheck(workspace);
|
||||||
|
Utils.forceDeleteWithCheck(SapforTasksPackageInterface.getPackageArchive(sapforTasksPackage));
|
||||||
|
//внешние ключи не работают
|
||||||
|
Vector<SapforTask> tasks = new Vector<>();
|
||||||
|
for (SapforTask task : account_db.sapforTasks.Data.values()) {
|
||||||
|
if (task.sapfortaskspackage_id.equals(sapforTasksPackage.id)) // todo group_name -> group_id
|
||||||
|
tasks.add(task);
|
||||||
|
}
|
||||||
|
for (SapforTask task : tasks) {
|
||||||
|
account_db.Delete(task);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@@ -357,18 +369,32 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
DBObject dbObject = null;
|
DBObject dbObject = null;
|
||||||
Test test = null;
|
Test test = null;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
case PublishSapforPackageTasks:
|
||||||
|
Print("Опубликовать задачи SAPFOR для пользователя " + request.arg);
|
||||||
|
SetCurrentAccountDB(request.arg);
|
||||||
|
Vector<Object> tasks = (Vector<Object>) request.object;
|
||||||
|
account_db.BeginTransaction();
|
||||||
|
for (Object object : tasks) {
|
||||||
|
SapforTask task = (SapforTask) object;
|
||||||
|
task.id = db.IncMaxTaskId();
|
||||||
|
if (account_db.InsertWithCheck_(task) != null)
|
||||||
|
PublishAction(task);
|
||||||
|
}
|
||||||
|
account_db.Commit();
|
||||||
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
|
break;
|
||||||
case DownloadSapforTasksPackage:
|
case DownloadSapforTasksPackage:
|
||||||
Print("Загрузить пакет тестов SAPFOR " + request.object + " для пользователя " + request.arg);
|
Print("Загрузить пакет тестов SAPFOR " + request.object + " для пользователя " + request.arg);
|
||||||
SetCurrentAccountDB(request.arg);
|
SetCurrentAccountDB(request.arg);
|
||||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
//---
|
//---
|
||||||
if (!account_db.sapforTasksPackages.containsKey(request.object))
|
if (!account_db.sapforTasksPackages.containsKey(request.object))
|
||||||
throw new RepositoryRefuseException("Не существует пакета с ключом "+Utils.Brackets(request.object));
|
throw new RepositoryRefuseException("Не существует пакета с ключом " + Utils.Brackets(request.object));
|
||||||
//--
|
//--
|
||||||
SapforTasksPackage sapforTasksPackage = account_db.sapforTasksPackages.get(request.object);
|
SapforTasksPackage sapforTasksPackage = account_db.sapforTasksPackages.get(request.object);
|
||||||
//---
|
//---
|
||||||
//1 - архивировать пакет.
|
//1 - архивировать пакет.
|
||||||
File packageArchive = new File(Global.SapforPackagesDirectory, sapforTasksPackage.id+".zip");
|
File packageArchive = SapforTasksPackageInterface.getPackageArchive(sapforTasksPackage);
|
||||||
Utils.forceDeleteWithCheck(packageArchive);
|
Utils.forceDeleteWithCheck(packageArchive);
|
||||||
//---
|
//---
|
||||||
ZipFolderPass zip = new ZipFolderPass();
|
ZipFolderPass zip = new ZipFolderPass();
|
||||||
@@ -377,7 +403,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
Print("Архив успешно запакован");
|
Print("Архив успешно запакован");
|
||||||
} else throw new RepositoryRefuseException("Не удалось запаковать архив пакета");
|
} else throw new RepositoryRefuseException("Не удалось запаковать архив пакета");
|
||||||
//---
|
//---
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SynchronizeTests:
|
case SynchronizeTests:
|
||||||
//временный проход. синхронизирует тесты на заданной машине, с сервера.
|
//временный проход. синхронизирует тесты на заданной машине, с сервера.
|
||||||
@@ -432,9 +457,9 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
case PublishAccountObjects:
|
case PublishAccountObjects:
|
||||||
Print("Опубликовать объекты для пользователя " + request.arg);
|
Print("Опубликовать объекты для пользователя " + request.arg);
|
||||||
SetCurrentAccountDB(request.arg);
|
SetCurrentAccountDB(request.arg);
|
||||||
Vector<Object> objects_ = (Vector<Object>) request.object;
|
Vector<Object> objects__ = (Vector<Object>) request.object;
|
||||||
account_db.BeginTransaction();
|
account_db.BeginTransaction();
|
||||||
for (Object object : objects_)
|
for (Object object : objects__)
|
||||||
if (account_db.InsertWithCheck_((DBObject) object) != null)
|
if (account_db.InsertWithCheck_((DBObject) object) != null)
|
||||||
PublishAction((DBObject) object);
|
PublishAction((DBObject) object);
|
||||||
account_db.Commit();
|
account_db.Commit();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class DownloadSapforTasksPackage extends TestingSystemPass<SapforTasksPac
|
|||||||
public String getButtonText() {
|
public String getButtonText() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
File packageArchive = null;
|
File tmpArchive = null;
|
||||||
@Override
|
@Override
|
||||||
protected boolean canStart(Object... args) throws Exception {
|
protected boolean canStart(Object... args) throws Exception {
|
||||||
if (Current.Check(Log, Current.SapforTasksPackage)) {
|
if (Current.Check(Log, Current.SapforTasksPackage)) {
|
||||||
@@ -32,11 +32,11 @@ public class DownloadSapforTasksPackage extends TestingSystemPass<SapforTasksPac
|
|||||||
@Override
|
@Override
|
||||||
protected void ServerAction() throws Exception {
|
protected void ServerAction() throws Exception {
|
||||||
Command(new ServerExchangeUnit_2021(ServerCode.DownloadSapforTasksPackage, Current.getAccount().email, target.id));
|
Command(new ServerExchangeUnit_2021(ServerCode.DownloadSapforTasksPackage, Current.getAccount().email, target.id));
|
||||||
response.Unpack(packageArchive = Utils.getTempFileName(target.id));
|
response.Unpack(tmpArchive = Utils.getTempFileName(target.id));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected boolean validate() {
|
protected boolean validate() {
|
||||||
return packageArchive !=null&& packageArchive.exists();
|
return tmpArchive != null && tmpArchive.exists();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void performDone() throws Exception {
|
protected void performDone() throws Exception {
|
||||||
@@ -44,9 +44,9 @@ public class DownloadSapforTasksPackage extends TestingSystemPass<SapforTasksPac
|
|||||||
File packageWorkspace = new File(Global.SapforPackagesDirectory, target.id);
|
File packageWorkspace = new File(Global.SapforPackagesDirectory, target.id);
|
||||||
Utils.forceDeleteWithCheck(packageWorkspace);
|
Utils.forceDeleteWithCheck(packageWorkspace);
|
||||||
if (passes.get(PassCode_2021.UnzipFolderPass).Do(
|
if (passes.get(PassCode_2021.UnzipFolderPass).Do(
|
||||||
packageArchive.getAbsolutePath(),
|
tmpArchive.getAbsolutePath(),
|
||||||
Global.SapforPackagesDirectory.getAbsolutePath(), false
|
Global.SapforPackagesDirectory.getAbsolutePath(), false
|
||||||
));
|
)) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user