diff options
author | Eike Stepper | 2011-12-13 17:03:40 +0000 |
---|---|---|
committer | Eike Stepper | 2011-12-13 17:03:40 +0000 |
commit | df26a6d92729d723c661d3a626dd2103569194c7 (patch) | |
tree | 6ef7a90223e441b240584ac3ee8b449fba156a14 /plugins | |
parent | 2c44e957ac29ea292b1dc38f47ab6131dec0223d (diff) | |
download | cdo-df26a6d92729d723c661d3a626dd2103569194c7.tar.gz cdo-df26a6d92729d723c661d3a626dd2103569194c7.tar.xz cdo-df26a6d92729d723c661d3a626dd2103569194c7.zip |
Small refeactoring of the perf framework
Diffstat (limited to 'plugins')
11 files changed, 181 insertions, 106 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF index c9c9cb534a..d7f24da43a 100644 --- a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF @@ -172,6 +172,8 @@ Export-Package: base;version="4.0.100"; org.eclipse.emf.cdo.tests.objectivity, org.eclipse.emf.cdo.tests.ui, org.eclipse.emf.cdo.tests.mongodb", + org.eclipse.emf.cdo.tests.performance;version="4.0.100", + org.eclipse.emf.cdo.tests.performance.framework;version="4.0.100", org.eclipse.emf.cdo.tests.revisioncache;version="4.0.100"; x-friends:="org.eclipse.emf.cdo.dawn.tests, org.eclipse.emf.cdo.tests.db, diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java index 5a97ad78c1..f4b8f780fe 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java @@ -67,7 +67,7 @@ public abstract class ConfigTestSuite implements IConstants { try { - TestWrapper wrapper = new TestWrapper(testClass, scenario); + TestWrapper wrapper = new TestWrapper(testClass, scenario, this); if (wrapper.testCount() != 0) { suite.addTest(wrapper); @@ -114,6 +114,13 @@ public abstract class ConfigTestSuite implements IConstants protected abstract void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario); /** + * Can be overridden by subclasses. + */ + protected void prepareTest(ConfigTest configTest) + { + } + + /** * @author Eike Stepper */ private static final class ConstraintsViolatedException extends Exception @@ -128,11 +135,12 @@ public abstract class ConfigTestSuite implements IConstants { private IScenario scenario; - public TestWrapper(Class<? extends ConfigTest> testClass, IScenario scenario) throws ConstraintsViolatedException + public TestWrapper(Class<? extends ConfigTest> testClass, IScenario scenario, ConfigTestSuite suite) + throws ConstraintsViolatedException { // super(testClass, testClass.getName()); // Important for the UI to set the *qualified* class name! this.scenario = scenario; - addTestsFromTestCase(testClass); + addTestsFromTestCase(testClass, suite); } @Override @@ -156,7 +164,8 @@ public abstract class ConfigTestSuite implements IConstants } } - private void addTestsFromTestCase(final Class<?> theClass) throws ConstraintsViolatedException + private void addTestsFromTestCase(final Class<?> theClass, ConfigTestSuite suite) + throws ConstraintsViolatedException { setName(theClass.getName()); @@ -199,7 +208,7 @@ public abstract class ConfigTestSuite implements IConstants { if (validateConstraints(method, capabilities)) { - addTestMethod(method, names, theClass); + addTestMethod(method, names, theClass, suite); } } @@ -236,7 +245,7 @@ public abstract class ConfigTestSuite implements IConstants return true; } - private void addTestMethod(Method m, List<String> names, Class<?> theClass) + private void addTestMethod(Method m, List<String> names, Class<?> theClass, ConfigTestSuite suite) { String name = m.getName(); if (names.contains(name)) @@ -255,7 +264,14 @@ public abstract class ConfigTestSuite implements IConstants } names.add(name); - addTest(createTest(theClass, name)); + Test test = createTest(theClass, name); + if (test instanceof ConfigTest) + { + ConfigTest configTest = (ConfigTest)test; + suite.prepareTest(configTest); + } + + addTest(test); } private boolean isPublicTestMethod(Method m) diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java index de0d66a9c3..d3646bd151 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java @@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.tests.performance; import org.eclipse.emf.cdo.tests.bundle.OM; import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite; +import org.eclipse.emf.cdo.tests.performance.framework.PerformanceTestSuite; import java.util.List; @@ -23,7 +23,7 @@ import junit.framework.TestSuite; /** * @author Eike Stepper */ -public class AllPerformanceTests extends ConfigTestSuite +public class AllPerformanceTests extends PerformanceTestSuite { public static Test suite() { @@ -48,7 +48,6 @@ public class AllPerformanceTests extends ConfigTestSuite @Override protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario) { - testClasses.addAll(getTestClasses(OM.BUNDLE, "org.eclipse.emf.cdo.tests.performance.tests")); + testClasses.addAll(getTestClasses(OM.BUNDLE, "org.eclipse.emf.cdo.tests.performance")); } - } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/tests/DeleteRandom.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java index 3fb02fe023..919312645b 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/tests/DeleteRandom.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java @@ -8,13 +8,13 @@ * Contributors: * Stefan Winkler - initial API and implementation */ -package org.eclipse.emf.cdo.tests.performance.tests; +package org.eclipse.emf.cdo.tests.performance; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.emf.cdo.tests.model1.Category; import org.eclipse.emf.cdo.tests.model1.Company; -import org.eclipse.emf.cdo.tests.performance.framework.AbstractCDOPerformanceMeasurement; +import org.eclipse.emf.cdo.tests.performance.framework.PerformanceTest; import org.eclipse.emf.cdo.transaction.CDOTransaction; import java.util.Random; @@ -22,11 +22,11 @@ import java.util.Random; /** * @author Stefan Winkler */ -public class DeleteRandom extends AbstractCDOPerformanceMeasurement +public class DeleteRandomTest extends PerformanceTest { private static final String RES_NAME = "res"; - private static final int AMOUNT_ELEMENTS = 20000; + private static final int AMOUNT_ELEMENTS = 1000; private CDOSession session; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PerformanceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java index 7a94388507..f5204fd769 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PerformanceTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java @@ -8,10 +8,12 @@ * Contributors: * Martin Fluegge - initial API and implementation */ -package org.eclipse.emf.cdo.tests; +package org.eclipse.emf.cdo.tests.performance; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires; import org.eclipse.emf.cdo.tests.model1.Customer; import org.eclipse.emf.cdo.tests.model1.SalesOrder; import org.eclipse.emf.cdo.transaction.CDOTransaction; @@ -38,7 +40,8 @@ import java.util.Map; /** * @author Martin Fluegge */ -public class PerformanceTest extends AbstractCDOTest +@Requires("excluded") +public class MartinsPerformanceTest extends AbstractCDOTest { protected static EClass mapContainerEClass; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/AbstractCDOPerformanceMeasurement.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/AbstractCDOPerformanceMeasurement.java deleted file mode 100644 index 41c9aafbec..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/AbstractCDOPerformanceMeasurement.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Stefan Winkler - initial API and implementation - */ -package org.eclipse.emf.cdo.tests.performance.framework; - -import org.eclipse.emf.cdo.tests.AbstractCDOTest; - -/** - * @author Stefan Winkler - */ -public abstract class AbstractCDOPerformanceMeasurement extends AbstractCDOTest -{ - private long startTime; - - private IPerformanceResultCollector performanceResultCollector; - - @Override - protected void doSetUp() throws Exception - { - super.doSetUp(); - - /* - * TODO Eike: is there a way to inject the result collector here - * by setting it in the test properties before the tests are executed? - */ - Object collector = getTestProperties().get("performanceResultCollector"); - if (collector instanceof IPerformanceResultCollector) - { - performanceResultCollector = (IPerformanceResultCollector)collector; - } - else - { - performanceResultCollector = new PerformanceResultCollector(); - } - startTime = System.currentTimeMillis(); - } - - @Override - protected void doTearDown() throws Exception - { - long time = System.currentTimeMillis() - startTime; - - // Output test data - performanceResultCollector.addRecord(getScenario(), getClass().getName(), getName(), time); - - super.doTearDown(); - } -} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceResultCollector.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IProbeCollector.java index 3bd02c971f..40485c9805 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceResultCollector.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IProbeCollector.java @@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.tests.config.IScenario; /** * @author Stefan Winkler */ -public interface IPerformanceResultCollector +public interface IProbeCollector { - public void addRecord(IScenario scenario, String testName, String testCaseName, long time); + public void addProbe(IScenario scenario, String testName, String testCaseName, long millis); } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceResultCollector.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceResultCollector.java deleted file mode 100644 index 6a600a84da..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceResultCollector.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Stefan Winkler - initial API and implementation - */ -package org.eclipse.emf.cdo.tests.performance.framework; - -import org.eclipse.emf.cdo.tests.config.IScenario; - -import java.text.MessageFormat; - -/** - * Preliminary result collector which prints directly to system out. In the future this should be replaced by a - * collector which can write to a file or something. - * - * @author Stefan Winkler - */ -public class PerformanceResultCollector implements IPerformanceResultCollector -{ - public void addRecord(IScenario scenario, String testName, String testCaseName, long time) - { - String message = MessageFormat.format("{0};{1};{2};{3};{4};{5};{6}", scenario.getContainerConfig().getName(), - scenario.getRepositoryConfig().getName(), scenario.getSessionConfig().getName(), scenario.getModelConfig() - .getName(), testName, testCaseName, time); - System.out.println(message); - } -} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTest.java new file mode 100644 index 0000000000..5e3bb9ca71 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Winkler - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.performance.framework; + +import org.eclipse.emf.cdo.tests.AbstractCDOTest; + +/** + * @author Stefan Winkler + */ +public abstract class PerformanceTest extends AbstractCDOTest +{ + private IProbeCollector probeCollector; + + private long startTimeMillis; + + public PerformanceTest() + { + } + + void setProbeCollector(IProbeCollector probeCollector) + { + this.probeCollector = probeCollector; + } + + @Override + protected void doSetUp() throws Exception + { + super.doSetUp(); + startTimeMillis = System.currentTimeMillis(); + } + + @Override + protected void doTearDown() throws Exception + { + long stopTimeMillis = System.currentTimeMillis(); + long probe = stopTimeMillis - startTimeMillis; + + // Output test data + probeCollector.addProbe(getScenario(), getClass().getName(), getName(), probe); + + super.doTearDown(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTestSuite.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTestSuite.java new file mode 100644 index 0000000000..3d9454ff1f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceTestSuite.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.performance.framework; + +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite; + +/** + * @author Eike Stepper + */ +public abstract class PerformanceTestSuite extends ConfigTestSuite +{ + private IProbeCollector probeCollector = createProbeCollector(); + + @Override + protected void prepareTest(ConfigTest configTest) + { + super.prepareTest(configTest); + if (configTest instanceof PerformanceTest) + { + PerformanceTest performanceTest = (PerformanceTest)configTest; + performanceTest.setProbeCollector(probeCollector); + } + } + + /** + * Can be overridden by subclasses. + */ + protected IProbeCollector createProbeCollector() + { + return new PrintStreamProbeCollector(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamProbeCollector.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamProbeCollector.java new file mode 100644 index 0000000000..b1b6dd48bc --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamProbeCollector.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Winkler - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.performance.framework; + +import org.eclipse.emf.cdo.tests.config.IScenario; + +import java.io.PrintStream; +import java.text.MessageFormat; + +/** + * Preliminary probe collector which prints directly to a {@link PrintStream}, such as {@link System#out}. + * + * @author Stefan Winkler + */ +public class PrintStreamProbeCollector implements IProbeCollector +{ + private PrintStream out; + + public PrintStreamProbeCollector(PrintStream out) + { + this.out = out; + } + + public PrintStreamProbeCollector() + { + this(System.out); + } + + public void addProbe(IScenario scenario, String testName, String testCaseName, long millis) + { + String message = MessageFormat.format("{0};{1};{2};{3};{4};{5};{6}", // + scenario.getContainerConfig().getName(), // + scenario.getRepositoryConfig().getName(), // + scenario.getSessionConfig().getName(), // + scenario.getModelConfig().getName(), // + testName, // + testCaseName, // + millis); + + out.println(message); + } +} |