Running unit test in parallel
Hi! We are using wicket-1.4.8. We have a lot of unit tests and it takes long time to run them. To reduce running time at multi-core systems we decided to run them parallel in multiple threads. I use this http://mycila.googlecode.com/svn/sandbox/src/main/java/com/mycila/sandbox/junit/runner/ConcurrentSuite.java class to run junits concurrently. First problem I've faced with was some exception from org.apache.wicket.jmx.Initializer : *org.apache.wicket.WicketRuntimeException: javax.management.InstanceAlreadyExistsException: org.apache.wicket.app.SimpleWicketTester$1:type=Application at org.apache.wicket.jmx.Initializer.init(Initializer.java:207) at org.apache.wicket.Application.callInitializers(Application.java:843) at org.apache.wicket.Application.initializeComponents(Application.java:678) at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:725) at org.apache.wicket.protocol.http.MockWebApplication.init(MockWebApplication.java:168) at org.apache.wicket.util.tester.BaseWicketTester.init(BaseWicketTester.java:219) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:325) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:308) at com.infoblox.platform.test.PlatformWicketTester.init(PlatformWicketTester.java:60) at com.infoblox.nios.ui.widget.test.SimpleWicketTester.setUp(SimpleWicketTester.java:54) * I've patched the Initializer file, added some synchronization: * synchronized (mbeanServer) { int i = 0; while (mbeanServer.isRegistered(appBeanName)) { tempDomain = name + - + i++; //$NON-NLS-1$ appBeanName = new ObjectName(tempDomain + :type=Application); //$NON-NLS-1$ } domain = tempDomain; Application appBean = new Application(application); register(appBean, appBeanName); register(new ApplicationSettings(application), new ObjectName(domain + :type=Application,name=ApplicationSettings)); //$NON-NLS-1$ register(new DebugSettings(application), new ObjectName(domain + :type=Application,name=DebugSettings)); //$NON-NLS-1$ register(new MarkupSettings(application), new ObjectName(domain + :type=Application,name=MarkupSettings)); //$NON-NLS-1$ register(new ResourceSettings(application), new ObjectName(domain + :type=Application,name=ResourceSettings)); //$NON-NLS-1$ register(new PageSettings(application), new ObjectName(domain + :type=Application,name=PageSettings)); //$NON-NLS-1$ register(new RequestCycleSettings(application), new ObjectName(domain + :type=Application,name=RequestCycleSettings)); //$NON-NLS-1$ register(new SecuritySettings(application), new ObjectName(domain + :type=Application,name=SecuritySettings)); //$NON-NLS-1$ register(new SessionSettings(application), new ObjectName(domain + :type=Application,name=SessionSettings)); //$NON-NLS-1$ register(new CookieValuePersisterSettings(application), new ObjectName(domain + :type=Application,name=CookieValuePersisterSettings)); //$NON-NLS-1$ RequestLogger sessionsBean = new RequestLogger(application); ObjectName sessionsBeanName = new ObjectName(domain + :type=RequestLogger); //$NON-NLS-1$ register(sessionsBean, sessionsBeanName); }* and the problem was gone. The second problem I found was such mysterious exceptions from different classes: *org.apache.wicket.WicketRuntimeException: Exception in rendering component: [MarkupContainer [Component id = _header_0]] at org.apache.wicket.Component.renderComponent(Component.java:2658) at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1512) at org.apache.wicket.Component.render(Component.java:2450) at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:229) at org.apache.wicket.markup.resolver.HtmlHeaderResolver.resolve(HtmlHeaderResolver.java:80) at org.apache.wicket.markup.resolver.ComponentResolvers.resolve(ComponentResolvers.java:81) at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1418) at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1528) at org.apache.wicket.Page.onRender(Page.java:1565) at org.apache.wicket.Component.render(Component.java:2450) at org.apache.wicket.Page.renderPage(Page.java:914) at org.apache.wicket.request.target.component.PageRequestTarget.respond(PageRequestTarget.java:63) at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1258) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at
Re: Running unit test in parallel
I didn't mean that I want to run core tests. I need to run junits for wicket-based web applications in 3-4 parallel threads. We have a lot of tests based on WicketTester and it takes a lot of time to run them. Parallel running reduces execution time significantly. But as far as I can see it's impossible with wicket 1.4. I'm not sure about 1.5.x but I can't migrate to this version just to check. 22 декабря 2011 г. 18:25 пользователь Martin Grigorov mgrigo...@apache.orgнаписал: Hi, Some people ran 1.5.x core tests in parallel with JUnit/Surefire parallel support and the problems they had were related with setting current Locale with Locale.setDefault(), i.e. JVM wide. Some tests expect specific i18n-ized results and due to changed Locale they failed. Improvements in this area for 1.4.x wont be done but you can provide patches for 1.5 if there are no API breaks and for 6.0 with API changes. On Thu, Dec 22, 2011 at 5:18 PM, Vervenko Pavel willcode4f...@tut.by wrote: Hi! We are using wicket-1.4.8. We have a lot of unit tests and it takes long time to run them. To reduce running time at multi-core systems we decided to run them parallel in multiple threads. I use this http://mycila.googlecode.com/svn/sandbox/src/main/java/com/mycila/sandbox/junit/runner/ConcurrentSuite.java class to run junits concurrently. First problem I've faced with was some exception from org.apache.wicket.jmx.Initializer : *org.apache.wicket.WicketRuntimeException: javax.management.InstanceAlreadyExistsException: org.apache.wicket.app.SimpleWicketTester$1:type=Application at org.apache.wicket.jmx.Initializer.init(Initializer.java:207) at org.apache.wicket.Application.callInitializers(Application.java:843) at org.apache.wicket.Application.initializeComponents(Application.java:678) at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:725) at org.apache.wicket.protocol.http.MockWebApplication.init(MockWebApplication.java:168) at org.apache.wicket.util.tester.BaseWicketTester.init(BaseWicketTester.java:219) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:325) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:308) at com.infoblox.platform.test.PlatformWicketTester.init(PlatformWicketTester.java:60) at com.infoblox.nios.ui.widget.test.SimpleWicketTester.setUp(SimpleWicketTester.java:54) * I've patched the Initializer file, added some synchronization: * synchronized (mbeanServer) { int i = 0; while (mbeanServer.isRegistered(appBeanName)) { tempDomain = name + - + i++; //$NON-NLS-1$ appBeanName = new ObjectName(tempDomain + :type=Application); //$NON-NLS-1$ } domain = tempDomain; Application appBean = new Application(application); register(appBean, appBeanName); register(new ApplicationSettings(application), new ObjectName(domain + :type=Application,name=ApplicationSettings)); //$NON-NLS-1$ register(new DebugSettings(application), new ObjectName(domain + :type=Application,name=DebugSettings)); //$NON-NLS-1$ register(new MarkupSettings(application), new ObjectName(domain + :type=Application,name=MarkupSettings)); //$NON-NLS-1$ register(new ResourceSettings(application), new ObjectName(domain + :type=Application,name=ResourceSettings)); //$NON-NLS-1$ register(new PageSettings(application), new ObjectName(domain + :type=Application,name=PageSettings)); //$NON-NLS-1$ register(new RequestCycleSettings(application), new ObjectName(domain + :type=Application,name=RequestCycleSettings)); //$NON-NLS-1$ register(new SecuritySettings(application), new ObjectName(domain + :type=Application,name=SecuritySettings)); //$NON-NLS-1$ register(new SessionSettings(application), new ObjectName(domain + :type=Application,name=SessionSettings)); //$NON-NLS-1$ register(new CookieValuePersisterSettings(application), new ObjectName(domain + :type=Application,name=CookieValuePersisterSettings)); //$NON-NLS-1$ RequestLogger sessionsBean = new RequestLogger(application); ObjectName sessionsBeanName = new ObjectName(domain + :type=RequestLogger); //$NON-NLS-1$ register(sessionsBean, sessionsBeanName); }* and the problem was gone. The second problem I found was such mysterious exceptions from different classes: *org.apache.wicket.WicketRuntimeException: Exception in rendering component: [MarkupContainer [Component id = _header_0]] at org.apache.wicket.Component.renderComponent(Component.java:2658) at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1512) at org.apache.wicket.Component.render(Component.java:2450) at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:229