Skip to content

Commit

Permalink
Remove perftest result distributed folder before start perftest if th…
Browse files Browse the repository at this point in the history
…at already exist
  • Loading branch information
donggyu04 authored and junoyoon committed Feb 15, 2019
1 parent 946ce90 commit 5a86378
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public File getPerfTestDirectory(String id) {
return mkDir(file);
}

File getDistributedFolderName(String id) {
public File getDistributedFolderName(String id) {
int numericId = 0;
try {
numericId = (Integer.parseInt(id) / 1000) * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.ngrinder.model.Status;
import org.ngrinder.perftest.model.NullSingleConsole;
import org.ngrinder.perftest.service.samplinglistener.*;
import org.ngrinder.script.handler.ScriptHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -207,9 +206,8 @@ protected boolean hasEnoughFreeAgents(PerfTest test) {
public void doTest(final PerfTest perfTest) {
SingleConsole singleConsole = null;
try {
GrinderProperties grinderProperties = perfTestService.prepareTest(perfTest);
singleConsole = startConsole(perfTest);
ScriptHandler prepareDistribution = perfTestService.prepareDistribution(perfTest);
GrinderProperties grinderProperties = perfTestService.getGrinderProperties(perfTest, prepareDistribution);
startAgentsOn(perfTest, grinderProperties, checkCancellation(singleConsole));
distributeFileOn(perfTest, checkCancellation(singleConsole));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,19 @@ public ScriptHandler prepareDistribution(PerfTest perfTest) {
return handler;
}

public GrinderProperties prepareTest(PerfTest perfTest) {
cleanupPerftestDistibutionFolder(perfTest);
ScriptHandler prepareDistribution = prepareDistribution(perfTest);
return getGrinderProperties(perfTest, prepareDistribution);
}

private void cleanupPerftestDistibutionFolder(PerfTest perfTest) {
File distributedFolder = config.getHome().getDistributedFolderName(perfTest.getId().toString());
if (distributedFolder.exists()) {
FileUtils.deleteQuietly(distributedFolder);
}
}

/**
* Get the process and thread policy java script.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,18 @@ public void testStartConsole() throws IOException {
perfTest.setScriptName("/hello/world.py");
assertThat(perfTest, not(nullValue()));

// Distribute files
GrinderProperties grinderProperties = perfTestService.prepareTest(perfTest);

// Start console
SingleConsole singleConsole = perfTestRunnable.startConsole(perfTest);
assertThat(singleConsole, not(nullValue()));
assertThat(singleConsole.getConsolePort(), is(perfTest.getPort()));

// Start agents
perfTest.setAgentCount(1);
GrinderProperties grinderProperties = perfTestService.getGrinderProperties(perfTest);
singleConsole.setReportPath(perfTestService.getReportFileDirectory(perfTest));

// Distribute files
perfTestService.prepareDistribution(perfTest);
perfTestRunnable.startAgentsOn(perfTest, grinderProperties, singleConsole);
sleep(3000);
perfTestRunnable.distributeFileOn(perfTest, singleConsole);
Expand Down

0 comments on commit 5a86378

Please sign in to comment.