Author: sannegrinovero
Date: 2009-10-30 06:52:10 -0400 (Fri, 30 Oct 2009)
New Revision: 17881
Added:
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyPerfTest.java
search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerPerfTest.java
Removed:
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java
search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerTestCase.java
Modified:
search/trunk/pom.xml
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java
Log:
HSEARCH-408 Improve execution speed of functional tests: disabled some performance-only
tests, reduced size of data generated in some bigger functional tests.
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2009-10-29 20:44:57 UTC (rev 17880)
+++ search/trunk/pom.xml 2009-10-30 10:52:10 UTC (rev 17881)
@@ -51,7 +51,7 @@
</contributors>
<properties>
- <slf4jVersion>1.5.6</slf4jVersion>
+ <slf4jVersion>1.5.8</slf4jVersion>
<luceneVersion>2.4.1</luceneVersion>
<hibernateVersion>3.5.0.Beta-1</hibernateVersion>
<hibernateCommonsAnnotationVersion>3.2.0.Beta1</hibernateCommonsAnnotationVersion>
@@ -799,6 +799,7 @@
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<excludes>
<exclude>**/classloading/*.java</exclude>
+ <exclude>**/*PerfTest.java</exclude>
</excludes>
</configuration>
</plugin>
@@ -825,6 +826,7 @@
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<excludes>
<exclude>none</exclude>
+ <exclude>**/*PerfTest.java</exclude>
</excludes>
<includes>
<include>**/classloading/*Test.java</include>
Modified:
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java
===================================================================
---
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java 2009-10-29
20:44:57 UTC (rev 17880)
+++
search/trunk/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java 2009-10-30
10:52:10 UTC (rev 17881)
@@ -29,7 +29,6 @@
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.hibernate.Transaction;
-import org.hibernate.search.Environment;
import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.backend.impl.batchlucene.LuceneBatchBackend;
@@ -44,9 +43,9 @@
*/
public class IndexingGeneratedCorpusTest extends TestCase {
- private final int BOOK_NUM = 3000;
- private final int ANCIENTBOOK_NUM = 200;
- private final int DVD_NUM = 2000;
+ private final int BOOK_NUM = 300;
+ private final int ANCIENTBOOK_NUM = 60;
+ private final int DVD_NUM = 200;
private SentenceInventor sentenceInventor = new SentenceInventor( 7L, 10000 );
private FullTextSessionBuilder builder;
Copied:
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyPerfTest.java
(from rev 17850,
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java)
===================================================================
---
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyPerfTest.java
(rev 0)
+++
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyPerfTest.java 2009-10-30
10:52:10 UTC (rev 17881)
@@ -0,0 +1,36 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors
as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.optimizer;
+
+/**
+ * @author Emmanuel Bernard
+ */
+//having name end in *PerfTest disables it from functional tests
+public class IncrementalOptimizerStrategyPerfTest extends OptimizerPerfTest {
+ protected void configure(org.hibernate.cfg.Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( "hibernate.search.default.optimizer.transaction_limit.max",
"10" );
+ }
+}
Deleted:
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java
===================================================================
---
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java 2009-10-29
20:44:57 UTC (rev 17880)
+++
search/trunk/src/test/java/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java 2009-10-30
10:52:10 UTC (rev 17881)
@@ -1,35 +0,0 @@
-/* $Id$
- *
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors
as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.search.test.optimizer;
-
-/**
- * @author Emmanuel Bernard
- */
-public class IncrementalOptimizerStrategyTest extends OptimizerTestCase {
- protected void configure(org.hibernate.cfg.Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( "hibernate.search.default.optimizer.transaction_limit.max",
"10" );
- }
-}
Copied:
search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerPerfTest.java
(from rev 17850,
search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerTestCase.java)
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerPerfTest.java
(rev 0)
+++
search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerPerfTest.java 2009-10-30
10:52:10 UTC (rev 17881)
@@ -0,0 +1,210 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors
as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.optimizer;
+
+import java.io.File;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.impl.FullTextSessionImpl;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
+
+/**
+ * @author Emmanuel Bernard
+ */
+//having name end in *PerfTest disables it from functional tests
+public class OptimizerPerfTest extends SearchTestCase {
+ protected void setUp() throws Exception {
+ File sub = getBaseIndexDir();
+ FileHelper.delete( sub );
+ sub.mkdir();
+ File[] files = sub.listFiles();
+ for (File file : files) {
+ if ( file.isDirectory() ) {
+ FileHelper.delete( file );
+ }
+ }
+ //super.setUp(); //we need a fresh session factory each time for index set up
+ buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ File sub = getBaseIndexDir();
+ FileHelper.delete( sub );
+ }
+
+ public void testConcurrency() throws Exception {
+ int nThreads = 15;
+ ExecutorService es = Executors.newFixedThreadPool( nThreads );
+ Work work = new Work( getSessions() );
+ ReverseWork reverseWork = new ReverseWork( getSessions() );
+ long start = System.currentTimeMillis();
+ int iteration = 100;
+ for (int i = 0; i < iteration; i++) {
+ es.execute( work );
+ es.execute( reverseWork );
+ }
+ while ( work.count < iteration - 1 ) {
+ Thread.sleep( 20 );
+ }
+ System.out.println( iteration + " iterations (8 tx per iteration) in " +
nThreads + " threads: " + ( System
+ .currentTimeMillis() - start ) );
+ }
+
+ protected static class Work implements Runnable {
+ private final SessionFactory sf;
+ public volatile int count = 0;
+
+ public Work(SessionFactory sf) {
+ this.sf = sf;
+ }
+
+ public void run() {
+ try {
+ Session s = sf.openSession();
+ Transaction tx = s.beginTransaction();
+ Worker w = new Worker( "Emmanuel", 65 );
+ s.persist( w );
+ Construction c = new Construction( "Bellagio", "Las Vagas Nevada"
);
+ s.persist( c );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ w = (Worker) s.get( Worker.class, w.getId() );
+ w.setName( "Gavin" );
+ c = (Construction) s.get( Construction.class, c.getId() );
+ c.setName( "W Hotel" );
+ tx.commit();
+ s.close();
+
+ try {
+ Thread.sleep( 50 );
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File
Templates.
+ }
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ FullTextSession fts = new FullTextSessionImpl( s );
+ QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
+ Query query;
+ try {
+ query = parser.parse( "name:Gavin" );
+ }
+ catch (ParseException e) {
+ throw new RuntimeException( e );
+ }
+ boolean results = fts.createFullTextQuery( query ).list().size() > 0;
+ //don't test because in case of async, it query happens before actual saving
+ //if ( !results ) throw new RuntimeException( "No results!" );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ w = (Worker) s.get( Worker.class, w.getId() );
+ s.delete( w );
+ c = (Construction) s.get( Construction.class, c.getId() );
+ s.delete( c );
+ tx.commit();
+ s.close();
+ count++;
+ } catch (Throwable t) {
+ t.printStackTrace( );
+ }
+ }
+ }
+
+ protected static class ReverseWork implements Runnable {
+ private SessionFactory sf;
+
+ public ReverseWork(SessionFactory sf) {
+ this.sf = sf;
+ }
+
+ public void run() {
+ try {
+ Session s = sf.openSession();
+ Transaction tx = s.beginTransaction();
+ Worker w = new Worker( "Mladen", 70 );
+ s.persist( w );
+ Construction c = new Construction( "Hover Dam", "Croatia" );
+ s.persist( c );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ w = (Worker) s.get( Worker.class, w.getId() );
+ w.setName( "Remi" );
+ c = (Construction) s.get( Construction.class, c.getId() );
+ c.setName( "Palais des festivals" );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ w = (Worker) s.get( Worker.class, w.getId() );
+ s.delete( w );
+ c = (Construction) s.get( Construction.class, c.getId() );
+ s.delete( c );
+ tx.commit();
+ s.close();
+ } catch (Throwable t) {
+ t.printStackTrace( );
+ }
+ }
+ }
+
+ protected void configure(org.hibernate.cfg.Configuration cfg) {
+ super.configure( cfg );
+ File sub = getBaseIndexDir();
+ cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath()
);
+ cfg.setProperty( "hibernate.search.default.directory_provider",
FSDirectoryProvider.class.getName() );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Worker.class,
+ Construction.class
+ };
+ }
+}
Deleted:
search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerTestCase.java
===================================================================
---
search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2009-10-29
20:44:57 UTC (rev 17880)
+++
search/trunk/src/test/java/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2009-10-30
10:52:10 UTC (rev 17881)
@@ -1,209 +0,0 @@
-/* $Id$
- *
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors
as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.search.test.optimizer;
-
-import java.io.File;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.search.Environment;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.impl.FullTextSessionImpl;
-import org.hibernate.search.store.FSDirectoryProvider;
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.util.FileHelper;
-
-/**
- * @author Emmanuel Bernard
- */
-public class OptimizerTestCase extends SearchTestCase {
- protected void setUp() throws Exception {
- File sub = getBaseIndexDir();
- FileHelper.delete( sub );
- sub.mkdir();
- File[] files = sub.listFiles();
- for (File file : files) {
- if ( file.isDirectory() ) {
- FileHelper.delete( file );
- }
- }
- //super.setUp(); //we need a fresh session factory each time for index set up
- buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- File sub = getBaseIndexDir();
- FileHelper.delete( sub );
- }
-
- public void testConcurrency() throws Exception {
- int nThreads = 15;
- ExecutorService es = Executors.newFixedThreadPool( nThreads );
- Work work = new Work( getSessions() );
- ReverseWork reverseWork = new ReverseWork( getSessions() );
- long start = System.currentTimeMillis();
- int iteration = 100;
- for (int i = 0; i < iteration; i++) {
- es.execute( work );
- es.execute( reverseWork );
- }
- while ( work.count < iteration - 1 ) {
- Thread.sleep( 20 );
- }
- System.out.println( iteration + " iterations (8 tx per iteration) in " +
nThreads + " threads: " + ( System
- .currentTimeMillis() - start ) );
- }
-
- protected static class Work implements Runnable {
- private final SessionFactory sf;
- public volatile int count = 0;
-
- public Work(SessionFactory sf) {
- this.sf = sf;
- }
-
- public void run() {
- try {
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
- Worker w = new Worker( "Emmanuel", 65 );
- s.persist( w );
- Construction c = new Construction( "Bellagio", "Las Vagas Nevada"
);
- s.persist( c );
- tx.commit();
- s.close();
-
- s = sf.openSession();
- tx = s.beginTransaction();
- w = (Worker) s.get( Worker.class, w.getId() );
- w.setName( "Gavin" );
- c = (Construction) s.get( Construction.class, c.getId() );
- c.setName( "W Hotel" );
- tx.commit();
- s.close();
-
- try {
- Thread.sleep( 50 );
- }
- catch (InterruptedException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File
Templates.
- }
-
- s = sf.openSession();
- tx = s.beginTransaction();
- FullTextSession fts = new FullTextSessionImpl( s );
- QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
- Query query;
- try {
- query = parser.parse( "name:Gavin" );
- }
- catch (ParseException e) {
- throw new RuntimeException( e );
- }
- boolean results = fts.createFullTextQuery( query ).list().size() > 0;
- //don't test because in case of async, it query happens before actual saving
- //if ( !results ) throw new RuntimeException( "No results!" );
- tx.commit();
- s.close();
-
- s = sf.openSession();
- tx = s.beginTransaction();
- w = (Worker) s.get( Worker.class, w.getId() );
- s.delete( w );
- c = (Construction) s.get( Construction.class, c.getId() );
- s.delete( c );
- tx.commit();
- s.close();
- count++;
- } catch (Throwable t) {
- t.printStackTrace( );
- }
- }
- }
-
- protected static class ReverseWork implements Runnable {
- private SessionFactory sf;
-
- public ReverseWork(SessionFactory sf) {
- this.sf = sf;
- }
-
- public void run() {
- try {
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
- Worker w = new Worker( "Mladen", 70 );
- s.persist( w );
- Construction c = new Construction( "Hover Dam", "Croatia" );
- s.persist( c );
- tx.commit();
- s.close();
-
- s = sf.openSession();
- tx = s.beginTransaction();
- w = (Worker) s.get( Worker.class, w.getId() );
- w.setName( "Remi" );
- c = (Construction) s.get( Construction.class, c.getId() );
- c.setName( "Palais des festivals" );
- tx.commit();
- s.close();
-
- s = sf.openSession();
- tx = s.beginTransaction();
- w = (Worker) s.get( Worker.class, w.getId() );
- s.delete( w );
- c = (Construction) s.get( Construction.class, c.getId() );
- s.delete( c );
- tx.commit();
- s.close();
- } catch (Throwable t) {
- t.printStackTrace( );
- }
- }
- }
-
- protected void configure(org.hibernate.cfg.Configuration cfg) {
- super.configure( cfg );
- File sub = getBaseIndexDir();
- cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath()
);
- cfg.setProperty( "hibernate.search.default.directory_provider",
FSDirectoryProvider.class.getName() );
- cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- }
-
- protected Class[] getMappings() {
- return new Class[] {
- Worker.class,
- Construction.class
- };
- }
-}