@@ -278,7 +278,7 @@ class ContainerManagerTests
278
278
)
279
279
expectGetInvokers(mockEtcd, invokers)
280
280
expectGetInvokers(mockEtcd, invokers)
281
- expectGetInvokers(mockEtcd, invokers) // this test case will run `getPrefix` twice
281
+ expectGetInvokers(mockEtcd, invokers) // this test case will run `getPrefix` twice, and another one for warmup
282
282
283
283
val mockJobManager = TestProbe ()
284
284
val mockWatcher = TestProbe ()
@@ -377,6 +377,65 @@ class ContainerManagerTests
377
377
receiver.expectMsg(s " invoker0- $msg1" )
378
378
}
379
379
380
+ it should " not try warmed containers if revision is unmatched" in {
381
+ val mockEtcd = mock[EtcdClient ]
382
+
383
+ // for test, only invoker2 is healthy, so that no-warmed creations can be only sent to invoker2
384
+ val invokers : List [InvokerHealth ] = List (
385
+ InvokerHealth (InvokerInstanceId (0 , userMemory = testMemory, tags = Seq .empty[String ]), Unhealthy ),
386
+ InvokerHealth (InvokerInstanceId (1 , userMemory = testMemory, tags = Seq .empty[String ]), Unhealthy ),
387
+ InvokerHealth (InvokerInstanceId (2 , userMemory = testMemory, tags = Seq .empty[String ]), Healthy ),
388
+ )
389
+ expectGetInvokers(mockEtcd, invokers)
390
+ expectGetInvokers(mockEtcd, invokers) // one for warmup
391
+
392
+ val mockJobManager = TestProbe ()
393
+ val mockWatcher = TestProbe ()
394
+ val receiver = TestProbe ()
395
+
396
+ val manager =
397
+ system.actorOf(ContainerManager
398
+ .props(factory(mockJobManager), mockMessaging(Some (receiver.ref)), testsid, mockEtcd, config, mockWatcher.ref))
399
+
400
+ // there are 1 warmed container for `test-namespace/test-action` but with a different revision
401
+ manager ! WatchEndpointInserted (
402
+ ContainerKeys .warmedPrefix,
403
+ ContainerKeys .warmedContainers(
404
+ testInvocationNamespace,
405
+ testfqn,
406
+ DocRevision (" 2-testRev" ),
407
+ InvokerInstanceId (0 , userMemory = 0 .bytes),
408
+ ContainerId (" fake" )),
409
+ " " ,
410
+ true )
411
+
412
+ val msg =
413
+ ContainerCreationMessage (
414
+ TransactionId .testing,
415
+ testInvocationNamespace,
416
+ testfqn,
417
+ testRevision,
418
+ actionMetadata,
419
+ testsid,
420
+ schedulerHost,
421
+ rpcPort)
422
+
423
+ // it should not reuse the warmed container
424
+ manager ! ContainerCreation (List (msg), 128 .MB , testInvocationNamespace)
425
+
426
+ // ignore warmUp message
427
+ receiver.ignoreMsg {
428
+ case s : String => s.contains(" warmUp" )
429
+ }
430
+
431
+ // it should be scheduled to the sole health invoker: invoker2
432
+ receiver.expectMsg(s " invoker2- $msg" )
433
+
434
+ mockJobManager.expectMsgPF() {
435
+ case RegisterCreationJob (`msg`) => true
436
+ }
437
+ }
438
+
380
439
it should " rescheduling container creation" in {
381
440
val mockEtcd = mock[EtcdClient ]
382
441
(mockEtcd
0 commit comments