This commit is contained in:
2023-12-15 02:34:30 +03:00
parent 106626eb9a
commit fd76843aff
10 changed files with 120 additions and 27 deletions

View File

@@ -0,0 +1,20 @@
package TestingSystem.Common.TestingPackageToKill;
import Common.Constants;
import Common.Database.iDBObject;
import TestingSystem.DVM.DVMPackage.DVMPackage;
public class TestingPackageToKill extends iDBObject {
public int packageId = Constants.Nan;
public int type = 0; // 0 - dvm /1 - sapfor
public TestingPackageToKill() {
}
public TestingPackageToKill(DVMPackage dvmPackage) {
packageId = dvmPackage.id;
type = 0;
}
/*
public TestingPackagetoKill(SAPFORPackage sapforPackage){
packageId = sapforPackage.id;
type = 1;
}
*/
}

View File

@@ -0,0 +1,7 @@
package TestingSystem.Common.TestingPackageToKill;
import Common.Database.iDBTable;
public class TestingPackagesToKillDBTable extends iDBTable<TestingPackageToKill> {
public TestingPackagesToKillDBTable() {
super(TestingPackageToKill.class);
}
}

View File

@@ -21,6 +21,7 @@ import TestingSystem.Common.Group.Group;
import TestingSystem.Common.TasksPackageToKill.TasksPackageToKill;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.Test.TestType;
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
import TestingSystem.DVM.DVMPackage.DVMPackage;
import TestingSystem.DVM.DVMTestingPlanner;
import TestingSystem.DVM.Tasks.TestCompilationTask;
@@ -380,6 +381,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
response.object = db.getFirstActiveDVMPackage();
break;
case DVMPackageNeedsKill:
Print("Проверить нуждает ли пакет DVM в убийстве");
DVMPackageNeedsKill();
break;
case UpdateActiveDVMPackages:
@@ -390,21 +392,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
}
}
private void DVMPackageNeedsKill() {
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = false;
/*
int packageId = (int) request.object;
boolean res_ = false;
for (TasksPackageToKill tasksPackageToKill : db.packagesToKill.Data.values()) {
if (tasksPackageToKill.packageId == packageId) {
res_ = true;
break;
}
}
response.object = res_;
*/
}
public void UpdateTestTasks() throws Exception {
Vector<TestCompilationTask> compilationTasks = (Vector<TestCompilationTask>) request.object;
account_db.BeginTransaction();
@@ -621,7 +608,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
} else if (object instanceof DVMPackage) {
DVMPackage dvmPackage = (DVMPackage) object;
//--
dvmPackage.state = TasksPackageState.Queued;
Utils.CheckAndCleanDirectory(dvmPackage.getLocalWorkspace());
//--
dvmPackage.saveJson();
@@ -684,6 +670,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//---------------------------------------------------------------------------------------------->>>
//устарели. убрать.
void ActualizeDVMPackages() throws Exception {
response = new ServerExchangeUnit_2021(ServerCode.OK);
Vector<Pair<Long, TasksPackageState>> keys_pairs = (Vector<Pair<Long, TasksPackageState>>) request.object;
//--
Vector<Pair<TasksPackage, Vector<TestRunTask>>> res = new Vector<>();
@@ -739,6 +726,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//--
//---
void UpdateActiveDVMPackages() throws Exception {
response = new ServerExchangeUnit_2021(ServerCode.OK);
Vector<Pair<Integer, TasksPackageState>> keys_pairs = (Vector<Pair<Integer, TasksPackageState>>) request.object;
Vector<DVMPackage> res = new Vector<>();
//--
@@ -751,4 +739,16 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
response.object = res;
}
private void DVMPackageNeedsKill() {
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 == 0)) {
res_ = true;
break;
}
}
response.object = res_;
}
}

View File

@@ -6,6 +6,7 @@ import TestingSystem.Common.Group.GroupsDBTable;
import TestingSystem.Common.TSetting.TSetting;
import TestingSystem.Common.TSetting.TSettingsDBTable;
import TestingSystem.Common.Test.TestDBTable;
import TestingSystem.Common.TestingPackageToKill.TestingPackagesToKillDBTable;
import TestingSystem.DVM.Configuration.ConfigurationDBTable;
import TestingSystem.DVM.DVMPackage.DVMPackage;
import TestingSystem.DVM.DVMPackage.DVMPackageDBTable;
@@ -24,6 +25,8 @@ public class TestsDatabase extends SQLiteDatabase {
public GroupsDBTable groups;
public DVMPackageDBTable dvmPackages;
//--
public TestingPackagesToKillDBTable testingPackagesToKill;
//--
public SapforConfigurationDBTable sapforConfigurations;
public SapforConfigurationCommandsDBTable sapforConfigurationCommands;
//----
@@ -38,6 +41,7 @@ public class TestsDatabase extends SQLiteDatabase {
addTable(tests = new TestDBTable());
addTable(dvmPackages = new DVMPackageDBTable());
addTable(settings = new TSettingsDBTable());
addTable(testingPackagesToKill = new TestingPackagesToKillDBTable());
//-
addTable(sapforConfigurations = new SapforConfigurationDBTable());
addTable(sapforConfigurationCommands = new SapforConfigurationCommandsDBTable());

View File

@@ -177,14 +177,14 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
LinkedHashMap<Integer, File> tests = getTestsFromJson();
//синхронизировать их.
for (int test_id : tests.keySet()) {
Print("testId="+test_id);
// Print("testId="+test_id);
File test = tests.get(test_id);
RemoteFile test_dst = new RemoteFile(testingPackage.user_workspace + "/projects/" + test_id, true);
Print("src="+test.getAbsolutePath());
Print("dst="+test_dst.full_name);
// Print("src="+test.getAbsolutePath());
// Print("dst="+test_dst.full_name);
user.connection.MKDIR(test_dst);
user.connection.SynchronizeSubDirsR(test, test_dst);
Print("done");
// Print("done");
}
}
@Override
@@ -328,11 +328,11 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
}
}
}
testingPackage.saveJson(); //запись обновленных результатов пакета в json!
Print("analysis done, ct_count=" + ct_count + " rt count=" + rt_count);
//--
}
}
testingPackage.saveJson(); //запись обновленных результатов пакета в json!
Print("analysis done, ct_count=" + ct_count + " rt count=" + rt_count);
//--
}
@Override
protected void Kill() throws Exception {

View File

@@ -0,0 +1,41 @@
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.Common.TasksPackageToKill.TasksPackageToKill;
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
import TestingSystem.DVM.DVMPackage.DVMPackage;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
public class AbortDVMPackage extends TestingSystemPass<DVMPackage> {
TestingPackageToKill packageToKill = null;
@Override
public String getIconPath() {
return "/icons/Ban.PNG";
}
@Override
public String getButtonText() {
return "";
}
@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, "", packageToKill));
}
}

View File

@@ -20,10 +20,16 @@ public class ActualizeDVMPackages extends TestingSystemPass<Vector<Pair<Integer,
@Override
protected boolean canStart(Object... args) throws Exception {
target = new Vector<>();
System.out.println("active packages");
for (DVMPackage dvmPackage : Global.testingServer.db.dvmPackages.Data.values()) {
if (dvmPackage.state.isActive())
System.out.println(dvmPackage.id+" "+dvmPackage.state);
if (dvmPackage.state.isActive()) {
System.out.println(dvmPackage.state);
target.add(new Pair(dvmPackage.id, dvmPackage.state));
System.out.println(dvmPackage.id);
}
}
System.out.println("found "+target.size());
return !target.isEmpty();
}
@Override
@@ -40,6 +46,6 @@ public class ActualizeDVMPackages extends TestingSystemPass<Vector<Pair<Integer,
}
@Override
protected void showDone() throws Exception {
Global.testingServer.db.dvmPackages.RefreshUI();
Global.testingServer.db.dvmPackages.ShowUI(); ///RefreshUI()
}
}

View File

@@ -7,6 +7,7 @@ import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.Common.TestingServer;
import TestingSystem.DVM.DVMPackage.DVMPackage;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import Visual_DVM_2021.Passes.Server.PublishServerObject;
import javafx.util.Pair;
public class StartDVMPackage extends PublishServerObject<TestingServer, DVMPackage>{
@@ -36,9 +37,15 @@ public class StartDVMPackage extends PublishServerObject<TestingServer, DVMPacka
if (UI.Question("Будет запущено:\n"
+target.tasksCount + " задач на запуск.\n" +
"Продолжить")) {
target.state = TasksPackageState.Queued;
return true;
}
}
return false;
}
@Override
protected void performDone() throws Exception {
super.performDone();
TestingServer.ResetTimer();
}
}

View File

@@ -313,12 +313,15 @@ public enum PassCode_2021 {
AddTasksToDVMPackage,
StartDVMPackage,
DeleteDVMPackage,
AbortDVMPackage,
//->
TestPass;
public String getDescription() {
switch (this) {
case Undefined:
return "?";
case AbortDVMPackage:
return "Прервать пакет тестирования DVM";
case DeleteDVMPackage:
return "Удалить пакет задач DVM";
case StartDVMPackage: