Skip to content
Permalink
Browse files
GEODE-6181: Testname derieved from the Class name. (#22)
* Removed name from TestConfig
	* Test name derieved from the classname.
  • Loading branch information
nabarunnag committed Dec 11, 2018
1 parent 3e920d3 commit 84eb22d59c1f875b370c67153f267a777a69ea24
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 36 deletions.
@@ -53,7 +53,6 @@ public PartitionedGetBenchmark() {}
@Override
public TestConfig configure() {
TestConfig config = GeodeBenchmark.createConfig();
config.name(getClass().getName());
ClientServerTopology.configure(config);
config.before(new CreatePartitionedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
@@ -52,7 +52,6 @@ public void run() throws Exception {
@Override
public TestConfig configure() {
TestConfig config = GeodeBenchmark.createConfig();
config.name(getClass().getName());
ClientServerTopology.configure(config);
config.before(new CreatePartitionedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
@@ -53,7 +53,6 @@ public ReplicatedGetBenchmark() {}
@Override
public TestConfig configure() {
TestConfig config = GeodeBenchmark.createConfig();
config.name(getClass().getName());
ClientServerTopology.configure(config);
config.before(new CreateReplicatedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
@@ -52,7 +52,6 @@ public void run() throws Exception {
@Override
public TestConfig configure() {
TestConfig config = GeodeBenchmark.createConfig();
config.name(getClass().getName());
ClientServerTopology.configure(config);
config.before(new CreateReplicatedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
@@ -43,7 +43,6 @@ public class TestConfig implements Serializable {
private List<TestStep> before = new ArrayList<>();
private List<TestStep> workload = new ArrayList<>();
private List<TestStep> after = new ArrayList<>();
private String name;

/**
* Define a role for the test.
@@ -116,14 +115,6 @@ public void warmupSeconds(long warmupSeconds) {
workloadConfig.warmupSeconds(warmupSeconds);
}

/**
* Set the name of this benchmark. This name must be unique within a benchmarking run. Comparisons
* between runs will use this name to identify the same benchmark in both runs.
*/
public void name(String name) {
this.name = name;
}

public long getDurationSeconds() {
return workloadConfig.getDurationSeconds();
}
@@ -148,10 +139,6 @@ public List<TestStep> getAfter() {
return after;
}

public String getName() {
return name;
}

/**
* Return the total number of JVMs required to run this test
*/
@@ -78,11 +78,11 @@ public static TestRunner minimalRunner(final File outputDir) {
return new DefaultTestRunner(new RemoteJVMFactory(new LocalInfrastructureFactory()),
outputDir) {
@Override
public void runTest(TestConfig config) throws Exception {
public void runTest(TestConfig config, String testName) throws Exception {
config.warmupSeconds(0);
config.durationSeconds(1);
config.threads(1);
super.runTest(config);
super.runTest(config, testName);
}
};
}
@@ -54,17 +54,14 @@ public DefaultTestRunner(RemoteJVMFactory remoteJvmFactory, File outputDir) {
@Override
public void runTest(PerformanceTest test) throws Exception {
TestConfig config = test.configure();
runTest(config);
String testName = test.getClass().getName();
runTest(config, testName);
}

protected void runTest(TestConfig config)
protected void runTest(TestConfig config, String testName)
throws Exception {
int nodes = config.getTotalJVMs();

if (config.getName() == null) {
throw new IllegalStateException("Benchmark must have a name.");
}
File benchmarkOutput = new File(outputDir, config.getName());
File benchmarkOutput = new File(outputDir, testName);
if (benchmarkOutput.exists()) {
throw new IllegalStateException(
"Benchmark output directory already exists: " + benchmarkOutput.getPath());
@@ -56,25 +56,29 @@ public void setup() throws IOException {
public void runsBeforeWorkload() throws Exception {
runner.runTest(() -> {
TestConfig testConfig = new TestConfig();
testConfig.name(SAMPLE_BENCHMARK);
testConfig.role("all", 1);
testConfig.before(context -> System.out.println("hello"), "all");
return testConfig;
});
}

@Test
public void generatesOutputDirectoryPerBenchmark() throws Exception {
public static class OutputDirectoryTest implements PerformanceTest {

runner.runTest(() -> {
@Override
public TestConfig configure() {
TestConfig testConfig = new TestConfig();
testConfig.name(SAMPLE_BENCHMARK);
testConfig.role("all", 1);
testConfig.workload(new EmptyBenchmark(), "all");
return testConfig;
});
}
}

@Test
public void generatesOutputDirectoryPerBenchmark() throws Exception {

runner.runTest(new OutputDirectoryTest());

File expectedBenchmarkDir = new File(outputDir, SAMPLE_BENCHMARK);
File expectedBenchmarkDir = new File(outputDir, OutputDirectoryTest.class.getName());
assertTrue(expectedBenchmarkDir.exists());

// Node directory name is the role + a number
@@ -92,7 +96,6 @@ public void generatesOutputDirectoryPerBenchmark() throws Exception {
public void configuresJVMOptions() throws Exception {
runner.runTest(() -> {
TestConfig testConfig = new TestConfig();
testConfig.name(SAMPLE_BENCHMARK);
testConfig.role("all", 1);
testConfig.jvmArgs("all", "-Dprop1=true", "-Dprop2=5");
testConfig.before(context -> {
@@ -54,7 +54,6 @@ public void testRunnerRunsBeforeAndAfterTasks() throws Exception {

PerformanceTest test = () -> {
TestConfig config = new TestConfig();
config.name("SampleBenchmark");
config.role("before", 1);
config.role("workload", 1);
config.role("after", 1);
@@ -85,7 +84,6 @@ public void requiresAtLeastOneRole() throws Exception {

PerformanceTest test = () -> {
TestConfig config = new TestConfig();
config.name("SampleBenchmark");
config.role("before", 1);

config.before(before);

0 comments on commit 84eb22d

Please sign in to comment.