Skip to content

Commit

Permalink
add tool to batch execute tests with keep running flag
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasgeiger committed Sep 26, 2016
1 parent 0161a00 commit a944928
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/main/groovy/betsy/tools/BatchTestRunningEngines.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package betsy.tools;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.List;

import betsy.bpmn.BPMNMain;
import betsy.bpmn.engines.AbstractBPMNEngine;
import betsy.bpmn.repositories.BPMNEngineRepository;
import betsy.common.analytics.CsvReportLoader;
import betsy.common.analytics.html.HtmlAnalytics;
import betsy.common.analytics.model.CsvReport;
import betsy.common.tasks.WaitTasks;
import betsy.common.tasks.ZipTasks;

/**
* Tool to batch execute tests without reinstall/restart of engines between each test
*/
public class BatchTestRunningEngines {

public static void main(String[] args) throws IOException {
String enginesString = args[0];
String testsString = args[1];

long timestamp = System.currentTimeMillis();

Path globalResultFile = Paths.get("test-zips/"+timestamp+"_globalResults.csv");
Files.createFile(globalResultFile);

BPMNEngineRepository bpmnEngineRepository = new BPMNEngineRepository();
List<AbstractBPMNEngine> engines = bpmnEngineRepository.getByNames(enginesString.split(","));

for(AbstractBPMNEngine engine : engines) {
if(engine.isInstalled()) {
engine.uninstall();
}

engine.install();

engine.startup();

BPMNMain.main(engine.getEngineID(), testsString, "-k", "-r");

engine.shutdown();

appendResultsToGlobalFile(globalResultFile, Paths.get("test/reports/results.csv"));

WaitTasks.sleep(5000);

ZipTasks.zipFolder(Paths.get("test-zips/"+engine.getEngineID()+"_"+timestamp+"-test.zip"),Paths.get("test"));

}

new HtmlAnalytics(new CsvReportLoader(globalResultFile, new CsvReport()).load()).toHtmlReport(Paths.get("test-zips/"+timestamp+"_globalReport.html"));
}

private static void appendResultsToGlobalFile(Path target, Path toAdd) throws IOException {
Files.write(target, Files.readAllLines(toAdd, StandardCharsets.UTF_8), StandardOpenOption.APPEND);
}
}

0 comments on commit a944928

Please sign in to comment.