промежуточный. встраиваю тестирование сапфор в существующий планировщик. пока есть баги.

This commit is contained in:
2023-10-13 02:06:46 +03:00
parent c69202d72c
commit 81d6330660
6 changed files with 74 additions and 91 deletions

View File

@@ -17,6 +17,7 @@ public class SapforTasksPackage extends nDBObject {
public long StartDate = 0; //дата начала выполнения
public long ChangeDate = 0;//дата окончания выполнения
//-
@Description("DEFAULT 'Queued'")
public TasksPackageState state = TasksPackageState.Queued;
// допустимые состояния
//Queued

View File

@@ -1,86 +0,0 @@
package SapforTestingSystem.ServerSapforTestingPlanner;
import Common.Constants;
import Common.Utils.Utils;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.TasksPackage.TasksPackageState;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.TestingSystemPass;
import java.io.File;
import java.io.Serializable;
import java.util.Date;
public class ServerSapforTestingPlanner {
SapforTasksPackage sapforTasksPackage = null;
//---
int getSleepMillis() {
return 2000;
}
Object ServerCommand(ServerCode code_in, String arg, Serializable object_in) throws Exception {
TestingSystemPass<Object> pass = new TestingSystemPass<Object>() {
@Override
public String getDescription() {
return "";
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(code_in, arg, object_in));
target = response.object;
}
};
if (!pass.Do()) throw new PassException("Ошибка взаимодействия с сервером " + code_in);
return pass.target;
}
//---
void UpdatePackage(SapforTasksPackage package_in) throws Exception {
package_in.ChangeDate = new Date().getTime();
ServerCommand(ServerCode.EditObject, "", package_in);
}
void PackageStart() throws Exception {
File workspace = new File(sapforTasksPackage.workspace);
File script = new File(sapforTasksPackage.workspace, "start");
ProcessBuilder procBuilder = new ProcessBuilder(script.getAbsolutePath());
procBuilder.directory(workspace);
procBuilder.start();
sapforTasksPackage.state = TasksPackageState.RunningExecution;
UpdatePackage(sapforTasksPackage);
}
void CheckPackageState() throws Exception {
File done = new File(sapforTasksPackage.workspace, Constants.DONE);
File aborted = new File(sapforTasksPackage.workspace, Constants.ABORTED);
if (done.exists()) {
sapforTasksPackage.state = TasksPackageState.Done;
UpdatePackage(sapforTasksPackage);
} else if (aborted.exists()) {
sapforTasksPackage.state = TasksPackageState.Aborted;
UpdatePackage(sapforTasksPackage);
}
}
public void Perform() {
while (true) {
try {
//-
sapforTasksPackage = (SapforTasksPackage) ServerCommand(ServerCode.GetFirstActiveSapforTasksPackage, "", null);
switch (sapforTasksPackage.state) {
case PackageStart:
PackageStart();
break;
case RunningExecution:
CheckPackageState();
break;
default:
break;
}
//-
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
Utils.sleep(getSleepMillis());
} catch (Exception ignored) {
}
}
}
}
}