уничтожение процесса тестирования.
This commit is contained in:
6
.idea/workspace.xml
generated
6
.idea/workspace.xml
generated
@@ -8,8 +8,12 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||||
<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/Common/GlobalProperties.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/GlobalProperties.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Common/Constants/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Constants/Constants.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Common/Global.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Global.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Common/Utils/InterruptThread.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/InterruptThread.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/Json/SapforScenario_json.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/Json/SapforScenario_json.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTestingPlaner/SapforTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTestingPlaner/SapforTestingPlanner.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTestingPlaner/SapforTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTestingPlaner/SapforTestingPlanner.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/ThreadsPlanner/ThreadsPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/ThreadsPlanner/ThreadsPlanner.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
|||||||
@@ -1,22 +1,6 @@
|
|||||||
package Common.Constants;
|
package Common.Constants;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
public class Constants {
|
public class Constants {
|
||||||
public static final int Nan = -1;
|
|
||||||
public static char toStrike = (char) 822;
|
|
||||||
public static final Pattern VALID_EMAIL_ADDRESS_REGEX =
|
|
||||||
Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
|
|
||||||
public static char[] forbidden_file_name_characters = new char[]{
|
|
||||||
'#', '%', '&', '{', '}',
|
|
||||||
'<', '>', '*', '?', '!',
|
|
||||||
'$', '\'', '\"', '@', '+',
|
|
||||||
'`', '|', '=', '#', ':', '/', '\\',
|
|
||||||
'~', '^'
|
|
||||||
};
|
|
||||||
public static char[] regular_metasymbols = new char[]{
|
|
||||||
'<', '>', '(', ')', '[', ']', '{', '}', '^', '-', '=', '$', '!', '|', '?', '*', '+', '.'
|
|
||||||
};
|
|
||||||
//все запретные символы через пробел.
|
|
||||||
public static String all_forbidden_characters_string = "";
|
|
||||||
//https://losst.ru/komandy-terminala-linux
|
//https://losst.ru/komandy-terminala-linux
|
||||||
public static String[] linux_system_commands = new String[]{
|
public static String[] linux_system_commands = new String[]{
|
||||||
//<editor-fold desc="все линуксовые команды. их МНОГО">
|
//<editor-fold desc="все линуксовые команды. их МНОГО">
|
||||||
@@ -355,4 +339,21 @@ public class Constants {
|
|||||||
"zypper"
|
"zypper"
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
};
|
};
|
||||||
|
public static final int Nan = -1;
|
||||||
|
public static char toStrike = (char) 822;
|
||||||
|
public static final Pattern VALID_EMAIL_ADDRESS_REGEX =
|
||||||
|
Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
|
||||||
|
public static char[] forbidden_file_name_characters = new char[]{
|
||||||
|
'#', '%', '&', '{', '}',
|
||||||
|
'<', '>', '*', '?', '!',
|
||||||
|
'$', '\'', '\"', '@', '+',
|
||||||
|
'`', '|', '=', '#', ':', '/', '\\',
|
||||||
|
'~', '^'
|
||||||
|
};
|
||||||
|
public static char[] regular_metasymbols = new char[]{
|
||||||
|
'<', '>', '(', ')', '[', ']', '{', '}', '^', '-', '=', '$', '!', '|', '?', '*', '+', '.'
|
||||||
|
};
|
||||||
|
//все запретные символы через пробел.
|
||||||
|
public static String all_forbidden_characters_string = "";
|
||||||
|
public static String aborted = "ABORTED";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -345,6 +345,7 @@ public class Global {
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
public static void ScenarioMode() throws Exception {
|
public static void ScenarioMode() throws Exception {
|
||||||
|
isWindows = System.getProperty("os.name").startsWith("Windows");
|
||||||
Log = new Loggable() {
|
Log = new Loggable() {
|
||||||
@Override
|
@Override
|
||||||
public String getLogHomePath() {
|
public String getLogHomePath() {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.io.File;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
public class InterruptThread extends Thread{
|
public class InterruptThread extends Thread{
|
||||||
//------------
|
//------------
|
||||||
public static final String Eliminated = "Eliminated";
|
|
||||||
public InterruptThread(int sleep_ms, Callable action){
|
public InterruptThread(int sleep_ms, Callable action){
|
||||||
super(() -> {
|
super(() -> {
|
||||||
File interruptFile = new File(db_project_info.interrupt);
|
File interruptFile = new File(db_project_info.interrupt);
|
||||||
@@ -14,7 +13,7 @@ public class InterruptThread extends Thread{
|
|||||||
while (true) {
|
while (true) {
|
||||||
Thread.sleep(sleep_ms);
|
Thread.sleep(sleep_ms);
|
||||||
if (interruptFile.exists()) {
|
if (interruptFile.exists()) {
|
||||||
FileUtils.writeStringToFile(new File(Eliminated + " by INTERRUPT file"), "");
|
FileUtils.writeStringToFile(new File("ABORTED"), "");
|
||||||
FileUtils.forceDelete(interruptFile);
|
FileUtils.forceDelete(interruptFile);
|
||||||
action.call();
|
action.call();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import com.google.gson.annotations.Expose;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
public class SapforScenario_json {
|
public class SapforScenario_json {
|
||||||
|
@Expose
|
||||||
|
public String sapfor_drv = ""; //файл с сапфором. Имя уникально для сценария.
|
||||||
@Expose
|
@Expose
|
||||||
public List<String> tests = new Vector<>();
|
public List<String> tests = new Vector<>();
|
||||||
@Expose
|
@Expose
|
||||||
public List<SapforPackage_json> packages= new Vector<>();
|
public List<SapforPackage_json> packages = new Vector<>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,17 @@ import SapforTestingSystem.ThreadsPlanner.ThreadsPlanner;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
public class SapforTestingPlanner extends ThreadsPlanner {
|
public class SapforTestingPlanner extends ThreadsPlanner {
|
||||||
|
SapforScenario_json scenario_json = null;
|
||||||
public SapforTestingPlanner() throws Exception {
|
public SapforTestingPlanner() throws Exception {
|
||||||
super(Global.properties.threadsTimeout, Global.properties.threadsNum);
|
super(Global.properties.threadsTimeout, Global.properties.threadsNum);
|
||||||
SapforScenario_json scenario_json = (SapforScenario_json) Utils.jsonFromFile(new File(Global.Home, "scenario.txt"), SapforScenario_json.class);
|
scenario_json = (SapforScenario_json) Utils.jsonFromFile(new File(Global.Home, "scenario.txt"), SapforScenario_json.class);
|
||||||
//формирование списка задач.
|
//формирование списка задач.
|
||||||
for (SapforPackage_json sapforPackage_json : scenario_json.packages) {
|
for (SapforPackage_json sapforPackage_json : scenario_json.packages) {
|
||||||
for (String testName : scenario_json.tests) {
|
for (String testName : scenario_json.tests) {
|
||||||
addThread(() -> {
|
addThread(() -> {
|
||||||
try {
|
try {
|
||||||
new SapforTest(
|
new SapforTest(
|
||||||
new File(Global.Home, "SAPFOR_F.exe"),
|
new File(Global.Home, scenario_json.sapfor_drv),
|
||||||
Paths.get(Global.Home, sapforPackage_json.id, testName).toFile(),
|
Paths.get(Global.Home, sapforPackage_json.id, testName).toFile(),
|
||||||
sapforPackage_json.flags,
|
sapforPackage_json.flags,
|
||||||
sapforPackage_json.codes).Do();
|
sapforPackage_json.codes).Do();
|
||||||
@@ -28,5 +29,17 @@ public class SapforTestingPlanner extends ThreadsPlanner {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
interruptThread.start();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void Interrupt() throws Exception {
|
||||||
|
System.out.println("killing "+scenario_json.sapfor_drv+"...");
|
||||||
|
String kill_command = Global.isWindows? ("taskkill /FI \"IMAGENAME eq " + scenario_json.sapfor_drv+ "\" /F /T"):
|
||||||
|
("killall -SIGKILL " + scenario_json.sapfor_drv);
|
||||||
|
Process killer = Runtime.getRuntime().exec(kill_command);
|
||||||
|
killer.waitFor();
|
||||||
|
System.out.println("done!");
|
||||||
|
//todo для надежности сделать еще один kill с внешнего процесса.
|
||||||
|
// может быть гонка, что нить успеет запустить процесс уже после интеррупта.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
public abstract class ThreadsPlanner {
|
public abstract class ThreadsPlanner {
|
||||||
//-->
|
//-->
|
||||||
Thread interruptThread = new InterruptThread(5000, () -> {
|
protected Thread interruptThread = new InterruptThread(5000, () -> {
|
||||||
|
try {
|
||||||
|
Interrupt();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Global.Log.PrintException(exception);
|
||||||
|
}
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@@ -42,6 +47,8 @@ public abstract class ThreadsPlanner {
|
|||||||
Global.Log.Print("Planner finished");
|
Global.Log.Print("Planner finished");
|
||||||
finalize();
|
finalize();
|
||||||
}
|
}
|
||||||
|
public void Interrupt() throws Exception {
|
||||||
|
}
|
||||||
protected void checkActiveThreads() throws Exception {
|
protected void checkActiveThreads() throws Exception {
|
||||||
Vector<Integer> toExclude = new Vector<>();
|
Vector<Integer> toExclude = new Vector<>();
|
||||||
//--
|
//--
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public class StartSapforTests extends Pass_2021<SapforScenario> {
|
|||||||
Utils.CheckAndCleanDirectory(scenarioWorkspace);
|
Utils.CheckAndCleanDirectory(scenarioWorkspace);
|
||||||
target.workspace = scenarioWorkspace.getAbsolutePath();
|
target.workspace = scenarioWorkspace.getAbsolutePath();
|
||||||
target.testsNames = String.join(";", testsNames_lower);
|
target.testsNames = String.join(";", testsNames_lower);
|
||||||
sapfor = new File(target.workspace, "SAPFOR_F.exe"); //развилка на линукс
|
sapfor = new File(target.workspace, Utils.getDateName("SAPFOR_F") + (Global.isWindows ? ".exe" : "")); //развилка на линукс
|
||||||
ShowMessage2("Копирование SAPFOR");
|
ShowMessage2("Копирование SAPFOR");
|
||||||
FileUtils.copyFile(Current.getSapfor().getFile(), sapfor);
|
FileUtils.copyFile(Current.getSapfor().getFile(), sapfor);
|
||||||
ShowMessage2("Копирование визуализатора");
|
ShowMessage2("Копирование визуализатора");
|
||||||
@@ -232,6 +232,7 @@ public class StartSapforTests extends Pass_2021<SapforScenario> {
|
|||||||
//----
|
//----
|
||||||
File scenarioFile = new File(target.workspace, "scenario.txt");
|
File scenarioFile = new File(target.workspace, "scenario.txt");
|
||||||
SapforScenario_json scenario_json = new SapforScenario_json();
|
SapforScenario_json scenario_json = new SapforScenario_json();
|
||||||
|
scenario_json.sapfor_drv = sapfor.getName();
|
||||||
scenario_json.tests.addAll(allTests.keySet());
|
scenario_json.tests.addAll(allTests.keySet());
|
||||||
//----
|
//----
|
||||||
Global.db.Update(target);
|
Global.db.Update(target);
|
||||||
|
|||||||
Reference in New Issue
Block a user