create 'shape' index explicitly to ensure tests don't hang
This commit is contained in:
parent
deda7a37fc
commit
8363fcf281
|
@ -33,36 +33,27 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.common.Priority;
|
|
||||||
import org.elasticsearch.common.geo.GeoJSONShapeSerializer;
|
import org.elasticsearch.common.geo.GeoJSONShapeSerializer;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.elasticsearch.test.integration.AbstractSharedClusterTest;
|
import org.elasticsearch.test.integration.AbstractSharedClusterTest;
|
||||||
import org.testng.annotations.BeforeTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.spatial4j.core.shape.Shape;
|
import com.spatial4j.core.shape.Shape;
|
||||||
|
|
||||||
public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||||
|
|
||||||
@BeforeTest
|
|
||||||
public void createNodes() throws Exception {
|
|
||||||
cluster().ensureAtLeastNumNodes(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIndexPointsFilterRectangle() throws Exception {
|
public void testIndexPointsFilterRectangle() throws Exception {
|
||||||
client().admin().indices().prepareDelete().execute().actionGet();
|
|
||||||
|
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||||
.startObject("properties").startObject("location")
|
.startObject("properties").startObject("location")
|
||||||
.field("type", "geo_shape")
|
.field("type", "geo_shape")
|
||||||
.field("tree", "quadtree")
|
.field("tree", "quadtree")
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject().string();
|
.endObject().endObject().string();
|
||||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
||||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
ensureGreen();
|
||||||
|
|
||||||
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
||||||
.field("name", "Document 1")
|
.field("name", "Document 1")
|
||||||
|
@ -80,8 +71,7 @@ public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()).execute().actionGet();
|
.endObject()).execute().actionGet();
|
||||||
|
|
||||||
client().admin().indices().prepareRefresh().execute().actionGet();
|
refresh();
|
||||||
|
|
||||||
Shape shape = newRectangle().topLeft(-45, 45).bottomRight(45, -45).build();
|
Shape shape = newRectangle().topLeft(-45, 45).bottomRight(45, -45).build();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = client().prepareSearch()
|
||||||
|
@ -104,7 +94,6 @@ public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEdgeCases() throws Exception {
|
public void testEdgeCases() throws Exception {
|
||||||
client().admin().indices().prepareDelete().execute().actionGet();
|
|
||||||
|
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||||
.startObject("properties").startObject("location")
|
.startObject("properties").startObject("location")
|
||||||
|
@ -112,8 +101,8 @@ public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||||
.field("tree", "quadtree")
|
.field("tree", "quadtree")
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject().string();
|
.endObject().endObject().string();
|
||||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
||||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
ensureGreen();
|
||||||
|
|
||||||
client().prepareIndex("test", "type1", "blakely").setSource(jsonBuilder().startObject()
|
client().prepareIndex("test", "type1", "blakely").setSource(jsonBuilder().startObject()
|
||||||
.field("name", "Blakely Island")
|
.field("name", "Blakely Island")
|
||||||
|
@ -146,16 +135,14 @@ public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIndexedShapeReference() throws Exception {
|
public void testIndexedShapeReference() throws Exception {
|
||||||
client().admin().indices().prepareDelete().execute().actionGet();
|
|
||||||
|
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||||
.startObject("properties").startObject("location")
|
.startObject("properties").startObject("location")
|
||||||
.field("type", "geo_shape")
|
.field("type", "geo_shape")
|
||||||
.field("tree", "quadtree")
|
.field("tree", "quadtree")
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject().string();
|
.endObject().endObject().string();
|
||||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
||||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
ensureGreen();
|
||||||
|
|
||||||
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
||||||
.field("name", "Document 1")
|
.field("name", "Document 1")
|
||||||
|
@ -165,18 +152,17 @@ public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()).execute().actionGet();
|
.endObject()).execute().actionGet();
|
||||||
|
|
||||||
client().admin().indices().prepareRefresh("test").execute().actionGet();
|
refresh();
|
||||||
|
|
||||||
Shape shape = newRectangle().topLeft(-45, 45).bottomRight(45, -45).build();
|
Shape shape = newRectangle().topLeft(-45, 45).bottomRight(45, -45).build();
|
||||||
XContentBuilder shapeContent = jsonBuilder().startObject()
|
XContentBuilder shapeContent = jsonBuilder().startObject()
|
||||||
.startObject("shape");
|
.startObject("shape");
|
||||||
GeoJSONShapeSerializer.serialize(shape, shapeContent);
|
GeoJSONShapeSerializer.serialize(shape, shapeContent);
|
||||||
shapeContent.endObject();
|
shapeContent.endObject();
|
||||||
|
createIndex("shapes");
|
||||||
|
ensureGreen();
|
||||||
client().prepareIndex("shapes", "shape_type", "Big_Rectangle").setSource(shapeContent).execute().actionGet();
|
client().prepareIndex("shapes", "shape_type", "Big_Rectangle").setSource(shapeContent).execute().actionGet();
|
||||||
client().admin().indices().prepareRefresh().execute().actionGet();
|
refresh();
|
||||||
|
|
||||||
client().admin().indices().prepareRefresh("shapes").execute().actionGet();
|
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("test")
|
SearchResponse searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(),
|
.setQuery(filteredQuery(matchAllQuery(),
|
||||||
|
@ -198,8 +184,6 @@ public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||||
|
|
||||||
@Test // Issue 2944
|
@Test // Issue 2944
|
||||||
public void testThatShapeIsReturnedEvenWhenExclusionsAreSet() throws Exception {
|
public void testThatShapeIsReturnedEvenWhenExclusionsAreSet() throws Exception {
|
||||||
client().admin().indices().prepareDelete().execute().actionGet();
|
|
||||||
|
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||||
.startObject("properties").startObject("location")
|
.startObject("properties").startObject("location")
|
||||||
.field("type", "geo_shape")
|
.field("type", "geo_shape")
|
||||||
|
@ -209,9 +193,8 @@ public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.string();
|
.string();
|
||||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
||||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
ensureGreen();
|
||||||
|
|
||||||
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
||||||
.field("name", "Document 1")
|
.field("name", "Document 1")
|
||||||
.startObject("location")
|
.startObject("location")
|
||||||
|
|
Loading…
Reference in New Issue