4141/** Cloud-specific Luke tests that require SolrCloud features like managed schema and Schema API. */
4242public class LukeHandlerCloudTest extends SolrCloudTestCase {
4343
44+ private static final String DISTRIB_COLLECTION = "lukeDistribTests" ;
45+ private static final int NUM_DOCS = 20 ;
46+
4447 @ BeforeClass
4548 public static void setupCluster () throws Exception {
46- configureCluster (2 ).addConfig ("managed" , configset ("cloud-managed" )).configure ();
49+ System .setProperty ("managed.schema.mutable" , "true" );
50+ configureCluster (2 )
51+ .addConfig ("managed" , configset ("cloud-managed" ))
52+ .addConfig ("dynamic" , configset ("cloud-dynamic" ))
53+ .configure ();
54+
55+ CollectionAdminRequest .createCollection (DISTRIB_COLLECTION , "dynamic" , 2 , 1 )
56+ .processAndWait (cluster .getSolrClient (), DEFAULT_TIMEOUT );
57+ cluster .waitForActiveCollection (DISTRIB_COLLECTION , 2 , 2 );
58+
59+ for (int i = 0 ; i < NUM_DOCS ; i ++) {
60+ SolrInputDocument doc = new SolrInputDocument ();
61+ doc .addField ("id" , String .valueOf (i ));
62+ doc .addField ("name" , "name_" + i );
63+ doc .addField ("subject" , "subject value " + (i % 5 ));
64+ cluster .getSolrClient ().add (DISTRIB_COLLECTION , doc );
65+ }
66+ cluster .getSolrClient ().commit (DISTRIB_COLLECTION );
4767 }
4868
4969 private void requestLuke (String collection , SolrParams extra ) throws Exception {
@@ -52,6 +72,28 @@ private void requestLuke(String collection, SolrParams extra) throws Exception {
5272 req .process (cluster .getSolrClient (), collection );
5373 }
5474
75+ @ Test
76+ public void testDistributedShardError () {
77+ SolrParams lukeParams = params ("id" , "0" , "show" , "schema" );
78+
79+ Exception ex = expectThrows (Exception .class , () -> requestLuke (DISTRIB_COLLECTION , lukeParams ));
80+ String fullMessage = SolrException .getRootCause (ex ).getMessage ();
81+ assertTrue (
82+ "exception should mention doc style mismatch: " + fullMessage ,
83+ fullMessage .contains ("missing doc param for doc style" ));
84+ }
85+
86+ @ Test
87+ public void testDistributedDocIdRejected () {
88+ SolrParams lukeParams = params ("docId" , "0" );
89+
90+ Exception ex = expectThrows (Exception .class , () -> requestLuke (DISTRIB_COLLECTION , lukeParams ));
91+ String fullMessage = SolrException .getRootCause (ex ).getMessage ();
92+ assertTrue (
93+ "exception should mention docId not supported: " + fullMessage ,
94+ fullMessage .contains ("docId parameter is not supported in distributed mode" ));
95+ }
96+
5597 /**
5698 * Verifies that distributed Luke detects inconsistent index flags across shards. Uses Schema API
5799 * to change a field's {@code stored} property between indexing on different shards, producing
@@ -60,7 +102,6 @@ private void requestLuke(String collection, SolrParams extra) throws Exception {
60102 @ Test
61103 public void testInconsistentIndexFlagsAcrossShards () throws Exception {
62104 String collection = "lukeInconsistentFlags" ;
63- System .setProperty ("managed.schema.mutable" , "true" );
64105 CollectionAdminRequest .createCollection (collection , "managed" , 2 , 1 )
65106 .processAndWait (cluster .getSolrClient (), DEFAULT_TIMEOUT );
66107
0 commit comments