Skip to content

Commit

Permalink
Add standalone bundle that runs bundle installation tests
Browse files Browse the repository at this point in the history
The test bundle can be found at
testsuite/performance/target/test-libs/standalone-bundles/bundle-perf-test.jar
this bundle does not have a dependency on shrinkwrap or arquillian.
However the test bundle depends on the fact that the bundles being
installed are created beforehand. This is done with the
 org.jboss.osgi.test.performance.bundle.tool.BundleCreator tool
which can be run from the command line.
The maven build runs this tool automatically during the test-compile
phase for 25 bundles. If a different population of test bundles is
required the BundleCreator tool must be run again with the desired
number of bundles as argument.

The bundle-perf-test.jar bundle needs to be configured with the
following system properties:
    org.jboss.osgi.test.performance.bundles.dir
  The directory wher the test bundles are (i.e. where BundleCreator
has created them). Default '.'

    org.jboss.osgi.test.performance.bundle.size
  The population size (i.e. the number for test bundles being
installed). Default 25.
  • Loading branch information
bosschaert committed Oct 8, 2010
1 parent b569fec commit efbba8c
Show file tree
Hide file tree
Showing 17 changed files with 698 additions and 323 deletions.
1 change: 1 addition & 0 deletions testsuite/performance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<configuration>
<tasks>
<property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
<property name="maven.test.classpath" refid="maven.test.classpath" />
<property name="tests.output.dir" value="${project.build.directory}" />
<ant antfile="scripts/antrun-test-jars.xml" />
</tasks>
Expand Down
16 changes: 11 additions & 5 deletions testsuite/performance/scripts/antrun-test-jars.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@

<target name="build-test-jars" depends="init" description="Build the test deployments">

<!-- Please add alphabetically -->

<!-- Bundle Performance Test -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/standalone-bundles/bundle-perf-test.jar" files="${tests.resources.dir}/bundles/bundle-perf-test-bundle.bnd"/>

<!-- Service Performance Test -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/standalone-bundles/service-perf-test.jar" files="${tests.resources.dir}/bundles/service-perf-test-bundle.bnd"/>

<!-- Please add alphabetically -->

<!-- Generate test jars for standalone use -->
<java classname="org.jboss.osgi.test.performance.bundle.tool.BundleCreator"
classpath="${maven.test.classpath}" fork="true" dir="${tests.output.dir}">
<arg value="25"/>
<arg value="${tests.output.dir}/test-libs/standalone-bundles/bundle-perf-test-bundles"/>
<sysproperty key="log4j.output.dir" value="${tests.output.dir}"/>
</java>

</target>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected List<String> getThreadNames(int numThreads)
List<String> names = new ArrayList<String>(numThreads);
for (int i = 0; i < numThreads; i++)
{
names.add("Thread_" + (i + 1) + "_");
names.add("Thread_" + (i + 1));
}
return names;
}
Expand Down Expand Up @@ -121,5 +121,5 @@ public void run()
* @param parameter the parameter passed into the {@link #runTest(int, Object)} method.
* @throws Exception if anything goes wrong throw an exception. This will fail the test.
*/
abstract protected void runThread(String threadName, T parameter) throws Exception;
abstract public void runThread(String threadName, T parameter) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.net.URI;
import java.util.Date;

import org.jboss.arquillian.osgi.OSGiContainer;
import org.jboss.osgi.test.performance.AbstractThreadedBenchmark;
import org.jboss.osgi.test.performance.ChartType;
import org.jboss.osgi.test.performance.ChartTypeImpl;
Expand Down Expand Up @@ -69,22 +68,22 @@
*/
public class BundleInstallAndStartBenchmark extends AbstractThreadedBenchmark<Integer>
{
static final String COMMON_BUNDLE_PREFIX = "commonBundle#";
static final String UTIL_BUNDLE_PREFIX = "utilBundle#";
static final String VERSIONED_IMPL_BUNDLE_PREFIX = "versionedImplBundle#";
static final String VERSIONED_INTF_BUNDLE_PREFIX = "versionedIntfBundle#";
static final String TEST_BUNDLE_PREFIX = "testBundle#";
public static final String COMMON_BUNDLE_PREFIX = "commonBundle#";
public static final String UTIL_BUNDLE_PREFIX = "utilBundle#";
public static final String VERSIONED_IMPL_BUNDLE_PREFIX = "versionedImplBundle#";
public static final String VERSIONED_INTF_BUNDLE_PREFIX = "versionedIntfBundle#";
public static final String TEST_BUNDLE_PREFIX = "testBundle#";

private static final ChartType INSTALL_START = new ChartTypeImpl("IS", "Bundle Install and Start Time", "Number of Bundles", "Time (ms)");
private final File bundleStorage;
private final OSGiContainer container;
private final TestBundleProvider testBundleProvider;

protected BundleInstallAndStartBenchmark(OSGiContainer container, BundleContext bc)
public BundleInstallAndStartBenchmark(TestBundleProvider tbp, BundleContext bc)
{
super(bc);
bundleStorage = new File(tempDir, "bundles");
bundleStorage.mkdirs();
this.container = container;
testBundleProvider = tbp;
}

@Override
Expand All @@ -106,7 +105,7 @@ public void run(int numThreads, int numBundlesPerThread) throws Exception
runTest(numThreads, numBundlesPerThread);
}

void prepareTest(int numThreads, int numBundlesPerThread) throws Exception
public void prepareTest(int numThreads, int numBundlesPerThread) throws Exception
{
installBaseLineBundles();

Expand All @@ -131,7 +130,7 @@ private void createTestBundles(String threadName, int numBundlesPerThread) throw
for (int i = 0; i < numBundlesPerThread; i++)
{
InputStream is = getTestBundle(threadName, i);
FileOutputStream fos = new FileOutputStream(new File(bundleStorage, threadName + i + ".jar"));
FileOutputStream fos = new FileOutputStream(new File(bundleStorage, threadName + "_" + i + ".jar"));
try
{
pumpStreams(is, fos);
Expand All @@ -145,13 +144,13 @@ private void createTestBundles(String threadName, int numBundlesPerThread) throw
}

@Override
protected void runThread(String threadName, Integer numBundlesPerThread) throws Exception
public void runThread(String threadName, Integer numBundlesPerThread) throws Exception
{
System.out.println("Starting at " + new Date());
long start = System.currentTimeMillis();
for (int i = 0; i < numBundlesPerThread; i++)
{
URI uri = new File(bundleStorage, threadName + i + ".jar").toURI();
URI uri = new File(bundleStorage, threadName + "_" + i + ".jar").toURI();
Bundle bundle = bundleContext.installBundle(uri.toString());
bundle.start();
}
Expand All @@ -173,27 +172,27 @@ protected void runThread(String threadName, Integer numBundlesPerThread) throws

private InputStream getCommonBundle(final String version) throws Exception
{
return container.getTestArchiveStream(COMMON_BUNDLE_PREFIX + version);
return testBundleProvider.getTestArchiveStream(COMMON_BUNDLE_PREFIX + version);
}

private InputStream getUtilBundle(final int i) throws Exception
{
return container.getTestArchiveStream(UTIL_BUNDLE_PREFIX + i);
return testBundleProvider.getTestArchiveStream(UTIL_BUNDLE_PREFIX + i);
}

private InputStream getVersionedIntfBundle(final String version) throws Exception
{
return container.getTestArchiveStream(VERSIONED_INTF_BUNDLE_PREFIX + version);
return testBundleProvider.getTestArchiveStream(VERSIONED_INTF_BUNDLE_PREFIX + version);
}

private InputStream getVersionedImplBundle(final int version) throws Exception
{
return container.getTestArchiveStream(VERSIONED_IMPL_BUNDLE_PREFIX + version);
return testBundleProvider.getTestArchiveStream(VERSIONED_IMPL_BUNDLE_PREFIX + version);
}

private InputStream getTestBundle(final String threadName, final int counter) throws Exception
{
return container.getTestArchiveStream(TEST_BUNDLE_PREFIX + threadName + "#" + counter);
return testBundleProvider.getTestArchiveStream(TEST_BUNDLE_PREFIX + threadName + "#" + counter);
}

public static void pumpStreams(InputStream is, OutputStream os) throws IOException
Expand Down

0 comments on commit efbba8c

Please sign in to comment.