Skip to content

Commit

Permalink
Enforce test scope for all the test with SuiteScopeTestCase
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <kalsac@amazon.com>
  • Loading branch information
Sachin Kale committed Sep 1, 2023
1 parent 10dc127 commit 4bdc7c1
Show file tree
Hide file tree
Showing 49 changed files with 175 additions and 136 deletions.
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.action.admin.indices.get;

import org.junit.Before;
import org.opensearch.action.admin.indices.alias.Alias;
import org.opensearch.action.admin.indices.get.GetIndexRequest.Feature;
import org.opensearch.action.support.IndicesOptions;
Expand All @@ -58,10 +59,10 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class GetIndexIT extends OpenSearchIntegTestCase {
@Override
protected void setupSuiteScopeCluster() throws Exception {
@Before
protected void setupTest() throws Exception {
assertAcked(prepareCreate("idx").addAlias(new Alias("alias_idx")).setSettings(Settings.builder().put("number_of_shards", 1)).get());
ensureSearchable("idx");
createIndex("empty_idx");
Expand Down
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.search.aggregations;

import org.junit.Before;
import org.opensearch.OpenSearchException;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchPhaseExecutionException;
Expand All @@ -53,7 +54,7 @@
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertSearchResponse;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class AggregationsIntegrationIT extends OpenSearchIntegTestCase {

static int numDocs;
Expand All @@ -63,8 +64,8 @@ public class AggregationsIntegrationIT extends OpenSearchIntegTestCase {
+ LARGE_STRING.length()
+ "] used in the request has exceeded the allowed maximum";

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
assertAcked(prepareCreate("index").setMapping("f", "type=keyword").get());
numDocs = randomIntBetween(1, 20);
List<IndexRequestBuilder> docs = new ArrayList<>();
Expand Down
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.search.aggregations;

import org.junit.Before;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.common.geo.GeoPoint;
import org.opensearch.search.aggregations.bucket.histogram.DateHistogramInterval;
Expand All @@ -55,16 +56,16 @@
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.closeTo;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class MissingValueIT extends OpenSearchIntegTestCase {

@Override
protected int maximumNumberOfShards() {
return 2;
}

@Override
protected void setupSuiteScopeCluster() throws Exception {
@Before
protected void setupTest() throws Exception {
assertAcked(prepareCreate("idx").setMapping("date", "type=date", "location", "type=geo_point", "str", "type=keyword").get());
indexRandom(
true,
Expand Down
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.OpenSearchException;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchPhaseExecutionException;
Expand Down Expand Up @@ -67,14 +68,14 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class AdjacencyMatrixIT extends OpenSearchIntegTestCase {

static int numDocs, numSingleTag1Docs, numSingleTag2Docs, numTag1Docs, numTag2Docs, numMultiTagDocs;
static final int MAX_NUM_FILTERS = 3;

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
createIndex("idx");
createIndex("idx2");
assertAcked(
Expand Down
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.search.aggregations.Aggregator.SubAggCollectionMode;
Expand All @@ -43,16 +44,16 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.IsNull.notNullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class BooleanTermsIT extends OpenSearchIntegTestCase {

private static final String SINGLE_VALUED_FIELD_NAME = "b_value";
private static final String MULTI_VALUED_FIELD_NAME = "b_values";

static int numSingleTrues, numSingleFalses, numMultiTrues, numMultiFalses;

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
createIndex("idx");
createIndex("idx_unmapped");
ensureSearchable();
Expand Down
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.OpenSearchException;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchPhaseExecutionException;
Expand Down Expand Up @@ -92,7 +93,7 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class DateHistogramIT extends OpenSearchIntegTestCase {

static Map<ZonedDateTime, Map<String, Object>> expectedMultiSortBuckets;
Expand Down Expand Up @@ -138,8 +139,8 @@ private IndexRequestBuilder indexDoc(int month, int day, int value) throws Excep
);
}

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
createIndex("idx", "idx_unmapped");
// TODO: would be nice to have more random data here
assertAcked(prepareCreate("empty_bucket_idx").setMapping("value", "type=integer"));
Expand Down
Expand Up @@ -59,8 +59,7 @@
* DateHistogramTests so the AssertingLocalTransport for these tests can be set to only use versions 1.4 onwards while keeping the other
* tests using all versions
*/
@OpenSearchIntegTestCase.SuiteScopeTestCase
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE)

public class DateHistogramOffsetIT extends OpenSearchIntegTestCase {

private static final String DATE_FORMAT = "yyyy-MM-dd:hh-mm-ss";
Expand Down
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.OpenSearchException;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchPhaseExecutionException;
Expand Down Expand Up @@ -75,7 +76,7 @@
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class DateRangeIT extends OpenSearchIntegTestCase {

private static IndexRequestBuilder indexDoc(int month, int day, int value) throws Exception {
Expand All @@ -102,8 +103,8 @@ private static ZonedDateTime date(int month, int day, ZoneId timezone) {

private static int numDocs;

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
createIndex("idx");
createIndex("idx_unmapped");

Expand Down
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.action.admin.indices.refresh.RefreshRequest;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.action.search.SearchType;
Expand Down Expand Up @@ -64,7 +65,7 @@
/**
* Tests the Sampler aggregation
*/
@OpenSearchIntegTestCase.SuiteScopeTestCase

public class DiversifiedSamplerIT extends OpenSearchIntegTestCase {

public static final int NUM_SHARDS = 2;
Expand All @@ -73,8 +74,8 @@ public String randomExecutionHint() {
return randomBoolean() ? null : randomFrom(SamplerAggregator.ExecutionMode.values()).toString();
}

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
assertAcked(
prepareCreate("test").setSettings(
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0)
Expand Down
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.OpenSearchException;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchResponse;
Expand Down Expand Up @@ -85,7 +86,7 @@
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.core.IsNull.notNullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class DoubleTermsIT extends AbstractTermsTestCase {

@Override
Expand Down Expand Up @@ -141,8 +142,8 @@ protected Map<String, Function<Map<String, Object>, Object>> nonDeterministicPlu
private static final String MULTI_VALUED_FIELD_NAME = "d_values";
private static HashMap<Double, Map<String, Object>> expectedMultiSortBuckets;

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
createIndex("idx");
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < NUM_DOCS; i++) {
Expand Down
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.OpenSearchException;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchResponse;
Expand Down Expand Up @@ -59,13 +60,13 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class FilterIT extends OpenSearchIntegTestCase {

static int numDocs, numTag1Docs;

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
createIndex("idx");
createIndex("idx2");
numDocs = randomIntBetween(5, 20);
Expand Down
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.OpenSearchException;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchResponse;
Expand Down Expand Up @@ -65,13 +66,13 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class FiltersIT extends OpenSearchIntegTestCase {

static int numDocs, numTag1Docs, numTag2Docs, numOtherDocs;

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
createIndex("idx");
createIndex("idx2");
numDocs = randomIntBetween(5, 20);
Expand Down
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.Version;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchPhaseExecutionException;
Expand Down Expand Up @@ -69,7 +70,7 @@
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class GeoDistanceIT extends OpenSearchIntegTestCase {

@Override
Expand All @@ -90,8 +91,8 @@ private IndexRequestBuilder indexCity(String idx, String name, String... latLons
return client().prepareIndex(idx).setSource(source);
}

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
prepareCreate("idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword").get();

Expand Down
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.OpenSearchException;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchResponse;
Expand All @@ -52,13 +53,13 @@
import static org.hamcrest.Matchers.sameInstance;
import static org.hamcrest.core.IsNull.notNullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class GlobalIT extends OpenSearchIntegTestCase {

static int numDocs;

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
createIndex("idx");
createIndex("idx2");
List<IndexRequestBuilder> builders = new ArrayList<>();
Expand Down
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.search.aggregations.bucket;

import org.junit.Before;
import org.opensearch.OpenSearchException;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchPhaseExecutionException;
Expand Down Expand Up @@ -84,7 +85,7 @@
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.core.IsNull.notNullValue;

@OpenSearchIntegTestCase.SuiteScopeTestCase

public class HistogramIT extends OpenSearchIntegTestCase {

private static final String SINGLE_VALUED_FIELD_NAME = "l_value";
Expand Down Expand Up @@ -135,8 +136,8 @@ protected Map<String, Function<Map<String, Object>, Object>> nonDeterministicPlu
}
}

@Override
public void setupSuiteScopeCluster() throws Exception {
@Before
public void setupTest() throws Exception {
createIndex("idx");
createIndex("idx_unmapped");

Expand Down

0 comments on commit 4bdc7c1

Please sign in to comment.