реализованы таймауты в 40 секунд у тестирования сапфора. копирование сапфора при тестировании заменено на символические ссылки.
This commit is contained in:
@@ -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