/*
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch licenses this file to you under
 * the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.elasticsearch.indices;

import org.elasticsearch.action.admin.indices.seal.SealIndicesResponse;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;

import static org.hamcrest.Matchers.equalTo;

@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE, numDataNodes = 1)
public class SealTests extends ElasticsearchIntegrationTest {

    @Test
    public void testUnallocatedShardsDoesNotHang() throws InterruptedException {
        // create an index but because no data nodes are available no shards will be allocated
        createIndex("test");
        // this should not hang but instead immediately return with empty result set
        SealIndicesResponse sealIndicesResponse = client().admin().indices().prepareSealIndices("test").get();
        assertThat(sealIndicesResponse.results().size(), equalTo(0));
    }
}

@@ -890,16 +890,76 @@
 sponse;%0A
+import org.elasticsearch.common.settings.ImmutableSettings;%0A
 import o
@@ -1034,16 +1034,54 @@
 .Test;%0A%0A
+import static java.lang.Thread.sleep;%0A
 import s
@@ -1208,13 +1208,12 @@
 ope.
-SUI
 TE
+ST
 , nu
@@ -1229,9 +1229,9 @@
 s = 
-1
+0
 )%0Apu
@@ -1382,16 +1382,304 @@
 ption %7B%0A
+        ImmutableSettings.Builder settingsBuilder = ImmutableSettings.builder()%0A                .put(%22node.data%22, false)%0A                .put(%22node.master%22, true)%0A                .put(%22path.data%22, createTempDir().toString());%0A        internalCluster().startNode(settingsBuilder.build());%0A
         
@@ -1680,16 +1680,17 @@
       //
+ 
  create 
@@ -1991,16 +1991,85 @@
 .get();%0A
+        // just to make sure the test actually tests the right thing%0A
         

fix test