рефакторинг серверной части сапфора.
This commit is contained in:
31
.idea/workspace.xml
generated
31
.idea/workspace.xml
generated
@@ -7,7 +7,36 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/DeleteTestingPackages.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/AbortTestingPackage.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/ActualizeTestingPackages.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AbortSapforPackage.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/DeleteSapforPackage.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforPackage.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/StartTestingPackage.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/TestingPackageToKill/TestingPackageToKill.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestingPackageToKill/TestingPackageToKill.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestingPlanner.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/Common/TestsDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestsDatabase.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforConfiguration_json.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforConfiguration_json.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforTasksPackage_json.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforTasksPackage_json.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforTasksResults_json.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforTasksResults_json.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforTest_json.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforTest_json.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforVersionState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/Json/SapforVersionState.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/SapforPackage/SapforPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforPackage/SapforPackage.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforPackage/SapforPackagesBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforPackage/SapforPackagesBar.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/TestingSystem/SAPFOR/SapforTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTestingPlanner.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AbortDVMPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AbortDVMPackage.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ActualizeDVMPackages.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ActualizeDVMPackages.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ActualizePackages.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ActualizePackages.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ActualizeSAPFORPackages.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ActualizeSapforPackages.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AddSapforPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AddSapforPackage.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartDVMPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartDVMPackage.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" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"PerformanceAnalyzerPath": "",
|
"PerformanceAnalyzerPath": "",
|
||||||
"ComponentsBackUpsCount": 10,
|
"ComponentsBackUpsCount": 10,
|
||||||
"TestingKernels": 28,
|
"TestingKernels": 28,
|
||||||
"AutoCheckTesting": false,
|
"AutoCheckTesting": true,
|
||||||
"CheckTestingIntervalSeconds": 10,
|
"CheckTestingIntervalSeconds": 10,
|
||||||
"EmailOnTestingProgress": false
|
"EmailOnTestingProgress": false
|
||||||
}
|
}
|
||||||
@@ -88,6 +88,6 @@ public enum ServerCode {
|
|||||||
// PublishTestProject
|
// PublishTestProject
|
||||||
GetFirstActiveDVMPackage,
|
GetFirstActiveDVMPackage,
|
||||||
DVMPackageNeedsKill, // не доделано.
|
DVMPackageNeedsKill, // не доделано.
|
||||||
UpdateActiveDVMPackages
|
UpdateActiveDVMPackages,
|
||||||
;
|
GetFirstActiveSapforPackage, SapforPackageNeedsKill, UpdateActiveSapforPackages;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,4 @@ public class TestingPackageToKill extends iDBObject {
|
|||||||
public int type = 0; // 0 - dvm /1 - sapfor
|
public int type = 0; // 0 - dvm /1 - sapfor
|
||||||
public TestingPackageToKill() {
|
public TestingPackageToKill() {
|
||||||
}
|
}
|
||||||
public TestingPackageToKill(DVMPackage dvmPackage) {
|
|
||||||
packageId = dvmPackage.id;
|
|
||||||
type = 0;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
public TestingPackagetoKill(SAPFORPackage sapforPackage){
|
|
||||||
packageId = sapforPackage.id;
|
|
||||||
type = 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,20 +90,6 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
|||||||
}
|
}
|
||||||
protected void Disconnect() {
|
protected void Disconnect() {
|
||||||
}
|
}
|
||||||
//---
|
|
||||||
/*
|
|
||||||
protected void CheckExecutionStates() throws Exception{
|
|
||||||
|
|
||||||
case CompilationWorkspacesCreation:
|
|
||||||
case CompilationPreparation:
|
|
||||||
case CompilationExecution:
|
|
||||||
case RunningWorkspacesCreation:
|
|
||||||
case RunningPreparation:
|
|
||||||
case RunningExecution:
|
|
||||||
if (CheckNextState()) UpdatePackage();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//жизненный цикл планировщика
|
//жизненный цикл планировщика
|
||||||
protected void Session() throws Exception {
|
protected void Session() throws Exception {
|
||||||
switch (testingPackage.state) {
|
switch (testingPackage.state) {
|
||||||
@@ -136,7 +122,6 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
|||||||
}
|
}
|
||||||
// ---
|
// ---
|
||||||
public void Perform() {
|
public void Perform() {
|
||||||
while (true) {
|
|
||||||
try {
|
try {
|
||||||
testingPackage = null;
|
testingPackage = null;
|
||||||
testingPackage = (P) ServerCommand(getActivePackageCode());
|
testingPackage = (P) ServerCommand(getActivePackageCode());
|
||||||
@@ -173,11 +158,11 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
|||||||
System.gc();
|
System.gc();
|
||||||
//--
|
//--
|
||||||
}
|
}
|
||||||
|
//else Print(this.getClass().getSimpleName()+": no active package found");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
Utils.sleep(getSleepMillis());
|
Utils.sleep(getSleepMillis());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
|||||||
import TestingSystem.DVM.UserConnection;
|
import TestingSystem.DVM.UserConnection;
|
||||||
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||||
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
|
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
|
||||||
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||||
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||||
import TestingSystem.SAPFOR.SapforTasksPackage.SapforPackageData;
|
import TestingSystem.SAPFOR.SapforTasksPackage.SapforPackageData;
|
||||||
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
|
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
|
||||||
|
import TestingSystem.SAPFOR.SapforTestingPlanner;
|
||||||
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
||||||
import Visual_DVM_2021.Passes.All.DownloadRepository;
|
import Visual_DVM_2021.Passes.All.DownloadRepository;
|
||||||
import Visual_DVM_2021.Passes.All.ZipFolderPass;
|
import Visual_DVM_2021.Passes.All.ZipFolderPass;
|
||||||
@@ -50,6 +52,149 @@ import java.util.*;
|
|||||||
|
|
||||||
import static Common.Constants.tests_db_name;
|
import static Common.Constants.tests_db_name;
|
||||||
public class TestingServer extends RepositoryServer<TestsDatabase> {
|
public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||||
|
@Override
|
||||||
|
public void beforePublishAction(DBObject object) throws Exception {
|
||||||
|
if (object instanceof TasksPackage) {
|
||||||
|
TasksPackage tasksPackage = (TasksPackage) object;
|
||||||
|
tasksPackage.id = db.IncKey(SettingName.DVMPackageMaxId);
|
||||||
|
} else if (object instanceof SapforTasksPackage) {
|
||||||
|
SapforTasksPackage sapforTasksPackage = (SapforTasksPackage) object;
|
||||||
|
sapforTasksPackage.id = db.IncKey(SettingName.SAPFORPackageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void afterPublishAction(DBObject object) throws Exception {
|
||||||
|
if (object instanceof TasksPackage) {
|
||||||
|
//объект уже вставлен.
|
||||||
|
TasksPackage tasksPackage = (TasksPackage) object;
|
||||||
|
//-
|
||||||
|
for (int group_id : tasksPackage.sorted_tasks.keySet()) {
|
||||||
|
if (db.groups.containsKey(group_id)) {
|
||||||
|
Group group = db.groups.get(group_id);
|
||||||
|
LinkedHashMap<Integer, Vector<TestCompilationTask>> group_tasks = tasksPackage.sorted_tasks.get((group_id));
|
||||||
|
for (int test_id : group_tasks.keySet()) {
|
||||||
|
if (db.tests.containsKey(test_id)) {
|
||||||
|
Test test = db.tests.get(test_id);
|
||||||
|
//---
|
||||||
|
for (TestCompilationTask task : group_tasks.get(test_id)) {
|
||||||
|
Print("принять задачу на компиляцию " + group_id + ":" + test_id + ":" + task.flags);
|
||||||
|
//Теперь эту задачу надо поставить в очередь. и вернуть пользователю, уже с id
|
||||||
|
task.state = TaskState.Waiting;
|
||||||
|
task.id = db.IncKey(SettingName.TaskMaxId);
|
||||||
|
task.taskspackage_id = tasksPackage.id;
|
||||||
|
task.makefile_text = group.GenerateMakefile(test, tasksPackage.dvm_drv, task.flags);
|
||||||
|
task.test_home = tasksPackage.user_workspace + "/projects/" + test_id;
|
||||||
|
//-->>
|
||||||
|
task.remote_workspace =
|
||||||
|
new RemoteFile(
|
||||||
|
tasksPackage.user_workspace + "/tests/" + tasksPackage.id,
|
||||||
|
String.valueOf(task.id), true).full_name;
|
||||||
|
account_db.Insert(task);
|
||||||
|
if (task.runTasks != null) {
|
||||||
|
for (TestRunTask rt : task.runTasks) {
|
||||||
|
rt.id = db.IncKey(SettingName.TaskMaxId);
|
||||||
|
rt.taskspackage_id = tasksPackage.id;
|
||||||
|
rt.testcompilationtask_id = task.id;
|
||||||
|
rt.remote_workspace =
|
||||||
|
new RemoteFile(
|
||||||
|
tasksPackage.user_workspace + "/tests/" + tasksPackage.id,
|
||||||
|
String.valueOf(rt.id), true).full_name;
|
||||||
|
rt.binary_name = "spf_" + rt.id + "_" + rt.matrix.replace(" ", "_");
|
||||||
|
account_db.Insert(rt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (object instanceof Test) {
|
||||||
|
Test test = (Test) object;
|
||||||
|
if (!test.unpackProjectOnServer()) {
|
||||||
|
db.Delete(test);
|
||||||
|
throw new RepositoryRefuseException(
|
||||||
|
"Не удалось прикрепить проект к тесту с id " + test.id
|
||||||
|
+ "\nТест будет удален"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (object instanceof DVMPackage) {
|
||||||
|
DVMPackage dvmPackage = (DVMPackage) object;
|
||||||
|
//--
|
||||||
|
Utils.CheckAndCleanDirectory(dvmPackage.getLocalWorkspace());
|
||||||
|
//--
|
||||||
|
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; // объект больше не нужен.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void afterDeleteAction(DBObject object) throws Exception {
|
||||||
|
if (object instanceof Test) {
|
||||||
|
Test test = (Test) object;
|
||||||
|
Utils.forceDeleteWithCheck(test.getArchive());
|
||||||
|
Utils.forceDeleteWithCheck(test.getServerPath());
|
||||||
|
} else if (object instanceof Group) {
|
||||||
|
Group group = (Group) object;
|
||||||
|
Vector<Test> tests = new Vector<>();
|
||||||
|
for (Test group_test : db.tests.Data.values()) {
|
||||||
|
if (group_test.group_id == group.id)
|
||||||
|
tests.add(group_test);
|
||||||
|
}
|
||||||
|
for (Test group_test : tests) {
|
||||||
|
db.Delete(group_test);
|
||||||
|
Utils.forceDeleteWithCheck(group_test.getArchive());
|
||||||
|
Utils.forceDeleteWithCheck(group_test.getServerPath());
|
||||||
|
}
|
||||||
|
} else if (object instanceof ServerSapfor) {
|
||||||
|
Utils.forceDeleteWithCheck(
|
||||||
|
new File(
|
||||||
|
((ServerSapfor) object).home_path
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (object instanceof SapforTasksPackage) {
|
||||||
|
SapforTasksPackage sapforTasksPackage = (SapforTasksPackage) object;
|
||||||
|
File workspace = new File(
|
||||||
|
sapforTasksPackage.workspace
|
||||||
|
);
|
||||||
|
System.out.println(Utils.Brackets(workspace.getAbsolutePath()));
|
||||||
|
Utils.forceDeleteWithCheck(workspace);
|
||||||
|
Utils.forceDeleteWithCheck(sapforTasksPackage.getArchive());
|
||||||
|
//внешние ключи не работают
|
||||||
|
Vector<SapforTask> tasks = new Vector<>();
|
||||||
|
for (SapforTask task : account_db.sapforTasks.Data.values()) {
|
||||||
|
if (task.sapfortaskspackage_id == sapforTasksPackage.id) // todo group_name -> group_id
|
||||||
|
tasks.add(task);
|
||||||
|
}
|
||||||
|
for (SapforTask task : tasks) {
|
||||||
|
account_db.Delete(task);
|
||||||
|
}
|
||||||
|
} else if (object instanceof SapforConfiguration) {
|
||||||
|
SapforConfiguration sapforConfiguration = (SapforConfiguration) object;
|
||||||
|
Vector<SapforConfigurationCommand> commands = new Vector<>();
|
||||||
|
for (SapforConfigurationCommand command : db.sapforConfigurationCommands.Data.values()) {
|
||||||
|
if (command.sapforconfiguration_id == sapforConfiguration.id)
|
||||||
|
commands.add(command);
|
||||||
|
}
|
||||||
|
for (SapforConfigurationCommand command : commands) {
|
||||||
|
db.Delete(command);
|
||||||
|
}
|
||||||
|
} else if (object instanceof DVMPackage) {
|
||||||
|
DVMPackage dvmPackage = (DVMPackage) object;
|
||||||
|
File workspace = dvmPackage.getLocalWorkspace();
|
||||||
|
Utils.forceDeleteWithCheck(workspace);
|
||||||
|
} else if (object instanceof SapforPackage) {
|
||||||
|
SapforPackage sapforPackage = (SapforPackage) object;
|
||||||
|
File workspace = sapforPackage.getLocalWorkspace();
|
||||||
|
Utils.forceDeleteWithCheck(workspace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-->>>
|
||||||
LinkedHashMap<String, TasksDatabase> accountsBases = new LinkedHashMap<>();
|
LinkedHashMap<String, TasksDatabase> accountsBases = new LinkedHashMap<>();
|
||||||
//--------------------------------->>>
|
//--------------------------------->>>
|
||||||
public TestingServer() {
|
public TestingServer() {
|
||||||
@@ -109,8 +254,16 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
protected TestingPlanner_OLD testingPlannerOLD = new TestingPlanner_OLD();
|
protected TestingPlanner_OLD testingPlannerOLD = new TestingPlanner_OLD();
|
||||||
protected Thread testingThread = new Thread(() -> testingPlannerOLD.Perform());
|
protected Thread testingThread = new Thread(() -> testingPlannerOLD.Perform());
|
||||||
//---
|
//---
|
||||||
protected DVMTestingPlanner DVMTestingPlanner_ = new DVMTestingPlanner();
|
protected DVMTestingPlanner DVMTestingPlanner = new DVMTestingPlanner();
|
||||||
protected Thread testingThread_2023 = new Thread(() -> DVMTestingPlanner_.Perform());
|
protected SapforTestingPlanner sapforTestingPlanner = new SapforTestingPlanner();
|
||||||
|
//--
|
||||||
|
protected Thread testingThread_2023 = new Thread(() -> {
|
||||||
|
while (true) {
|
||||||
|
DVMTestingPlanner.Perform();
|
||||||
|
sapforTestingPlanner.Perform();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//------>>>
|
||||||
//------>>>
|
//------>>>
|
||||||
public static Timer checkTimer = null;
|
public static Timer checkTimer = null;
|
||||||
public static void TimerOn() {
|
public static void TimerOn() {
|
||||||
@@ -380,13 +533,25 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
GetFirstActiveDVMPackage();
|
GetFirstActiveDVMPackage();
|
||||||
break;
|
break;
|
||||||
case DVMPackageNeedsKill:
|
case DVMPackageNeedsKill:
|
||||||
Print("Проверить нуждает ли пакет DVM в убийстве");
|
Print("Проверить нуждается ли пакет DVM в убийстве");
|
||||||
DVMPackageNeedsKill();
|
DVMPackageNeedsKill();
|
||||||
break;
|
break;
|
||||||
case UpdateActiveDVMPackages:
|
case UpdateActiveDVMPackages:
|
||||||
Print("Получить данные по пакетам DVM");
|
Print("Получить данные по пакетам DVM");
|
||||||
UpdateActiveDVMPackages();
|
UpdateActiveDVMPackages();
|
||||||
break;
|
break;
|
||||||
|
case GetFirstActiveSapforPackage:
|
||||||
|
Print("Получить первый активный пакет задач SAPFOR");
|
||||||
|
GetFirstActiveSapforPackage();
|
||||||
|
break;
|
||||||
|
case SapforPackageNeedsKill:
|
||||||
|
Print("Проверить нуждает ли пакет SAPFOR в убийстве");
|
||||||
|
SapforPackageNeedsKill();
|
||||||
|
break;
|
||||||
|
case UpdateActiveSapforPackages:
|
||||||
|
Print("Получить данные по пакетам Sapfor");
|
||||||
|
UpdateActiveSapforPackages();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
|
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
|
||||||
}
|
}
|
||||||
@@ -539,137 +704,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
SetCurrentAccountDB(request.arg);
|
SetCurrentAccountDB(request.arg);
|
||||||
return account_db;
|
return account_db;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void beforePublishAction(DBObject object) throws Exception {
|
|
||||||
if (object instanceof TasksPackage) {
|
|
||||||
TasksPackage tasksPackage = (TasksPackage) object;
|
|
||||||
tasksPackage.id = db.IncKey(SettingName.DVMPackageMaxId);
|
|
||||||
} else if (object instanceof SapforTasksPackage) {
|
|
||||||
SapforTasksPackage sapforTasksPackage = (SapforTasksPackage) object;
|
|
||||||
sapforTasksPackage.id = db.IncKey(SettingName.SAPFORPackageId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void afterPublishAction(DBObject object) throws Exception {
|
|
||||||
if (object instanceof TasksPackage) {
|
|
||||||
//объект уже вставлен.
|
|
||||||
TasksPackage tasksPackage = (TasksPackage) object;
|
|
||||||
//-
|
|
||||||
for (int group_id : tasksPackage.sorted_tasks.keySet()) {
|
|
||||||
if (db.groups.containsKey(group_id)) {
|
|
||||||
Group group = db.groups.get(group_id);
|
|
||||||
LinkedHashMap<Integer, Vector<TestCompilationTask>> group_tasks = tasksPackage.sorted_tasks.get((group_id));
|
|
||||||
for (int test_id : group_tasks.keySet()) {
|
|
||||||
if (db.tests.containsKey(test_id)) {
|
|
||||||
Test test = db.tests.get(test_id);
|
|
||||||
//---
|
|
||||||
for (TestCompilationTask task : group_tasks.get(test_id)) {
|
|
||||||
Print("принять задачу на компиляцию " + group_id + ":" + test_id + ":" + task.flags);
|
|
||||||
//Теперь эту задачу надо поставить в очередь. и вернуть пользователю, уже с id
|
|
||||||
task.state = TaskState.Waiting;
|
|
||||||
task.id = db.IncKey(SettingName.TaskMaxId);
|
|
||||||
task.taskspackage_id = tasksPackage.id;
|
|
||||||
task.makefile_text = group.GenerateMakefile(test, tasksPackage.dvm_drv, task.flags);
|
|
||||||
task.test_home = tasksPackage.user_workspace + "/projects/" + test_id;
|
|
||||||
//-->>
|
|
||||||
task.remote_workspace =
|
|
||||||
new RemoteFile(
|
|
||||||
tasksPackage.user_workspace + "/tests/" + tasksPackage.id,
|
|
||||||
String.valueOf(task.id), true).full_name;
|
|
||||||
account_db.Insert(task);
|
|
||||||
if (task.runTasks != null) {
|
|
||||||
for (TestRunTask rt : task.runTasks) {
|
|
||||||
rt.id = db.IncKey(SettingName.TaskMaxId);
|
|
||||||
rt.taskspackage_id = tasksPackage.id;
|
|
||||||
rt.testcompilationtask_id = task.id;
|
|
||||||
rt.remote_workspace =
|
|
||||||
new RemoteFile(
|
|
||||||
tasksPackage.user_workspace + "/tests/" + tasksPackage.id,
|
|
||||||
String.valueOf(rt.id), true).full_name;
|
|
||||||
rt.binary_name = "spf_" + rt.id + "_" + rt.matrix.replace(" ", "_");
|
|
||||||
account_db.Insert(rt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (object instanceof Test) {
|
|
||||||
Test test = (Test) object;
|
|
||||||
if (!test.unpackProjectOnServer()) {
|
|
||||||
db.Delete(test);
|
|
||||||
throw new RepositoryRefuseException(
|
|
||||||
"Не удалось прикрепить проект к тесту с id " + test.id
|
|
||||||
+ "\nТест будет удален"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else if (object instanceof DVMPackage) {
|
|
||||||
DVMPackage dvmPackage = (DVMPackage) object;
|
|
||||||
//--
|
|
||||||
Utils.CheckAndCleanDirectory(dvmPackage.getLocalWorkspace());
|
|
||||||
//--
|
|
||||||
dvmPackage.saveJson();
|
|
||||||
dvmPackage.package_json = null; // объект больше не нужен.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void afterDeleteAction(DBObject object) throws Exception {
|
|
||||||
if (object instanceof Test) {
|
|
||||||
Test test = (Test) object;
|
|
||||||
Utils.forceDeleteWithCheck(test.getArchive());
|
|
||||||
Utils.forceDeleteWithCheck(test.getServerPath());
|
|
||||||
} else if (object instanceof Group) {
|
|
||||||
Group group = (Group) object;
|
|
||||||
Vector<Test> tests = new Vector<>();
|
|
||||||
for (Test group_test : db.tests.Data.values()) {
|
|
||||||
if (group_test.group_id == group.id)
|
|
||||||
tests.add(group_test);
|
|
||||||
}
|
|
||||||
for (Test group_test : tests) {
|
|
||||||
db.Delete(group_test);
|
|
||||||
Utils.forceDeleteWithCheck(group_test.getArchive());
|
|
||||||
Utils.forceDeleteWithCheck(group_test.getServerPath());
|
|
||||||
}
|
|
||||||
} else if (object instanceof ServerSapfor) {
|
|
||||||
Utils.forceDeleteWithCheck(
|
|
||||||
new File(
|
|
||||||
((ServerSapfor) object).home_path
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else if (object instanceof SapforTasksPackage) {
|
|
||||||
SapforTasksPackage sapforTasksPackage = (SapforTasksPackage) object;
|
|
||||||
File workspace = new File(
|
|
||||||
sapforTasksPackage.workspace
|
|
||||||
);
|
|
||||||
System.out.println(Utils.Brackets(workspace.getAbsolutePath()));
|
|
||||||
Utils.forceDeleteWithCheck(workspace);
|
|
||||||
Utils.forceDeleteWithCheck(sapforTasksPackage.getArchive());
|
|
||||||
//внешние ключи не работают
|
|
||||||
Vector<SapforTask> tasks = new Vector<>();
|
|
||||||
for (SapforTask task : account_db.sapforTasks.Data.values()) {
|
|
||||||
if (task.sapfortaskspackage_id == sapforTasksPackage.id) // todo group_name -> group_id
|
|
||||||
tasks.add(task);
|
|
||||||
}
|
|
||||||
for (SapforTask task : tasks) {
|
|
||||||
account_db.Delete(task);
|
|
||||||
}
|
|
||||||
} else if (object instanceof SapforConfiguration) {
|
|
||||||
SapforConfiguration sapforConfiguration = (SapforConfiguration) object;
|
|
||||||
Vector<SapforConfigurationCommand> commands = new Vector<>();
|
|
||||||
for (SapforConfigurationCommand command : db.sapforConfigurationCommands.Data.values()) {
|
|
||||||
if (command.sapforconfiguration_id == sapforConfiguration.id)
|
|
||||||
commands.add(command);
|
|
||||||
}
|
|
||||||
for (SapforConfigurationCommand command : commands) {
|
|
||||||
db.Delete(command);
|
|
||||||
}
|
|
||||||
} else if (object instanceof DVMPackage) {
|
|
||||||
DVMPackage dvmPackage = (DVMPackage) object;
|
|
||||||
File workspace = new File(Global.PackagesDirectory, String.valueOf(dvmPackage.id));
|
|
||||||
Utils.forceDeleteWithCheck(workspace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------------------------->>>
|
//---------------------------------------------------------------------------------------------->>>
|
||||||
//устарели. убрать.
|
//устарели. убрать.
|
||||||
void ActualizeDVMPackages() throws Exception {
|
void ActualizeDVMPackages() throws Exception {
|
||||||
@@ -736,6 +770,15 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
response.object = new DVMPackage(dvmPackage);
|
response.object = new DVMPackage(dvmPackage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void GetFirstActiveSapforPackage() throws Exception {
|
||||||
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
|
response.object = null;
|
||||||
|
SapforPackage sapforPackage = db.getFirstActiveSapforPackage();
|
||||||
|
if (sapforPackage != null) {
|
||||||
|
//нужно вернуть копию объекта с иным адресом!!
|
||||||
|
response.object = new SapforPackage(sapforPackage);
|
||||||
|
}
|
||||||
|
}
|
||||||
//---
|
//---
|
||||||
void UpdateActiveDVMPackages() throws Exception {
|
void UpdateActiveDVMPackages() throws Exception {
|
||||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
@@ -751,6 +794,20 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
}
|
}
|
||||||
response.object = res;
|
response.object = res;
|
||||||
}
|
}
|
||||||
|
private void UpdateActiveSapforPackages() {
|
||||||
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
|
Vector<Pair<Integer, Long>> keys_pairs = (Vector<Pair<Integer, Long>>) request.object;
|
||||||
|
Vector<SapforPackage> res = new Vector<>();
|
||||||
|
//--
|
||||||
|
for (Pair<Integer, Long> p : keys_pairs) {
|
||||||
|
if (db.sapforPackages.containsKey(p.getKey())) {
|
||||||
|
SapforPackage actual = db.sapforPackages.get(p.getKey());
|
||||||
|
if (actual.ChangeDate != p.getValue())
|
||||||
|
res.add(new SapforPackage(actual));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.object = res;
|
||||||
|
}
|
||||||
private void DVMPackageNeedsKill() {
|
private void DVMPackageNeedsKill() {
|
||||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
int packageId = (int) request.object;
|
int packageId = (int) request.object;
|
||||||
@@ -763,4 +820,16 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
}
|
}
|
||||||
response.object = res_;
|
response.object = res_;
|
||||||
}
|
}
|
||||||
|
private void SapforPackageNeedsKill() throws Exception {
|
||||||
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
|
int packageId = (int) request.object;
|
||||||
|
boolean res_ = false;
|
||||||
|
for (TestingPackageToKill packageToKill : db.testingPackagesToKill.Data.values()) {
|
||||||
|
if ((packageToKill.packageId == packageId) && (packageToKill.type == 1)) {
|
||||||
|
res_ = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.object = res_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ import TestingSystem.DVM.DVMPackage.DVMPackageDBTable;
|
|||||||
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||||
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfigurationDBTable;
|
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfigurationDBTable;
|
||||||
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommandsDBTable;
|
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommandsDBTable;
|
||||||
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||||
import TestingSystem.SAPFOR.SapforPackage.SapforPackageDBTable;
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackageDBTable;
|
||||||
|
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
|
||||||
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforsDBTable;
|
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforsDBTable;
|
||||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
|
|
||||||
@@ -105,4 +107,34 @@ public class TestsDatabase extends SQLiteDatabase {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public SapforPackage getFirstActiveSapforPackage() {
|
||||||
|
SapforPackage first_active = null;
|
||||||
|
SapforPackage first_queued = null;
|
||||||
|
if (!sapforPackages.Data.isEmpty()) {
|
||||||
|
for (SapforPackage p : sapforPackages.Data.values()) {
|
||||||
|
switch (p.state) {
|
||||||
|
case Done:
|
||||||
|
case Aborted:
|
||||||
|
break;
|
||||||
|
case Queued:
|
||||||
|
if (first_queued == null) first_queued = p;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (first_active == null) first_active = p; //это и будет первый активный.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (first_active != null) return first_active;
|
||||||
|
if (first_queued != null) {
|
||||||
|
first_queued.state = TasksPackageState.TestsSynchronize;
|
||||||
|
try {
|
||||||
|
Update(first_queued);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return first_queued;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import Common.Constants;
|
|||||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
public class SapforConfiguration_json {
|
public class SapforConfiguration_json implements Serializable {
|
||||||
@Expose
|
@Expose
|
||||||
public int id = Constants.Nan;
|
public int id = Constants.Nan;
|
||||||
@Expose
|
@Expose
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package TestingSystem.SAPFOR.Json;
|
package TestingSystem.SAPFOR.Json;
|
||||||
|
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||||
|
import TestingSystem.SAPFOR.SapforTasksPackage.UI.PackageSummary;
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
public class SapforTasksPackage_json {
|
public class SapforTasksPackage_json implements Serializable {
|
||||||
@Expose
|
@Expose
|
||||||
public int kernels = 1;
|
public int kernels = 1;
|
||||||
@Expose
|
@Expose
|
||||||
@@ -12,4 +15,7 @@ public class SapforTasksPackage_json {
|
|||||||
public List<SapforTest_json> tests = new Vector<>();
|
public List<SapforTest_json> tests = new Vector<>();
|
||||||
@Expose
|
@Expose
|
||||||
public List<SapforConfiguration_json> configurations = new Vector<>();
|
public List<SapforConfiguration_json> configurations = new Vector<>();
|
||||||
|
//---
|
||||||
|
@Expose
|
||||||
|
public List<SapforTask> tasks = new Vector<>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import com.google.gson.annotations.Expose;
|
|||||||
|
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
public class SapforTasksResults_json {
|
public class SapforTasksResults_json implements Serializable {
|
||||||
//---
|
//---
|
||||||
public PackageSummary root = null;
|
public PackageSummary root = null;
|
||||||
public PackageSummary comparison_root = null;
|
public PackageSummary comparison_root = null;
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package TestingSystem.SAPFOR.Json;
|
package TestingSystem.SAPFOR.Json;
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
public class SapforTest_json {
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
public class SapforTest_json implements Serializable {
|
||||||
@Expose
|
@Expose
|
||||||
public String test_description = "";
|
public int id;
|
||||||
|
@Expose
|
||||||
|
public String description = "";
|
||||||
@Expose
|
@Expose
|
||||||
public String group_description = "";
|
public String group_description = "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package TestingSystem.SAPFOR.Json;
|
package TestingSystem.SAPFOR.Json;
|
||||||
public enum SapforVersionState {
|
import java.io.Serializable;
|
||||||
|
public enum SapforVersionState implements Serializable {
|
||||||
Empty, //версия оказалась пуста.
|
Empty, //версия оказалась пуста.
|
||||||
Normal, //версия построена
|
Normal, //версия построена
|
||||||
HasErrors //в журнале версии есть ошибки. то есть, не удалось построить следующую версию.
|
HasErrors //в журнале версии есть ошибки. то есть, не удалось построить следующую версию.
|
||||||
|
|||||||
@@ -13,31 +13,42 @@ import Visual_DVM_2021.Passes.PassCode_2021;
|
|||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
public class PackageModeSupervisor extends ThreadsPlanner {
|
public class PackageModeSupervisor extends ThreadsPlanner {
|
||||||
SapforTasksPackage_json package_json = null;
|
SapforTasksPackage_json package_json = null;
|
||||||
SapforTasksResults_json results_json = new SapforTasksResults_json();
|
File sapfor_drv=null;
|
||||||
|
|
||||||
public PackageModeSupervisor() throws Exception {
|
public PackageModeSupervisor() throws Exception {
|
||||||
super(2000);
|
super(2000);
|
||||||
package_json = (SapforTasksPackage_json) Utils.jsonFromFile(new File(Global.Home, Constants.package_json), SapforTasksPackage_json.class);
|
package_json = (SapforTasksPackage_json) Utils.jsonFromFile(new File(Constants.package_json), SapforTasksPackage_json.class);
|
||||||
|
//--
|
||||||
|
File sapfor_src = new File(package_json.sapfor_drv);
|
||||||
|
sapfor_drv = new File(Global.Home,Utils.getDateName("SAPFOR_F"));
|
||||||
|
FileUtils.copyFile(sapfor_src, sapfor_drv);
|
||||||
|
if (!sapfor_drv.setExecutable(true))
|
||||||
|
throw new Exception("Не удалось сделать файл " + sapfor_drv.getName() + " исполняемым!");
|
||||||
|
File PID = new File( "PID");
|
||||||
|
FileUtils.writeStringToFile(PID, sapfor_drv.getName(), Charset.defaultCharset());
|
||||||
|
//---
|
||||||
Date startDate = new Date();
|
Date startDate = new Date();
|
||||||
results_json.StartDate = startDate.getTime();
|
|
||||||
File started = new File(Constants.STARTED);
|
File started = new File(Constants.STARTED);
|
||||||
FileUtils.writeStringToFile(started, String.valueOf(startDate));
|
FileUtils.writeStringToFile(started, String.valueOf(startDate));
|
||||||
//формирование списка задач.
|
//формирование списка задач.
|
||||||
File sapfor_drv = new File(Global.Home, package_json.sapfor_drv);
|
|
||||||
setMaxKernels(package_json.kernels);
|
setMaxKernels(package_json.kernels);
|
||||||
|
int max_rask_id=0;
|
||||||
for (SapforConfiguration_json sapforConfiguration_json : package_json.configurations) {
|
for (SapforConfiguration_json sapforConfiguration_json : package_json.configurations) {
|
||||||
for (SapforTest_json test : package_json.tests) {
|
for (SapforTest_json test : package_json.tests) {
|
||||||
//--- чтобы было можно на нее сослаться после выполнения всех нитей.
|
//--- чтобы было можно на нее сослаться после выполнения всех нитей.
|
||||||
SapforTask task = new SapforTask();
|
SapforTask task = new SapforTask();
|
||||||
|
task.id = max_rask_id++;
|
||||||
task.group_description = test.group_description;
|
task.group_description = test.group_description;
|
||||||
task.test_description = test.test_description;
|
task.test_description = test.description;
|
||||||
task.flags = sapforConfiguration_json.flags;
|
task.flags = sapforConfiguration_json.flags;
|
||||||
task.sapfor_configuration_id = sapforConfiguration_json.id;
|
task.sapfor_configuration_id = sapforConfiguration_json.id;
|
||||||
task.sapfortaskspackage_id = Integer.parseInt(new File(Global.Home).getName());
|
task.sapfortaskspackage_id = Integer.parseInt(new File(Global.Home).getName());
|
||||||
results_json.tasks.add(task);
|
package_json.tasks.add(task);
|
||||||
Vector<String> codes_s = new Vector<>();
|
Vector<String> codes_s = new Vector<>();
|
||||||
for (PassCode_2021 code : sapforConfiguration_json.codes) {
|
for (PassCode_2021 code : sapforConfiguration_json.codes) {
|
||||||
codes_s.add(code.toString());
|
codes_s.add(code.toString());
|
||||||
@@ -56,11 +67,22 @@ public class PackageModeSupervisor extends ThreadsPlanner {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() {
|
protected void finalize() {
|
||||||
results_json.EndDate = new Date().getTime();
|
|
||||||
//записать результаты всех задач.
|
//записать результаты всех задач.
|
||||||
try {
|
try {
|
||||||
Utils.jsonToFile(results_json, new File(Global.Home, Constants.results_json));
|
Utils.jsonToFile(package_json, new File(Constants.package_json));
|
||||||
FileUtils.writeStringToFile(new File(Constants.DONE), "");
|
FileUtils.writeStringToFile(new File(Constants.DONE), "");
|
||||||
|
//--
|
||||||
|
//Очистка
|
||||||
|
|
||||||
|
//очистка служебных файлов.
|
||||||
|
Utils.deleteFilesByExtensions(new File(Global.Home),
|
||||||
|
"proj", "dep", "jar"
|
||||||
|
// ,"sh", "exe", "bat"
|
||||||
|
);
|
||||||
|
//удаление сапфора
|
||||||
|
|
||||||
|
if (sapfor_drv.exists())
|
||||||
|
FileUtils.forceDelete(sapfor_drv);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Global.Log.PrintException(e);
|
Global.Log.PrintException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package TestingSystem.SAPFOR.SapforPackage;
|
package TestingSystem.SAPFOR.SapforPackage;
|
||||||
import Common.Constants;
|
import Common.Constants;
|
||||||
|
import Common.Database.DBObject;
|
||||||
import Common.Global;
|
import Common.Global;
|
||||||
import TestingSystem.Common.TestingPackage.TestingPackage;
|
import TestingSystem.Common.TestingPackage.TestingPackage;
|
||||||
import TestingSystem.SAPFOR.Json.SapforTasksResults_json;
|
import TestingSystem.SAPFOR.Json.SapforTasksPackage_json;
|
||||||
import com.sun.org.glassfish.gmbal.Description;
|
import com.sun.org.glassfish.gmbal.Description;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
public class SapforPackage extends TestingPackage {
|
public class SapforPackage extends TestingPackage<SapforTasksPackage_json> {
|
||||||
@Description("DEFAULT ''")
|
@Description("DEFAULT ''")
|
||||||
public String testsNames = "";//имена тестов через ; для отображения
|
public String testsNames = "";//имена тестов через ; для отображения
|
||||||
//---
|
//---
|
||||||
@@ -15,9 +16,24 @@ public class SapforPackage extends TestingPackage {
|
|||||||
public String testsIds = "";
|
public String testsIds = "";
|
||||||
@Description("DEFAULT ''")
|
@Description("DEFAULT ''")
|
||||||
public String configurationsIds = "";
|
public String configurationsIds = "";
|
||||||
|
public SapforPackage(){
|
||||||
|
|
||||||
|
}
|
||||||
|
public SapforPackage(SapforPackage sapforPackage) {
|
||||||
|
SynchronizeFields(sapforPackage);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void SynchronizeFields(DBObject src) {
|
||||||
|
super.SynchronizeFields(src);
|
||||||
|
SapforPackage p = (SapforPackage) src;
|
||||||
|
testsNames = p.testsNames;
|
||||||
|
sapforId = p.sapforId;
|
||||||
|
testsIds = p.testsIds;
|
||||||
|
configurationsIds = p.configurationsIds;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public Class getJsonClass() {
|
public Class getJsonClass() {
|
||||||
return SapforTasksResults_json.class;
|
return SapforTasksPackage_json.class;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public File getHomeDirectory() {
|
public File getHomeDirectory() {
|
||||||
|
|||||||
@@ -3,10 +3,11 @@ import Common.UI.Menus_2023.DataMenuBar;
|
|||||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
public class SapforPackagesBar extends DataMenuBar {
|
public class SapforPackagesBar extends DataMenuBar {
|
||||||
public SapforPackagesBar() {
|
public SapforPackagesBar() {
|
||||||
super("пакеты задач SAPFOR"
|
super("пакеты задач SAPFOR",
|
||||||
//, PassCode_2021.AddSapforPackage
|
PassCode_2021.AddSapforPackage,
|
||||||
// PassCode_2021.AbortSapforTaskPackage,
|
PassCode_2021.StartSapforPackage,
|
||||||
// PassCode_2021.DeleteSapforTasksPackage
|
PassCode_2021.AbortSapforPackage,
|
||||||
);
|
PassCode_2021.DeleteSapforPackage
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class SapforTasksPackageSupervisor {
|
|||||||
package_json.kernels = sapforTasksPackage.kernels;
|
package_json.kernels = sapforTasksPackage.kernels;
|
||||||
for (Test test : data.tests.values()) {
|
for (Test test : data.tests.values()) {
|
||||||
SapforTest_json test_json = new SapforTest_json();
|
SapforTest_json test_json = new SapforTest_json();
|
||||||
test_json.test_description = test.description;
|
test_json.description = test.description;
|
||||||
test_json.group_description = data.groups.get(test.group_id).description;
|
test_json.group_description = data.groups.get(test.group_id).description;
|
||||||
package_json.tests.add(test_json);
|
package_json.tests.add(test_json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,125 @@
|
|||||||
package TestingSystem.SAPFOR;
|
package TestingSystem.SAPFOR;
|
||||||
public class SapforTestingPlanner {
|
import Common.Constants;
|
||||||
|
import Common.Current;
|
||||||
|
import Common.Global;
|
||||||
|
import Common.GlobalProperties;
|
||||||
|
import Common.Utils.Utils;
|
||||||
|
import Repository.Server.ServerCode;
|
||||||
|
import TestingSystem.Common.TestingPlanner;
|
||||||
|
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||||
|
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
||||||
|
import TestingSystem.SAPFOR.Json.SapforTest_json;
|
||||||
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
||||||
|
File workspace;
|
||||||
|
@Override
|
||||||
|
protected ServerCode getActivePackageCode() {
|
||||||
|
return ServerCode.GetFirstActiveSapforPackage;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected ServerCode getCheckIfNeedsKillCode() {
|
||||||
|
return ServerCode.SapforPackageNeedsKill;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected TasksPackageState getStateAfterStart() {
|
||||||
|
return TasksPackageState.RunningExecution;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void InitSessionCredentials() {
|
||||||
|
workspace = testingPackage.getLocalWorkspace();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void TestsSynchronize() throws Exception {
|
||||||
|
testingPackage.readJson();
|
||||||
|
//--
|
||||||
|
//копирование тестов по конфигурациям.
|
||||||
|
for (SapforConfiguration_json configuration_json : testingPackage.package_json.configurations) {
|
||||||
|
//--
|
||||||
|
//-->>
|
||||||
|
File configurationWorkspace = new File(workspace, String.valueOf(configuration_json.id));
|
||||||
|
FileUtils.forceMkdir(configurationWorkspace);
|
||||||
|
//--->>>
|
||||||
|
for (SapforTest_json test_json : testingPackage.package_json.tests) {
|
||||||
|
File test_root = new File(configurationWorkspace, test_json.description);
|
||||||
|
Utils.CheckAndCleanDirectory(test_root);
|
||||||
|
FileUtils.copyDirectory(new File(Global.TestsDirectory, String.valueOf(test_json.id)), test_root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void PackageWorkspaceCreation() throws Exception {
|
||||||
|
//копирование визуализатора
|
||||||
|
File visualiser = new File(workspace, "VisualSapfor.jar");
|
||||||
|
FileUtils.copyFile(new File(Global.Home, "TestingSystem.jar"), visualiser);
|
||||||
|
//создание настроек
|
||||||
|
GlobalProperties properties = new GlobalProperties();
|
||||||
|
properties.Mode = Current.Mode.Package;
|
||||||
|
Utils.jsonToFile(properties, new File(workspace, "properties"));
|
||||||
|
//подготовка пакетного режима. Запустит его уже очередь.
|
||||||
|
Utils.createScript(workspace, workspace, "start", "java -jar VisualSapfor.jar");
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void PackageStart() throws Exception {
|
||||||
|
File script = new File(workspace, "start");
|
||||||
|
ProcessBuilder procBuilder = new ProcessBuilder(script.getAbsolutePath());
|
||||||
|
procBuilder.directory(workspace);
|
||||||
|
procBuilder.start();
|
||||||
|
//--->>
|
||||||
|
File started = new File(workspace, Constants.STARTED);
|
||||||
|
while (!started.exists()) {
|
||||||
|
Print("waiting for package start...");
|
||||||
|
Utils.sleep(1000);
|
||||||
|
}
|
||||||
|
File pid = new File(workspace,"PID");
|
||||||
|
testingPackage.PID = FileUtils.readFileToString(pid, Charset.defaultCharset());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected boolean CheckNextState() throws Exception {
|
||||||
|
File workspace = testingPackage.getLocalWorkspace();
|
||||||
|
File done = new File(workspace, Constants.DONE);
|
||||||
|
File aborted = new File(workspace, Constants.ABORTED);
|
||||||
|
if (done.exists()) {
|
||||||
|
testingPackage.state = TasksPackageState.Analysis;
|
||||||
|
return true;
|
||||||
|
} else if (aborted.exists()) {
|
||||||
|
testingPackage.state = TasksPackageState.Aborted;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void DownloadResults() throws Exception {
|
||||||
|
//не требуется.
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void AnalyseResults() throws Exception {
|
||||||
|
//не требуется.
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void Kill() throws Exception {
|
||||||
|
File workspace = testingPackage.getLocalWorkspace();
|
||||||
|
//----
|
||||||
|
File interrupt_file = new File(workspace, Constants.INTERRUPT);
|
||||||
|
//----
|
||||||
|
FileUtils.writeStringToFile(interrupt_file, new Date().toString());
|
||||||
|
File aborted_file = new File(workspace, Constants.ABORTED);
|
||||||
|
do {
|
||||||
|
Print("waiting for interrupt...");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} while (!aborted_file.exists());
|
||||||
|
Print("coup de grace..");
|
||||||
|
String kill_command = "killall -SIGKILL " + testingPackage.PID;
|
||||||
|
Print(kill_command);
|
||||||
|
Process killer = Runtime.getRuntime().exec(kill_command);
|
||||||
|
killer.waitFor();
|
||||||
|
Print("done!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
44
src/Visual_DVM_2021/Passes/AbortTestingPackage.java
Normal file
44
src/Visual_DVM_2021/Passes/AbortTestingPackage.java
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package Visual_DVM_2021.Passes;
|
||||||
|
import Common.Current;
|
||||||
|
import Repository.Server.ServerCode;
|
||||||
|
import Repository.Server.ServerExchangeUnit_2021;
|
||||||
|
import TestingSystem.Common.TestingPackage.TestingPackage;
|
||||||
|
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||||
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||||
|
public abstract class AbortTestingPackage extends TestingSystemPass<TestingPackage> {
|
||||||
|
TestingPackageToKill packageToKill = null;
|
||||||
|
@Override
|
||||||
|
public String getIconPath() {
|
||||||
|
return "/icons/Ban.PNG";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getButtonText() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
public abstract Current currentName();
|
||||||
|
public abstract int getAbortType();
|
||||||
|
@Override
|
||||||
|
protected boolean canStart(Object... args) throws Exception {
|
||||||
|
packageToKill = null;
|
||||||
|
if (Current.Check(Log, currentName())) {
|
||||||
|
target = (TestingPackage) Current.get(currentName());
|
||||||
|
switch (target.state) {
|
||||||
|
case Done:
|
||||||
|
case Aborted:
|
||||||
|
Log.Writeln_("Пакет уже завершен.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
packageToKill = new TestingPackageToKill();
|
||||||
|
packageToKill.packageId = target.id;
|
||||||
|
packageToKill.type = getAbortType();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void ServerAction() throws Exception {
|
||||||
|
Command(new ServerExchangeUnit_2021(ServerCode.PublishObject, null, packageToKill));
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/Visual_DVM_2021/Passes/ActualizeTestingPackages.java
Normal file
55
src/Visual_DVM_2021/Passes/ActualizeTestingPackages.java
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package Visual_DVM_2021.Passes;
|
||||||
|
import Common.Database.iDBTable;
|
||||||
|
import Common.Global;
|
||||||
|
import Repository.Server.ServerCode;
|
||||||
|
import Repository.Server.ServerExchangeUnit_2021;
|
||||||
|
import TestingSystem.Common.TestingPackage.TestingPackage;
|
||||||
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||||
|
import javafx.util.Pair;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
public abstract class ActualizeTestingPackages<P extends TestingPackage> extends TestingSystemPass<Vector<Pair<Integer, Long>>> {
|
||||||
|
Class p;
|
||||||
|
public ActualizeTestingPackages(Class<P> p_in) {
|
||||||
|
p = p_in;
|
||||||
|
}
|
||||||
|
iDBTable<P> getTable() {
|
||||||
|
return (iDBTable<P>) Global.testingServer.db.tables.get(p);
|
||||||
|
}
|
||||||
|
protected abstract ServerCode getCheckCode();
|
||||||
|
@Override
|
||||||
|
protected boolean needsAnimation() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected boolean canStart(Object... args) throws Exception {
|
||||||
|
target = new Vector<>();
|
||||||
|
System.out.println("active packages");
|
||||||
|
for (P testingPackage : getTable().Data.values()) {
|
||||||
|
System.out.println(testingPackage.id + " " + testingPackage.state);
|
||||||
|
if (testingPackage.state.isActive()) {
|
||||||
|
System.out.println(testingPackage.state);
|
||||||
|
target.add(new Pair(testingPackage.id, testingPackage.ChangeDate));
|
||||||
|
System.out.println(testingPackage.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("found " + target.size());
|
||||||
|
return !target.isEmpty();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void ServerAction() throws Exception {
|
||||||
|
Command(new ServerExchangeUnit_2021(getCheckCode(), "", target));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void performDone() throws Exception {
|
||||||
|
Vector<P> res = (Vector<P>) response.object;
|
||||||
|
Global.testingServer.db.BeginTransaction();
|
||||||
|
for (P actual : res)
|
||||||
|
Global.testingServer.db.UpdateWithCheck(actual);
|
||||||
|
Global.testingServer.db.Commit();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void showDone() throws Exception {
|
||||||
|
getTable().ShowUI(); ///RefreshUI()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,37 +5,15 @@ import Repository.Server.ServerExchangeUnit_2021;
|
|||||||
import TestingSystem.Common.TasksPackageToKill.TasksPackageToKill;
|
import TestingSystem.Common.TasksPackageToKill.TasksPackageToKill;
|
||||||
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||||
|
import Visual_DVM_2021.Passes.AbortTestingPackage;
|
||||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||||
public class AbortDVMPackage extends TestingSystemPass<DVMPackage> {
|
public class AbortDVMPackage extends AbortTestingPackage {
|
||||||
TestingPackageToKill packageToKill = null;
|
|
||||||
@Override
|
@Override
|
||||||
public String getIconPath() {
|
public Current currentName() {
|
||||||
return "/icons/Ban.PNG";
|
return Current.DVMPackage;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getButtonText() {
|
public int getAbortType() {
|
||||||
return "";
|
return 0;
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected boolean canStart(Object... args) throws Exception {
|
|
||||||
packageToKill = null;
|
|
||||||
if (Current.Check(Log, Current.DVMPackage)) {
|
|
||||||
target = Current.getDVMPackage();
|
|
||||||
switch (target.state) {
|
|
||||||
case Done:
|
|
||||||
case Aborted:
|
|
||||||
Log.Writeln_("Пакет уже завершен.");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
packageToKill = new TestingPackageToKill(target);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void ServerAction() throws Exception {
|
|
||||||
Command(new ServerExchangeUnit_2021(ServerCode.PublishObject, null, packageToKill));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/Visual_DVM_2021/Passes/All/AbortSapforPackage.java
Normal file
13
src/Visual_DVM_2021/Passes/All/AbortSapforPackage.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package Visual_DVM_2021.Passes.All;
|
||||||
|
import Common.Current;
|
||||||
|
import Visual_DVM_2021.Passes.AbortTestingPackage;
|
||||||
|
public class AbortSapforPackage extends AbortTestingPackage {
|
||||||
|
@Override
|
||||||
|
public Current currentName() {
|
||||||
|
return Current.SapforPackage;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int getAbortType() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,46 +1,13 @@
|
|||||||
package Visual_DVM_2021.Passes.All;
|
package Visual_DVM_2021.Passes.All;
|
||||||
import Common.Global;
|
|
||||||
import Repository.Server.ServerCode;
|
import Repository.Server.ServerCode;
|
||||||
import Repository.Server.ServerExchangeUnit_2021;
|
|
||||||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
import Visual_DVM_2021.Passes.ActualizeTestingPackages;
|
||||||
import javafx.util.Pair;
|
public class ActualizeDVMPackages extends ActualizeTestingPackages<DVMPackage> {
|
||||||
|
public ActualizeDVMPackages() {
|
||||||
import java.util.Vector;
|
super(DVMPackage.class);
|
||||||
public class ActualizeDVMPackages extends TestingSystemPass<Vector<Pair<Integer, Long>>> {
|
|
||||||
@Override
|
|
||||||
protected boolean needsAnimation() {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected boolean canStart(Object... args) throws Exception {
|
protected ServerCode getCheckCode() {
|
||||||
target = new Vector<>();
|
return ServerCode.UpdateActiveDVMPackages;
|
||||||
System.out.println("active packages");
|
|
||||||
for (DVMPackage dvmPackage : Global.testingServer.db.dvmPackages.Data.values()) {
|
|
||||||
System.out.println(dvmPackage.id + " " + dvmPackage.state);
|
|
||||||
if (dvmPackage.state.isActive()) {
|
|
||||||
System.out.println(dvmPackage.state);
|
|
||||||
target.add(new Pair(dvmPackage.id, dvmPackage.ChangeDate));
|
|
||||||
System.out.println(dvmPackage.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("found " + target.size());
|
|
||||||
return !target.isEmpty();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void ServerAction() throws Exception {
|
|
||||||
Command(new ServerExchangeUnit_2021(ServerCode.UpdateActiveDVMPackages, "", target));
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void performDone() throws Exception {
|
|
||||||
Vector<DVMPackage> res = (Vector<DVMPackage>) response.object;
|
|
||||||
Global.testingServer.db.BeginTransaction();
|
|
||||||
for (DVMPackage actual : res)
|
|
||||||
Global.testingServer.db.UpdateWithCheck(actual);
|
|
||||||
Global.testingServer.db.Commit();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void showDone() throws Exception {
|
|
||||||
Global.testingServer.db.dvmPackages.ShowUI(); ///RefreshUI()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ public class ActualizePackages extends Pass_2021 {
|
|||||||
@Override
|
@Override
|
||||||
protected void body() throws Exception {
|
protected void body() throws Exception {
|
||||||
passes.get(PassCode_2021.ActualizeDVMPackages).Do();
|
passes.get(PassCode_2021.ActualizeDVMPackages).Do();
|
||||||
// passes.get(PassCode_2021.ActualizeSAPFORPackages).Do();
|
passes.get(PassCode_2021.ActualizeSapforPackages).Do();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
package Visual_DVM_2021.Passes.All;
|
|
||||||
import Common.Current;
|
|
||||||
import Common.Global;
|
|
||||||
import Repository.Server.ServerCode;
|
|
||||||
import Repository.Server.ServerExchangeUnit_2021;
|
|
||||||
import TestingSystem.DVM.Tasks.TestRunTask;
|
|
||||||
import TestingSystem.DVM.TasksPackage.TasksPackage;
|
|
||||||
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
|
||||||
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
|
||||||
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
|
|
||||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
|
||||||
import javafx.util.Pair;
|
|
||||||
|
|
||||||
import java.util.Vector;
|
|
||||||
public class ActualizeSAPFORPackages extends TestingSystemPass<Vector<Pair<Long, TasksPackageState>>> {
|
|
||||||
@Override
|
|
||||||
protected boolean needsAnimation() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected boolean canStart(Object... args) throws Exception {
|
|
||||||
target = new Vector<>();
|
|
||||||
for (SapforTasksPackage tasksPackage : Global.testingServer.account_db.sapforTasksPackages.Data.values()) {
|
|
||||||
if (tasksPackage.state.isActive())
|
|
||||||
target.add(new Pair<>(tasksPackage.id, tasksPackage.state));
|
|
||||||
}
|
|
||||||
return !target.isEmpty();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void ServerAction() throws Exception {
|
|
||||||
Command(new ServerExchangeUnit_2021(ServerCode.ActualizeSAPFORPackages, Current.getAccount().email, target));
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void performDone() throws Exception {
|
|
||||||
int i = 0;
|
|
||||||
Vector<Pair<SapforTasksPackage, Vector<SapforTask>>> res = (Vector<Pair<SapforTasksPackage, Vector<SapforTask>>>) response.object;
|
|
||||||
Global.testingServer.account_db.BeginTransaction();
|
|
||||||
for (Pair<SapforTasksPackage, Vector<SapforTask>> pair : res) {
|
|
||||||
SapforTasksPackage tasksPackage = pair.getKey();
|
|
||||||
Global.testingServer.account_db.UpdateWithCheck(tasksPackage);
|
|
||||||
if (tasksPackage.state.equals(TasksPackageState.Done)) {
|
|
||||||
++i;
|
|
||||||
for (SapforTask task : pair.getValue()) {
|
|
||||||
Global.testingServer.account_db.UpdateWithCheck(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Global.testingServer.account_db.Commit();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void showDone() throws Exception {
|
|
||||||
Global.testingServer.account_db.sapforTasksPackages.RefreshUI();
|
|
||||||
Global.testingServer.account_db.sapforTasks.ShowUI();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
13
src/Visual_DVM_2021/Passes/All/ActualizeSapforPackages.java
Normal file
13
src/Visual_DVM_2021/Passes/All/ActualizeSapforPackages.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package Visual_DVM_2021.Passes.All;
|
||||||
|
import Repository.Server.ServerCode;
|
||||||
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||||
|
import Visual_DVM_2021.Passes.ActualizeTestingPackages;
|
||||||
|
public class ActualizeSapforPackages extends ActualizeTestingPackages<SapforPackage> {
|
||||||
|
public ActualizeSapforPackages() {
|
||||||
|
super(SapforPackage.class);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected ServerCode getCheckCode() {
|
||||||
|
return ServerCode.UpdateActiveSapforPackages;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,253 @@
|
|||||||
package Visual_DVM_2021.Passes.All;
|
package Visual_DVM_2021.Passes.All;
|
||||||
import Visual_DVM_2021.Passes.Pass_2021;
|
import Common.Constants;
|
||||||
public class AddSapforPackage extends Pass_2021 {
|
import Common.Current;
|
||||||
|
import Common.Database.Database;
|
||||||
|
import Common.Global;
|
||||||
|
import Common.UI.UI;
|
||||||
|
import Common.Utils.Index;
|
||||||
|
import ProjectData.LanguageName;
|
||||||
|
import TestingSystem.Common.Group.Group;
|
||||||
|
import TestingSystem.Common.Test.Test;
|
||||||
|
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||||
|
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
||||||
|
import TestingSystem.SAPFOR.Json.SapforTasksPackage_json;
|
||||||
|
import TestingSystem.SAPFOR.Json.SapforTest_json;
|
||||||
|
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||||
|
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
|
||||||
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||||
|
import Visual_DVM_2021.Passes.AddObjectPass;
|
||||||
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Vector;
|
||||||
|
public class AddSapforPackage extends AddObjectPass<SapforPackage> {
|
||||||
|
//--
|
||||||
|
protected int allTasksCount = 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 Vector<String> testsIds = null;
|
||||||
|
protected Vector<String> configurationsIds = null;
|
||||||
|
protected File sapfor = null;
|
||||||
|
//---
|
||||||
|
protected boolean checkTestName(Test test) {
|
||||||
|
String name = test.description.toLowerCase();
|
||||||
|
if (testsNames_lower.contains(name)) {
|
||||||
|
Log.Writeln_("В пакет не могут входить тесты с одинаковыми именами (без учета регистра):" + test.description.toLowerCase());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
testsNames_lower.add(name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
protected boolean getGroupTests(int groupId) {
|
||||||
|
Vector<Integer> groupTests = new Vector<>();
|
||||||
|
Vector<Integer> selectedGroupTests = new Vector<>();
|
||||||
|
//---
|
||||||
|
for (Test test : Global.testingServer.db.tests.Data.values()) {
|
||||||
|
if (test.group_id==groupId) {
|
||||||
|
groupTests.add(test.id);
|
||||||
|
if (test.isSelected())
|
||||||
|
selectedGroupTests.add(test.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!groupTests.isEmpty() && !selectedGroupTests.isEmpty())
|
||||||
|
groupTests = selectedGroupTests;
|
||||||
|
//---
|
||||||
|
if (groupTests.isEmpty()) {
|
||||||
|
Log.Writeln_("Пустая группа тестов: " + groupId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
for (int testId : groupTests) {
|
||||||
|
Test test = Global.testingServer.db.tests.get(testId);
|
||||||
|
if (!checkTestName(test))
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
testsByDescriptions.put(test.description, test);
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
groupsTests.put(groupId, groupTests);
|
||||||
|
//--
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean checkTerminalCode(SapforConfiguration sapforConfiguration, PassCode_2021 code, int count, Vector<PassCode_2021> codes) {
|
||||||
|
if (count > 2) {
|
||||||
|
Log.Writeln_("Неверная конфигурация:" + sapforConfiguration.id + ": " +
|
||||||
|
code.getDescription() +
|
||||||
|
" возможно только один раз.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
if ((count == 1) && codes.size() > 1) {
|
||||||
|
if (!codes.lastElement().equals(code)) {
|
||||||
|
Log.Writeln_("Неверная конфигурация:" + sapforConfiguration.id + ": " +
|
||||||
|
code.getDescription() +
|
||||||
|
" может быть только завершающей командой!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public boolean getConfigurationCommands(SapforConfiguration sapforConfiguration) {
|
||||||
|
//1. получить список всех команд.
|
||||||
|
Vector<PassCode_2021> codes = new Vector<>();
|
||||||
|
//-- счетчик завершающих команд.
|
||||||
|
LinkedHashMap<PassCode_2021, Index> terminalCodesCount = new LinkedHashMap<>();
|
||||||
|
for (PassCode_2021 code : Constants.terminalSapforTestingCodes)
|
||||||
|
terminalCodesCount.put(code, new Index());
|
||||||
|
//--
|
||||||
|
for (SapforConfigurationCommand command : Global.testingServer.db.sapforConfigurationCommands.Data.values()) {
|
||||||
|
if (command.sapforconfiguration_id==sapforConfiguration.id) {
|
||||||
|
codes.add(command.passCode);
|
||||||
|
//---
|
||||||
|
for (PassCode_2021 t_code : Constants.terminalSapforTestingCodes) {
|
||||||
|
if (command.passCode.equals(t_code))
|
||||||
|
terminalCodesCount.get(t_code).Inc();
|
||||||
|
}
|
||||||
|
//---
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
if (codes.size() == 0) {
|
||||||
|
Log.Writeln_("Пустая конфигурация:" + sapforConfiguration.id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (PassCode_2021 t_code : Constants.terminalSapforTestingCodes) {
|
||||||
|
if (!checkTerminalCode(sapforConfiguration, t_code,
|
||||||
|
terminalCodesCount.get(t_code).getValue(), codes
|
||||||
|
))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//временный вариант. в дальнейшем, следует сделать возможность формирования.(?)
|
||||||
|
public AddSapforPackage() {
|
||||||
|
super(SapforPackage.class);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected Database getDb() {
|
||||||
|
return Global.testingServer.db;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected boolean canStart(Object... args) throws Exception {
|
||||||
|
if (!Current.getAccount().CheckRegistered(Log)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Current.Check(Log, Current.ServerSapfor)) {
|
||||||
|
for (SapforPackage sapforPackage : Global.testingServer.db.sapforPackages.Data.values()) {
|
||||||
|
if (sapforPackage.state.equals(TasksPackageState.Draft)) {
|
||||||
|
Log.Writeln_("Может существовать только один пакет, готовящийся к публикации.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
allTasksCount = 0;
|
||||||
|
groupsTests = new LinkedHashMap<>();
|
||||||
|
testsNames_lower = new Vector<>();
|
||||||
|
testsByDescriptions = new LinkedHashMap<>();
|
||||||
|
groupsLanguages = new Vector<>();
|
||||||
|
testsIds =new Vector<>();
|
||||||
|
configurationsIds = new Vector<>();
|
||||||
|
//--
|
||||||
|
if (Global.testingServer.db.sapforConfigurations.getCheckedCount() == 0) {
|
||||||
|
Log.Writeln_("Не отмечено ни одной конфигурации SAPFOR.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//-
|
||||||
|
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems()) {
|
||||||
|
if (!getConfigurationCommands(configuration))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
if (Global.testingServer.db.groups.getCheckedCount() == 0) {
|
||||||
|
Log.Writeln_("Не отмечено ни одной группы тестов");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
for (Group group : Global.testingServer.db.groups.getCheckedItems()) {
|
||||||
|
//---
|
||||||
|
if (!groupsLanguages.contains(group.language))
|
||||||
|
groupsLanguages.add(group.language);
|
||||||
|
//-
|
||||||
|
if (groupsLanguages.get(0) != LanguageName.fortran) {
|
||||||
|
Log.Writeln_("Поддерживается пакетный режим только для языка Fortran!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (groupsLanguages.size() > 1) {
|
||||||
|
Log.Writeln_("Запуск тестов на разных языках в рамках одного пакета запрещен!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//---
|
||||||
|
if (!getGroupTests(group.id))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
for (int i = 0; i < Global.testingServer.db.sapforConfigurations.getCheckedCount(); ++i) {
|
||||||
|
for (Vector<Integer> tests : groupsTests.values())
|
||||||
|
allTasksCount += tests.size();
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
for (Test test : testsByDescriptions.values())
|
||||||
|
testsIds.add(String.valueOf(test.id));
|
||||||
|
//--
|
||||||
|
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems())
|
||||||
|
configurationsIds.add(String.valueOf(configuration.id));
|
||||||
|
//--
|
||||||
|
target = new SapforPackage();
|
||||||
|
target.id = Constants.Nan;
|
||||||
|
//-
|
||||||
|
target.sender_name = Current.getAccount().name;
|
||||||
|
target.sender_address = Current.getAccount().email;
|
||||||
|
//-
|
||||||
|
target.drv = Current.getServerSapfor().call_command;
|
||||||
|
target.version = Current.getServerSapfor().version;
|
||||||
|
target.kernels = Global.properties.TestingKernels;
|
||||||
|
target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
|
||||||
|
//--
|
||||||
|
target.tasksCount = allTasksCount;
|
||||||
|
target.testsIds = String.join("\n", testsIds);
|
||||||
|
target.configurationsIds = String.join("\n", configurationsIds);
|
||||||
|
//--
|
||||||
|
target.sapforId = Current.getServerSapfor().id;
|
||||||
|
target.testsNames = String.join(";", testsNames_lower);
|
||||||
|
//
|
||||||
|
SapforTasksPackage_json package_json = new SapforTasksPackage_json();
|
||||||
|
target.package_json = package_json;
|
||||||
|
///-------------------------------
|
||||||
|
package_json.kernels = target.kernels;
|
||||||
|
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;
|
||||||
|
package_json.tests.add(test_json);
|
||||||
|
}
|
||||||
|
///-------------------------------
|
||||||
|
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();
|
||||||
|
configuration_json.codes.add(PassCode_2021.SPF_CorrectCodeStylePass); //всегда добавляется.
|
||||||
|
configuration_json.codes.addAll(configuration.getPassCodes());
|
||||||
|
//--->>
|
||||||
|
package_json.configurations.add(configuration_json);
|
||||||
|
//-->>
|
||||||
|
}
|
||||||
|
package_json.sapfor_drv = Current.getServerSapfor().call_command;
|
||||||
|
///-------------------------------
|
||||||
|
return (UI.Question("Будет добавлено:\n"
|
||||||
|
+ allTasksCount + " задач\n" +
|
||||||
|
"Продолжить"));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void body() throws Exception {
|
||||||
|
//черновик не вставляется в бд. идет только как элемент списка.
|
||||||
|
Global.testingServer.db.sapforPackages.Data.put(target.id, target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
8
src/Visual_DVM_2021/Passes/All/DeleteSapforPackage.java
Normal file
8
src/Visual_DVM_2021/Passes/All/DeleteSapforPackage.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package Visual_DVM_2021.Passes.All;
|
||||||
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||||
|
import Visual_DVM_2021.Passes.DeleteTestingPackages;
|
||||||
|
public class DeleteSapforPackage extends DeleteTestingPackages<SapforPackage> {
|
||||||
|
public DeleteSapforPackage() {
|
||||||
|
super(SapforPackage.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,46 +1,13 @@
|
|||||||
package Visual_DVM_2021.Passes.All;
|
package Visual_DVM_2021.Passes.All;
|
||||||
import Common.Current;
|
import Common.Current;
|
||||||
import Common.Global;
|
|
||||||
import Common.UI.UI;
|
|
||||||
import Common.Utils.Utils;
|
|
||||||
import Repository.Server.ServerCode;
|
|
||||||
import Repository.Server.ServerExchangeUnit_2021;
|
|
||||||
import TestingSystem.Common.TestingServer;
|
|
||||||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||||
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
import Visual_DVM_2021.Passes.StartTestingPackage;
|
||||||
import Visual_DVM_2021.Passes.Server.PublishServerObject;
|
public class StartDVMPackage extends StartTestingPackage<DVMPackage> {
|
||||||
import javafx.util.Pair;
|
|
||||||
public class StartDVMPackage extends PublishServerObject<TestingServer, DVMPackage>{
|
|
||||||
public StartDVMPackage() {
|
public StartDVMPackage() {
|
||||||
super(Global.testingServer, DVMPackage.class);
|
super(DVMPackage.class);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected int getTimeout() {
|
protected Current getCurrentName() {
|
||||||
return 0;
|
return Current.DVMPackage;
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getIconPath() {
|
|
||||||
return "/icons/Start.png";
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected boolean canStart(Object... args) throws Exception {
|
|
||||||
if (!Current.getAccount().CheckRegistered(Log)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (Current.Check(Log, Current.DVMPackage)) {
|
|
||||||
target = Current.getDVMPackage();
|
|
||||||
//-
|
|
||||||
if (target.tasksCount == 0) {
|
|
||||||
Log.Writeln_("В пакете отсутствуют задачи.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (UI.Question("Будет запущено:\n"
|
|
||||||
+target.tasksCount + " задач на запуск.\n" +
|
|
||||||
"Продолжить")) {
|
|
||||||
target.state = TasksPackageState.Queued;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/Visual_DVM_2021/Passes/All/StartSapforPackage.java
Normal file
13
src/Visual_DVM_2021/Passes/All/StartSapforPackage.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package Visual_DVM_2021.Passes.All;
|
||||||
|
import Common.Current;
|
||||||
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||||
|
import Visual_DVM_2021.Passes.StartTestingPackage;
|
||||||
|
public class StartSapforPackage extends StartTestingPackage<SapforPackage> {
|
||||||
|
public StartSapforPackage() {
|
||||||
|
super(SapforPackage.class);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected Current getCurrentName() {
|
||||||
|
return Current.SapforPackage;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -204,7 +204,6 @@ public class StartSapforTests extends PublishServerAccountObject<SapforTasksPack
|
|||||||
target.state = TasksPackageState.Queued;
|
target.state = TasksPackageState.Queued;
|
||||||
target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
|
target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
|
||||||
//---
|
//---
|
||||||
//--
|
|
||||||
return (UI.Question("Будет запущено:\n"
|
return (UI.Question("Будет запущено:\n"
|
||||||
+ allTasksCount + " задач\n" +
|
+ allTasksCount + " задач\n" +
|
||||||
"Продолжить"));
|
"Продолжить"));
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ public enum PassCode_2021 {
|
|||||||
ExportTasksPackageToExcel,
|
ExportTasksPackageToExcel,
|
||||||
//->
|
//->
|
||||||
ActualizeDVMPackages,
|
ActualizeDVMPackages,
|
||||||
ActualizeSAPFORPackages,
|
ActualizeSapforPackages,
|
||||||
ActualizePackages,
|
ActualizePackages,
|
||||||
//->
|
//->
|
||||||
AddDVMPackage,
|
AddDVMPackage,
|
||||||
@@ -316,12 +316,21 @@ public enum PassCode_2021 {
|
|||||||
AbortDVMPackage,
|
AbortDVMPackage,
|
||||||
//->
|
//->
|
||||||
AddSapforPackage,
|
AddSapforPackage,
|
||||||
|
DeleteSapforPackage,
|
||||||
|
StartSapforPackage,
|
||||||
|
AbortSapforPackage,
|
||||||
//->
|
//->
|
||||||
TestPass;
|
TestPass;
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case Undefined:
|
case Undefined:
|
||||||
return "?";
|
return "?";
|
||||||
|
case AbortSapforPackage:
|
||||||
|
return "Прервать пакет тестирования SAPFOR";
|
||||||
|
case StartSapforPackage:
|
||||||
|
return "Запустить пакет задач SAPFOR";
|
||||||
|
case DeleteSapforPackage:
|
||||||
|
return "Удалить пакеты тестирования SAPFOR";
|
||||||
case AddSapforPackage:
|
case AddSapforPackage:
|
||||||
return "Добавить пакет задач SAPFOR";
|
return "Добавить пакет задач SAPFOR";
|
||||||
case AbortDVMPackage:
|
case AbortDVMPackage:
|
||||||
@@ -338,7 +347,7 @@ public enum PassCode_2021 {
|
|||||||
return "Обновить пакеты задач";
|
return "Обновить пакеты задач";
|
||||||
case ActualizeDVMPackages:
|
case ActualizeDVMPackages:
|
||||||
return "Обновить пакеты тестирования DVM";
|
return "Обновить пакеты тестирования DVM";
|
||||||
case ActualizeSAPFORPackages:
|
case ActualizeSapforPackages:
|
||||||
return "Обновить пакеты тестирования SAPFOR";
|
return "Обновить пакеты тестирования SAPFOR";
|
||||||
case ExportTasksPackageToExcel:
|
case ExportTasksPackageToExcel:
|
||||||
return "Экспорт пакета задач в Excel";
|
return "Экспорт пакета задач в Excel";
|
||||||
|
|||||||
48
src/Visual_DVM_2021/Passes/StartTestingPackage.java
Normal file
48
src/Visual_DVM_2021/Passes/StartTestingPackage.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package Visual_DVM_2021.Passes;
|
||||||
|
import Common.Current;
|
||||||
|
import Common.Global;
|
||||||
|
import Common.UI.UI;
|
||||||
|
import TestingSystem.Common.TestingPackage.TestingPackage;
|
||||||
|
import TestingSystem.Common.TestingServer;
|
||||||
|
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||||
|
import Visual_DVM_2021.Passes.Server.PublishServerObject;
|
||||||
|
public abstract class StartTestingPackage<P extends TestingPackage> extends PublishServerObject<TestingServer, P> {
|
||||||
|
public StartTestingPackage(Class<P> p_in) {
|
||||||
|
super(Global.testingServer, p_in);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected int getTimeout() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getIconPath() {
|
||||||
|
return "/icons/Start.png";
|
||||||
|
}
|
||||||
|
protected abstract Current getCurrentName();
|
||||||
|
@Override
|
||||||
|
protected boolean canStart(Object... args) throws Exception {
|
||||||
|
if (!Current.getAccount().CheckRegistered(Log)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Current.Check(Log, getCurrentName())) {
|
||||||
|
target = (P) Current.get(getCurrentName());
|
||||||
|
//-
|
||||||
|
if (!target.state.equals(TasksPackageState.Draft)) {
|
||||||
|
Log.Writeln_("Возможно запустить только пакет, готовящийся к публикации!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (target.tasksCount == 0) {
|
||||||
|
Log.Writeln_("В пакете отсутствуют задачи.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (UI.Question("Будет запущено:\n"
|
||||||
|
+ target.tasksCount + " задач.\n" +
|
||||||
|
"Продолжить")) {
|
||||||
|
target.state = TasksPackageState.Queued;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user