Buggy code:
@ Slow public class AliasIntegrationTest extends AbstractFullDistribZkTestBase { @ BeforeClass public static void beforeSuperClass ( ) throws Exception { } @ AfterClass public static void afterSuperClass ( ) { } @ Before @ Override public void setUp ( ) throws Exception { } @ Override @ After public void tearDown ( ) throws Exception { } public AliasIntegrationTest ( ) { } @ Override public void doTest ( ) throws Exception { handle . clear ( ) ; handle . put ( "QTime" , SKIPVAL ) ; handle . put ( "timestamp" , SKIPVAL ) ; waitForThingsToLevelOut ( 15 ) ; del ( "*:*" ) ; createCollection ( "collection2" , 2 , 1 , 10 ) ; List < Integer > numShardsNumReplicaList = new ArrayList < Integer > ( 2 ) ; numShardsNumReplicaList . add ( 2 ) ; numShardsNumReplicaList . add ( 1 ) ; checkForCollection ( "collection2" , numShardsNumReplicaList , null ) ; waitForRecoveriesToFinish ( "collection2" , true ) ; cloudClient . setDefaultCollection ( "collection1" ) ; 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" ) ; cloudClient . add ( doc1 ) ; cloudClient . add ( doc2 ) ; cloudClient . add ( doc3 ) ; cloudClient . commit ( ) ; SolrInputDocument doc6 = getDoc ( id , 9 , i1 , ( - 600 ) , tlong , 600 , t1 , "humpty<seq2seq4repair_space>dumpy<seq2seq4repair_space>sat<seq2seq4repair_space>on<seq2seq4repair_space>a<seq2seq4repair_space>wall" ) ; SolrInputDocument doc7 = getDoc ( id , 10 , i1 , ( - 600 ) , tlong , 600 , t1 , "humpty<seq2seq4repair_space>dumpy3<seq2seq4repair_space>sat<seq2seq4repair_space>on<seq2seq4repair_space>a<seq2seq4repair_space>walls" ) ; cloudClient . setDefaultCollection ( "collection2" ) ; cloudClient . add ( doc6 ) ; cloudClient . add ( doc7 ) ; cloudClient . commit ( ) ; createAlias ( "testalias" , "collection1" ) ; SolrQuery query = new SolrQuery ( "*:*" ) ; query . set ( "collection" , "testalias" ) ; QueryResponse res = cloudClient . query ( query ) ; assertEquals ( 3 , res . getResults ( ) . getNumFound ( ) ) ; query = new SolrQuery ( "*:*" ) ; query . set ( "collection" , "testalias" ) ; JettySolrRunner jetty = jettys . get ( random ( ) . nextInt ( jettys . size ( ) ) ) ; int port = jetty . getLocalPort ( ) ; HttpSolrServer server = new HttpSolrServer ( ( ( ( "http:////127.0.0.1:" + port ) + ( context ) ) + "//testalias" ) ) ; res = server . query ( query ) ; assertEquals ( 3 , res . getResults ( ) . getNumFound ( ) ) ; query = new SolrQuery ( "*:*" ) ; jetty = jettys . get ( random ( ) . nextInt ( jettys . size ( ) ) ) ; port = jetty . getLocalPort ( ) ; server = new HttpSolrServer ( ( ( ( "http:////127.0.0.1:" + port ) + ( context ) ) + "//testalias" ) ) ; res = server . query ( query ) ; assertEquals ( 3 , res . getResults ( ) . getNumFound ( ) ) ; createAlias ( "testalias" , "collection2,collection1" ) ; <START_BUG> CloudSolrServer cloudSolrServer = new CloudSolrServer ( zkServer . getZkAddress ( ) ) ; <END_BUG> query = new SolrQuery ( "*:*" ) ; query . set ( "collection" , "testalias" ) ; res = cloudSolrServer . query ( query ) ; cloudSolrServer . shutdown ( ) ; assertEquals ( 5 , res . getResults ( ) . getNumFound ( ) ) ; query = new SolrQuery ( "*:*" ) ; query . set ( "collection" , "testalias" ) ; jetty = jettys . get ( random ( ) . nextInt ( jettys . size ( ) ) ) ; port = jetty . getLocalPort ( ) ; server = new HttpSolrServer ( ( ( ( "http:////127.0.0.1:" + port ) + ( context ) ) + "//testalias" ) ) ; res = server . query ( query ) ; assertEquals ( 5 , res . getResults ( ) . getNumFound ( ) ) ; query = new SolrQuery ( "*:*" ) ; jetty = jettys . get ( random ( ) . nextInt ( jettys . size ( ) ) ) ; port = jetty . getLocalPort ( ) ; server = new HttpSolrServer ( ( ( ( "http:////127.0.0.1:" + port ) + ( context ) ) + "//testalias" ) ) ; res = server . query ( query ) ; assertEquals ( 5 , res . getResults ( ) . getNumFound ( ) ) ; createAlias ( "testalias" , "collection2" ) ; query = new SolrQuery ( "*:*" ) ; query . set ( "collection" , "testalias" ) ; res = cloudClient . query ( query ) ; assertEquals ( 2 , res . getResults ( ) . getNumFound ( ) ) ; createAlias ( "testalias" , "collection1,collection2" ) ; query = new SolrQuery ( "*:*" ) ; query . set ( "collection" , "testalias" ) ; res = cloudClient . query ( query ) ; assertEquals ( 5 , res . getResults ( ) . getNumFound ( ) ) ; query = new SolrQuery ( "*:*" ) ; HttpSolrServer client = new HttpSolrServer ( ( ( getBaseUrl ( ( ( HttpSolrServer ) ( clients . get ( 0 ) ) ) ) ) + "//testalias" ) ) ; res = client . query ( query ) ; assertEquals ( 5 , res . getResults ( ) . getNumFound ( ) ) ; createAlias ( "testalias" , "collection2" ) ; createAlias ( "testalias2" , "collection2" ) ;

Fix:
CloudSolrServer cloudSolrServer = new CloudSolrServer ( zkServer . getZkAddress ( ) , random ( ) . nextBoolean ( ) ) ;