Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 6e21df42 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

testrunner

parent 6fe892dd
Pipeline #62061 failed with stage
in 1 minute and 4 seconds
......@@ -81,7 +81,7 @@ public class ScenarioRun implements Runnable {
synchronized (scenarioStore) {
logger.info(String.format("Initializing scenario. Start of scenario '%s'...", scenario.getName()));
scenarioStore.getTopography().reset();
System.out.println("StartIt " + scenario.getName());
MainModelBuilder modelBuilder = new MainModelBuilder(scenarioStore);
modelBuilder.createModelAndRandom();
......
......@@ -278,4 +278,8 @@ public class DataProcessingJsonManager {
return maxId;
}
public boolean containsOutputFile(String name){
return this.outputFiles.stream().anyMatch(f -> f.getFileName().equals(name));
}
}
......@@ -5,6 +5,7 @@ import org.apache.log4j.Logger;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.projects.ScenarioRun;
import java.util.HashMap;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -17,6 +18,7 @@ import java.util.concurrent.TimeUnit;
public class ScenarioExecutorService extends ThreadPoolExecutor {
private static Logger log = LogManager.getLogger(ScenarioExecutorService.class);
// private HashMap<String, Throwable> output
public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory) {
return new ScenarioExecutorService(nThreads, nThreads,
......
package org.vadere.simulator.projects.migration;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import java.io.PrintStream;
public class StdOutRedirecter {
private Logger logger = LogManager.getLogger(StdOutRedirecter.class);
private PrintStream defaultOut;
private PrintStream defaultErr;
public StdOutRedirecter(){
// this.logger = logger;
}
public void redirect(){
defaultOut = System.out;
defaultErr = System.err;
System.setOut(useLogger(System.out));
System.setErr(useLogger(System.err));
}
private PrintStream useLogger(final PrintStream realPrintStream){
return new PrintStream(realPrintStream){
@Override
public void print(final String string){
logger.warn(string);
}
@Override
public void println(final String string){
logger.warn(string);
}
};
}
public void reset(){
System.setOut(defaultOut);
System.setErr(defaultErr);
}
}
......@@ -7,6 +7,7 @@ import org.vadere.simulator.control.ScenarioExecutorService;
import org.vadere.simulator.entrypoints.ScenarioFactory;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.projects.ScenarioRun;
import org.vadere.simulator.projects.dataprocessing.DataProcessingJsonManager;
import java.io.File;
import java.io.IOException;
......@@ -29,10 +30,16 @@ public class TestSimulationRunner {
private static Logger logger = LogManager.getLogger(TestSimulationRunner.class);
private final String outputPath = "target/TestRuns/output";
private ThreadFactory threadFactory = r -> {
final Thread thread = new Thread(r);
thread.setUncaughtExceptionHandler( (t, e) -> {
System.out.println(t.getName());
@Test
public void RunAllSimulations() {
// remove/clean dir from target folder and create new empty tree (used for output)
});
return thread;
};
private void initOutputDir(){
try {
if (Paths.get(outputPath).toFile().exists()) {
Files.walk(Paths.get(outputPath).getParent())
......@@ -44,20 +51,25 @@ public class TestSimulationRunner {
} catch (IOException e) {
e.printStackTrace();
}
}
ThreadFactory threadFactory = r -> {
final Thread thread = new Thread(r);
return thread;
};
@Test
public void RunAllSimulations() {
// remove/clean dir from target folder and create new empty tree (used for output)
initOutputDir();
ExecutorService threadPool = ScenarioExecutorService.newFixedThreadPool(4, threadFactory);
ExecutorService threadPool = ScenarioExecutorService.newFixedThreadPool(1, threadFactory);
ScenarioAppender scenarioAppender = new ScenarioAppender(Paths.get(outputPath));
LogManager.getRootLogger().addAppender(scenarioAppender);
List<Path> scenarios = getScenarioFiles(Paths.get("../VadereModelTests/TestOSM"));
// StdOutRedirecter redirecter = new StdOutRedirecter();
// redirecter.redirect();
List<Path> scenarios = getScenarioFiles(Paths.get("../VadereModelTests"));
// List<Path> scenarios = getScenarioFiles(Paths.get("../VadereModelTests/TestOSM"));
List<Path> chicken = scenarios.stream().filter(f -> f.getFileName().endsWith("basic_1_chicken_osm1.scenario")).collect(Collectors.toList());
List<Path> subset = scenarios.subList(0, 3);
List<Path> subset = scenarios.subList(0, 5);
subset.addAll(chicken);
System.out.println(subset.size());
for (Path scenarioPath : subset) {
......@@ -69,25 +81,86 @@ public class TestSimulationRunner {
}
logger.info("#####Start scenario: " + scenarioPath.getFileName());
s.getAttributesSimulation().setWriteSimulationData(true);
threadPool.submit(new ScenarioRun(s, outputPath, (listener) -> System.out.println("done")));
}
threadPool.shutdown();
if (!threadPool.isTerminated()) {
try {
logger.info("waiting 60 sec....");
threadPool.awaitTermination(60, TimeUnit.SECONDS);
logger.info("waiting 10 min....");
threadPool.awaitTermination(10, TimeUnit.MINUTES);
} catch (InterruptedException e) {
e.printStackTrace();
threadPool.shutdownNow();
} finally {
LogManager.getRootLogger().removeAppender(scenarioAppender);
System.out.println("before reset");
// redirecter.reset();
System.out.println("after reset");
}
}
}
private void addTrajectoriesOutputfile(final Scenario scenario){
DataProcessingJsonManager m = scenario.getDataProcessingJsonManager();
}
@Test
public void TestProjects(){
List<Path> projects = getProjectDirs(Paths.get("../VadereModelTests/"));
for (Path projectPath : projects) {
//
}
}
@Test
public void getProjectDirsTest(){
getProjectDirs(Paths.get("../VadereModelTests/")).forEach(p -> System.out.println(p.toString()));
}
private List<Path> getProjectDirs(Path vadereModelTest){
LinkedList<Path> projectPath = new LinkedList<>();
FileVisitor<Path> visitor = new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
if (Files.exists(dir.resolve("vadere.project"))){
projectPath.add(dir);
return FileVisitResult.SKIP_SUBTREE;
}
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
return FileVisitResult.CONTINUE;
}
};
try {
Files.walkFileTree(vadereModelTest, visitor);
} catch (IOException e) {
e.printStackTrace();
}
return projectPath;
}
private List<Path> getScenarioFiles(Path vadereModelTest) {
LinkedList<Path> scenarioFiles = new LinkedList<>();
FileVisitor<Path> visitor = new FileVisitor<Path>() {
......
......@@ -61,6 +61,56 @@ public class AttributesSimulation extends Attributes {
return randomSeed;
}
public void setFinishTime(double finishTime) {
checkSealed();
this.finishTime = finishTime;
}
public void setSimTimeStepLength(double simTimeStepLength) {
checkSealed();
this.simTimeStepLength = simTimeStepLength;
}
public void setRealTimeSimTimeRatio(double realTimeSimTimeRatio) {
checkSealed();
this.realTimeSimTimeRatio = realTimeSimTimeRatio;
}
public void setWriteSimulationData(boolean writeSimulationData) {
checkSealed();
this.writeSimulationData = writeSimulationData;
}
public void setVisualizationEnabled(boolean visualizationEnabled) {
checkSealed();
this.visualizationEnabled = visualizationEnabled;
}
public void setPrintFPS(boolean printFPS) {
checkSealed();
this.printFPS = printFPS;
}
public void setNeedsBoundary(boolean needsBoundary) {
checkSealed();
this.needsBoundary = needsBoundary;
}
public void setDigitsPerCoordinate(int digitsPerCoordinate) {
checkSealed();
this.digitsPerCoordinate = digitsPerCoordinate;
}
public void setUseRandomSeed(boolean useRandomSeed) {
checkSealed();
this.useRandomSeed = useRandomSeed;
}
public void setRandomSeed(long randomSeed) {
checkSealed();
this.randomSeed = randomSeed;
}
@Override
public boolean equals(Object o) {
if (this == o)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment