[
https://issues.apache.org/jira/browse/BROOKLYN-241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15199386#comment-15199386
]
Alex Heneveld commented on BROOKLYN-241:
----------------------------------------
I use this test fragment added to CatalogYamlTemplateTest
{code}
static Stopwatch elapsed, inTest;
static int iterCount = 0;
@Test(invocationCount=1000)
public void testSetupTime() throws Exception {
if (elapsed==null) {
elapsed = Stopwatch.createStarted();
inTest = Stopwatch.createUnstarted();
}
inTest.start();
testAddCatalogItem();
inTest.stop();
iterCount++;
Duration dInTest = Duration.of(inTest);
Duration dElapsed = Duration.of(elapsed);
System.err.println("Iter "+iterCount+"; "+dInTest+" / "+dElapsed+" in
test => setup/teardown time; "+
dElapsed.multiply(1.0/iterCount)+" mean per test cycle; "+
"setup/teardown taking
"+((int)(100*(dElapsed.toNanoseconds()-dInTest.toNanoseconds())/dElapsed.toNanoseconds()))+"
%" );
}
{code}
It's crude but effective; looking at stderr shows lines like:
{code}
Iter 139; 4s 396ms / 1m 13s 737ms in test => setup/teardown time; 530ms 482us
14ns mean per test cycle; setup/teardown taking 94 %
{code}
And running jstack-active while it's running suggests the culprit is OSGi:
{code}
at
org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:165)
at
org.apache.brooklyn.rt.felix.EmbeddedFelixFramework.installExtensionBundle(EmbeddedFelixFramework.java:209)
at
org.apache.brooklyn.rt.felix.EmbeddedFelixFramework.installBootBundles(EmbeddedFelixFramework.java:145)
at
org.apache.brooklyn.rt.felix.EmbeddedFelixFramework.newFrameworkStarted(EmbeddedFelixFramework.java:108)
at org.apache.brooklyn.util.core.osgi.Osgis.getFramework(Osgis.java:324)
at
org.apache.brooklyn.core.mgmt.ha.OsgiManager.start(OsgiManager.java:80)
at
org.apache.brooklyn.core.mgmt.internal.LocalManagementContext.<init>(LocalManagementContext.java:196)
at
org.apache.brooklyn.core.mgmt.internal.LocalManagementContext.<init>(LocalManagementContext.java:164)
at
org.apache.brooklyn.core.mgmt.internal.LocalManagementContext.<init>(LocalManagementContext.java:156)
at
org.apache.brooklyn.core.mgmt.internal.LocalManagementContext.<init>(LocalManagementContext.java:143)
at
org.apache.brooklyn.core.test.entity.LocalManagementContextForTests.<init>(LocalManagementContextForTests.java:41)
{code}
(Since it's Felix not Karaf it's possible this is unrelated to the recent OSGi
work. I think I would have noticed earlier if CAMP REST API tests took >2m to
run but maybe not! Still, feels like we could improve build time dramatically
here.)
> Many tests taking too long to run due to OSGi
> ---------------------------------------------
>
> Key: BROOKLYN-241
> URL: https://issues.apache.org/jira/browse/BROOKLYN-241
> Project: Brooklyn
> Issue Type: Bug
> Reporter: Alex Heneveld
>
> Since the introduction of Felix, a good number of our tests are taking a long
> time to run (eg 500ms average, for 100 or so tests; previously I'm pretty
> sure these were <100ms).
> As people build frequently this needs to be optimized.
> /cc [~svet] [~cipi] [~aled.sage]
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)