diff --git a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporter.java b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporter.java index 21b084e957298..5f53dbb6e39db 100644 --- a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporter.java +++ b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporter.java @@ -20,11 +20,9 @@ * @opensearch.internal */ public abstract class QueryInsightsExporter> { - private QueryInsightsExporterType type; - private String identifier; + private final String identifier; - QueryInsightsExporter(QueryInsightsExporterType type, String identifier) { - this.type = type; + QueryInsightsExporter(String identifier) { this.identifier = identifier; } @@ -35,18 +33,10 @@ public abstract class QueryInsightsExporter> { */ public abstract void export(List records) throws Exception; - public void setType(QueryInsightsExporterType type) { - this.type = type; - } - - public QueryInsightsExporterType getType() { - return type; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - + /** + * Get the identifier of this exporter + * @return identifier of this exporter + */ public String getIdentifier() { return identifier; } diff --git a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporterType.java b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporterType.java index 92466411ac47c..7c2a9b86fb642 100644 --- a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporterType.java +++ b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporterType.java @@ -16,15 +16,19 @@ * @opensearch.internal */ public enum QueryInsightsExporterType { - /* local index exporter */ - LOCAL_INDEX("local_index"); + /** local index exporter */ + LOCAL_INDEX; - private final String type; - - QueryInsightsExporterType(String type) { - this.type = type; + @Override + public String toString() { + return super.toString().toLowerCase(Locale.ROOT); } + /** + * Parse QueryInsightsExporterType from String + * @param type the String representation of the QueryInsightsExporterType + * @return QueryInsightsExporterType + */ public static QueryInsightsExporterType parse(String type) { return valueOf(type.toUpperCase(Locale.ROOT)); } diff --git a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsLocalIndexExporter.java b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsLocalIndexExporter.java index b9cbfb80c325c..d6317971f1d52 100644 --- a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsLocalIndexExporter.java +++ b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsLocalIndexExporter.java @@ -51,13 +51,20 @@ public class QueryInsightsLocalIndexExporter> ext /** The mapping for the local index that holds the data */ private final InputStream localIndexMapping; + /** + * Create a QueryInsightsLocalIndexExporter Object + * @param clusterService The clusterService of the node + * @param client The OpenSearch Client to support index operations + * @param localIndexName The local index name to export the data to + * @param localIndexMapping The mapping for the local index + */ public QueryInsightsLocalIndexExporter( ClusterService clusterService, Client client, String localIndexName, InputStream localIndexMapping ) { - super(QueryInsightsExporterType.LOCAL_INDEX, localIndexName); + super(localIndexName); this.clusterService = clusterService; this.client = client; this.localIndexMapping = localIndexMapping; @@ -70,42 +77,35 @@ public QueryInsightsLocalIndexExporter( * @throws IOException if an error occurs */ @Override - public synchronized void export(List records) throws IOException { + public void export(List records) throws IOException { if (records.size() == 0) { return; } - if (checkIfIndexExists()) { - bulkRecord(records); - } else { - // local index not exist - initLocalIndex(new ActionListener<>() { - @Override - public void onResponse(CreateIndexResponse response) { - if (response.isAcknowledged()) { - log.debug( - String.format(Locale.ROOT, "successfully initialized local index %s for query insight.", getIdentifier()) - ); - try { - bulkRecord(records); - } catch (IOException e) { - log.error(String.format(Locale.ROOT, "fail to ingest query insight data to local index, error: %s", e)); - } - } else { - log.error( - String.format( - Locale.ROOT, - "request to created local index %s for query insight not acknowledged.", - getIdentifier() - ) - ); + boolean indexExists = checkAndInitLocalIndex(new ActionListener<>() { + @Override + public void onResponse(CreateIndexResponse response) { + if (response.isAcknowledged()) { + log.debug(String.format(Locale.ROOT, "successfully initialized local index %s for query insight.", getIdentifier())); + try { + bulkRecord(records); + } catch (IOException e) { + log.error(String.format(Locale.ROOT, "fail to ingest query insight data to local index, error: %s", e)); } + } else { + log.error( + String.format(Locale.ROOT, "request to created local index %s for query insight not acknowledged.", getIdentifier()) + ); } + } - @Override - public void onFailure(Exception e) { - log.error(String.format(Locale.ROOT, "error creating local index for query insight: %s", e)); - } - }); + @Override + public void onFailure(Exception e) { + log.error(String.format(Locale.ROOT, "error creating local index for query insight: %s", e)); + } + }); + + if (indexExists) { + bulkRecord(records); } } @@ -120,15 +120,21 @@ private boolean checkIfIndexExists() { } /** - * Initialize the local OpenSearch Index for the exporter + * Check and initialize the local OpenSearch Index for the exporter * * @param listener the listener to be notified upon completion + * @return boolean to represent if the index has already been created before calling this function * @throws IOException if an error occurs */ - private synchronized void initLocalIndex(ActionListener listener) throws IOException { - CreateIndexRequest createIndexRequest = new CreateIndexRequest(this.getIdentifier()).mapping(getIndexMappings()) - .settings(Settings.builder().put("index.hidden", false).build()); - client.admin().indices().create(createIndexRequest, listener); + private synchronized boolean checkAndInitLocalIndex(ActionListener listener) throws IOException { + if (!checkIfIndexExists()) { + CreateIndexRequest createIndexRequest = new CreateIndexRequest(this.getIdentifier()).mapping(getIndexMappings()) + .settings(Settings.builder().put("index.hidden", false).build()); + client.admin().indices().create(createIndexRequest, listener); + return false; + } else { + return true; + } } /** diff --git a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/service/QueryInsightsService.java b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/service/QueryInsightsService.java index 64e45e4327eee..bf97707c7f3bd 100644 --- a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/service/QueryInsightsService.java +++ b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/core/service/QueryInsightsService.java @@ -46,7 +46,7 @@ public abstract class QueryInsightsService, S ext /** enable insight data export */ private boolean enableExport; - /** The internal store that holds the query insight data */ + /** The internal thread-safe store that holds the query insight data */ @Nullable protected S store; @@ -59,8 +59,19 @@ public abstract class QueryInsightsService, S ext /** The internal OpenSearch thread pool that execute async processing and exporting tasks*/ protected final ThreadPool threadPool; + + /** + * Holds a reference to delayed operation {@link Scheduler.Cancellable} so it can be cancelled when + * the service closed concurrently. + */ protected volatile Scheduler.Cancellable scheduledFuture; + /** + * Create the Query Insights Service object + * @param threadPool The OpenSearch thread pool to run async tasks + * @param store The in memory store to keep the Query Insights data + * @param exporter The optional {@link QueryInsightsExporter} to export the Query Insights data + */ @Inject public QueryInsightsService(ThreadPool threadPool, @Nullable S store, @Nullable E exporter) { this.threadPool = threadPool; @@ -102,7 +113,13 @@ public List getQueryData() throws IllegalArgumentException { public abstract void clearOutdatedData(); /** - * Restart the exporter with new config + * Reset the exporter with new config + * + * This function can be used to enable/disable an exporter, change the type of the exporter, + * or change the identifier of the exporter. + * @param enabled the enable flag to set on the exporter + * @param type The QueryInsightsExporterType to set on the exporter + * @param identifier the Identifier to set on the exporter */ public abstract void resetExporter(boolean enabled, QueryInsightsExporterType type, String identifier); @@ -113,18 +130,34 @@ public void clearAllData() { store.clear(); } + /** + * Set flag to enable or disable Query Insights data collection + * @param enableCollect Flag to enable or disable Query Insights data collection + */ public void setEnableCollect(boolean enableCollect) { this.enableCollect = enableCollect; } + /** + * Get if the Query Insights data collection is enabled + * @return if the Query Insights data collection is enabled + */ public boolean getEnableCollect() { return this.enableCollect; } + /** + * Set flag to enable or disable Query Insights data export + * @param enableExport + */ public void setEnableExport(boolean enableExport) { this.enableExport = enableExport; } + /** + * Get if the Query Insights data export is enabled + * @return if the Query Insights data export is enabled + */ public boolean getEnableExport() { return this.enableExport; } @@ -156,7 +189,6 @@ private void doExport() { List storedData = getQueryData(); try { exporter.export(storedData); - log.debug(String.format(Locale.ROOT, "finish exporting query insight data to sink %s", storedData)); } catch (Exception e) { throw new RuntimeException(String.format(Locale.ROOT, "failed to export query insight data to sink, error: %s", e)); } @@ -165,6 +197,10 @@ private void doExport() { @Override protected void doClose() {} + /** + * Get the export interval set for the {@link QueryInsightsExporter} + * @return export interval + */ public TimeValue getExportInterval() { return exportInterval; } diff --git a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/rules/model/SearchQueryLatencyRecord.java b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/rules/model/SearchQueryLatencyRecord.java index 6e978489b9f15..97b423e092673 100644 --- a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/rules/model/SearchQueryLatencyRecord.java +++ b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/rules/model/SearchQueryLatencyRecord.java @@ -29,12 +29,36 @@ public final class SearchQueryLatencyRecord extends SearchQueryRecord { // latency info for each search phase private final Map phaseLatencyMap; + /** + * Constructor for SearchQueryLatencyRecord + * + * @param in A {@link StreamInput} object. + * @throws IOException if the stream cannot be deserialized. + */ public SearchQueryLatencyRecord(final StreamInput in) throws IOException { super(in); this.phaseLatencyMap = in.readMap(StreamInput::readString, StreamInput::readLong); this.setValue(in.readLong()); } + @Override + protected void addCustomXContent(XContentBuilder builder, Params params) throws IOException { + builder.field(PHASE_LATENCY_MAP, this.getPhaseLatencyMap()); + builder.field(TOOK, this.getValue()); + } + + /** + * Constructor of the SearchQueryLatencyRecord + * + * @param timestamp The timestamp of the query. + * @param searchType The manner at which the search operation is executed. see {@link SearchType} + * @param source The search source that was executed by the query. + * @param totalShards Total number of shards as part of the search query across all indices + * @param indices The indices involved in the search query + * @param propertyMap Extra attributes and information about a search query + * @param phaseLatencyMap A map contains per-phase latency data + * @param tookInNanos Total time took to finish this request + */ public SearchQueryLatencyRecord( final Long timestamp, final SearchType searchType, @@ -49,19 +73,15 @@ public SearchQueryLatencyRecord( this.phaseLatencyMap = phaseLatencyMap; } + /** + * Get the phase level latency map of this request record + * + * @return Map contains per-phase latency of this request record + */ public Map getPhaseLatencyMap() { return phaseLatencyMap; } - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(); - super.toXContent(builder, params); - builder.field(PHASE_LATENCY_MAP, this.getPhaseLatencyMap()); - builder.field(TOOK, this.getValue()); - return builder.endObject(); - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); @@ -69,6 +89,11 @@ public void writeTo(StreamOutput out) throws IOException { out.writeLong(getValue()); } + /** + * Compare if two SearchQueryLatencyRecord are equal + * @param other The Other SearchQueryLatencyRecord to compare to + * @return boolean + */ public boolean equals(SearchQueryLatencyRecord other) { if (!super.equals(other)) { return false; diff --git a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/rules/model/SearchQueryRecord.java b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/rules/model/SearchQueryRecord.java index bb6b2ae23e01e..f086a9e38c4cd 100644 --- a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/rules/model/SearchQueryRecord.java +++ b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/rules/model/SearchQueryRecord.java @@ -34,13 +34,13 @@ public abstract class SearchQueryRecord> ToXContentObject { private static final Logger log = LogManager.getLogger(SearchQueryRecord.class); - protected static final String TIMESTAMP = "timestamp"; - protected static final String SEARCH_TYPE = "searchType"; - protected static final String SOURCE = "source"; - protected static final String TOTAL_SHARDS = "totalShards"; - protected static final String INDICES = "indices"; - protected static final String PROPERTY_MAP = "propertyMap"; - protected static final String VALUE = "value"; + private static final String TIMESTAMP = "timestamp"; + private static final String SEARCH_TYPE = "searchType"; + private static final String SOURCE = "source"; + private static final String TOTAL_SHARDS = "totalShards"; + private static final String INDICES = "indices"; + private static final String PROPERTY_MAP = "propertyMap"; + private static final String VALUE = "value"; private final Long timestamp; @@ -57,6 +57,13 @@ public abstract class SearchQueryRecord> private T value; + /** + * Constructor of the SearchQueryRecord + * + * @param in A {@link StreamInput} object. + * @throws IOException if the stream cannot be deserialized. + * @throws ClassCastException ClassCastException + */ public SearchQueryRecord(final StreamInput in) throws IOException, ClassCastException { this.timestamp = in.readLong(); this.searchType = SearchType.fromString(in.readString().toLowerCase(Locale.ROOT)); @@ -66,6 +73,17 @@ public SearchQueryRecord(final StreamInput in) throws IOException, ClassCastExce this.propertyMap = in.readMap(); } + /** + * Constructor of the SearchQueryRecord + * + * @param timestamp The timestamp of the query. + * @param searchType The manner at which the search operation is executed. see {@link SearchType} + * @param source The search source that was executed by the query. + * @param totalShards Total number of shards as part of the search query across all indices + * @param indices The indices involved in the search query + * @param propertyMap Extra attributes and information about a search query + * @param value The value on this SearchQueryRecord + */ public SearchQueryRecord( final Long timestamp, final SearchType searchType, @@ -79,6 +97,16 @@ public SearchQueryRecord( this.value = value; } + /** + * Constructor of the SearchQueryRecord + * + * @param timestamp The timestamp of the query. + * @param searchType The manner at which the search operation is executed. see {@link SearchType} + * @param source The search source that was executed by the query. + * @param totalShards Total number of shards as part of the search query across all indices + * @param indices The indices involved in the search query + * @param propertyMap Extra attributes and information about a search query + */ public SearchQueryRecord( final Long timestamp, final SearchType searchType, @@ -139,6 +167,7 @@ public T getValue() { /** * Set the value of the query metric record + * @param value The value to set on the record */ public void setValue(T value) { this.value = value; @@ -156,14 +185,19 @@ public int compareTo(SearchQueryRecord otherRecord) { return value.compareTo(otherRecord.getValue()); } + /** + * Compare if two SearchQueryRecord are equal + * @param other The Other SearchQueryRecord to compare to + * @return boolean + */ public boolean equals(SearchQueryRecord other) { - if (false == this.timestamp.equals(other.getTimestamp()) - && this.searchType.equals(other.getSearchType()) - && this.source.equals(other.getSource()) - && this.totalShards == other.getTotalShards() - && this.indices.length == other.getIndices().length - && this.propertyMap.size() == other.getPropertyMap().size() - && this.value.equals(other.getValue())) { + if (!this.timestamp.equals(other.getTimestamp()) + || !this.searchType.equals(other.getSearchType()) + || !this.source.equals(other.getSource()) + || this.totalShards != other.getTotalShards() + || this.indices.length != other.getIndices().length + || this.propertyMap.size() != other.getPropertyMap().size() + || !this.value.equals(other.getValue())) { return false; } for (int i = 0; i < indices.length; i++) { @@ -192,15 +226,25 @@ private T castToValue(Object obj) throws ClassCastException { } } + /** + * Add custom XContent fields to the record + * @param builder XContent builder + * @param params XContent parameters + * @throws IOException IOException + */ + protected abstract void addCustomXContent(XContentBuilder builder, Params params) throws IOException; + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startObject(); builder.field(TIMESTAMP, timestamp); builder.field(SEARCH_TYPE, searchType); builder.field(SOURCE, source); builder.field(TOTAL_SHARDS, totalShards); builder.field(INDICES, indices); builder.field(PROPERTY_MAP, propertyMap); - return builder; + addCustomXContent(builder, params); + return builder.endObject(); } @Override diff --git a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/settings/QueryInsightsSettings.java b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/settings/QueryInsightsSettings.java index a741daff76516..818959bf7f12a 100644 --- a/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/settings/QueryInsightsSettings.java +++ b/plugins/query-insights/src/main/java/org/opensearch/plugin/insights/settings/QueryInsightsSettings.java @@ -26,8 +26,11 @@ public class QueryInsightsSettings { * Default Values and Settings */ public static final TimeValue MAX_WINDOW_SIZE = new TimeValue(21600, TimeUnit.SECONDS); + /** Default N size for top N queries */ public static final int MAX_N_SIZE = 100; - public static final TimeValue MIN_EXPORT_INTERVAL = new TimeValue(21600, TimeUnit.SECONDS); + /** Default min export interval for Query Insights exporters */ + public static final TimeValue MIN_EXPORT_INTERVAL = new TimeValue(1, TimeUnit.SECONDS); + /** Default local index mapping for top n queries records */ public static final String DEFAULT_LOCAL_INDEX_MAPPING = "mappings/top_n_queries_record.json"; /** Default window size in seconds to keep the top N queries with latency data in query insight store */ public static final int DEFAULT_WINDOW_SIZE = 60; @@ -43,8 +46,9 @@ public class QueryInsightsSettings { * */ public static final String TOP_QUERIES_BASE_URI = PLUGINS_BASE_URI + "/top_queries"; + /** Default prefix for top N queries feature */ public static final String TOP_N_QUERIES_SETTING_PREFIX = "search.top_n_queries"; - + /** Default prefix for top N queries by latency feature */ public static final String TOP_N_LATENCY_QUERIES_PREFIX = TOP_N_QUERIES_SETTING_PREFIX + ".latency"; /** * Boolean setting for enabling top queries by latency. diff --git a/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/QueryInsightsPluginTests.java b/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/QueryInsightsPluginTests.java index 45255b055984f..93031f0a865dd 100644 --- a/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/QueryInsightsPluginTests.java +++ b/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/QueryInsightsPluginTests.java @@ -8,12 +8,78 @@ package org.opensearch.plugin.insights; +import org.opensearch.action.ActionRequest; +import org.opensearch.client.Client; +import org.opensearch.cluster.service.ClusterService; +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Settings; +import org.opensearch.core.action.ActionResponse; +import org.opensearch.plugin.insights.settings.QueryInsightsSettings; +import org.opensearch.plugins.ActionPlugin; +import org.opensearch.rest.RestHandler; import org.opensearch.test.OpenSearchTestCase; -import org.junit.Assert; +import org.opensearch.threadpool.ThreadPool; +import org.junit.Before; + +import java.util.List; + +import static org.mockito.Mockito.mock; public class QueryInsightsPluginTests extends OpenSearchTestCase { - public void testDummy() { - Assert.assertEquals(1, 1); + private QueryInsightsPlugin queryInsightsPlugin; + + private final Client client = mock(Client.class); + private ClusterService clusterService; + private final ThreadPool threadPool = mock(ThreadPool.class); + + @Before + public void setup() { + queryInsightsPlugin = new QueryInsightsPlugin(); + Settings.Builder settingsBuilder = Settings.builder(); + Settings settings = settingsBuilder.build(); + ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + clusterSettings.registerSetting(QueryInsightsSettings.TOP_N_LATENCY_QUERIES_ENABLED); + clusterSettings.registerSetting(QueryInsightsSettings.TOP_N_LATENCY_QUERIES_SIZE); + clusterSettings.registerSetting(QueryInsightsSettings.TOP_N_LATENCY_QUERIES_WINDOW_SIZE); + clusterSettings.registerSetting(QueryInsightsSettings.TOP_N_LATENCY_QUERIES_EXPORTER_ENABLED); + clusterSettings.registerSetting(QueryInsightsSettings.TOP_N_LATENCY_QUERIES_EXPORTER_TYPE); + clusterSettings.registerSetting(QueryInsightsSettings.TOP_N_LATENCY_QUERIES_EXPORTER_INTERVAL); + clusterSettings.registerSetting(QueryInsightsSettings.TOP_N_LATENCY_QUERIES_EXPORTER_IDENTIFIER); + + clusterService = new ClusterService(settings, clusterSettings, threadPool); + + } + + public void testGetSettings() { + assertEquals(0, queryInsightsPlugin.getSettings().size()); } + + public void testCreateComponent() { + List components = (List) queryInsightsPlugin.createComponents( + client, + clusterService, + threadPool, + null, + null, + null, + null, + null, + null, + null, + null + ); + assertEquals(0, components.size()); + } + + public void testGetRestHandlers() { + List components = queryInsightsPlugin.getRestHandlers(Settings.EMPTY, null, null, null, null, null, null); + assertEquals(0, components.size()); + } + + public void testGetActions() { + List> components = queryInsightsPlugin.getActions(); + assertEquals(0, components.size()); + } + } diff --git a/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporterTests.java b/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporterTests.java index da7857fe3214d..64d296e501519 100644 --- a/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporterTests.java +++ b/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsExporterTests.java @@ -20,20 +20,16 @@ public class QueryInsightsExporterTests extends OpenSearchTestCase { public class DummyExporter> extends QueryInsightsExporter { DummyExporter(String identifier) { - super(QueryInsightsExporterType.LOCAL_INDEX, identifier); + super(identifier); } @Override public void export(List records) {} } - public void testSetAndGetType() { + public void testGetType() { DummyExporter exporter = new DummyExporter<>("test-index"); - exporter.setType(QueryInsightsExporterType.LOCAL_INDEX); - exporter.setIdentifier("test-index"); - QueryInsightsExporterType type = exporter.getType(); String identifier = exporter.getIdentifier(); - assertEquals(QueryInsightsExporterType.LOCAL_INDEX, type); assertEquals("test-index", identifier); } } diff --git a/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsLocalIndexExporterTests.java b/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsLocalIndexExporterTests.java index 78ef630bf4e92..f1cac56447cfb 100644 --- a/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsLocalIndexExporterTests.java +++ b/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/exporter/QueryInsightsLocalIndexExporterTests.java @@ -73,6 +73,7 @@ public class QueryInsightsLocalIndexExporterTests extends OpenSearchTestCase { private QueryInsightsLocalIndexExporter queryInsightLocalIndexExporter; + @SuppressWarnings("unchecked") @Before public void setup() throws IOException { final CreateIndexResponse createIndexResponse = new CreateIndexResponse(true, false, "test-index"); @@ -224,6 +225,7 @@ public void testInitIndexSucceed() throws IOException { ); } + @SuppressWarnings("unchecked") public void testInitIndexFailed() throws IOException { when(mockRoutingTable.hasIndex(anyString())).thenReturn(false); when(clusterState.getRoutingTable()).thenReturn(mockRoutingTable); diff --git a/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/service/QueryInsightsServiceTests.java b/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/service/QueryInsightsServiceTests.java index b2c111542fe2c..b3eaf61dbb9a7 100644 --- a/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/service/QueryInsightsServiceTests.java +++ b/plugins/query-insights/src/test/java/org/opensearch/plugin/insights/core/service/QueryInsightsServiceTests.java @@ -39,6 +39,7 @@ public class QueryInsightsServiceTests extends OpenSearchTestCase { private ThreadPool threadPool = mock(ThreadPool.class); private DummyQueryInsightsService dummyQueryInsightsService; + @SuppressWarnings("unchecked") private QueryInsightsLocalIndexExporter exporter = mock(QueryInsightsLocalIndexExporter.class); static class DummyQueryInsightsService extends QueryInsightsService<