diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialExtentAggregationNoLicenseIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialExtentAggregationNoLicenseIT.java index f4378de627dd9..6d3a28b9060ee 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialExtentAggregationNoLicenseIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialExtentAggregationNoLicenseIT.java @@ -7,8 +7,11 @@ package org.elasticsearch.xpack.esql.spatial; +import org.elasticsearch.license.License; +import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.license.internal.XPackLicenseStatus; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.xpack.esql.action.EsqlPluginWithNonEnterpriseOrExpiredLicense; +import org.elasticsearch.xpack.esql.plugin.EsqlPlugin; import org.elasticsearch.xpack.spatial.SpatialPlugin; import java.util.Collection; @@ -18,11 +21,45 @@ public class SpatialExtentAggregationNoLicenseIT extends SpatialExtentAggregatio @Override protected Collection> nodePlugins() { - return List.of(SpatialPlugin.class, EsqlPluginWithNonEnterpriseOrExpiredLicense.class); + return List.of(TestSpatialPlugin.class, TestEsqlPlugin.class); } @Override public void testStExtentAggregationWithShapes() { assertStExtentFailsWith("index_geo_shape"); } + + private static XPackLicenseState getLicenseState() { + License.OperationMode operationMode; + boolean active; + if (randomBoolean()) { + operationMode = randomFrom( + License.OperationMode.GOLD, + License.OperationMode.BASIC, + License.OperationMode.MISSING, + License.OperationMode.STANDARD + ); + active = true; + } else { + operationMode = randomFrom(License.OperationMode.PLATINUM, License.OperationMode.ENTERPRISE, License.OperationMode.TRIAL); + active = false; // expired + } + + return new XPackLicenseState( + () -> System.currentTimeMillis(), + new XPackLicenseStatus(operationMode, active, "Test license expired") + ); + } + + public static class TestEsqlPlugin extends EsqlPlugin { + protected XPackLicenseState getLicenseState() { + return SpatialExtentAggregationNoLicenseIT.getLicenseState(); + } + } + + public static class TestSpatialPlugin extends SpatialPlugin { + protected XPackLicenseState getLicenseState() { + return SpatialExtentAggregationNoLicenseIT.getLicenseState(); + } + } }