Move index creation to test setup method
This commit is contained in:
parent
b8c2f05ff5
commit
91d1789258
|
@ -25,7 +25,6 @@ import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.Range.Bucket;
|
import org.elasticsearch.search.aggregations.bucket.range.Range.Bucket;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.ipv4.IPv4RangeBuilder;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.max.Max;
|
import org.elasticsearch.search.aggregations.metrics.max.Max;
|
||||||
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
|
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
|
||||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||||
|
@ -84,6 +83,33 @@ public class IPv4RangeTests extends ElasticsearchIntegrationTest {
|
||||||
}
|
}
|
||||||
indexRandom(true, builders.toArray(new IndexRequestBuilder[builders.size()]));
|
indexRandom(true, builders.toArray(new IndexRequestBuilder[builders.size()]));
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
assertAcked(prepareCreate("range_idx")
|
||||||
|
.addMapping("type", "ip", "type=ip", "ips", "type=ip"));
|
||||||
|
IndexRequestBuilder[] builders = new IndexRequestBuilder[4];
|
||||||
|
|
||||||
|
builders[0] = client().prepareIndex("range_idx", "type").setSource(jsonBuilder()
|
||||||
|
.startObject()
|
||||||
|
.field("ip", "0.0.0.0")
|
||||||
|
.endObject());
|
||||||
|
|
||||||
|
builders[1] = client().prepareIndex("range_idx", "type").setSource(jsonBuilder()
|
||||||
|
.startObject()
|
||||||
|
.field("ip", "0.0.0.255")
|
||||||
|
.endObject());
|
||||||
|
|
||||||
|
builders[2] = client().prepareIndex("range_idx", "type").setSource(jsonBuilder()
|
||||||
|
.startObject()
|
||||||
|
.field("ip", "255.255.255.0")
|
||||||
|
.endObject());
|
||||||
|
|
||||||
|
builders[3] = client().prepareIndex("range_idx", "type").setSource(jsonBuilder()
|
||||||
|
.startObject()
|
||||||
|
.field("ip", "255.255.255.255")
|
||||||
|
.endObject());
|
||||||
|
|
||||||
|
indexRandom(true, builders);
|
||||||
|
}
|
||||||
ensureSearchable();
|
ensureSearchable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,35 +923,9 @@ public class IPv4RangeTests extends ElasticsearchIntegrationTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mask0SpecialIps() throws Exception {
|
public void mask0SpecialIps() {
|
||||||
assertAcked(prepareCreate("idx_range")
|
|
||||||
.addMapping("type", "ip", "type=ip", "ips", "type=ip"));
|
|
||||||
IndexRequestBuilder[] builders = new IndexRequestBuilder[4];
|
|
||||||
|
|
||||||
builders[0] = client().prepareIndex("idx_range", "type").setSource(jsonBuilder()
|
SearchResponse response = client().prepareSearch("range_idx")
|
||||||
.startObject()
|
|
||||||
.field("ip", "0.0.0.0")
|
|
||||||
.endObject());
|
|
||||||
|
|
||||||
builders[1] = client().prepareIndex("idx_range", "type").setSource(jsonBuilder()
|
|
||||||
.startObject()
|
|
||||||
.field("ip", "0.0.0.255")
|
|
||||||
.endObject());
|
|
||||||
|
|
||||||
builders[2] = client().prepareIndex("idx_range", "type").setSource(jsonBuilder()
|
|
||||||
.startObject()
|
|
||||||
.field("ip", "255.255.255.0")
|
|
||||||
.endObject());
|
|
||||||
|
|
||||||
builders[3] = client().prepareIndex("idx_range", "type").setSource(jsonBuilder()
|
|
||||||
.startObject()
|
|
||||||
.field("ip", "255.255.255.255")
|
|
||||||
.endObject());
|
|
||||||
|
|
||||||
indexRandom(true, builders);
|
|
||||||
ensureSearchable();
|
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("idx_range")
|
|
||||||
.addAggregation(ipRange("range")
|
.addAggregation(ipRange("range")
|
||||||
.field("ip")
|
.field("ip")
|
||||||
.addMaskRange("0.0.0.0/0"))
|
.addMaskRange("0.0.0.0/0"))
|
||||||
|
|
Loading…
Reference in New Issue