|
54 | 54 | import static org.elasticsearch.xpack.ml.utils.NativeMemoryCalculator.STATIC_JVM_UPPER_THRESHOLD; |
55 | 55 | import static org.hamcrest.Matchers.containsString; |
56 | 56 | import static org.hamcrest.Matchers.equalTo; |
| 57 | +import static org.hamcrest.Matchers.greaterThan; |
57 | 58 | import static org.hamcrest.Matchers.is; |
58 | 59 | import static org.hamcrest.Matchers.nullValue; |
59 | 60 | import static org.mockito.ArgumentMatchers.any; |
@@ -331,6 +332,53 @@ public void testScale_GivenModelWithZeroAllocations() { |
331 | 332 | assertThat(result.requiredCapacity().node().memory().getBytes(), equalTo(0L)); |
332 | 333 | } |
333 | 334 |
|
| 335 | + public void testScale_GivenTrainedModelAllocationAndNoMlNode() { |
| 336 | + MlAutoscalingDeciderService service = buildService(); |
| 337 | + service.onMaster(); |
| 338 | + |
| 339 | + ClusterState clusterState = new ClusterState.Builder(new ClusterName("cluster")).metadata( |
| 340 | + Metadata.builder() |
| 341 | + .putCustom( |
| 342 | + TrainedModelAssignmentMetadata.NAME, |
| 343 | + new TrainedModelAssignmentMetadata( |
| 344 | + Map.of( |
| 345 | + "model", |
| 346 | + TrainedModelAssignment.Builder.empty( |
| 347 | + new StartTrainedModelDeploymentAction.TaskParams( |
| 348 | + "model", |
| 349 | + "model-deployment", |
| 350 | + 400, |
| 351 | + 1, |
| 352 | + 2, |
| 353 | + 100, |
| 354 | + null, |
| 355 | + Priority.NORMAL, |
| 356 | + 0L, |
| 357 | + 0L |
| 358 | + ), |
| 359 | + new AdaptiveAllocationsSettings(true, 0, 4) |
| 360 | + ).setAssignmentState(AssignmentState.STARTING).build() |
| 361 | + ) |
| 362 | + ) |
| 363 | + ) |
| 364 | + .build() |
| 365 | + ).build(); |
| 366 | + |
| 367 | + AutoscalingDeciderResult result = service.scale( |
| 368 | + Settings.EMPTY, |
| 369 | + new DeciderContext( |
| 370 | + clusterState, |
| 371 | + new AutoscalingCapacity(AutoscalingCapacity.AutoscalingResources.ZERO, AutoscalingCapacity.AutoscalingResources.ZERO) |
| 372 | + ) |
| 373 | + ); |
| 374 | + |
| 375 | + assertThat(result.reason().summary(), containsString("requesting scale up")); |
| 376 | + assertThat(result.requiredCapacity().total().memory().getBytes(), greaterThan(TEST_JOB_SIZE)); |
| 377 | + assertThat(result.requiredCapacity().total().processors().count(), equalTo(2.0)); |
| 378 | + assertThat(result.requiredCapacity().node().memory().getBytes(), greaterThan(TEST_JOB_SIZE)); |
| 379 | + assertThat(result.requiredCapacity().node().processors().count(), equalTo(2.0)); |
| 380 | + } |
| 381 | + |
334 | 382 | private DiscoveryNode buildNode(String id, ByteSizeValue machineMemory, int allocatedProcessors) { |
335 | 383 | return DiscoveryNodeUtils.create( |
336 | 384 | id, |
|
0 commit comments