You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2011/08/17 18:52:31 UTC

svn commit: r1158825 - /maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java

Author: cstamas
Date: Wed Aug 17 16:52:31 2011
New Revision: 1158825

URL: http://svn.apache.org/viewvc?rev=1158825&view=rev
Log:
Fixed flakey UT that was breaking from time time. It was doing illegal stuff (publishing index concurrently into SAME directory), but this fact was not noticed since the UT was actually testing something else, not the results of the publish operation that was rubbish probably (overwritten by multiple threads, being inconsistent).

Modified:
    maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java

Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java?rev=1158825&r1=1158824&r2=1158825&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java (original)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java Wed Aug 17 16:52:31 2011
@@ -21,6 +21,7 @@ package org.apache.maven.index;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.index.packer.IndexPacker;
@@ -39,6 +40,8 @@ public class ConcurrentUseWithMergedCont
 
     protected File repoPublish = new File( getBasedir(), "target/repo-publish" );
 
+    protected final AtomicInteger counter = new AtomicInteger();
+
     @Override
     protected void setUp()
         throws Exception
@@ -52,7 +55,13 @@ public class ConcurrentUseWithMergedCont
     protected int readIndex( final NexusIndexer nexusIndexer, final IndexingContext indexingContext )
         throws IOException
     {
-        final IndexPackingRequest request = new IndexPackingRequest( context, repoPublish );
+        // note: concurrent Index publishing into SAME directory is not supported and should be avoided.
+        // This test had multiple threads doing it, and since it was not checking actual results of publish (that was
+        // not the goal of the test, but simultaneous publishing of merged context that has member changes happening),
+        // it was probably publish rubbish anyway.
+        final File publish = new File( repoPublish, "publish-" + counter.getAndIncrement() );
+
+        final IndexPackingRequest request = new IndexPackingRequest( context, publish );
 
         request.setCreateIncrementalChunks( false );