реализованы таймауты в 40 секунд у тестирования сапфора. копирование сапфора при тестировании заменено на символические ссылки.
This commit is contained in:
2
.idea/workspace.xml
generated
2
.idea/workspace.xml
generated
@@ -10,6 +10,8 @@
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/Component/Sapfor/Sapfor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/Component/Sapfor/Sapfor.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/SAPFOR/PackageModeSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/SAPFOR/PackageModeSupervisor.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
||||
@@ -207,8 +207,10 @@ public abstract class Sapfor extends OSDComponent {
|
||||
Utils_.CheckDirectory(data_workspace);
|
||||
File outputFile = new File(data_workspace, outName);
|
||||
File errorsFile = new File(data_workspace, errName);
|
||||
// File logFile = new File(data_workspace, "log.txt");
|
||||
Utils_.forceDeleteWithCheck(outputFile);
|
||||
Utils_.forceDeleteWithCheck(errorsFile);
|
||||
// Utils_.forceDeleteWithCheck(logFile);
|
||||
//---
|
||||
File file = new File(data_workspace, name + (Utils_.isWindows() ? ".bat" : ".sh"));
|
||||
FileUtils.write(file,
|
||||
@@ -224,33 +226,36 @@ public abstract class Sapfor extends OSDComponent {
|
||||
if (!file.setExecutable(true))
|
||||
throw new Exception("Не удалось сделать файл скрипта " + name + " исполняемым!");
|
||||
//-- Windows
|
||||
boolean flag = false;
|
||||
//запустить процесс
|
||||
boolean process_started = false;
|
||||
do {
|
||||
try {
|
||||
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
|
||||
procBuilder.directory(workspace);
|
||||
process = procBuilder.start();
|
||||
//-
|
||||
for (int i=0; i<40; ++i){
|
||||
if (process.waitFor(1, TimeUnit.SECONDS)){
|
||||
//дождались. все хорошо.
|
||||
exit_code=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//-
|
||||
if (exit_code!=0){
|
||||
//процесс все еще не завершен. Убить.
|
||||
process.destroyForcibly();
|
||||
}
|
||||
//-
|
||||
flag = true; //флаг означал что запуск процесса состоялся. не столь важно успешно или нет.
|
||||
process_started = true;
|
||||
} catch (Exception ex) {
|
||||
Utils_.MainLog.PrintException(ex);
|
||||
Utils_.sleep(1000);
|
||||
}
|
||||
}
|
||||
while (!flag);
|
||||
while (!process_started);
|
||||
//--
|
||||
for (int i=0; i<40; ++i){
|
||||
if (process.waitFor(1, TimeUnit.SECONDS)){
|
||||
//дождались. все хорошо.
|
||||
exit_code=0;
|
||||
// FileUtils.writeStringToFile(logFile,sapfor_drv.getName()+" done for "+i+" seconds");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (exit_code!=0){
|
||||
// FileUtils.writeStringToFile(logFile,sapfor_drv.getName()+" timeout");
|
||||
//-
|
||||
Process killer = Runtime.getRuntime().exec("pkill -SIGKILL -f "+sapfor_drv.getName());
|
||||
killer.waitFor();
|
||||
//-
|
||||
}
|
||||
process = null;
|
||||
//---
|
||||
Vector<String> outputLines = new Vector<>(FileUtils.readLines(outputFile));
|
||||
|
||||
@@ -11,29 +11,32 @@ import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Date;
|
||||
public class PackageModeSupervisor extends ThreadsPlanner {
|
||||
SapforPackage_json package_json = null;
|
||||
File sapfor_drv = null;
|
||||
// File sapfor_drv = null;
|
||||
public PackageModeSupervisor() throws Exception {
|
||||
super(2000);
|
||||
package_json = (SapforPackage_json) Utils_.jsonFromFile(new File(Constants.package_json), SapforPackage_json.class);
|
||||
//--
|
||||
File sapfor_src = new File(package_json.sapfor_drv);
|
||||
sapfor_drv = new File(Utils_.getHomeDirectory(), Utils_.getDateName("SAPFOR_F"));
|
||||
FileUtils.copyFile(sapfor_src, sapfor_drv);
|
||||
if (!sapfor_drv.setExecutable(true))
|
||||
throw new Exception("Не удалось сделать файл " + sapfor_drv.getName() + " исполняемым!");
|
||||
//--
|
||||
String pid_prefix = Utils_.getDateName("SAPFOR_F");
|
||||
//--
|
||||
File PID = new File("PID");
|
||||
FileUtils.writeStringToFile(PID, sapfor_drv.getName(), Charset.defaultCharset());
|
||||
FileUtils.writeStringToFile(PID, pid_prefix, Charset.defaultCharset());
|
||||
//---
|
||||
Date startDate = new Date();
|
||||
File started = new File(CommonConstants.STARTED);
|
||||
FileUtils.writeStringToFile(started, String.valueOf(startDate));
|
||||
//формирование списка задач.
|
||||
setMaxKernels(package_json.kernels);
|
||||
for (SapforTask task : package_json.tasks)
|
||||
addThread(new TaskThread(task, sapfor_drv));
|
||||
for (SapforTask task : package_json.tasks) {
|
||||
File task_drv = new File(Utils_.getHomeDirectory(),pid_prefix+"_"+task.id);
|
||||
Files.createSymbolicLink(task_drv.toPath(), sapfor_src.toPath());
|
||||
addThread(new TaskThread(task, task_drv));
|
||||
}
|
||||
interruptThread.start();
|
||||
}
|
||||
@Override
|
||||
@@ -55,8 +58,8 @@ public class PackageModeSupervisor extends ThreadsPlanner {
|
||||
// ,"sh", "exe", "bat"
|
||||
);
|
||||
//удаление сапфора exception
|
||||
if (sapfor_drv.exists())
|
||||
FileUtils.forceDelete(sapfor_drv);
|
||||
// if (sapfor_drv.exists())
|
||||
// FileUtils.forceDelete(sapfor_drv);
|
||||
} catch (Exception e) {
|
||||
Utils_.MainLog.PrintException(e);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
@@ -148,6 +149,7 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
||||
}
|
||||
@Override
|
||||
protected void DownloadResults() throws Exception {
|
||||
//-
|
||||
UpdatePackageState(TasksPackageState.Analysis);
|
||||
}
|
||||
@Override
|
||||
@@ -155,6 +157,16 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
||||
//не требуется.
|
||||
testingPackage.progress = 100;
|
||||
testingPackage.checkFinishState();
|
||||
//--
|
||||
File workspace = testingPackage.getLocalWorkspace();
|
||||
File[] links = workspace.listFiles();
|
||||
if (links!=null){
|
||||
Print("files found: "+links.length);
|
||||
for (File file: links) {
|
||||
if (file.isFile() && file.getName().startsWith("SAPFOR"))
|
||||
FileUtils.forceDelete(file);
|
||||
}
|
||||
}
|
||||
//--для эталона
|
||||
if (testingPackage.ethalon_id != CommonConstants.Nan) {
|
||||
TextLog log = new TextLog();
|
||||
@@ -218,7 +230,8 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
||||
Thread.sleep(1000);
|
||||
} while (!aborted_file.exists());
|
||||
Print("coup de grace..");
|
||||
String kill_command = "killall -SIGKILL " + testingPackage.PID;
|
||||
// String kill_command = "killall -SIGKILL " + testingPackage.PID;
|
||||
String kill_command = "pkill -SIGKILL -f " + testingPackage.PID;
|
||||
Print(kill_command);
|
||||
Process killer = Runtime.getRuntime().exec(kill_command);
|
||||
killer.waitFor();
|
||||
|
||||
Reference in New Issue
Block a user