запись результатов тестирования в бд
This commit is contained in:
@@ -4,12 +4,15 @@ import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.GlobalProperties;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Tasks.TaskState;
|
||||
import Repository.Server.ServerCode;
|
||||
import SapforTestingSystem.Json.SapforConfiguration_json;
|
||||
import SapforTestingSystem.Json.SapforTasksPackage_json;
|
||||
import SapforTestingSystem.Json.SapforTasksResults_json;
|
||||
import SapforTestingSystem.Json.SapforTest_json;
|
||||
import SapforTestingSystem.SapforConfiguration.SapforConfiguration;
|
||||
import SapforTestingSystem.SapforConfiguration.SapforConfigurationInterface;
|
||||
import SapforTestingSystem.SapforTask.SapforTask;
|
||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||
import TestingSystem.Group.Group;
|
||||
import TestingSystem.TasksPackage.TasksPackageState;
|
||||
@@ -139,9 +142,9 @@ public class SapforTasksPackageSupervisor {
|
||||
File done = new File(sapforTasksPackage.workspace, Constants.DONE);
|
||||
File aborted = new File(sapforTasksPackage.workspace, Constants.ABORTED);
|
||||
if (done.exists()) {
|
||||
sapforTasksPackage.state = TasksPackageState.Done;
|
||||
sapforTasksPackage.state = TasksPackageState.Analysis;
|
||||
planner.UpdateSapforPackage();
|
||||
System.out.println("package done");
|
||||
System.out.println("package done, start Analysis");
|
||||
} else if (aborted.exists()) {
|
||||
sapforTasksPackage.state = TasksPackageState.Aborted;
|
||||
planner.UpdateSapforPackage();
|
||||
@@ -171,6 +174,95 @@ public class SapforTasksPackageSupervisor {
|
||||
killer.waitFor();
|
||||
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 {
|
||||
if (packageNeedsKill()) {
|
||||
System.out.println("PACKAGE " + sapforTasksPackage.id + " NEEDS TO KILL");
|
||||
@@ -190,6 +282,11 @@ public class SapforTasksPackageSupervisor {
|
||||
case RunningExecution:
|
||||
CheckPackageState();
|
||||
break;
|
||||
case Analysis:
|
||||
AnalysePackage();
|
||||
sapforTasksPackage.state = TasksPackageState.Done;
|
||||
planner.UpdateSapforPackage();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user