новая распаковка анализа
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$/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/files/Planner/CompilationTask.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/CompilationTask.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/files/Planner/Utils.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/Utils.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" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
||||
@@ -12,16 +12,14 @@ import TestingSystem.DVM.Tasks.TestRunTask;
|
||||
import TestingSystem.DVM.Tasks.TestTask;
|
||||
import TestingSystem.DVM.TasksPackage.TasksPackage;
|
||||
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
||||
import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import java.util.*;
|
||||
public class TestsSupervisor_2022 {
|
||||
protected TestingPlanner planner; //планировщик.
|
||||
protected UserConnection connection;
|
||||
@@ -152,10 +150,10 @@ public class TestsSupervisor_2022 {
|
||||
//состояния пакета могут меняться только по возрастанию. ищем, появилось ли такое.
|
||||
Vector<TasksPackageState> higherStates = tasksPackage.state.getHigherStates();
|
||||
Collections.reverse(higherStates); //берем в обратном порядке, чтобы быстрее найти высшее.
|
||||
for (TasksPackageState state: higherStates){
|
||||
for (TasksPackageState state : higherStates) {
|
||||
RemoteFile file = new RemoteFile(stateDir, state.toString());
|
||||
if (connection.Exists(file)){
|
||||
System.out.println("found new state: "+file.name);
|
||||
if (connection.Exists(file)) {
|
||||
System.out.println("found new state: " + file.name);
|
||||
tasksPackage.state = state;
|
||||
planner.UpdatePackage();
|
||||
return;
|
||||
@@ -166,92 +164,106 @@ public class TestsSupervisor_2022 {
|
||||
Utils.CheckDirectory(packageLocalWorkspace);
|
||||
RemoteFile remote_results = new RemoteFile(packageRemoteWorkspace, "results");
|
||||
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace, "results.zip");
|
||||
connection.ShellCommand(
|
||||
|
||||
"zip -r "+Utils.DQuotes(remote_results_archive.full_name)+" "+Utils.DQuotes(remote_results.full_name));
|
||||
/*
|
||||
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace.full_name, "results.zip");
|
||||
|
||||
if (connection.Exists()) {
|
||||
connection.getSingleFile(remote_results_archive, results_archive);
|
||||
File results_archive = new File(packageLocalWorkspace, "results.zip");
|
||||
connection.performScript(packageRemoteWorkspace, "zip -r " + Utils.DQuotes("results.zip") + " " + Utils.DQuotes("results"));
|
||||
//---
|
||||
if (connection.Exists(remote_results_archive)) {
|
||||
connection.getSingleFile(remote_results_archive.full_name, results_archive.getAbsolutePath());
|
||||
UnzipFolderPass unzipFolderPass = new UnzipFolderPass();
|
||||
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 {
|
||||
System.out.println("analysing results");
|
||||
if (false) {
|
||||
int ct_count = 0;
|
||||
int rt_count = 0;
|
||||
for (TestCompilationTask testCompilationTask : compilationTasks) {
|
||||
ct_count++;
|
||||
if (CheckTask(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;
|
||||
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 rt_count = 0;
|
||||
//--
|
||||
for (TestCompilationTask testCompilationTask : compilationTasks) {
|
||||
ct_count++;
|
||||
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 {
|
||||
CheckTask(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 {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
if (taskWorkspace.exists()) {
|
||||
System.out.println("id=" + testTask.id + ": path=" + taskWorkspace.getAbsolutePath());
|
||||
File stateFile = new File(taskWorkspace, "TaskState");
|
||||
File outFile = new File(taskWorkspace, Constants.out_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");
|
||||
if (outFile.exists())
|
||||
testTask.output = FileUtils.readFileToString(outFile);
|
||||
if (errFile.exists())
|
||||
testTask.errors = FileUtils.readFileToString(errFile);
|
||||
if (timeFile.exists())
|
||||
testTask.Time = Double.parseDouble(Utils.ReadAllText(timeFile));
|
||||
if ((testTask instanceof TestRunTask) && stsFile.exists()) {
|
||||
TestRunTask testRunTask = (TestRunTask) testTask;
|
||||
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 false;
|
||||
|
||||
@@ -8,6 +8,7 @@ import GlobalData.RemoteFile.RemoteFile;
|
||||
import GlobalData.User.User;
|
||||
import Visual_DVM_2021.Passes.PassException;
|
||||
import com.jcraft.jsch.*;
|
||||
import javafx.util.Pair;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -213,4 +214,24 @@ public class UserConnection {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
|
||||
files.add(out);
|
||||
files.add(err);
|
||||
for (RemoteFile file : files) {
|
||||
if (Exists(directory))
|
||||
if (Exists(file))
|
||||
sftpChannel.rm(file.full_name);
|
||||
}
|
||||
//--
|
||||
|
||||
Reference in New Issue
Block a user