/*
 * Licensed to ElasticSearch and Shay Banon 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.mapping;

import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.action.count.CountResponse;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.test.AbstractIntegrationTest;
import org.junit.Test;

import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.hamcrest.Matchers.*;

/**
 *
 */
public class SimpleDeleteMappingTests extends AbstractIntegrationTest {

    @Test
    public void simpleDeleteMapping() throws Exception {
        for (int i = 0; i < 10; i++) {
            client().prepareIndex("test", "type1", Integer.toString(i)).setSource(jsonBuilder().startObject()
                    .field("value", "test" + i)
                    .endObject()).execute().actionGet();
        }

        ensureGreen();
        client().admin().indices().prepareRefresh().execute().actionGet();

        for (int i = 0; i < 10; i++) {
            CountResponse countResponse = client().prepareCount().setQuery(matchAllQuery()).execute().actionGet();
            assertThat(countResponse.getCount(), equalTo(10l));
        }

        ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState();
        assertThat(clusterState.metaData().index("test").mappings().containsKey("type1"), equalTo(true));
        GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings("test").setTypes("type1").execute().actionGet();
        assertThat(mappingsResponse.getMappings().get("test").get("type1"), notNullValue());

        client().admin().indices().prepareDeleteMapping().setType("type1").execute().actionGet();
        Thread.sleep(500); // for now, we don't have ack logic, so just wait

        for (int i = 0; i < 10; i++) {
            CountResponse countResponse = client().prepareCount().setQuery(matchAllQuery()).execute().actionGet();
            assertThat(countResponse.getCount(), equalTo(0l));
        }

        clusterState = client().admin().cluster().prepareState().execute().actionGet().getState();
        assertThat(clusterState.metaData().index("test").mappings().containsKey("type1"), equalTo(false));
        mappingsResponse = client().admin().indices().prepareGetMappings("test").setTypes("type1").execute().actionGet();
        assertThat(mappingsResponse.getMappings().get("test"), nullValue());
    }
}

@@ -2140,32 +2140,503 @@
 t().getState();%0A
+        if (!clusterState.metaData().index(%22test%22).mappings().containsKey(%22type1%22)) %7B%0A            logger.info(%22mapping of type %5B%7B%7D%5D is not in the clusterstate version: %5B%7B%7D%5D localNode: %5B%7B%7D%5D nodes: %5B%7B%7D%5D%22, %22type1%22, %0A                    clusterState.version(), clusterState.nodes().localNode(), clusterState.nodes().dataNodes().values());%0A            logger.info(%22Current mappings in clusterstate: %5B%7B%7D%5D%22, clusterState.metaData().index(%22test%22).mappings().keySet());%0A        %7D%0A
         assertTh

Add more debug info to SimpleDeleteMappingTests