прерывание пакета. первый вариант.

This commit is contained in:
2023-10-17 00:22:06 +03:00
parent c822cc452b
commit 19f7230eb5
10 changed files with 90 additions and 9 deletions

View File

@@ -33,7 +33,7 @@ public enum Current {
Undefined,
//--
ServerSapfor,
SapforScenario,
SapforTasksPackage,
SapforEtalonTaskResult,//самый левый пакет
SapforTaskResult,
//--
@@ -368,10 +368,10 @@ public enum Current {
return (GlobalData.SapforProfile.SapforProfile) get(Current.SapforProfile);
}
public static boolean HasSapforTasksPackage() {
return get(Current.SapforScenario) != null;
return get(Current.SapforTasksPackage) != null;
}
public static SapforTestingSystem.SapforTasksPackage.SapforTasksPackage getSapforTasksPackage() {
return (SapforTestingSystem.SapforTasksPackage.SapforTasksPackage) get(Current.SapforScenario);
return (SapforTestingSystem.SapforTasksPackage.SapforTasksPackage) get(Current.SapforTasksPackage);
}
//сапфоры установленные на тестовый сервер.
public static boolean HasServerSapfor() {
@@ -385,7 +385,7 @@ public enum Current {
switch (this) {
case ServerSapfor:
return "тестовая версия SAPFOR";
case SapforScenario:
case SapforTasksPackage:
return "сценарий SAPFOR";
case SapforProfile:
return "Профиль SAPFOR";

View File

@@ -1,7 +1,8 @@
package Common.UI.Menus_2023.SapforTasksPackagesBar;
import Common.UI.Menus_2023.DataMenuBar;
import Visual_DVM_2021.Passes.PassCode_2021;
public class SapforTasksPackagesBar extends DataMenuBar {
public SapforTasksPackagesBar() {
super("пакеты задач");
super("пакеты задач", PassCode_2021.AbortSapforTaskPackage);
}
}

View File

@@ -25,7 +25,7 @@ public class TestingBar extends VisualiserMenuBar {
add(sKernels = new JSpinner());
sKernels.setPreferredSize(new Dimension(60, 26));
sKernels.setMaximumSize(new Dimension(60, 26));
sKernels.setModel(new SpinnerNumberModel(TestingServer.kernels, 1, 16, 1));
sKernels.setModel(new SpinnerNumberModel(TestingServer.kernels, 1, 64, 1));
UI.MakeSpinnerRapid(sKernels, e -> {
TestingServer.kernels = (int) sKernels.getValue();
});

View File

@@ -70,5 +70,6 @@ public enum ServerCode {
InstallSapforForTesting,
StartSapforTests,
GetFirstActiveSapforTasksPackage,
AbortSapforTasksPackage,
OLD
}

View File

@@ -13,7 +13,7 @@ public class SapforTasksPackagesDBTable extends DBTable<String, SapforTasksPacka
}
@Override
public Current CurrentName() {
return Current.SapforScenario;
return Current.SapforTasksPackage;
}
@Override
public String getSingleDescription() {

View File

@@ -14,7 +14,7 @@ import java.util.Vector;
//https://stackoverflow.com/questions/2127318/java-how-can-i-do-dynamic-casting-of-a-variable-from-one-type-to-another
public class GroupInterface {
//-
public static boolean filterMyOnly = true;
public static boolean filterMyOnly = false;
//--
public static boolean isVisible(Group object) {
return (!filterMyOnly || Current.getAccount().email.equals(object.sender_address)) &&

View File

@@ -1,4 +1,5 @@
package TestingSystem;
import Common.Constants;
import Common.Database.DBObject;
import Common.Database.rDBObject;
import Common.Global;
@@ -21,6 +22,7 @@ import TestingSystem.Tasks.TestCompilationTask;
import TestingSystem.Tasks.TestRunTask;
import TestingSystem.Tasks.TestTask;
import TestingSystem.TasksPackage.TasksPackage;
import TestingSystem.TasksPackage.TasksPackageState;
import TestingSystem.TasksPackageToKill.TasksPackageToKill;
import TestingSystem.Test.Test;
import TestingSystem.Test.TestInterface;
@@ -37,6 +39,7 @@ import javax.swing.*;
import java.io.File;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Vector;
import java.util.stream.Collectors;
@@ -311,6 +314,31 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
groups.sort(Comparator.comparing(o -> o.description));
return groups;
}
private void AbortSapforTasksPackage(SapforTasksPackage object) throws Exception {
if (object.state.equals(TasksPackageState.RunningExecution)) {
File workspace = new File(object.workspace);
//----
File interrupt_file = new File(object.workspace, Constants.INTERRUPT);
//----
FileUtils.writeStringToFile(interrupt_file, new Date().toString());
File aborted_file = new File(object.workspace, Constants.ABORTED);
do {
System.out.println("waiting for interrupt...");
Thread.sleep(1000);
} while (!aborted_file.exists());
System.out.println("coup de grace..");
File[] files = workspace.listFiles((dir, name) -> name.startsWith("SAPFOR_F_"));
if ((files != null) && (files.length > 0)) {
File sapfor = files[0];
String kill_command = "killall -SIGKILL " + sapfor.getName();
System.out.println(kill_command);
Process killer = Runtime.getRuntime().exec(kill_command);
killer.waitFor();
System.out.println("done!");
} else throw new Exception("Не найдена копия SAPFOR");
}else throw new RepositoryRefuseException()
}
@Override
protected void Session() throws Exception {
DBObject dbObject = null;
@@ -323,6 +351,15 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//------------->>
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case AbortSapforTasksPackage:
Print("Прервать пакет тестов SAPFOR");
SetCurrentAccountDB(request.arg);
if (account_db.sapforTasksPackages.containsKey(request.object)) {
SapforTasksPackage sapforTasksPackage = account_db.sapforTasksPackages.get(request.object);
AbortSapforTasksPackage(sapforTasksPackage);
response = new ServerExchangeUnit_2021(ServerCode.OK);
} else throw new RepositoryRefuseException("Не существует пакета " + Utils.Brackets(request.object));
break;
//--
case CheckPackageToKill:
SetCurrentAccountDB(request.arg);

View File

@@ -0,0 +1,28 @@
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
import Visual_DVM_2021.Passes.TestingSystemPass;
public class AbortSapforTaskPackage extends TestingSystemPass<SapforTasksPackage> {
@Override
public String getIconPath() {
return "/icons/Ban.PNG";
}
@Override
public String getButtonText() {
return "";
}
@Override
protected boolean canStart(Object... args) throws Exception {
if (Current.Check(Log, Current.SapforTasksPackage)){
target = Current.getSapforTasksPackage();
return true;
};
return false;
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.AbortSapforTasksPackage, Current.getAccount().email, target.id));
}
}

View File

@@ -4,6 +4,7 @@ public enum PassCode_2021 {
//-
ShowAllParallelVariants,
ShowParallelVariantsCoverage,
AbortSapforTaskPackage,
//-
DeleteServerSapfor,
StartSapforTests,
@@ -307,6 +308,8 @@ public enum PassCode_2021 {
switch (this) {
case Undefined:
return "?";
case AbortSapforTaskPackage:
return "Прервать пакет задач SAPFOR";
case ShowAllParallelVariants:
return "Отобразить все параллельные варианты";
case ShowParallelVariantsCoverage: