title: Elasticsearch 2.2.0 ESIntegTestCase: ensureYellow() results in “timed out waiting for yellow”
body: <p>I am in the process of rewriting our integration tests to work with Elasticsearch 2.2.0.
  I have an abstract test case class which extends <code>org.elasticsearch.test.ESIntegTestCase</code>:</p>
  
  <pre><code>@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
  @ThreadLeakScope(ThreadLeakScope.Scope.NONE)
  public abstract class AbstractApplicationTest extends ESIntegTestCase {
     ...
  
      @Override
      protected Settings nodeSettings(int nodeOrdinal) {
          return Settings.settingsBuilder()
                  .put(super.nodeSettings(nodeOrdinal))
                  .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
                  .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
                  .put(Node.HTTP_ENABLED, true)
                  .put("script.groovy.sandbox.enabled", true)
                  .put("script.engine.groovy.inline.search", true)
                  .put("script.engine.groovy.inline.update", "true")
                  .put("script.inline", true)
                  .put("script.update", true)
                  .put("script.indexed", true)
                  .put("script.default_lang", "groovy")
                  .build();
      }
  
      @Override
      protected Collection&lt;Class&lt;? extends Plugin&gt;&gt; nodePlugins() {
          return pluginList(GroovyPlugin.class, DeleteByQueryPlugin.class, AnalysisICUPlugin.class);
      }
  
      @Before
      public void setUpElastic() throws Exception {
          // add the index and the mappings
          prepareCreate("bokun")
                  .setSettings(Settings.builder().loadFromSource(loadFromClasspath("indices/settings.json")))
                  .addMapping(AccommodationSearchIndex.INDEX_ACCOMMODATION_TYPE, loadFromClasspath("indices/accommodation.json"))
                  .addMapping(AccommodationSearchIndex.INDEX_ROOM_TYPE, loadFromClasspath("indices/room.json"))
                  ...
                  .execute().actionGet();
          ensureYellow();
      }
      ...
  }
  </code></pre>
  
  <p>My test case class extends this abstract class. It has 6 tests, and constantly 3-4 of them fail with the "timed out waiting for yellow" message during the call <code>ensureYellow()</code> above.</p>
  
  <p>If I comment out the <code>ensureYellow()</code> call, then I am getting "unavailable_shards_exception" from Elasticsearch when executing index requests:</p>
  
  <pre><code>{
      "took": 60001,
      "errors": true,
      "items": [{
          "index": {
              "_index": "bokun",
              "_type": "activity_availability",
              "_id": "20_20160309",
              "status": 503,
              "error": {
                  "type": "unavailable_shards_exception",
                  "reason": "[bokun][2] primary shard is not active Timeout: [1m], request: [shard bulk {[bokun][2]}]"
              }
          }
      }, {
          "index": {
              "_index": "bokun",
              "_type": "activity_availability",
              "_id": "20_20160310",
              "status": 503,
              "error": {
                  "type": "unavailable_shards_exception",
                  "reason": "[bokun][1] primary shard is not active Timeout: [1m], request: [shard bulk {[bokun][1]}]"
              }
          }
      }, 
      ...
      {
          "index": {
              "_index": "bokun",
              "_type": "activity_availability",
              "_id": "20_20160322",
              "status": 503,
              "error": {
                  "type": "unavailable_shards_exception",
                  "reason": "[bokun][0] primary shard is not active Timeout: [1m], request: [shard bulk {[bokun][0]}]"
              }
          }
      }, {
          "index": {
              "_index": "bokun",
              "_type": "activity",
              "_id": "12",
              "status": 503,
              "error": {
                  "type": "unavailable_shards_exception",
                  "reason": "[bokun][2] primary shard is not active Timeout: [1m], request: [shard bulk {[bokun][2]}]"
              }
          }
      }]
  }
  </code></pre>
  
  <p>The test case scope is <code>ESIntegTestCase.Scope.SUITE</code>, which means that a cluster will be created for each SUITE rather than test, and then I am creating the index and adding mappings before each test. I assume that after each test the index is deleted, as this <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/integration-tests.html1" rel="nofollow">page</a> states: </p>
  
  <blockquote>
    <p>By default the tests are run with unique cluster per test suite. Of
    course all indices and templates are deleted between each test.</p>
  </blockquote>
  
  <p>Does anyone know what I am doing wrong here?</p>
  
  <p>P.S. I am using SBT to run my tests.</p>