Skip to content

Commit e6cf223

Browse files
authored
Allow ESQL extra verifiers to access settings (elastic#129954)
1 parent bf2a283 commit e6cf223

File tree

16 files changed

+49
-175
lines changed

16 files changed

+49
-175
lines changed

x-pack/plugin/esql/qa/server/extra-checkers/build.gradle

Lines changed: 0 additions & 29 deletions
This file was deleted.

x-pack/plugin/esql/qa/server/extra-checkers/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/extra/ExtraCheckersIT.java

Lines changed: 0 additions & 80 deletions
This file was deleted.

x-pack/plugin/esql/qa/server/extra-checkers/src/main/java/org/elasticsearch/xpack/esql/qa/extra/DisallowCategorize.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

x-pack/plugin/esql/qa/server/extra-checkers/src/main/java/org/elasticsearch/xpack/esql/qa/extra/ExtraCheckersPlugin.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

x-pack/plugin/esql/qa/server/extra-checkers/src/main/resources/META-INF/services/org.elasticsearch.xpack.esql.analysis.Verifier$ExtraCheckers

Lines changed: 0 additions & 8 deletions
This file was deleted.

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionBreakerIT.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
8787
}
8888

8989
public static class EsqlTestPluginWithMockBlockFactory extends EsqlPlugin {
90+
public EsqlTestPluginWithMockBlockFactory(Settings settings) {
91+
super(settings);
92+
}
93+
9094
@Override
9195
protected BlockFactoryProvider blockFactoryProvider(
9296
CircuitBreaker breaker,

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlPluginWithEnterpriseOrTrialLicense.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package org.elasticsearch.xpack.esql.action;
99

10+
import org.elasticsearch.common.settings.Settings;
1011
import org.elasticsearch.license.License;
1112
import org.elasticsearch.license.XPackLicenseState;
1213
import org.elasticsearch.license.internal.XPackLicenseStatus;
@@ -19,6 +20,10 @@
1920
* that require an Enteprise (or Trial) license.
2021
*/
2122
public class EsqlPluginWithEnterpriseOrTrialLicense extends EsqlPlugin {
23+
public EsqlPluginWithEnterpriseOrTrialLicense(Settings settings) {
24+
super(settings);
25+
}
26+
2227
protected XPackLicenseState getLicenseState() {
2328
License.OperationMode operationMode = randomFrom(License.OperationMode.ENTERPRISE, License.OperationMode.TRIAL);
2429
return new XPackLicenseState(() -> System.currentTimeMillis(), new XPackLicenseStatus(operationMode, true, "Test license expired"));

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlPluginWithNonEnterpriseOrExpiredLicense.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package org.elasticsearch.xpack.esql.action;
99

10+
import org.elasticsearch.common.settings.Settings;
1011
import org.elasticsearch.license.License;
1112
import org.elasticsearch.license.XPackLicenseState;
1213
import org.elasticsearch.license.internal.XPackLicenseStatus;
@@ -22,6 +23,10 @@
2223
* - an expired enterprise or trial license
2324
*/
2425
public class EsqlPluginWithNonEnterpriseOrExpiredLicense extends EsqlPlugin {
26+
public EsqlPluginWithNonEnterpriseOrExpiredLicense(Settings settings) {
27+
super(settings);
28+
}
29+
2530
protected XPackLicenseState getLicenseState() {
2631
License.OperationMode operationMode;
2732
boolean active;

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialNoLicenseTestCase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package org.elasticsearch.xpack.esql.spatial;
99

10+
import org.elasticsearch.common.settings.Settings;
1011
import org.elasticsearch.license.License;
1112
import org.elasticsearch.license.XPackLicenseState;
1213
import org.elasticsearch.license.internal.XPackLicenseStatus;
@@ -49,6 +50,10 @@ private static XPackLicenseState getLicenseState() {
4950
* This is used to test the behavior of spatial functions when no valid license is present.
5051
*/
5152
public static class TestEsqlPlugin extends EsqlPlugin {
53+
public TestEsqlPlugin(Settings settings) {
54+
super(settings);
55+
}
56+
5257
protected XPackLicenseState getLicenseState() {
5358
return SpatialNoLicenseTestCase.getLicenseState();
5459
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package org.elasticsearch.xpack.esql.analysis;
99

10+
import org.elasticsearch.common.settings.Settings;
1011
import org.elasticsearch.license.XPackLicenseState;
1112
import org.elasticsearch.xpack.esql.LicenseAware;
1213
import org.elasticsearch.xpack.esql.capabilities.PostAnalysisPlanVerificationAware;
@@ -60,7 +61,7 @@ public interface ExtraCheckers {
6061
* Build a list of checks to perform on the plan. Each one is called once per
6162
* {@link LogicalPlan} node in the plan.
6263
*/
63-
List<BiConsumer<LogicalPlan, Failures>> extra();
64+
List<BiConsumer<LogicalPlan, Failures>> extra(Settings settings);
6465
}
6566

6667
/**
@@ -69,15 +70,17 @@ public interface ExtraCheckers {
6970
private final List<ExtraCheckers> extraCheckers;
7071
private final Metrics metrics;
7172
private final XPackLicenseState licenseState;
73+
private final Settings settings;
7274

7375
public Verifier(Metrics metrics, XPackLicenseState licenseState) {
74-
this(metrics, licenseState, Collections.emptyList());
76+
this(metrics, licenseState, Collections.emptyList(), Settings.EMPTY);
7577
}
7678

77-
public Verifier(Metrics metrics, XPackLicenseState licenseState, List<ExtraCheckers> extraCheckers) {
79+
public Verifier(Metrics metrics, XPackLicenseState licenseState, List<ExtraCheckers> extraCheckers, Settings settings) {
7880
this.metrics = metrics;
7981
this.licenseState = licenseState;
8082
this.extraCheckers = extraCheckers;
83+
this.settings = settings;
8184
}
8285

8386
/**
@@ -102,7 +105,7 @@ Collection<Failure> verify(LogicalPlan plan, BitSet partialMetrics) {
102105
// collect plan checkers
103106
var planCheckers = planCheckers(plan);
104107
for (ExtraCheckers e : extraCheckers) {
105-
planCheckers.addAll(e.extra());
108+
planCheckers.addAll(e.extra(settings));
106109
}
107110

108111
// Concrete verifications

0 commit comments

Comments
 (0)