4141import org .elasticsearch .index .shard .IndexShard ;
4242import org .elasticsearch .index .store .Store ;
4343import org .elasticsearch .indices .IndicesService ;
44+ import org .elasticsearch .indices .SystemIndexDescriptor ;
4445import org .elasticsearch .plugins .ActionPlugin ;
4546import org .elasticsearch .plugins .Plugin ;
47+ import org .elasticsearch .plugins .SystemIndexPlugin ;
4648import org .elasticsearch .test .ESIntegTestCase ;
4749import org .elasticsearch .test .InternalTestCluster ;
4850import org .elasticsearch .test .transport .MockTransportService ;
5153
5254import java .util .Arrays ;
5355import java .util .Collection ;
56+ import java .util .Collections ;
5457import java .util .List ;
58+ import java .util .Locale ;
5559import java .util .Set ;
5660import java .util .concurrent .atomic .AtomicBoolean ;
5761
7074@ ESIntegTestCase .ClusterScope (scope = ESIntegTestCase .Scope .TEST , numDataNodes = 0 )
7175public class ClusterInfoServiceIT extends ESIntegTestCase {
7276
73- public static class TestPlugin extends Plugin implements ActionPlugin {
77+ private static final String TEST_SYSTEM_INDEX_NAME = ".test-cluster-info-system-index" ;
78+
79+ public static class TestPlugin extends Plugin implements ActionPlugin , SystemIndexPlugin {
7480
7581 private final BlockingActionFilter blockingActionFilter ;
7682
@@ -82,6 +88,12 @@ public TestPlugin() {
8288 public List <ActionFilter > getActionFilters () {
8389 return singletonList (blockingActionFilter );
8490 }
91+
92+ @ Override
93+ public Collection <SystemIndexDescriptor > getSystemIndexDescriptors (Settings settings ) {
94+ return Collections .singletonList (new SystemIndexDescriptor (TEST_SYSTEM_INDEX_NAME ,
95+ "System index for [" + getTestClass ().getName () + ']' ));
96+ }
8597 }
8698
8799 public static class BlockingActionFilter extends org .elasticsearch .action .support .ActionFilter .Simple {
@@ -117,13 +129,18 @@ private void setClusterInfoTimeout(String timeValue) {
117129
118130 public void testClusterInfoServiceCollectsInformation () {
119131 internalCluster ().startNodes (2 );
120- assertAcked (prepareCreate ("test" ).setSettings (Settings .builder ()
121- .put (Store .INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING .getKey (), 0 )
122- .put (EnableAllocationDecider .INDEX_ROUTING_REBALANCE_ENABLE_SETTING .getKey (), EnableAllocationDecider .Rebalance .NONE ).build ()));
132+
133+ final String indexName = randomBoolean () ? randomAlphaOfLength (5 ).toLowerCase (Locale .ROOT ) : TEST_SYSTEM_INDEX_NAME ;
134+ assertAcked (prepareCreate (indexName )
135+ .setSettings (Settings .builder ()
136+ .put (Store .INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING .getKey (), 0 )
137+ .put (EnableAllocationDecider .INDEX_ROUTING_REBALANCE_ENABLE_SETTING .getKey (), EnableAllocationDecider .Rebalance .NONE )
138+ .put (IndexMetadata .SETTING_INDEX_HIDDEN , randomBoolean ())
139+ .build ()));
123140 if (randomBoolean ()) {
124- assertAcked (client ().admin ().indices ().prepareClose ("test" ));
141+ assertAcked (client ().admin ().indices ().prepareClose (indexName ));
125142 }
126- ensureGreen ("test" );
143+ ensureGreen (indexName );
127144 InternalTestCluster internalTestCluster = internalCluster ();
128145 // Get the cluster info service on the master node
129146 final InternalClusterInfoService infoService = (InternalClusterInfoService ) internalTestCluster
0 commit comments