|
64 | 64 | import org.elasticsearch.xpack.inference.services.elastic.response.ElasticInferenceServiceAuthorizationResponseEntity; |
65 | 65 | import org.elasticsearch.xpack.inference.services.elastic.sparseembeddings.ElasticInferenceServiceSparseEmbeddingsModel; |
66 | 66 | import org.elasticsearch.xpack.inference.services.elasticsearch.ElserModels; |
| 67 | +import org.elasticsearch.xpack.inference.services.settings.RateLimitSettings; |
67 | 68 | import org.hamcrest.MatcherAssert; |
68 | 69 | import org.hamcrest.Matchers; |
69 | 70 | import org.junit.After; |
@@ -297,6 +298,39 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists |
297 | 298 | } |
298 | 299 | } |
299 | 300 |
|
| 301 | + public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenRateLimitFieldExistsInServiceSettings() throws IOException { |
| 302 | + try (var service = createServiceWithMockSender()) { |
| 303 | + Map<String, Object> serviceSettingsMap = new HashMap<>( |
| 304 | + Map.of( |
| 305 | + ServiceFields.MODEL_ID, |
| 306 | + ElserModels.ELSER_V2_MODEL, |
| 307 | + RateLimitSettings.FIELD_NAME, |
| 308 | + new HashMap<>(Map.of(RateLimitSettings.REQUESTS_PER_MINUTE_FIELD, 100)) |
| 309 | + ) |
| 310 | + ); |
| 311 | + |
| 312 | + var persistedConfig = getPersistedConfigMap(serviceSettingsMap, Map.of(), Map.of()); |
| 313 | + |
| 314 | + var model = service.parsePersistedConfigWithSecrets( |
| 315 | + "id", |
| 316 | + TaskType.SPARSE_EMBEDDING, |
| 317 | + persistedConfig.config(), |
| 318 | + persistedConfig.secrets() |
| 319 | + ); |
| 320 | + |
| 321 | + assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); |
| 322 | + |
| 323 | + var parsedModel = (ElasticInferenceServiceSparseEmbeddingsModel) model; |
| 324 | + assertThat(parsedModel.getServiceSettings().modelId(), is(ElserModels.ELSER_V2_MODEL)); |
| 325 | + assertThat(parsedModel.getTaskSettings(), is(EmptyTaskSettings.INSTANCE)); |
| 326 | + assertThat(parsedModel.getSecretSettings(), is(EmptySecretSettings.INSTANCE)); |
| 327 | + assertThat( |
| 328 | + serviceSettingsMap, |
| 329 | + is(Map.of(RateLimitSettings.FIELD_NAME, Map.of(RateLimitSettings.REQUESTS_PER_MINUTE_FIELD, 100))) |
| 330 | + ); |
| 331 | + } |
| 332 | + } |
| 333 | + |
300 | 334 | public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExistsInTaskSettings() throws IOException { |
301 | 335 | try (var service = createServiceWithMockSender()) { |
302 | 336 | var taskSettings = Map.of("extra_key", (Object) "value"); |
|
0 commit comments