Buggy code:
@ Slow public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase { private static final String DEFAULT_COLLECTION = "collection1" ; private static final boolean DEBUG = false ; String t1 = "a_t" ; String i1 = "a_si" ; String nint = "n_i" ; String tint = "n_ti" ; String nfloat = "n_f" ; String tfloat = "n_tf" ; String ndouble = "n_d" ; String tdouble = "n_td" ; String nlong = "n_l" ; String tlong = "other_tl1" ; String ndate = "n_dt" ; String tdate = "n_tdt" ; String oddField = "oddField_s" ; String missingField = "ignore_exception__missing_but_valid_field_t" ; String invalidField = "ignore_exception__invalid_field_not_in_schema" ; private Map < String , List < SolrServer > > otherCollectionClients = new HashMap < String , List < SolrServer > > ( ) ; private String oneInstanceCollection = "oneInstanceCollection" ; private String oneInstanceCollection2 = "oneInstanceCollection2" ; ThreadPoolExecutor executor = new ThreadPoolExecutor ( 0 , Integer . MAX_VALUE , 5 , TimeUnit . SECONDS , new SynchronousQueue < Runnable > ( ) , new DefaultSolrThreadFactory ( "testExecutor" ) ) ; CompletionService < Request > completionService ; Set < Future < Request > > pending ; @ Before @ Override public void setUp ( ) throws Exception { } public BasicDistributedZkTest ( ) { } @ Override protected void setDistributedParams ( ModifiableSolrParams params ) { } @ Override public void doTest ( ) throws Exception { } private void testUnloadShardAndCollection ( ) throws Exception { } private void testCoreUnloadAndLeaders ( ) throws Exception { } private void testUnloadLotsOfCores ( ) throws Exception { } private void testStopAndStartCoresInOneInstance ( ) throws Exception { } private void createCores ( final HttpSolrServer server , ThreadPoolExecutor executor , final String collection , final int numShards , int cnt ) { } private String getBaseUrl ( SolrServer client ) { } private void testCollectionsAPI ( ) throws Exception { Map < String , List < Integer > > collectionInfos = new HashMap < String , List < Integer > > ( ) ; int cnt = atLeast ( 3 ) ; for ( int i = 0 ; i < cnt ; i ++ ) { <START_BUG> createCollection ( collectionInfos , i , ( ( _TestUtil . nextInt ( random ( ) , 0 , shardCount ) ) + 1 ) , ( ( _TestUtil . nextInt ( random ( ) , 0 , 5 ) ) + 1 ) ) ; <END_BUG> } Set < Map . Entry < String , List < Integer > > > collectionInfosEntrySet = collectionInfos . entrySet ( ) ; for ( Map . Entry < String , List < Integer > > entry : collectionInfosEntrySet ) { String collection = entry . getKey ( ) ; List < Integer > list = entry . getValue ( ) ; checkForCollection ( collection , list . get ( 0 ) ) ; String url = getUrlFromZk ( collection ) ; HttpSolrServer collectionClient = new HttpSolrServer ( url ) ; waitForNon403or404or503 ( collectionClient ) ; } for ( int j = 0 ; j < cnt ; j ++ ) { waitForRecoveriesToFinish ( ( "awholynewcollection_" + j ) , zkStateReader , false ) ; } List < String > collectionNameList = new ArrayList < String > ( ) ; collectionNameList . addAll ( collectionInfos . keySet ( ) ) ; String collectionName = collectionNameList . get ( random ( ) . nextInt ( collectionNameList . size ( ) ) ) ; String url = getUrlFromZk ( collectionName ) ; HttpSolrServer collectionClient = new HttpSolrServer ( url ) ; SolrInputDocument doc1 = getDoc ( id , 6 , i1 , ( - 600 ) , tlong , 600 , t1 , "humpty<seq2seq4repair_space>dumpy<seq2seq4repair_space>sat<seq2seq4repair_space>on<seq2seq4repair_space>a<seq2seq4repair_space>wall" ) ; SolrInputDocument doc2 = getDoc ( id , 7 , i1 , ( - 600 ) , tlong , 600 , t1 , "humpty<seq2seq4repair_space>dumpy3<seq2seq4repair_space>sat<seq2seq4repair_space>on<seq2seq4repair_space>a<seq2seq4repair_space>walls" ) ; SolrInputDocument doc3 = getDoc ( id , 8 , i1 , ( - 600 ) , tlong , 600 , t1 , "humpty<seq2seq4repair_space>dumpy2<seq2seq4repair_space>sat<seq2seq4repair_space>on<seq2seq4repair_space>a<seq2seq4repair_space>walled" ) ; collectionClient . add ( doc1 ) ; collectionClient . add ( doc2 ) ; collectionClient . add ( doc3 ) ; collectionClient . commit ( ) ; assertEquals ( 3 , collectionClient . query ( new SolrQuery ( "*:*" ) ) . getResults ( ) . getNumFound ( ) ) ; Map < String , Long > urlToTimeBefore = new HashMap < String , Long > ( ) ; collectStartTimes ( collectionName , urlToTimeBefore ) ; assertTrue ( ( ( urlToTimeBefore . size ( ) ) > 0 ) ) ; ModifiableSolrParams params = new ModifiableSolrParams ( ) ; params . set ( "action" , RELOAD . toString ( ) ) ; params . set ( "name" , collectionName ) ; QueryRequest request = new QueryRequest ( params ) ; request . setPath ( "//admin//collections" ) ; final String baseUrl = ( ( HttpSolrServer ) ( clients . get ( 0 ) ) ) . getBaseURL ( ) . substring ( 0 , ( ( ( ( ( HttpSolrServer ) ( clients . get ( 0 ) ) ) . getBaseURL ( ) . length ( ) ) - ( BasicDistributedZkTest . DEFAULT_COLLECTION . length ( ) ) ) - 1 ) ) ; createNewSolrServer ( "" , baseUrl ) . request ( request ) ; boolean allTimesAreCorrect = waitForReloads ( collectionName , urlToTimeBefore ) ; assertTrue ( "some<seq2seq4repair_space>core<seq2seq4repair_space>start<seq2seq4repair_space>times<seq2seq4repair_space>did<seq2seq4repair_space>not<seq2seq4repair_space>change<seq2seq4repair_space>on<seq2seq4repair_space>reload" , allTimesAreCorrect ) ; waitForRecoveriesToFinish ( ( "awholynewcollection_" + ( cnt - 1 ) ) , zkStateReader , false ) ; params = new ModifiableSolrParams ( ) ; params . set ( "action" , DELETE . toString ( ) ) ; params . set ( "name" , collectionName ) ; request = new QueryRequest ( params ) ; request . setPath ( "//admin//collections" ) ; createNewSolrServer ( "" , baseUrl ) . request ( request ) ; checkForMissingCollection ( collectionName ) ; params = new ModifiableSolrParams ( ) ; params . set ( "action" , DELETE . toString ( ) ) ; params . set ( "name" , "unknown_collection" ) ;

Fix:
createCollection ( collectionInfos , i , ( ( _TestUtil . nextInt ( random ( ) , 0 , shardCount ) ) + 1 ) , ( ( _TestUtil . nextInt ( random ( ) , 0 , 3 ) ) + 1 ) ) ;