реализованы таймауты в 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$/.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$/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/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>
|
</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" />
|
||||||
|
|||||||
@@ -207,8 +207,10 @@ public abstract class Sapfor extends OSDComponent {
|
|||||||
Utils_.CheckDirectory(data_workspace);
|
Utils_.CheckDirectory(data_workspace);
|
||||||
File outputFile = new File(data_workspace, outName);
|
File outputFile = new File(data_workspace, outName);
|
||||||
File errorsFile = new File(data_workspace, errName);
|
File errorsFile = new File(data_workspace, errName);
|
||||||
|
// File logFile = new File(data_workspace, "log.txt");
|
||||||
Utils_.forceDeleteWithCheck(outputFile);
|
Utils_.forceDeleteWithCheck(outputFile);
|
||||||
Utils_.forceDeleteWithCheck(errorsFile);
|
Utils_.forceDeleteWithCheck(errorsFile);
|
||||||
|
// Utils_.forceDeleteWithCheck(logFile);
|
||||||
//---
|
//---
|
||||||
File file = new File(data_workspace, name + (Utils_.isWindows() ? ".bat" : ".sh"));
|
File file = new File(data_workspace, name + (Utils_.isWindows() ? ".bat" : ".sh"));
|
||||||
FileUtils.write(file,
|
FileUtils.write(file,
|
||||||
@@ -224,33 +226,36 @@ public abstract class Sapfor extends OSDComponent {
|
|||||||
if (!file.setExecutable(true))
|
if (!file.setExecutable(true))
|
||||||
throw new Exception("Не удалось сделать файл скрипта " + name + " исполняемым!");
|
throw new Exception("Не удалось сделать файл скрипта " + name + " исполняемым!");
|
||||||
//-- Windows
|
//-- Windows
|
||||||
boolean flag = false;
|
//запустить процесс
|
||||||
|
boolean process_started = false;
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
|
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
|
||||||
procBuilder.directory(workspace);
|
procBuilder.directory(workspace);
|
||||||
process = procBuilder.start();
|
process = procBuilder.start();
|
||||||
//-
|
process_started = true;
|
||||||
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; //флаг означал что запуск процесса состоялся. не столь важно успешно или нет.
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Utils_.MainLog.PrintException(ex);
|
Utils_.MainLog.PrintException(ex);
|
||||||
Utils_.sleep(1000);
|
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;
|
process = null;
|
||||||
//---
|
//---
|
||||||
Vector<String> outputLines = new Vector<>(FileUtils.readLines(outputFile));
|
Vector<String> outputLines = new Vector<>(FileUtils.readLines(outputFile));
|
||||||
|
|||||||
@@ -11,29 +11,32 @@ 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.Files;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
public class PackageModeSupervisor extends ThreadsPlanner {
|
public class PackageModeSupervisor extends ThreadsPlanner {
|
||||||
SapforPackage_json package_json = null;
|
SapforPackage_json package_json = null;
|
||||||
File sapfor_drv = null;
|
// File sapfor_drv = null;
|
||||||
public PackageModeSupervisor() throws Exception {
|
public PackageModeSupervisor() throws Exception {
|
||||||
super(2000);
|
super(2000);
|
||||||
package_json = (SapforPackage_json) Utils_.jsonFromFile(new File(Constants.package_json), SapforPackage_json.class);
|
package_json = (SapforPackage_json) Utils_.jsonFromFile(new File(Constants.package_json), SapforPackage_json.class);
|
||||||
//--
|
//--
|
||||||
File sapfor_src = new File(package_json.sapfor_drv);
|
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);
|
String pid_prefix = Utils_.getDateName("SAPFOR_F");
|
||||||
if (!sapfor_drv.setExecutable(true))
|
//--
|
||||||
throw new Exception("Не удалось сделать файл " + sapfor_drv.getName() + " исполняемым!");
|
|
||||||
File PID = new File("PID");
|
File PID = new File("PID");
|
||||||
FileUtils.writeStringToFile(PID, sapfor_drv.getName(), Charset.defaultCharset());
|
FileUtils.writeStringToFile(PID, pid_prefix, Charset.defaultCharset());
|
||||||
//---
|
//---
|
||||||
Date startDate = new Date();
|
Date startDate = new Date();
|
||||||
File started = new File(CommonConstants.STARTED);
|
File started = new File(CommonConstants.STARTED);
|
||||||
FileUtils.writeStringToFile(started, String.valueOf(startDate));
|
FileUtils.writeStringToFile(started, String.valueOf(startDate));
|
||||||
//формирование списка задач.
|
//формирование списка задач.
|
||||||
setMaxKernels(package_json.kernels);
|
setMaxKernels(package_json.kernels);
|
||||||
for (SapforTask task : package_json.tasks)
|
for (SapforTask task : package_json.tasks) {
|
||||||
addThread(new TaskThread(task, sapfor_drv));
|
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();
|
interruptThread.start();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@@ -55,8 +58,8 @@ public class PackageModeSupervisor extends ThreadsPlanner {
|
|||||||
// ,"sh", "exe", "bat"
|
// ,"sh", "exe", "bat"
|
||||||
);
|
);
|
||||||
//удаление сапфора exception
|
//удаление сапфора exception
|
||||||
if (sapfor_drv.exists())
|
// if (sapfor_drv.exists())
|
||||||
FileUtils.forceDelete(sapfor_drv);
|
// FileUtils.forceDelete(sapfor_drv);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Utils_.MainLog.PrintException(e);
|
Utils_.MainLog.PrintException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
|
|||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileFilter;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@@ -148,6 +149,7 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void DownloadResults() throws Exception {
|
protected void DownloadResults() throws Exception {
|
||||||
|
//-
|
||||||
UpdatePackageState(TasksPackageState.Analysis);
|
UpdatePackageState(TasksPackageState.Analysis);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@@ -155,6 +157,16 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
|||||||
//не требуется.
|
//не требуется.
|
||||||
testingPackage.progress = 100;
|
testingPackage.progress = 100;
|
||||||
testingPackage.checkFinishState();
|
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) {
|
if (testingPackage.ethalon_id != CommonConstants.Nan) {
|
||||||
TextLog log = new TextLog();
|
TextLog log = new TextLog();
|
||||||
@@ -218,7 +230,8 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
|||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} while (!aborted_file.exists());
|
} while (!aborted_file.exists());
|
||||||
Print("coup de grace..");
|
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);
|
Print(kill_command);
|
||||||
Process killer = Runtime.getRuntime().exec(kill_command);
|
Process killer = Runtime.getRuntime().exec(kill_command);
|
||||||
killer.waitFor();
|
killer.waitFor();
|
||||||
|
|||||||
Reference in New Issue
Block a user