новая распаковка анализа
This commit is contained in:
3
.idea/workspace.xml
generated
3
.idea/workspace.xml
generated
@@ -10,8 +10,7 @@
|
|||||||
<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/TestingSystem/DVM/TestsSupervisor_2022.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/TestsSupervisor_2022.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/TestingSystem/DVM/UserConnection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/files/Planner/CompilationTask.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/CompilationTask.h" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/SSH/ConnectionPass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/SSH/ConnectionPass.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/files/Planner/Utils.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/Utils.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" />
|
||||||
|
|||||||
@@ -12,16 +12,14 @@ import TestingSystem.DVM.Tasks.TestRunTask;
|
|||||||
import TestingSystem.DVM.Tasks.TestTask;
|
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 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.Collections;
|
|
||||||
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;
|
||||||
@@ -152,10 +150,10 @@ public class TestsSupervisor_2022 {
|
|||||||
//состояния пакета могут меняться только по возрастанию. ищем, появилось ли такое.
|
//состояния пакета могут меняться только по возрастанию. ищем, появилось ли такое.
|
||||||
Vector<TasksPackageState> higherStates = tasksPackage.state.getHigherStates();
|
Vector<TasksPackageState> higherStates = tasksPackage.state.getHigherStates();
|
||||||
Collections.reverse(higherStates); //берем в обратном порядке, чтобы быстрее найти высшее.
|
Collections.reverse(higherStates); //берем в обратном порядке, чтобы быстрее найти высшее.
|
||||||
for (TasksPackageState state: higherStates){
|
for (TasksPackageState state : higherStates) {
|
||||||
RemoteFile file = new RemoteFile(stateDir, state.toString());
|
RemoteFile file = new RemoteFile(stateDir, state.toString());
|
||||||
if (connection.Exists(file)){
|
if (connection.Exists(file)) {
|
||||||
System.out.println("found new state: "+file.name);
|
System.out.println("found new state: " + file.name);
|
||||||
tasksPackage.state = state;
|
tasksPackage.state = state;
|
||||||
planner.UpdatePackage();
|
planner.UpdatePackage();
|
||||||
return;
|
return;
|
||||||
@@ -166,92 +164,106 @@ public class TestsSupervisor_2022 {
|
|||||||
Utils.CheckDirectory(packageLocalWorkspace);
|
Utils.CheckDirectory(packageLocalWorkspace);
|
||||||
RemoteFile remote_results = new RemoteFile(packageRemoteWorkspace, "results");
|
RemoteFile remote_results = new RemoteFile(packageRemoteWorkspace, "results");
|
||||||
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace, "results.zip");
|
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace, "results.zip");
|
||||||
connection.ShellCommand(
|
File results_archive = new File(packageLocalWorkspace, "results.zip");
|
||||||
|
connection.performScript(packageRemoteWorkspace, "zip -r " + Utils.DQuotes("results.zip") + " " + Utils.DQuotes("results"));
|
||||||
"zip -r "+Utils.DQuotes(remote_results_archive.full_name)+" "+Utils.DQuotes(remote_results.full_name));
|
//---
|
||||||
/*
|
if (connection.Exists(remote_results_archive)) {
|
||||||
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace.full_name, "results.zip");
|
connection.getSingleFile(remote_results_archive.full_name, results_archive.getAbsolutePath());
|
||||||
|
|
||||||
if (connection.Exists()) {
|
|
||||||
connection.getSingleFile(remote_results_archive, results_archive);
|
|
||||||
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");
|
||||||
if (false) {
|
Vector<TestRunTask> runTasks = new Vector<>();
|
||||||
int ct_count = 0;
|
for (TestCompilationTask compilationTask : compilationTasks)
|
||||||
int rt_count = 0;
|
runTasks.addAll(compilationTask.runTasks);
|
||||||
for (TestCompilationTask testCompilationTask : compilationTasks) {
|
//----
|
||||||
ct_count++;
|
getTasksInfo(compilationTasks, "CompilationInfo.txt");
|
||||||
if (CheckTask(testCompilationTask)) {
|
getTasksInfo(runTasks, "RunningInfo.txt");
|
||||||
for (TestRunTask testRunTask : testCompilationTask.runTasks) {
|
//--
|
||||||
rt_count++;
|
int ct_count = 0;
|
||||||
testRunTask.compilation_state = testCompilationTask.state;
|
int rt_count = 0;
|
||||||
testRunTask.compilation_output = testCompilationTask.output;
|
//--
|
||||||
testRunTask.compilation_errors = testCompilationTask.errors;
|
for (TestCompilationTask testCompilationTask : compilationTasks) {
|
||||||
if (testCompilationTask.state == TaskState.DoneWithErrors) {
|
ct_count++;
|
||||||
testRunTask.state = TaskState.Canceled;
|
if (readTask(testCompilationTask)) {
|
||||||
|
for (TestRunTask testRunTask : testCompilationTask.runTasks) {
|
||||||
|
rt_count++;
|
||||||
|
testRunTask.compilation_state = testCompilationTask.state;
|
||||||
|
testRunTask.compilation_output = testCompilationTask.output;
|
||||||
|
testRunTask.compilation_errors = testCompilationTask.errors;
|
||||||
|
if (testCompilationTask.state == TaskState.DoneWithErrors) {
|
||||||
|
testRunTask.state = TaskState.Canceled;
|
||||||
|
} else {
|
||||||
|
readTask(testRunTask);
|
||||||
|
}
|
||||||
|
if (testRunTask.state.equals(TaskState.Finished)) {
|
||||||
|
//анализ задачи на запуск.
|
||||||
|
List<String> output_lines = Arrays.asList(testRunTask.output.split("\n"));
|
||||||
|
List<String> errors_lines = Arrays.asList(testRunTask.errors.split("\n"));
|
||||||
|
//---
|
||||||
|
if (Utils.isCrushed(output_lines, errors_lines)) {
|
||||||
|
testRunTask.state = TaskState.Crushed;
|
||||||
} else {
|
} else {
|
||||||
CheckTask(testRunTask);
|
Pair<TaskState, Integer> results = new Pair<>(TaskState.Done, 100);
|
||||||
}
|
switch (testRunTask.test_type) {
|
||||||
if (testRunTask.state.equals(TaskState.Finished)) {
|
case Correctness:
|
||||||
//анализ задачи на запуск.
|
results = Utils.analyzeCorrectness(output_lines);
|
||||||
List<String> output_lines = Arrays.asList(testRunTask.output.split("\n"));
|
break;
|
||||||
List<String> errors_lines = Arrays.asList(testRunTask.errors.split("\n"));
|
case Performance:
|
||||||
//---
|
results = Utils.analyzePerformance(output_lines);
|
||||||
if (Utils.isCrushed(output_lines, errors_lines)) {
|
break;
|
||||||
testRunTask.state = TaskState.Crushed;
|
default:
|
||||||
} else {
|
break;
|
||||||
Pair<TaskState, Integer> results = new Pair<>(TaskState.Done, 100);
|
|
||||||
switch (testRunTask.test_type) {
|
|
||||||
case Correctness:
|
|
||||||
results = Utils.analyzeCorrectness(output_lines);
|
|
||||||
break;
|
|
||||||
case Performance:
|
|
||||||
results = Utils.analyzePerformance(output_lines);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
testRunTask.state = results.getKey();
|
|
||||||
testRunTask.progress = results.getValue();
|
|
||||||
testRunTask.CleanTime = Utils.parseCleanTime(testRunTask.output);
|
|
||||||
}
|
}
|
||||||
|
testRunTask.state = results.getKey();
|
||||||
|
testRunTask.progress = results.getValue();
|
||||||
|
testRunTask.CleanTime = Utils.parseCleanTime(testRunTask.output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("ct_count=" + ct_count + " rt count=" + rt_count);
|
|
||||||
//теперь обновить их единым списком, и удалить задачи на компиляцию.
|
|
||||||
planner.ServerCommand(ServerCode.UpdateTestTasks, compilationTasks);
|
|
||||||
}
|
}
|
||||||
|
System.out.println("ct_count=" + ct_count + " rt count=" + rt_count);
|
||||||
|
//теперь обновить их единым списком, и удалить задачи на компиляцию.
|
||||||
|
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;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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.*;
|
import com.jcraft.jsch.*;
|
||||||
|
import javafx.util.Pair;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -213,4 +214,24 @@ public class UserConnection {
|
|||||||
public boolean Exists(RemoteFile file) throws Exception {
|
public boolean Exists(RemoteFile file) throws Exception {
|
||||||
return Exists(file.full_name);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -380,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))
|
if (Exists(file))
|
||||||
sftpChannel.rm(file.full_name);
|
sftpChannel.rm(file.full_name);
|
||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
|
|||||||
Reference in New Issue
Block a user