Compare commits
11 Commits
1f8ebdc9a2
...
15a179d8e9
| Author | SHA1 | Date | |
|---|---|---|---|
| 15a179d8e9 | |||
| a6a29e913a | |||
| f6bf044060 | |||
| c1d3d9208e | |||
| c21c7c2e10 | |||
| 5f076f14f4 | |||
| 11fae0bc4e | |||
| 3f9ba0feb3 | |||
| 7b28d1a84d | |||
| c37f3d9e70 | |||
| 163552d74f |
9
.idea/workspace.xml
generated
9
.idea/workspace.xml
generated
@@ -8,14 +8,7 @@
|
|||||||
<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 beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/GlobalData/Tasks/TaskState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GlobalData/Tasks/TaskState.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/DVM/TestsSupervisor_2022.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/TestsSupervisor_2022.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/RemoteInitialiseUser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/RemoteInitialiseUser.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/files/Planner/Planner.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/Planner.cpp" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/files/Planner/RunTask.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/RunTask.h" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/files/Planner/Supervisor.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/Supervisor.h" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/files/Planner/Task.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/Task.h" 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" />
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"InstructionPath": "",
|
"InstructionPath": "",
|
||||||
"PerformanceAnalyzerPath": "",
|
"PerformanceAnalyzerPath": "",
|
||||||
"ComponentsBackUpsCount": 10,
|
"ComponentsBackUpsCount": 10,
|
||||||
"TestingKernels": 16,
|
"TestingKernels": 28,
|
||||||
"AutoCheckTesting": false,
|
"AutoCheckTesting": false,
|
||||||
"CheckTestingIntervalSeconds": 10,
|
"CheckTestingIntervalSeconds": 10,
|
||||||
"EmailOnTestingProgress": true
|
"EmailOnTestingProgress": true
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ import Common.UI.Menus_2023.DataMenuBar;
|
|||||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
public class TasksPackagesMenuBar extends DataMenuBar {
|
public class TasksPackagesMenuBar extends DataMenuBar {
|
||||||
public TasksPackagesMenuBar() {
|
public TasksPackagesMenuBar() {
|
||||||
super("пакеты задач", PassCode_2021.AbortTaskPackage);
|
super("пакеты задач", PassCode_2021.AbortTaskPackage, PassCode_2021.DeleteTasksPackage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class TestRunTasksMenuBar extends DataMenuBar {
|
|||||||
filters= addMenus(cFilterMenu, rFilterMenu);
|
filters= addMenus(cFilterMenu, rFilterMenu);
|
||||||
}
|
}
|
||||||
public TestRunTasksMenuBar() {
|
public TestRunTasksMenuBar() {
|
||||||
super("задачи", PassCode_2021.DownloadTaskTest);
|
super("задачи",
|
||||||
|
PassCode_2021.DownloadTaskTest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,19 +108,24 @@ public class GlobalDatabase extends SQLiteDatabase {
|
|||||||
public PassCode_2021 getSynchronizePassCode() {
|
public PassCode_2021 getSynchronizePassCode() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public void SaveCredentials() throws Exception {
|
public void SaveCredentials(){
|
||||||
Credentials credentials = (Credentials) Current.get(Current.Credentials);
|
try {
|
||||||
if (Current.HasMachine())
|
Credentials credentials = (Credentials) Current.get(Current.Credentials);
|
||||||
credentials.machine_id = Current.getMachine().id;
|
if (Current.HasMachine())
|
||||||
if (Current.HasUser())
|
credentials.machine_id = Current.getMachine().id;
|
||||||
credentials.user_id = Current.getUser().id;
|
if (Current.HasUser())
|
||||||
if (Current.HasCompiler())
|
credentials.user_id = Current.getUser().id;
|
||||||
credentials.compiler_id = Current.getCompiler().id;
|
if (Current.HasCompiler())
|
||||||
if (Current.HasMakefile())
|
credentials.compiler_id = Current.getCompiler().id;
|
||||||
credentials.makefile_id = Current.getMakefile().id;
|
if (Current.HasMakefile())
|
||||||
if (Current.HasRunConfiguration())
|
credentials.makefile_id = Current.getMakefile().id;
|
||||||
credentials.runconfiguration_id = Current.getRunConfiguration().id;
|
if (Current.HasRunConfiguration())
|
||||||
Update(credentials);
|
credentials.runconfiguration_id = Current.getRunConfiguration().id;
|
||||||
|
Update(credentials);
|
||||||
|
}
|
||||||
|
catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void UpdateCredentials() {
|
public void UpdateCredentials() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class RemoteCompilationSupervisor extends RemoteTaskSupervisor<Compilatio
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void ValidateTaskResults() throws Exception {
|
protected void ValidateTaskResults() throws Exception {
|
||||||
if (pass.Exists(getRemoteProject().full_name, getBinary().name)) {
|
if (pass.Exists(getBinary())) {
|
||||||
RemoteFile renamed_binary = new RemoteFile(getRemoteProject().full_name, Utils.getDateName("spf_" + getBinary().name));
|
RemoteFile renamed_binary = new RemoteFile(getRemoteProject().full_name, Utils.getDateName("spf_" + getBinary().name));
|
||||||
pass.sftpChannel.rename(getBinary().full_name, renamed_binary.full_name);
|
pass.sftpChannel.rename(getBinary().full_name, renamed_binary.full_name);
|
||||||
task.binary_name = renamed_binary.name;
|
task.binary_name = renamed_binary.name;
|
||||||
|
|||||||
@@ -42,15 +42,17 @@ public abstract class RemoteTaskSupervisor<T extends Task> extends TaskSuperviso
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void CheckTask() throws Exception {
|
protected void CheckTask() throws Exception {
|
||||||
if (pass.Exists(getRemoteProject().full_name, Constants.DONE))
|
RemoteFile DONE = new RemoteFile(getRemoteProject(), Constants.DONE);
|
||||||
|
RemoteFile TIMEOUT = new RemoteFile(getRemoteProject(), Constants.TIMEOUT);
|
||||||
|
if (pass.Exists(DONE))
|
||||||
task.state = TaskState.Finished;
|
task.state = TaskState.Finished;
|
||||||
else if (pass.Exists(getRemoteProject().full_name, Constants.TIMEOUT))
|
else if (pass.Exists(TIMEOUT))
|
||||||
task.state = TaskState.AbortedByTimeout;
|
task.state = TaskState.AbortedByTimeout;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void AchieveResults() throws Exception {
|
protected void AchieveResults() throws Exception {
|
||||||
pass.tryGetSingleFile(getRemoteOutput(), task.getOutputFile(), 10240);
|
pass.tryGetSingleFileWithMaxSize(getRemoteOutput(), task.getOutputFile(), 10240);
|
||||||
pass.tryGetSingleFile(getRemoteErrors(), task.getErrorsFile(), 10240);
|
pass.tryGetSingleFileWithMaxSize(getRemoteErrors(), task.getErrorsFile(), 10240);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void AbortTask() throws Exception {
|
protected void AbortTask() throws Exception {
|
||||||
@@ -58,7 +60,7 @@ public abstract class RemoteTaskSupervisor<T extends Task> extends TaskSuperviso
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void CalculatePerformanceTime() throws Exception {
|
protected void CalculatePerformanceTime() throws Exception {
|
||||||
if (pass.tryGetSingleFile(getRemoteTime(), task.getTimeFile(), 0))
|
if (pass.tryGetSingleFileWithMaxSize(getRemoteTime(), task.getTimeFile(), 0))
|
||||||
task.RefreshTime();
|
task.RefreshTime();
|
||||||
}
|
}
|
||||||
protected String getStartCommand() {
|
protected String getStartCommand() {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class ServerRunSupervisor extends RemoteTaskSupervisor<RunTask> {
|
|||||||
}
|
}
|
||||||
if (!task.last_sts_name.isEmpty()) {
|
if (!task.last_sts_name.isEmpty()) {
|
||||||
RemoteFile remote_sts = new RemoteFile(getRemoteProject().full_name, task.last_sts_name);
|
RemoteFile remote_sts = new RemoteFile(getRemoteProject().full_name, task.last_sts_name);
|
||||||
task.hasDvmSts = pass.tryGetSingleFile(remote_sts, task.getLocalStsFile(), 10240);
|
task.hasDvmSts = pass.tryGetSingleFileWithMaxSize(remote_sts, task.getLocalStsFile(), 10240);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ import GlobalData.User.User;
|
|||||||
import Repository.EmailMessage;
|
import Repository.EmailMessage;
|
||||||
import Repository.Server.ServerCode;
|
import Repository.Server.ServerCode;
|
||||||
import Repository.Server.ServerExchangeUnit_2021;
|
import Repository.Server.ServerExchangeUnit_2021;
|
||||||
import TestingSystem.DVM.UserConnection;
|
|
||||||
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
|
|
||||||
import TestingSystem.SAPFOR.SapforTasksPackageSupervisor.SapforTasksPackageSupervisor;
|
|
||||||
import TestingSystem.DVM.Tasks.TestCompilationTask;
|
import TestingSystem.DVM.Tasks.TestCompilationTask;
|
||||||
import TestingSystem.DVM.Tasks.TestTask;
|
|
||||||
import TestingSystem.DVM.TasksPackage.TasksPackage;
|
import TestingSystem.DVM.TasksPackage.TasksPackage;
|
||||||
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||||
import TestingSystem.DVM.TestsSupervisor_2022;
|
import TestingSystem.DVM.TestsSupervisor_2022;
|
||||||
|
import TestingSystem.DVM.UserConnection;
|
||||||
|
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
|
||||||
|
import TestingSystem.SAPFOR.SapforTasksPackageSupervisor.SapforTasksPackageSupervisor;
|
||||||
import Visual_DVM_2021.Passes.PassException;
|
import Visual_DVM_2021.Passes.PassException;
|
||||||
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
|
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
|
||||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||||
@@ -39,10 +38,6 @@ public class TestingPlanner {
|
|||||||
//----------
|
//----------
|
||||||
SapforTasksPackage sapforTasksPackage = null;
|
SapforTasksPackage sapforTasksPackage = null;
|
||||||
//----------
|
//----------
|
||||||
public void UpdateTask(TestTask task_in) throws Exception {
|
|
||||||
task_in.ChangeDate = new Date().getTime();
|
|
||||||
ServerCommand(ServerCode.EditAccountObject, task_in);
|
|
||||||
}
|
|
||||||
public void UpdatePackage() throws Exception {
|
public void UpdatePackage() throws Exception {
|
||||||
tasksPackage.ChangeDate = new Date().getTime();
|
tasksPackage.ChangeDate = new Date().getTime();
|
||||||
ServerCommand(ServerCode.EditAccountObject, tasksPackage);
|
ServerCommand(ServerCode.EditAccountObject, tasksPackage);
|
||||||
@@ -177,8 +172,10 @@ public class TestingPlanner {
|
|||||||
supervisor = new TestsSupervisor_2022(this, user.connection, tasksPackage, new Vector<>(packageTasks.values()));
|
supervisor = new TestsSupervisor_2022(this, user.connection, tasksPackage, new Vector<>(packageTasks.values()));
|
||||||
supervisor.Perform();
|
supervisor.Perform();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Print("Ошибка сеанса, соединение будет разорвано.");
|
Print("Ошибка сеанса.");
|
||||||
Print(ex.getMessage());
|
Print(ex.getMessage());
|
||||||
|
}
|
||||||
|
finally {
|
||||||
if (user.connection != null) {
|
if (user.connection != null) {
|
||||||
user.connection.Disconnect();
|
user.connection.Disconnect();
|
||||||
user.connection = null;
|
user.connection = null;
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ import Common.UI.StatusEnum;
|
|||||||
import Common.UI.Themes.VisualiserFonts;
|
import Common.UI.Themes.VisualiserFonts;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
public enum TasksPackageState implements StatusEnum {
|
public enum TasksPackageState implements StatusEnum {
|
||||||
Queued,
|
Queued,
|
||||||
|
//--
|
||||||
TestsSynchronize, //оставить.
|
TestsSynchronize, //оставить.
|
||||||
PackageWorkspaceCreation,
|
PackageWorkspaceCreation,
|
||||||
PackageStart,
|
PackageStart,
|
||||||
@@ -19,7 +23,6 @@ public enum TasksPackageState implements StatusEnum {
|
|||||||
RunningExecution,
|
RunningExecution,
|
||||||
//--
|
//--
|
||||||
RunningEnd, //скачка архива
|
RunningEnd, //скачка архива
|
||||||
Cleaning, //todo удаление папки пакета на удаленной машине. пока отладки ради не делать.
|
|
||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
Analysis,
|
Analysis,
|
||||||
Done,
|
Done,
|
||||||
@@ -77,12 +80,15 @@ public enum TasksPackageState implements StatusEnum {
|
|||||||
return "загрузка результатов";
|
return "загрузка результатов";
|
||||||
case Analysis:
|
case Analysis:
|
||||||
return "анализ результатов";
|
return "анализ результатов";
|
||||||
case Cleaning:
|
|
||||||
return "очистка";
|
|
||||||
case Done:
|
case Done:
|
||||||
return "завершен";
|
return "завершен";
|
||||||
default:
|
default:
|
||||||
return StatusEnum.super.getDescription();
|
return StatusEnum.super.getDescription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector<TasksPackageState> getHigherStates(){
|
||||||
|
return Arrays.stream(values()).filter(state -> state.ordinal() > this.ordinal()).collect(Collectors.toCollection(Vector::new));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,17 +13,13 @@ import TestingSystem.DVM.Tasks.TestTask;
|
|||||||
import TestingSystem.DVM.TasksPackage.TasksPackage;
|
import TestingSystem.DVM.TasksPackage.TasksPackage;
|
||||||
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||||
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
||||||
import com.jcraft.jsch.ChannelSftp;
|
|
||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
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.nio.charset.Charset;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
|
||||||
public class TestsSupervisor_2022 {
|
public class TestsSupervisor_2022 {
|
||||||
protected TestingPlanner planner; //планировщик.
|
protected TestingPlanner planner; //планировщик.
|
||||||
protected UserConnection connection;
|
protected UserConnection connection;
|
||||||
@@ -140,60 +136,88 @@ public class TestsSupervisor_2022 {
|
|||||||
);
|
);
|
||||||
connection.ShellCommand(plannerStartCommand);
|
connection.ShellCommand(plannerStartCommand);
|
||||||
RemoteFile PID = new RemoteFile(packageRemoteWorkspace, "PID");
|
RemoteFile PID = new RemoteFile(packageRemoteWorkspace, "PID");
|
||||||
while (!connection.Exists(packageRemoteWorkspace.full_name, "STARTED")) {
|
RemoteFile STARTED = new RemoteFile(packageRemoteWorkspace, "STARTED");
|
||||||
|
while (!connection.Exists(STARTED)) {
|
||||||
System.out.println("waiting for package start...");
|
System.out.println("waiting for package start...");
|
||||||
Utils.sleep(1000);
|
Utils.sleep(1000);
|
||||||
}
|
}
|
||||||
if (connection.Exists(packageRemoteWorkspace.full_name, "PID")) {
|
if (connection.Exists(PID)) {
|
||||||
tasksPackage.pid = connection.readFromFile(PID);
|
tasksPackage.pid = connection.readFromFile(PID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void checkNextState() throws Exception {
|
public void checkNextState() throws Exception {
|
||||||
TasksPackageState oldState = tasksPackage.state;
|
RemoteFile stateDir = new RemoteFile(packageRemoteWorkspace, "state");
|
||||||
Vector<ChannelSftp.LsEntry> files_ = connection.sftpChannel.ls(packageRemoteWorkspace.full_name + "/state");
|
//состояния пакета могут меняться только по возрастанию. ищем, появилось ли такое.
|
||||||
Vector<ChannelSftp.LsEntry> files = new Vector<>();
|
Vector<TasksPackageState> higherStates = tasksPackage.state.getHigherStates();
|
||||||
for (ChannelSftp.LsEntry file : files_) {
|
Collections.reverse(higherStates); //берем в обратном порядке, чтобы быстрее найти высшее.
|
||||||
try {
|
for (TasksPackageState state : higherStates) {
|
||||||
TasksPackageState.valueOf(file.getFilename());
|
RemoteFile file = new RemoteFile(stateDir, state.toString());
|
||||||
files.add(file);
|
if (connection.Exists(file)) {
|
||||||
} catch (Exception ignore) {
|
System.out.println("found new state: " + file.name);
|
||||||
}
|
tasksPackage.state = state;
|
||||||
}
|
|
||||||
files.sort(Comparator.comparingInt(o -> o.getAttrs().getMTime()));
|
|
||||||
if (!files.isEmpty()) {
|
|
||||||
String fileName = files.get(files.size() - 1).getFilename();
|
|
||||||
System.out.println(fileName + " last file");
|
|
||||||
tasksPackage.state = TasksPackageState.valueOf(files.get(files.size() - 1).getFilename());
|
|
||||||
if (tasksPackage.state != oldState)
|
|
||||||
planner.UpdatePackage();
|
planner.UpdatePackage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void DownloadResults() throws Exception {
|
public void DownloadResults() throws Exception {
|
||||||
Utils.CheckDirectory(packageLocalWorkspace);
|
Utils.CheckDirectory(packageLocalWorkspace);
|
||||||
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace.full_name, "results.zip");
|
RemoteFile remote_results = new RemoteFile(packageRemoteWorkspace, "results");
|
||||||
|
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace, "results.zip");
|
||||||
File results_archive = new File(packageLocalWorkspace, "results.zip");
|
File results_archive = new File(packageLocalWorkspace, "results.zip");
|
||||||
if (connection.Exists(packageRemoteWorkspace.full_name, "results.zip")) {
|
connection.performScript(packageRemoteWorkspace, "zip -r " + Utils.DQuotes("results.zip") + " " + Utils.DQuotes("results"));
|
||||||
connection.getSingleFile(remote_results_archive, results_archive, 0);
|
//---
|
||||||
|
if (connection.Exists(remote_results_archive)) {
|
||||||
|
connection.getSingleFile(remote_results_archive.full_name, results_archive.getAbsolutePath());
|
||||||
UnzipFolderPass unzipFolderPass = new UnzipFolderPass();
|
UnzipFolderPass unzipFolderPass = new UnzipFolderPass();
|
||||||
unzipFolderPass.Do(results_archive.getAbsolutePath(), packageLocalWorkspace.getAbsolutePath(), false);
|
unzipFolderPass.Do(results_archive.getAbsolutePath(), packageLocalWorkspace.getAbsolutePath(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void getTasksInfo(Vector<? extends TestTask> tasks, String file_name) throws Exception {
|
||||||
|
LinkedHashMap<Long, TestTask> sorted_tasks = new LinkedHashMap<>();
|
||||||
|
for (TestTask task : tasks)
|
||||||
|
sorted_tasks.put(task.id, task);
|
||||||
|
//--
|
||||||
|
File info_file = Paths.get(packageLocalWorkspace.getAbsolutePath(), "results", file_name).toFile();
|
||||||
|
List<String> lines = FileUtils.readLines(info_file, Charset.defaultCharset());
|
||||||
|
for (String packed : lines) {
|
||||||
|
if (!packed.isEmpty()) {
|
||||||
|
String[] data = packed.split(" ");
|
||||||
|
long id = Long.parseLong(data[0]);
|
||||||
|
TaskState state = TaskState.valueOf(data[1]);
|
||||||
|
double time = Double.parseDouble(data[2]);
|
||||||
|
//--
|
||||||
|
TestTask task = sorted_tasks.get(id);
|
||||||
|
task.state = state;
|
||||||
|
task.Time = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public void AnalyseResults() throws Exception {
|
public void AnalyseResults() throws Exception {
|
||||||
System.out.println("analysing results");
|
System.out.println("analysing results");
|
||||||
|
Vector<TestRunTask> runTasks = new Vector<>();
|
||||||
|
for (TestCompilationTask compilationTask : compilationTasks)
|
||||||
|
runTasks.addAll(compilationTask.runTasks);
|
||||||
|
//----
|
||||||
|
getTasksInfo(compilationTasks, "CompilationInfo.txt");
|
||||||
|
getTasksInfo(runTasks, "RunningInfo.txt");
|
||||||
|
//--
|
||||||
int ct_count = 0;
|
int ct_count = 0;
|
||||||
int rt_count = 0;
|
int rt_count = 0;
|
||||||
|
//--
|
||||||
for (TestCompilationTask testCompilationTask : compilationTasks) {
|
for (TestCompilationTask testCompilationTask : compilationTasks) {
|
||||||
ct_count++;
|
ct_count++;
|
||||||
if (CheckTask(testCompilationTask)) {
|
if (readTask(testCompilationTask)) {
|
||||||
for (TestRunTask testRunTask : testCompilationTask.runTasks) {
|
for (TestRunTask testRunTask : testCompilationTask.runTasks) {
|
||||||
rt_count++;
|
rt_count++;
|
||||||
testRunTask.compilation_state = testCompilationTask.state;
|
testRunTask.compilation_state = testCompilationTask.state;
|
||||||
testRunTask.compilation_output = testCompilationTask.output;
|
testRunTask.compilation_output = testCompilationTask.output;
|
||||||
testRunTask.compilation_errors = testCompilationTask.errors;
|
testRunTask.compilation_errors = testCompilationTask.errors;
|
||||||
|
testRunTask.compilation_time = testCompilationTask.Time;
|
||||||
if (testCompilationTask.state == TaskState.DoneWithErrors) {
|
if (testCompilationTask.state == TaskState.DoneWithErrors) {
|
||||||
testRunTask.state = TaskState.Canceled;
|
testRunTask.state = TaskState.Canceled;
|
||||||
} else {
|
} else {
|
||||||
CheckTask(testRunTask);
|
readTask(testRunTask);
|
||||||
}
|
}
|
||||||
if (testRunTask.state.equals(TaskState.Finished)) {
|
if (testRunTask.state.equals(TaskState.Finished)) {
|
||||||
//анализ задачи на запуск.
|
//анализ задачи на запуск.
|
||||||
@@ -226,29 +250,21 @@ public class TestsSupervisor_2022 {
|
|||||||
//теперь обновить их единым списком, и удалить задачи на компиляцию.
|
//теперь обновить их единым списком, и удалить задачи на компиляцию.
|
||||||
planner.ServerCommand(ServerCode.UpdateTestTasks, compilationTasks);
|
planner.ServerCommand(ServerCode.UpdateTestTasks, compilationTasks);
|
||||||
}
|
}
|
||||||
public boolean CheckTask(TestTask testTask) throws Exception {
|
public boolean readTask(TestTask testTask) throws Exception {
|
||||||
File taskWorkspace = Paths.get(packageLocalWorkspace.getAbsolutePath(), "results", String.valueOf(testTask.id)).toFile();
|
File taskWorkspace = Paths.get(packageLocalWorkspace.getAbsolutePath(), "results", String.valueOf(testTask.id)).toFile();
|
||||||
if (taskWorkspace.exists()) {
|
if (taskWorkspace.exists()) {
|
||||||
System.out.println("id=" + testTask.id + ": path=" + taskWorkspace.getAbsolutePath());
|
System.out.println("id=" + testTask.id + ": path=" + taskWorkspace.getAbsolutePath());
|
||||||
File stateFile = new File(taskWorkspace, "TaskState");
|
|
||||||
File outFile = new File(taskWorkspace, Constants.out_file);
|
File outFile = new File(taskWorkspace, Constants.out_file);
|
||||||
File errFile = new File(taskWorkspace.getAbsolutePath(), Constants.err_file);
|
File errFile = new File(taskWorkspace.getAbsolutePath(), Constants.err_file);
|
||||||
File timeFile = new File(taskWorkspace.getAbsolutePath(), Constants.time_file);
|
|
||||||
File stsFile = new File(taskWorkspace.getAbsolutePath(), "statistic.txt");
|
File stsFile = new File(taskWorkspace.getAbsolutePath(), "statistic.txt");
|
||||||
if (outFile.exists())
|
if (outFile.exists())
|
||||||
testTask.output = FileUtils.readFileToString(outFile);
|
testTask.output = FileUtils.readFileToString(outFile);
|
||||||
if (errFile.exists())
|
if (errFile.exists())
|
||||||
testTask.errors = FileUtils.readFileToString(errFile);
|
testTask.errors = FileUtils.readFileToString(errFile);
|
||||||
if (timeFile.exists())
|
|
||||||
testTask.Time = Double.parseDouble(Utils.ReadAllText(timeFile));
|
|
||||||
if ((testTask instanceof TestRunTask) && stsFile.exists()) {
|
if ((testTask instanceof TestRunTask) && stsFile.exists()) {
|
||||||
TestRunTask testRunTask = (TestRunTask) testTask;
|
TestRunTask testRunTask = (TestRunTask) testTask;
|
||||||
testRunTask.statistic = FileUtils.readFileToString(stsFile);
|
testRunTask.statistic = FileUtils.readFileToString(stsFile);
|
||||||
}
|
}
|
||||||
if (stateFile.exists()) {
|
|
||||||
String stateText = FileUtils.readFileToString(stateFile, Charset.defaultCharset()).replace("\n", "");
|
|
||||||
testTask.state = TaskState.valueOf(stateText);
|
|
||||||
} else testTask.state = TaskState.InternalError; //поменять на то что состояние не найдено. ?
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -7,10 +7,8 @@ import GlobalData.Machine.Machine;
|
|||||||
import GlobalData.RemoteFile.RemoteFile;
|
import GlobalData.RemoteFile.RemoteFile;
|
||||||
import GlobalData.User.User;
|
import GlobalData.User.User;
|
||||||
import Visual_DVM_2021.Passes.PassException;
|
import Visual_DVM_2021.Passes.PassException;
|
||||||
import com.jcraft.jsch.ChannelSftp;
|
import com.jcraft.jsch.*;
|
||||||
import com.jcraft.jsch.ChannelShell;
|
import javafx.util.Pair;
|
||||||
import com.jcraft.jsch.JSch;
|
|
||||||
import com.jcraft.jsch.Session;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -108,57 +106,36 @@ public class UserConnection {
|
|||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
|
//todo из за мусора результатом пользоваться в общем случае невозможно.
|
||||||
//из за мусора результатом пользоваться в общем случае невозможно.
|
//следует перенаправлять вывод в какой нибудь временный файл на сервере.
|
||||||
public String ShellCommand(String command) throws Exception {
|
public String ShellCommand(String command) throws Exception {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
// System.out.println("command=" + Utils.Brackets(command));
|
|
||||||
pin.write((command + "\r\n").getBytes());
|
pin.write((command + "\r\n").getBytes());
|
||||||
ShellParser.ReadInvitation(fromServer); //первое приглашение после эхо. возможен мусор.
|
ShellParser.ReadInvitation(fromServer); //первое приглашение после эхо. возможен мусор.
|
||||||
result.append(ShellParser.getCommandResult(fromServer)); //возможный результат и второе приглашение.
|
result.append(ShellParser.getCommandResult(fromServer)); //возможный результат и второе приглашение.
|
||||||
// System.out.println("answer=" + Utils.Brackets(result));
|
|
||||||
//в реалиях визуалиазтора нас интересует только ПОСЛЕДНЯЯ СТРОКА ОТВЕТА.
|
|
||||||
String[] data = result.toString().split("\n");
|
String[] data = result.toString().split("\n");
|
||||||
// System.out.println("res="+Utils.Brackets(res));
|
|
||||||
return (data.length > 0) ? data[data.length - 1] : result.toString();
|
return (data.length > 0) ? data[data.length - 1] : result.toString();
|
||||||
}
|
}
|
||||||
//--
|
|
||||||
//тут имя файла короткое.
|
|
||||||
public boolean Exists(String folder, String name) throws Exception {
|
|
||||||
Vector<ChannelSftp.LsEntry> files = sftpChannel.ls(folder);
|
|
||||||
for (ChannelSftp.LsEntry file : files) {
|
|
||||||
file.getAttrs().getSize();
|
|
||||||
if (file.getFilename().equals(name)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//--
|
|
||||||
public void getSingleFile(String src, String dst) throws Exception {
|
public void getSingleFile(String src, String dst) throws Exception {
|
||||||
sftpChannel.get(src, dst);
|
sftpChannel.get(src, dst);
|
||||||
}
|
}
|
||||||
public long getFileKBSize(String path) throws Exception{
|
public long getFileKBSize(String path) throws Exception {
|
||||||
long size = sftpChannel.lstat(path).getSize();
|
long size = sftpChannel.lstat(path).getSize();
|
||||||
return size/1024;
|
return size / 1024;
|
||||||
}
|
}
|
||||||
public boolean getSingleFile(RemoteFile src, File dst, int maxSize) throws Exception {
|
public void getSingleFileWithMaxSize(RemoteFile src, File dst, int maxSize) throws Exception {
|
||||||
if (Exists(src.parent, src.name)) {
|
if ((maxSize == 0) || getFileKBSize(src.full_name) <= maxSize) {
|
||||||
if ((maxSize == 0) || getFileKBSize(src.full_name) <= maxSize) {
|
getSingleFile(src.full_name, dst.getAbsolutePath());
|
||||||
getSingleFile(src.full_name, dst.getAbsolutePath());
|
} else {
|
||||||
return true;
|
Utils.WriteToFile(dst, "Размер файла превышает " + maxSize + " KB.\n" + "Файл не загружен. Его можно просмотреть на машине по адресу\n" + Utils.Brackets(src.full_name));
|
||||||
} else {
|
|
||||||
Utils.WriteToFile(dst, "Размер файла превышает " + maxSize + " KB.\n" + "Файл не загружен. Его можно просмотреть на машине по адресу\n" + Utils.Brackets(src.full_name));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
public void putSingleFile(File src, RemoteFile dst) throws Exception {
|
public void putSingleFile(File src, RemoteFile dst) throws Exception {
|
||||||
sftpChannel.put(src.getAbsolutePath(), dst.full_name);
|
sftpChannel.put(src.getAbsolutePath(), dst.full_name);
|
||||||
}
|
}
|
||||||
//-
|
//-
|
||||||
public void MKDIR(RemoteFile dir) throws Exception {
|
public void MKDIR(RemoteFile dir) throws Exception {
|
||||||
if (!Exists(dir.parent, dir.name)) sftpChannel.mkdir(dir.full_name);
|
if (!Exists(dir)) sftpChannel.mkdir(dir.full_name);
|
||||||
}
|
}
|
||||||
//-
|
//-
|
||||||
public void RMDIR(String dir) throws Exception {
|
public void RMDIR(String dir) throws Exception {
|
||||||
@@ -210,12 +187,6 @@ public class UserConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public void copy(RemoteFile src, RemoteFile dst) throws Exception {
|
|
||||||
ShellCommand("cp " + Utils.DQuotes(src.full_name) + " " + Utils.DQuotes(dst.full_name));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//-------
|
|
||||||
public void writeToFile(String text, RemoteFile dst) throws Exception {
|
public void writeToFile(String text, RemoteFile dst) throws Exception {
|
||||||
sftpChannel.put(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), dst.full_name);
|
sftpChannel.put(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), dst.full_name);
|
||||||
sftpChannel.chmod(0777, dst.full_name);
|
sftpChannel.chmod(0777, dst.full_name);
|
||||||
@@ -225,4 +196,42 @@ public class UserConnection {
|
|||||||
sftpChannel.get(src.full_name, outputStream);
|
sftpChannel.get(src.full_name, outputStream);
|
||||||
return outputStream.toString(StandardCharsets.UTF_8.name());
|
return outputStream.toString(StandardCharsets.UTF_8.name());
|
||||||
}
|
}
|
||||||
|
//--
|
||||||
|
public boolean Exists(String file_full_name) throws Exception {
|
||||||
|
try {
|
||||||
|
sftpChannel.lstat(file_full_name);
|
||||||
|
return true;
|
||||||
|
} catch (SftpException e) {
|
||||||
|
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
|
||||||
|
// file doesn't exist
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// something else went wrong
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public boolean Exists(RemoteFile file) throws Exception {
|
||||||
|
return Exists(file.full_name);
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
public Pair<RemoteFile, RemoteFile> performScript(RemoteFile directory, String... commands) throws Exception {
|
||||||
|
RemoteFile script_file = new RemoteFile(directory, Constants.script);
|
||||||
|
RemoteFile out = new RemoteFile(directory, Constants.out_file);
|
||||||
|
RemoteFile err = new RemoteFile(directory, Constants.err_file);
|
||||||
|
//
|
||||||
|
Vector<RemoteFile> files = new Vector<>();
|
||||||
|
files.add(script_file);
|
||||||
|
files.add(out);
|
||||||
|
files.add(err);
|
||||||
|
for (RemoteFile file : files) {
|
||||||
|
if (Exists(file))
|
||||||
|
sftpChannel.rm(file.full_name);
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
writeToFile("cd " + Utils.DQuotes(directory.full_name)+"\n"+ String.join("\n", commands), script_file);
|
||||||
|
//--
|
||||||
|
ShellCommand(script_file.full_name + " 1>" + Utils.DQuotes(out.full_name) + " 2>" + Utils.DQuotes(err.full_name));
|
||||||
|
return new Pair<>(out, err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
src/Visual_DVM_2021/Passes/All/DeleteTasksPackage.java
Normal file
25
src/Visual_DVM_2021/Passes/All/DeleteTasksPackage.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package Visual_DVM_2021.Passes.All;
|
||||||
|
import Common.UI.UI;
|
||||||
|
import TestingSystem.DVM.TasksPackage.TasksPackage;
|
||||||
|
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||||
|
import Visual_DVM_2021.Passes.Server.DeleteServerAccountObject;
|
||||||
|
public class DeleteTasksPackage extends DeleteServerAccountObject<TasksPackage> {
|
||||||
|
public DeleteTasksPackage() {
|
||||||
|
super(TasksPackage.class);
|
||||||
|
}
|
||||||
|
public boolean checkActivity() {
|
||||||
|
if (!target.state.equals(TasksPackageState.Done) && !target.state.equals(TasksPackageState.Aborted)) {
|
||||||
|
Log.Writeln_("Нельзя удалить активный пакет!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected boolean canStart(Object... args) throws Exception {
|
||||||
|
return super.canStart(args) && checkActivity();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void showPreparation() throws Exception {
|
||||||
|
UI.getMainWindow().getTestingWindow().DropTestRunTasksComparison();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,11 +59,12 @@ public class InstallServerSapfor extends ConnectionPass<Object> {
|
|||||||
ShowMessage1("Сборка SAPFOR...");
|
ShowMessage1("Сборка SAPFOR...");
|
||||||
//-
|
//-
|
||||||
RemoteFile repo_bin = new RemoteFile(repoSapforHome.full_name, "Sapfor_F");
|
RemoteFile repo_bin = new RemoteFile(repoSapforHome.full_name, "Sapfor_F");
|
||||||
if (Exists(repoSapforHome.full_name, repo_bin.name))
|
if (Exists(repo_bin))
|
||||||
sftpChannel.rm(repo_bin.full_name);
|
sftpChannel.rm(repo_bin.full_name);
|
||||||
//--
|
//--
|
||||||
performScript(repoSapforHome, "cmake ../", "make -j 4");
|
performScript(repoSapforHome, "cmake ../", "make -j 4");
|
||||||
result = Exists(repoSapforHome.full_name, "Sapfor_F");
|
RemoteFile repoSapfor = new RemoteFile(repoSapforHome, "Sapfor_F");
|
||||||
|
result = Exists(repoSapfor);
|
||||||
if (result) {
|
if (result) {
|
||||||
RemoteFile sapforsDirectory = new RemoteFile(testingSystemHome.full_name, "Sapfors", true);
|
RemoteFile sapforsDirectory = new RemoteFile(testingSystemHome.full_name, "Sapfors", true);
|
||||||
//создать папку. Для того чтобы скопировать из репозитория.
|
//создать папку. Для того чтобы скопировать из репозитория.
|
||||||
@@ -116,6 +117,5 @@ public class InstallServerSapfor extends ConnectionPass<Object> {
|
|||||||
protected void performDone() throws Exception {
|
protected void performDone() throws Exception {
|
||||||
passes.get(PassCode_2021.PublishServerSapfor).Do(serverSapfor);
|
passes.get(PassCode_2021.PublishServerSapfor).Do(serverSapfor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -303,12 +303,15 @@ public enum PassCode_2021 {
|
|||||||
CreateTestFromFile,
|
CreateTestFromFile,
|
||||||
CreateTestsFromFiles,
|
CreateTestsFromFiles,
|
||||||
CreateGroupFromFiles,
|
CreateGroupFromFiles,
|
||||||
|
DeleteTasksPackage,
|
||||||
//->
|
//->
|
||||||
TestPass;
|
TestPass;
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case Undefined:
|
case Undefined:
|
||||||
return "?";
|
return "?";
|
||||||
|
case DeleteTasksPackage:
|
||||||
|
return "Удалить пакет задач";
|
||||||
case CreateGroupFromFiles:
|
case CreateGroupFromFiles:
|
||||||
return "Создать группу из файлов в папке";
|
return "Создать группу из файлов в папке";
|
||||||
case CreateTestsFromFiles:
|
case CreateTestsFromFiles:
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
|
|||||||
isConnected = true; // теперь можно прерывать метод.
|
isConnected = true; // теперь можно прерывать метод.
|
||||||
if (needsInitialize()) {
|
if (needsInitialize()) {
|
||||||
RemoteFile userWorkspace = new RemoteFile(user.workspace, true);
|
RemoteFile userWorkspace = new RemoteFile(user.workspace, true);
|
||||||
if (!Exists(sftpChannel.getHome(), userWorkspace.name))
|
if (!Exists(userWorkspace))
|
||||||
throw new WorkspaceNotFoundException(
|
throw new WorkspaceNotFoundException(
|
||||||
"Рабочее пространство пользователя " + Utils.Brackets(user.login)
|
"Рабочее пространство пользователя " + Utils.Brackets(user.login)
|
||||||
+ " на машине " + Utils.Brackets(machine.getURL())
|
+ " на машине " + Utils.Brackets(machine.getURL())
|
||||||
@@ -171,8 +171,8 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
|
|||||||
sftpChannel.get(src, dst);
|
sftpChannel.get(src, dst);
|
||||||
}
|
}
|
||||||
//с проверкой.
|
//с проверкой.
|
||||||
public boolean tryGetSingleFile(RemoteFile src, File dst, int maxSize) throws Exception {
|
public boolean tryGetSingleFileWithMaxSize(RemoteFile src, File dst, int maxSize) throws Exception {
|
||||||
if (Exists(src.parent, src.name)) {
|
if (Exists(src)) {
|
||||||
if ((maxSize == 0) || (getFileKBSize(src.full_name) <= maxSize)) {
|
if ((maxSize == 0) || (getFileKBSize(src.full_name) <= maxSize)) {
|
||||||
getSingleFile(src.full_name, dst.getAbsolutePath());
|
getSingleFile(src.full_name, dst.getAbsolutePath());
|
||||||
return true;
|
return true;
|
||||||
@@ -186,19 +186,11 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
|
|||||||
sftpChannel.put(src.getAbsolutePath(), dst.full_name);
|
sftpChannel.put(src.getAbsolutePath(), dst.full_name);
|
||||||
}
|
}
|
||||||
public void tryMKDir(RemoteFile dir) throws Exception {
|
public void tryMKDir(RemoteFile dir) throws Exception {
|
||||||
// System.out.print("try mkdir: '" + dir.full_name);
|
if (!Exists(dir)) sftpChannel.mkdir(dir.full_name);
|
||||||
if (!Exists(dir.parent, dir.name)) sftpChannel.mkdir(dir.full_name);
|
|
||||||
// System.out.println("..done");
|
|
||||||
}
|
}
|
||||||
public void tryRM(RemoteFile file) throws Exception {
|
public void tryRM(RemoteFile file) throws Exception {
|
||||||
// System.out.print("try remove: '" + file.full_name);
|
if (Exists(file))
|
||||||
if (Exists(file.parent, file.name)) {
|
|
||||||
// System.out.print("' :exists.needs remove..");
|
|
||||||
sftpChannel.rm(file.full_name);
|
sftpChannel.rm(file.full_name);
|
||||||
// System.out.println(" +");
|
|
||||||
} else {
|
|
||||||
// System.out.println("no such file");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void putSingleFile(String src, String dst) throws Exception {
|
public void putSingleFile(String src, String dst) throws Exception {
|
||||||
sftpChannel.put(src, dst);
|
sftpChannel.put(src, dst);
|
||||||
@@ -213,16 +205,6 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
|
|||||||
}
|
}
|
||||||
protected void ServerAction() throws Exception {
|
protected void ServerAction() throws Exception {
|
||||||
}
|
}
|
||||||
//тут имя файла короткое.
|
|
||||||
public boolean Exists(String folder, String name) throws Exception {
|
|
||||||
Vector<ChannelSftp.LsEntry> files = sftpChannel.ls(folder);
|
|
||||||
for (ChannelSftp.LsEntry file : files) {
|
|
||||||
if (file.getFilename().equals(name)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//https://losst.ru/komanda-find-v-linux#%D0%9E%D1%81%D0%BD%D0%BE%D0%B2%D0%BD%D1%8B%D0%B5_%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80%D1%8B_%D0%BA%D0%BE%D0%BC%D0%B0%D0%BD%D0%B4%D1%8B_find
|
//https://losst.ru/komanda-find-v-linux#%D0%9E%D1%81%D0%BD%D0%BE%D0%B2%D0%BD%D1%8B%D0%B5_%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80%D1%8B_%D0%BA%D0%BE%D0%BC%D0%B0%D0%BD%D0%B4%D1%8B_find
|
||||||
public String getStarter() {
|
public String getStarter() {
|
||||||
return String.join("/", user.workspace, modules, starter);
|
return String.join("/", user.workspace, modules, starter);
|
||||||
@@ -385,7 +367,7 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
|
|||||||
//скорее всего,временные методы. они есть в UserConnection, при удаленном запуске тестирования
|
//скорее всего,временные методы. они есть в UserConnection, при удаленном запуске тестирования
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
public void MKDIR(RemoteFile dir) throws Exception {
|
public void MKDIR(RemoteFile dir) throws Exception {
|
||||||
if (!Exists(dir.parent, dir.name)) sftpChannel.mkdir(dir.full_name);
|
if (!Exists(dir)) sftpChannel.mkdir(dir.full_name);
|
||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
public Pair<RemoteFile, RemoteFile> performScript(RemoteFile directory, String... commands) throws Exception {
|
public Pair<RemoteFile, RemoteFile> performScript(RemoteFile directory, String... commands) throws Exception {
|
||||||
@@ -398,7 +380,7 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
|
|||||||
files.add(out);
|
files.add(out);
|
||||||
files.add(err);
|
files.add(err);
|
||||||
for (RemoteFile file : files) {
|
for (RemoteFile file : files) {
|
||||||
if (Exists(directory.full_name, file.name))
|
if (Exists(file))
|
||||||
sftpChannel.rm(file.full_name);
|
sftpChannel.rm(file.full_name);
|
||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
@@ -406,9 +388,27 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
|
|||||||
//--
|
//--
|
||||||
ShellCommand("cd " + Utils.DQuotes(directory.full_name),
|
ShellCommand("cd " + Utils.DQuotes(directory.full_name),
|
||||||
script_file.full_name + " 1>" + Constants.out_file + " 2>" + Constants.err_file);
|
script_file.full_name + " 1>" + Constants.out_file + " 2>" + Constants.err_file);
|
||||||
|
|
||||||
return new Pair<>(out, err);
|
return new Pair<>(out, err);
|
||||||
}
|
}
|
||||||
|
//--
|
||||||
|
//--
|
||||||
|
public boolean Exists(String file_full_name) throws Exception {
|
||||||
|
try {
|
||||||
|
sftpChannel.stat(file_full_name);
|
||||||
|
return true;
|
||||||
|
} catch (SftpException e) {
|
||||||
|
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
|
||||||
|
// file doesn't exist
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// something else went wrong
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public boolean Exists(RemoteFile file) throws Exception {
|
||||||
|
return Exists(file.full_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,15 +37,6 @@ public class DebugForm implements DebugWindow, FormWithSplitters {
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void SaveSplitters() {
|
|
||||||
FormWithSplitters.super.SaveSplitters();
|
|
||||||
try {
|
|
||||||
Global.db.SaveCredentials();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Global.Log.PrintException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void DropRunTasksComparison() {
|
public void DropRunTasksComparison() {
|
||||||
singleRunTaskMaster.RemoveObject();
|
singleRunTaskMaster.RemoveObject();
|
||||||
singleRunTaskSlave.RemoveObject();
|
singleRunTaskSlave.RemoveObject();
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public class MainForm extends Form implements MainWindow {
|
|||||||
if (UI.debugWindow != null)
|
if (UI.debugWindow != null)
|
||||||
((FormWithSplitters) UI.debugWindow).SaveSplitters();
|
((FormWithSplitters) UI.debugWindow).SaveSplitters();
|
||||||
//--
|
//--
|
||||||
|
Global.db.SaveCredentials();
|
||||||
|
//--
|
||||||
Global.FinishApplication();
|
Global.FinishApplication();
|
||||||
}
|
}
|
||||||
public MainForm() {
|
public MainForm() {
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ public:
|
|||||||
File makeFileFile = File(makeFilePath, this->makefile_text);
|
File makeFileFile = File(makeFilePath, this->makefile_text);
|
||||||
String tests = userWorkspace + "/projects";
|
String tests = userWorkspace + "/projects";
|
||||||
String testPath = tests + "/" + test_id;
|
String testPath = tests + "/" + test_id;
|
||||||
String copyCommand = "cp -r " + String::DQuotes(testPath + "/.") + " " + String::DQuotes(workspace);
|
Utils::CopyDirectory(testPath, workspace);
|
||||||
system(copyCommand.getCharArray());
|
|
||||||
}
|
}
|
||||||
virtual String getLaunchScriptText() {
|
virtual String getLaunchScriptText() {
|
||||||
String modules = userWorkspace + "/modules";
|
String modules = userWorkspace + "/modules";
|
||||||
@@ -45,6 +44,7 @@ public:
|
|||||||
"make -j -f Makefile";
|
"make -j -f Makefile";
|
||||||
}
|
}
|
||||||
virtual void analyseResults() {
|
virtual void analyseResults() {
|
||||||
|
Task::analyseResults();
|
||||||
String binary = workspace + "/0";
|
String binary = workspace + "/0";
|
||||||
state = Utils::Exists(binary) ? Done : DoneWithErrors;
|
state = Utils::Exists(binary) ? Done : DoneWithErrors;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public:
|
|||||||
}
|
}
|
||||||
File(const String& name, const String& text) {
|
File(const String& name, const String& text) {
|
||||||
ptr = fopen(name.getCharArray(), "w");
|
ptr = fopen(name.getCharArray(), "w");
|
||||||
fprintf(ptr, "%s\n", text.getCharArray());
|
fprintf(ptr, "%s", text.getCharArray());
|
||||||
}
|
}
|
||||||
~File() {
|
~File() {
|
||||||
Close();
|
Close();
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ int main(int argc, char ** argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("PID=%d\n", pid);
|
printf("PID=%d\n", pid);
|
||||||
File pidFile("PID", String(pid));
|
File pidFile("PID", String(pid)+"\n");
|
||||||
pidFile.Close();
|
pidFile.Close();
|
||||||
//---
|
//---
|
||||||
File startFile("STARTED", "+");
|
File startFile("STARTED", "+");
|
||||||
|
|||||||
@@ -22,14 +22,4 @@ public:
|
|||||||
virtual String getStatePrefix() {
|
virtual String getStatePrefix() {
|
||||||
return String("Running");
|
return String("Running");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
virtual void Finalize(){
|
|
||||||
this->state = Archivation;
|
|
||||||
saveState();
|
|
||||||
printf("Archivation started\n");
|
|
||||||
Utils::ZipFolder(String("./"),String("archive.zip"));
|
|
||||||
printf("Archivation ended\n");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -96,8 +96,10 @@ public:
|
|||||||
virtual String copyResults(const String& pathRes) {
|
virtual String copyResults(const String& pathRes) {
|
||||||
String resultPath = Task::copyResults(pathRes);
|
String resultPath = Task::copyResults(pathRes);
|
||||||
if (Utils::Exists(workspace + "/sts.gz+")) {
|
if (Utils::Exists(workspace + "/sts.gz+")) {
|
||||||
String dvm_start = String::DQuotes(dvm_drv) + " pa " + String::DQuotes(String(getId()) + "/sts.gz+") + " " + String::DQuotes(resultPath + "/statistic.txt");
|
String stsPath(resultPath + "/statistic.txt");
|
||||||
|
String dvm_start = String::DQuotes(dvm_drv) + " pa " + String::DQuotes(String(getId()) + "/sts.gz+") + " " + String::DQuotes(stsPath);
|
||||||
system(dvm_start.getCharArray());
|
system(dvm_start.getCharArray());
|
||||||
|
while (!Utils::Exists(stsPath));
|
||||||
}
|
}
|
||||||
return resultPath;
|
return resultPath;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,8 @@
|
|||||||
enum SupervisorState {
|
enum SupervisorState {
|
||||||
WorkspacesCreation, //0
|
WorkspacesCreation, //0
|
||||||
Preparation, //1
|
Preparation, //1
|
||||||
Execution, //2
|
Execution, //2
|
||||||
Archivation, //3
|
End //3
|
||||||
End //4
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -32,8 +31,6 @@ public:
|
|||||||
return String("Preparation");
|
return String("Preparation");
|
||||||
case Execution:
|
case Execution:
|
||||||
return String("Execution");
|
return String("Execution");
|
||||||
case Archivation:
|
|
||||||
return String("Archivation");
|
|
||||||
case End:
|
case End:
|
||||||
return String("End");
|
return String("End");
|
||||||
default:
|
default:
|
||||||
@@ -71,7 +68,6 @@ public:
|
|||||||
saveState();
|
saveState();
|
||||||
break;
|
break;
|
||||||
case Execution:
|
case Execution:
|
||||||
Finalize();
|
|
||||||
this->state = End;
|
this->state = End;
|
||||||
saveState();
|
saveState();
|
||||||
break;
|
break;
|
||||||
@@ -126,7 +122,7 @@ public:
|
|||||||
|
|
||||||
String pathRes("results");
|
String pathRes("results");
|
||||||
Utils::Mkdir(pathRes);
|
Utils::Mkdir(pathRes);
|
||||||
//string buf;
|
string buf;
|
||||||
|
|
||||||
while (activeTasks) {
|
while (activeTasks) {
|
||||||
long oldActiveTasks = activeTasks;
|
long oldActiveTasks = activeTasks;
|
||||||
@@ -174,7 +170,7 @@ public:
|
|||||||
busyKernels -= task->getKernels();
|
busyKernels -= task->getKernels();
|
||||||
printf(" done task with %d kernels and id %ld\n", task->getKernels(), task->getId());
|
printf(" done task with %d kernels and id %ld\n", task->getKernels(), task->getId());
|
||||||
|
|
||||||
//buf += to_string(task->getId()) + " " + string(task->printState().getCharArray()) + " " + to_string(task->getTotalTime()) + "\n";
|
buf += to_string(task->getId()) + " " + string(task->printState().getCharArray()) + " " + to_string(task->getTotalTime()) + "\n";
|
||||||
task->copyResults(pathRes);
|
task->copyResults(pathRes);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -187,18 +183,12 @@ public:
|
|||||||
|
|
||||||
changeState();
|
changeState();
|
||||||
|
|
||||||
//String outFile(pathRes + "/info.txt");
|
String outFile(pathRes + "/"+getStatePrefix()+"Info.txt");
|
||||||
//File tmp(outFile, String(buf.c_str()));
|
File tmp(outFile, String(buf.c_str()));
|
||||||
|
|
||||||
Utils::ZipFolder(pathRes, pathRes + ".zip");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Finalize() { }
|
|
||||||
|
|
||||||
void saveState() {
|
void saveState() {
|
||||||
Utils::Sleep(1); //чтобы не было одинаковых по дате файлов.
|
Utils::Sleep(1); //чтобы не было одинаковых по дате файлов.
|
||||||
String stateFile = packageWorkspace + "/state/" + getStatePrefix() + printState();
|
String stateFile = packageWorkspace + "/state/" + getStatePrefix() + printState();
|
||||||
//printf("stateFile=<%s>\n", stateFile.getCharArray());
|
|
||||||
File tmp(stateFile, Utils::getDate());
|
File tmp(stateFile, Utils::getDate());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -173,15 +173,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != Running) {
|
if (state != Running) {
|
||||||
//-
|
|
||||||
busyKernels = Utils::min(busyKernels - kernels, maxKernels);
|
busyKernels = Utils::min(busyKernels - kernels, maxKernels);
|
||||||
freeKernels = Utils::max(0, maxKernels - busyKernels);
|
freeKernels = Utils::max(0, maxKernels - busyKernels);
|
||||||
//-
|
|
||||||
saveState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (state != Running);
|
return (state != Running);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,19 +187,11 @@ public:
|
|||||||
printf("%ld done with time %f\n", id, total_time);
|
printf("%ld done with time %f\n", id, total_time);
|
||||||
state = Finished;
|
state = Finished;
|
||||||
}
|
}
|
||||||
|
virtual String copyResults(const String& pathRes) {
|
||||||
virtual void saveState() {
|
String resultPath(packageWorkspace + "/" + pathRes + "/" + getId());
|
||||||
String stateFile = workspace + "/TaskState";
|
Utils::Mkdir(resultPath);
|
||||||
File tmp(stateFile, printState());
|
Utils::Copy(workspace + "/out.txt", resultPath + "/out.txt");
|
||||||
}
|
Utils::Copy(workspace + "/err.txt", resultPath + "/err.txt");
|
||||||
|
return resultPath;
|
||||||
virtual String copyResults(const String& pathRes) {
|
|
||||||
String resultPath(packageWorkspace + "/" + pathRes + "/" + getId());
|
|
||||||
Utils::Mkdir(resultPath);
|
|
||||||
Utils::Copy(workspace + "/TaskState", resultPath + "/TaskState");
|
|
||||||
Utils::Copy(workspace + "/out.txt", resultPath + "/out.txt");
|
|
||||||
Utils::Copy(workspace + "/err.txt", resultPath + "/err.txt");
|
|
||||||
Utils::Copy(workspace + "/total_time", resultPath + "/total_time");
|
|
||||||
return resultPath;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,8 +31,13 @@ public:
|
|||||||
|
|
||||||
//https://stackoverflow.com/questions/4568681/using-chmod-in-a-c-program
|
//https://stackoverflow.com/questions/4568681/using-chmod-in-a-c-program
|
||||||
static void Chmod(const String& path) {
|
static void Chmod(const String& path) {
|
||||||
String command = "chmod 777 " + String::DQuotes(path);
|
#if __cplusplus >= 201703L
|
||||||
system(command.getCharArray());
|
std::filesystem::permissions(path.getCharArray(), std::filesystem::perms::all);
|
||||||
|
#else
|
||||||
|
String command = "chmod 777 " + String::DQuotes(path);
|
||||||
|
int i=system(command.getCharArray());
|
||||||
|
printf("chmod 777 '%s' return code = %d\n", path.getCharArray(), i);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//https://stackoverflow.com/questions/230062/whats-the-best-way-to-check-if-a-file-exists-in-c
|
//https://stackoverflow.com/questions/230062/whats-the-best-way-to-check-if-a-file-exists-in-c
|
||||||
@@ -47,9 +52,23 @@ public:
|
|||||||
std::this_thread::sleep_for(timespan);
|
std::this_thread::sleep_for(timespan);
|
||||||
}
|
}
|
||||||
static void Copy(const String& src, const String& dst) {
|
static void Copy(const String& src, const String& dst) {
|
||||||
String command = "cp " + String::DQuotes(src) + " " + String::DQuotes(dst);
|
#if __cplusplus >= 201703L
|
||||||
system(command.getCharArray());
|
std::filesystem::copy(src.getCharArray(), dst.getCharArray());
|
||||||
|
#else
|
||||||
|
String command = "cp " + String::DQuotes(src) + " " + String::DQuotes(dst);
|
||||||
|
int i = system(command.getCharArray());
|
||||||
|
printf("cp '%s' return code = %d\n",src.getCharArray(), i);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
static void CopyDirectory(const String& src, const String& dst) {
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
|
std::filesystem::copy((src+ "/.").getCharArray(), dst.getCharArray(), std::filesystem::copy_options::recursive);
|
||||||
|
#else
|
||||||
|
String command = "cp -r " + String::DQuotes(src + "/.") + " " + String::DQuotes(dst);
|
||||||
|
int i = system(command.getCharArray());
|
||||||
|
printf("cp -r '%s' return code = %d\n",src.getCharArray(),i);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
static time_t getAbsoluteTime() {
|
static time_t getAbsoluteTime() {
|
||||||
return time(NULL);
|
return time(NULL);
|
||||||
}
|
}
|
||||||
@@ -58,8 +77,4 @@ public:
|
|||||||
String res(ctime(&ttime));
|
String res(ctime(&ttime));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
static void ZipFolder(const String& src, const String& dst) {
|
|
||||||
String command = "zip -r " + String::DQuotes(dst) + " " + String::DQuotes(src);
|
|
||||||
system(command.getCharArray());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user