@@ -42,14 +42,15 @@ import org.apache.openwhisk.core.etcd.EtcdKV.ContainerKeys
42
42
import org .apache .openwhisk .core .etcd .EtcdKV .ContainerKeys .inProgressContainer
43
43
import org .apache .openwhisk .core .scheduler .queue .NamespaceContainerCount
44
44
import org .apache .openwhisk .core .service .{DeleteEvent , PutEvent , UnwatchEndpoint , WatchEndpoint , WatcherService }
45
+ import org .apache .openwhisk .utils .retry
45
46
import org .junit .runner .RunWith
46
47
import org .scalamock .scalatest .MockFactory
47
48
import org .scalatest .concurrent .ScalaFutures
48
49
import org .scalatest .{FlatSpecLike , Matchers }
49
50
import org .scalatest .junit .JUnitRunner
50
51
51
52
import scala .concurrent .Future
52
- import scala .concurrent .duration .TimeUnit
53
+ import scala .concurrent .duration ._
53
54
54
55
@ RunWith (classOf [JUnitRunner ])
55
56
class ContainerCounterTests
@@ -252,10 +253,10 @@ class ContainerCounterTests
252
253
val watcher = system.actorOf(WatcherService .props(mockEtcdClient))
253
254
254
255
val ns = NamespaceContainerCount (namespace, mockEtcdClient, watcher)
255
- Thread .sleep( 1000 )
256
-
257
- ns.inProgressContainerNumByNamespace shouldBe 0
258
- ns.existingContainerNumByNamespace shouldBe 0
256
+ retry(() => {
257
+ ns.inProgressContainerNumByNamespace shouldBe 0
258
+ ns.existingContainerNumByNamespace shouldBe 0
259
+ }, 10 , Some ( 100 .milliseconds))
259
260
260
261
val invoker = " invoker0"
261
262
(0 to 100 ).foreach(i => {
@@ -271,9 +272,10 @@ class ContainerCounterTests
271
272
" test-value" )
272
273
})
273
274
274
- Thread .sleep(5000 )
275
- ns.inProgressContainerNumByNamespace shouldBe 101
276
- ns.existingContainerNumByNamespace shouldBe 101
275
+ retry(() => {
276
+ ns.inProgressContainerNumByNamespace shouldBe 101
277
+ ns.existingContainerNumByNamespace shouldBe 101
278
+ }, 50 , Some (100 .milliseconds))
277
279
}
278
280
279
281
class MockEtcdClient (client : Client , isLeader : Boolean , leaseNotFound : Boolean = false , failedCount : Int = 0 )
0 commit comments