Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public enum FeatureFlag {
null
),
RANDOM_SAMPLING("es.random_sampling_feature_flag_enabled=true", Version.fromString("9.2.0"), null),
INFERENCE_API_CCM("es.inference_api_ccm_feature_flag_enabled=true", Version.fromString("9.3.0"), null),
TSDB_SYNTHETIC_ID_FEATURE_FLAG("es.tsdb_synthetic_id_feature_flag_enabled=true", Version.fromString("9.3.0"), null),
GPU_FORMAT("es.gpu_vectors_indexing_feature_flag_enabled=true", Version.fromString("9.2.0"), null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.xpack.core.inference.action.PutCCMConfigurationAction;
import org.elasticsearch.xpack.inference.services.elastic.ccm.CCMFeatureFlag;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.ClassRule;

import java.io.IOException;
Expand Down Expand Up @@ -54,11 +52,6 @@ protected Settings restClientSettings() {
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build();
}

@BeforeClass
public static void classSetup() {
assumeTrue("CCM is behind a feature flag and snapshot only right now", CCMFeatureFlag.FEATURE_FLAG.isEnabled());
}

@After
public void cleanup() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class CCMRestBaseIT extends ESRestTestCase {

static final PutCCMConfigurationAction.Request ENABLE_CCM_REQUEST = PutCCMConfigurationAction.Request.createEnabled(
public static final PutCCMConfigurationAction.Request ENABLE_CCM_REQUEST = PutCCMConfigurationAction.Request.createEnabled(
"key",
TimeValue.THIRTY_SECONDS,
TimeValue.THIRTY_SECONDS
Expand All @@ -36,7 +36,7 @@ public class CCMRestBaseIT extends ESRestTestCase {
static final String GET_METHOD = "GET";
static final String DELETE_METHOD = "DELETE";

static CCMEnabledActionResponse putCCMConfiguration(PutCCMConfigurationAction.Request request) throws IOException {
public static CCMEnabledActionResponse putCCMConfiguration(PutCCMConfigurationAction.Request request) throws IOException {
return assertSuccessAndParseResponse(putRawRequest(INFERENCE_CCM_PATH, request));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,41 @@
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.upgrades.ParameterizedRollingUpgradeTestCase;
import org.elasticsearch.xpack.inference.MockElasticInferenceServiceAuthorizationServer;
import org.elasticsearch.xpack.inference.services.elastic.authorization.AuthorizationPoller;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;

import java.io.IOException;
import java.util.Map;

import static org.elasticsearch.xpack.inference.CCMRestBaseIT.ENABLE_CCM_REQUEST;
import static org.elasticsearch.xpack.inference.CCMRestBaseIT.putCCMConfiguration;
import static org.elasticsearch.xpack.inference.InferenceBaseRestTest.assertStatusOkOrCreated;
import static org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceSettings.ELASTIC_INFERENCE_SERVICE_URL;
import static org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceSettings.PERIODIC_AUTHORIZATION_ENABLED;
import static org.hamcrest.Matchers.is;

public class AuthorizationTaskExecutorUpgradeIT extends ParameterizedRollingUpgradeTestCase {

private static final MockElasticInferenceServiceAuthorizationServer mockEISServer =
new MockElasticInferenceServiceAuthorizationServer();

static {
// Ensure that the mock EIS server has an authorized response for each node that will be upgraded prior to the cluster starting
for (int i = 0; i < NODE_NUM; i++) {
mockEISServer.enqueueAuthorizeAllModelsResponse();
}
}

private static final Logger logger = LogManager.getLogger(AuthorizationTaskExecutorUpgradeIT.class);
private static final String BEFORE_AUTHORIZATION_TASK_FEATURE = "gte_v9.1.0";
// The bug where the authorization task is registered before the upgrade is complete was introduced in 9.3.0
// This is the currently latest version before that
private static final String MAX_CLUSTER_VERSION_BEFORE_BUG_INTRODUCED = "gte_v9.2.2";

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
private static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterVersion(), isOldClusterDetachedVersion())
.nodes(NODE_NUM)
Expand All @@ -45,9 +59,15 @@ public class AuthorizationTaskExecutorUpgradeIT extends ParameterizedRollingUpgr
.setting(PERIODIC_AUTHORIZATION_ENABLED.getKey(), "false")
// We need a url set for the authorization task to be created, but we don't actually care if we get a valid response
// just that the task will be created upon upgrade
.setting(ELASTIC_INFERENCE_SERVICE_URL.getKey(), "http://localhost:12345")
.setting(ELASTIC_INFERENCE_SERVICE_URL.getKey(), mockEISServer::getUrl)
.build();

// The reason we're doing this is to make sure the mock server is initialized first so we can get the address before communicating
// it to the cluster as a setting.
// Note: @ClassRule is executed once for the entire test class
@ClassRule
public static TestRule ruleChain = RuleChain.outerRule(mockEISServer).around(cluster);

private static final String GET_METHOD = "GET";

public AuthorizationTaskExecutorUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
Expand Down Expand Up @@ -86,6 +106,10 @@ && oldClusterHasFeature(MAX_CLUSTER_VERSION_BEFORE_BUG_INTRODUCED) == false

if (isUpgradedCluster()) {
logger.info("Cluster is fully upgraded scenario");
var response = putCCMConfiguration(ENABLE_CCM_REQUEST);

assertTrue(response.isEnabled());

// once fully upgraded, the authorization polling task should be created
assertBusy(() -> assertTrue(doesAuthPollingTaskExist()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.elasticsearch.xpack.inference.registry.ModelRegistry;
import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceSettings;
import org.elasticsearch.xpack.inference.services.elastic.authorization.AuthorizationTaskExecutor;
import org.elasticsearch.xpack.inference.services.elastic.ccm.CCMFeatureFlag;
import org.elasticsearch.xpack.inference.services.elastic.ccm.CCMModel;
import org.elasticsearch.xpack.inference.services.elastic.ccm.CCMService;
import org.elasticsearch.xpack.inference.services.elastic.ccm.CCMSettings;
Expand Down Expand Up @@ -75,8 +74,6 @@ public void delete(ActionListener<Void> listener) {

@BeforeClass
public static void initClass() throws IOException {
assumeTrue("CCM is behind a feature flag and snapshot only right now", CCMFeatureFlag.FEATURE_FLAG.isEnabled());

webServer.start();
gatewayUrl = getUrl(webServer);
chatCompletionResponseBody = ElasticInferenceServiceAuthorizationResponseEntityTests.getEisRainbowSprinklesAuthorizationResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public CCMFeature(Settings settings) {
}

public boolean isCcmSupportedEnvironment() {
return isCcmSupportedEnvironment && CCMFeatureFlag.FEATURE_FLAG.isEnabled();
return isCcmSupportedEnvironment;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class CCMSettings {
public static final Setting<Boolean> CCM_SUPPORTED_ENVIRONMENT = Setting.boolSetting(
"xpack.inference.elastic.ccm_supported_environment",
false,
true,
Setting.Property.NodeScope
);

Expand Down