@@ -26,23 +26,9 @@ import org.apache.openwhisk.common.{Enable, GracefulShutdown, TransactionId}
26
26
import org .apache .openwhisk .core .WhiskConfig
27
27
import org .apache .openwhisk .core .connector .ContainerCreationError ._
28
28
import org .apache .openwhisk .core .connector .test .TestConnector
29
- import org .apache .openwhisk .core .connector .{
30
- ContainerCreationAckMessage ,
31
- ContainerCreationError ,
32
- ContainerCreationMessage ,
33
- MessageProducer ,
34
- ResultMetadata
35
- }
36
- import org .apache .openwhisk .core .containerpool .docker .DockerContainer
29
+ import org .apache .openwhisk .core .connector .{ContainerCreationAckMessage , ContainerCreationError , ContainerCreationMessage , MessageProducer , ResultMetadata }
37
30
import org .apache .openwhisk .core .containerpool .v2 ._
38
- import org .apache .openwhisk .core .containerpool .{
39
- Container ,
40
- ContainerAddress ,
41
- ContainerPoolConfig ,
42
- ContainerRemoved ,
43
- PrewarmContainerCreationConfig ,
44
- PrewarmingConfig
45
- }
31
+ import org .apache .openwhisk .core .containerpool .{Container , ContainerAddress , ContainerId , ContainerPoolConfig , ContainerRemoved , PrewarmContainerCreationConfig , PrewarmingConfig }
46
32
import org .apache .openwhisk .core .database .test .DbUtils
47
33
import org .apache .openwhisk .core .entity .ExecManifest .{ImageName , ReactivePrewarmingConfig , RuntimeManifest }
48
34
import org .apache .openwhisk .core .entity ._
@@ -137,9 +123,12 @@ class FunctionPullingContainerPoolTests
137
123
private val schedulerInstanceId = SchedulerInstanceId (" 0" )
138
124
private val producer = stub[MessageProducer ]
139
125
private val prewarmedData = PreWarmData (mock[MockableV2Container ], actionKind, memoryLimit)
126
+ private val mockContainer = mock[MockableV2Container ]
127
+ (mockContainer.containerId _ : () => ContainerId ).expects().returning(ContainerId (" test-container-id" )).anyNumberOfTimes()
128
+
140
129
private val initializedData =
141
130
InitializedData (
142
- mock[ MockableV2Container ] ,
131
+ mockContainer ,
143
132
invocationNamespace.asString,
144
133
whiskAction.toExecutableWhiskAction.get,
145
134
TestProbe ().ref)
@@ -315,6 +304,8 @@ class FunctionPullingContainerPoolTests
315
304
private def retry [T ](fn : => T ) = org.apache.openwhisk.utils.retry(fn, 10 , Some (1 .second))
316
305
317
306
it should " stop containers gradually when shut down" in within(timeout * 20 ) {
307
+ (mockContainer.containerId _ : () => ContainerId ).expects().returning(ContainerId (" test-container-id" )).anyNumberOfTimes()
308
+
318
309
val (containers, factory) = testContainers(10 )
319
310
val disablingContainers = ListBuffer [ActorRef ]()
320
311
@@ -356,7 +347,7 @@ class FunctionPullingContainerPoolTests
356
347
pool,
357
348
ContainerIsPaused (
358
349
WarmData (
359
- stub[ DockerContainer ] ,
350
+ mockContainer ,
360
351
invocationNamespace.asString,
361
352
whiskAction.toExecutableWhiskAction.get,
362
353
doc.rev,
@@ -636,6 +627,7 @@ class FunctionPullingContainerPoolTests
636
627
}
637
628
638
629
it should " use a warmed container when invocationNamespace, action and revision matched" in within(timeout) {
630
+ (mockContainer.containerId _ : () => ContainerId ).expects().returning(ContainerId (" test-container-id" )).anyNumberOfTimes()
639
631
val (containers, factory) = testContainers(3 )
640
632
val doc = put(entityStore, whiskAction)
641
633
@@ -654,7 +646,7 @@ class FunctionPullingContainerPoolTests
654
646
pool.tell(
655
647
ContainerIsPaused (
656
648
WarmData (
657
- stub[ DockerContainer ] ,
649
+ mockContainer ,
658
650
invocationNamespace.asString,
659
651
whiskAction.toExecutableWhiskAction.get,
660
652
doc.rev,
@@ -687,6 +679,7 @@ class FunctionPullingContainerPoolTests
687
679
}
688
680
689
681
it should " retry when chosen warmed container is failed to resume" in within(timeout) {
682
+ (mockContainer.containerId _ : () => ContainerId ).expects().returning(ContainerId (" test-container-id" )).anyNumberOfTimes()
690
683
691
684
val (containers, factory) = testContainers(2 )
692
685
val doc = put(entityStore, whiskAction)
@@ -706,7 +699,7 @@ class FunctionPullingContainerPoolTests
706
699
pool.tell(
707
700
ContainerIsPaused (
708
701
WarmData (
709
- stub[ DockerContainer ] ,
702
+ mockContainer ,
710
703
invocationNamespace.asString,
711
704
whiskAction.toExecutableWhiskAction.get,
712
705
doc.rev,
@@ -724,7 +717,7 @@ class FunctionPullingContainerPoolTests
724
717
pool.tell(
725
718
ResumeFailed (
726
719
WarmData (
727
- stub[ DockerContainer ] ,
720
+ mockContainer ,
728
721
invocationNamespace.asString,
729
722
whiskAction.toExecutableWhiskAction.get,
730
723
doc.rev,
@@ -739,6 +732,7 @@ class FunctionPullingContainerPoolTests
739
732
}
740
733
741
734
it should " remove oldest previously used container to make space for the job passed to run" in within(timeout) {
735
+ (mockContainer.containerId _ : () => ContainerId ).expects().returning(ContainerId (" test-container-id" )).anyNumberOfTimes()
742
736
val (containers, factory) = testContainers(2 )
743
737
val doc = put(entityStore, whiskAction)
744
738
@@ -757,7 +751,7 @@ class FunctionPullingContainerPoolTests
757
751
pool.tell(
758
752
ContainerIsPaused (
759
753
WarmData (
760
- stub[ DockerContainer ] ,
754
+ mockContainer ,
761
755
invocationNamespace.asString,
762
756
whiskAction.toExecutableWhiskAction.get,
763
757
doc.rev,
@@ -769,7 +763,7 @@ class FunctionPullingContainerPoolTests
769
763
pool.tell(
770
764
ContainerIsPaused (
771
765
WarmData (
772
- stub[ DockerContainer ] ,
766
+ mockContainer ,
773
767
invocationNamespace.asString,
774
768
whiskAction.toExecutableWhiskAction.get,
775
769
doc.rev,
@@ -781,7 +775,7 @@ class FunctionPullingContainerPoolTests
781
775
pool.tell(
782
776
ContainerIsPaused (
783
777
WarmData (
784
- stub[ DockerContainer ] ,
778
+ mockContainer ,
785
779
invocationNamespace.asString,
786
780
whiskAction.toExecutableWhiskAction.get,
787
781
doc.rev,
@@ -854,6 +848,7 @@ class FunctionPullingContainerPoolTests
854
848
}
855
849
856
850
it should " send ack(success) to scheduler when chosen warmed container is resumed" in within(timeout) {
851
+ (mockContainer.containerId _ : () => ContainerId ).expects().returning(ContainerId (" test-container-id" )).anyNumberOfTimes()
857
852
val (containers, factory) = testContainers(1 )
858
853
val doc = put(entityStore, whiskAction)
859
854
// Actions are created with default memory limit (MemoryLimit.stdMemory). This means 4 actions can be scheduled.
@@ -878,7 +873,7 @@ class FunctionPullingContainerPoolTests
878
873
pool.tell(
879
874
ContainerIsPaused (
880
875
WarmData (
881
- stub[ DockerContainer ] ,
876
+ mockContainer ,
882
877
invocationNamespace.asString,
883
878
whiskAction.toExecutableWhiskAction.get,
884
879
doc.rev,
@@ -894,7 +889,7 @@ class FunctionPullingContainerPoolTests
894
889
pool.tell(
895
890
Resumed (
896
891
WarmData (
897
- stub[ DockerContainer ] ,
892
+ mockContainer ,
898
893
invocationNamespace.asString,
899
894
whiskAction.toExecutableWhiskAction.get,
900
895
doc.rev,
0 commit comments