Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanatia committed Nov 18, 2024
1 parent 8c66d02 commit bf9d6d7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.indices.IndicesExpressionGrouper;
import org.elasticsearch.telemetry.metric.MeterRegistry;
import org.elasticsearch.xpack.esql.action.EsqlExecutionInfo;
Expand Down Expand Up @@ -42,9 +42,9 @@ public class PlanExecutor {
private final Verifier verifier;
private final PlanningMetricsManager planningMetricsManager;
private final Client client;
private final ClusterState clusterState;
private final ClusterService clusterService;

public PlanExecutor(IndexResolver indexResolver, MeterRegistry meterRegistry, Client client, ClusterState clusterState) {
public PlanExecutor(IndexResolver indexResolver, MeterRegistry meterRegistry, Client client, ClusterService clusterService) {
this.indexResolver = indexResolver;
this.preAnalyzer = new PreAnalyzer();
this.functionRegistry = new EsqlFunctionRegistry();
Expand All @@ -53,7 +53,7 @@ public PlanExecutor(IndexResolver indexResolver, MeterRegistry meterRegistry, Cl
this.verifier = new Verifier(metrics);
this.planningMetricsManager = new PlanningMetricsManager(meterRegistry);
this.client = client;
this.clusterState = clusterState;
this.clusterService = clusterService;
}

public void esql(
Expand All @@ -80,7 +80,7 @@ public void esql(
planningMetrics,
indicesExpressionGrouper,
client,
clusterState
clusterService.state()
);
QueryMetric clientId = QueryMetric.fromString("rest");
metrics.total(clientId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public Collection<?> createComponents(PluginServices services) {
new IndexResolver(services.client()),
services.telemetryProvider().getMeterRegistry(),
services.client(),
services.clusterService().state()
services.clusterService()
),
new ExchangeService(services.clusterService().getSettings(), services.threadPool(), ThreadPool.Names.SEARCH, blockFactory),
blockFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ public void analyzedPlan(LogicalPlan parsed, EsqlExecutionInfo executionInfo, Ac

preAnalyze(parsed, executionInfo, (indices, policies) -> {
planningMetrics.gatherPreAnalysisMetrics(parsed);
inferenceContext.setIndices(indices.get().concreteIndices());
if (indices.isValid()) {
inferenceContext.setIndices(indices.get().concreteIndices());
}
Analyzer analyzer = new Analyzer(
new AnalyzerContext(
configuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.indices.IndicesExpressionGrouper;
import org.elasticsearch.telemetry.metric.MeterRegistry;
Expand Down Expand Up @@ -104,12 +105,9 @@ public void testFailedMetric() {
return null;
}).when(esqlClient).execute(eq(EsqlResolveFieldsAction.TYPE), any(), any());

var planExecutor = new PlanExecutor(
indexResolver,
MeterRegistry.NOOP,
null,
new ClusterState.Builder(new ClusterName("name")).build()
);
ClusterService clusterService = mock(ClusterService.class);
when(clusterService.state()).thenReturn(new ClusterState.Builder(new ClusterName("name")).build());
var planExecutor = new PlanExecutor(indexResolver, MeterRegistry.NOOP, null, clusterService);
var enrichResolver = mockEnrichResolver();

var request = new EsqlQueryRequest();
Expand Down

0 comments on commit bf9d6d7

Please sign in to comment.