Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

suppress remote repository access during Nexus5249IndexerManagerIT

mock index updater was configured too late during the test, which
resulted in some requests going through to real remote repository
and made tests sensitive to network connection quality in addition
to being  unnecessary slow.

Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
  • Loading branch information...
commit 43abd36811cf05f7ccb00f500bd850318cc54253 1 parent 5197f3a
ifedorenko ifedorenko authored cstamas committed
77 ...ndexer/nexus-indexer-lucene-plugin/src/test/java/org/sonatype/nexus/index/Nexus5249IndexerManagerIT.java
View
@@ -87,40 +87,6 @@
protected void prepare( final IOException failure )
throws Exception
{
- // count total of indexed, and total of indexed proxy repositories, and set the one to make it really go
- // remotely
- indexedRepositories = 0;
- indexedProxyRepositories = 0;
- for ( Repository repository : repositoryRegistry.getRepositories() )
- {
- if ( !repository.getRepositoryKind().isFacetAvailable( ShadowRepository.class )
- && !repository.getRepositoryKind().isFacetAvailable( GroupRepository.class )
- && repository.getRepositoryKind().isFacetAvailable( MavenRepository.class ) && repository.isIndexable() )
- {
- indexedRepositories++;
- }
- // leave only one to download remote indexes explicitly
- if ( repository.getRepositoryKind().isFacetAvailable( MavenProxyRepository.class ) )
- {
- final MavenProxyRepository mavenProxyRepository = repository.adaptToFacet( MavenProxyRepository.class );
- if ( repository.getId().equals( apacheSnapshots.getId() ) )
- {
- mavenProxyRepository.setDownloadRemoteIndexes( true );
- failingRepository = mavenProxyRepository;
- indexedProxyRepositories++;
- }
- else
- {
- mavenProxyRepository.setDownloadRemoteIndexes( false );
- }
- mavenProxyRepository.commitChanges();
- }
- }
-
- // as things above will trigger some bg tasks (failingRepository will be reindexed with a task)
- waitForTasksToStop();
- wairForAsyncEventsToCalmDown();
-
// faking IndexUpdater that will fail with given exception for given "failing" repository
final IndexUpdater realUpdater = lookup( IndexUpdater.class );
// predicate to match invocation when the arguments are for the failingRepository
@@ -166,6 +132,44 @@ public ScanningResult scan( ScanningRequest request )
final DefaultIndexerManager dim = (DefaultIndexerManager) indexerManager;
dim.setIndexUpdater( fakeUpdater );
dim.setScanner( fakeScanner );
+
+ // count total of indexed, and total of indexed proxy repositories, and set the one to make it really go
+ // remotely
+ indexedRepositories = 0;
+ indexedProxyRepositories = 0;
+ for ( Repository repository : repositoryRegistry.getRepositories() )
+ {
+ if ( !repository.getRepositoryKind().isFacetAvailable( ShadowRepository.class )
+ && !repository.getRepositoryKind().isFacetAvailable( GroupRepository.class )
+ && repository.getRepositoryKind().isFacetAvailable( MavenRepository.class ) && repository.isIndexable() )
+ {
+ indexedRepositories++;
+ }
+ // leave only one to download remote indexes explicitly
+ if ( repository.getRepositoryKind().isFacetAvailable( MavenProxyRepository.class ) )
+ {
+ final MavenProxyRepository mavenProxyRepository = repository.adaptToFacet( MavenProxyRepository.class );
+ if ( repository.getId().equals( apacheSnapshots.getId() ) )
+ {
+ mavenProxyRepository.setDownloadRemoteIndexes( true );
+ failingRepository = mavenProxyRepository;
+ indexedProxyRepositories++;
+ }
+ else
+ {
+ mavenProxyRepository.setDownloadRemoteIndexes( false );
+ }
+ mavenProxyRepository.commitChanges();
+ }
+ }
+
+ // as things above will trigger some bg tasks (failingRepository will be reindexed with a task)
+ waitForTasksToStop();
+ wairForAsyncEventsToCalmDown();
+
+ // reset counters
+ fetchCountingInvocationHandler.reset();
+ scanInvocationCount = 0;
}
@Test
@@ -312,6 +316,11 @@ public int getInvocationCount()
{
return count;
}
+
+ public void reset()
+ {
+ count = 0;
+ }
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.