mirror of
https://github.com/corda/corda.git
synced 2024-12-22 06:17:55 +00:00
Fix hanging test and fail fast on hang.
This commit is contained in:
parent
8ea20dd0d2
commit
17c9d231f4
@ -34,6 +34,7 @@ import java.security.PublicKey
|
|||||||
import java.time.Clock
|
import java.time.Clock
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.util.concurrent.*
|
import java.util.concurrent.*
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
||||||
// Use an in memory file system for testing attachment storage.
|
// Use an in memory file system for testing attachment storage.
|
||||||
@ -160,7 +161,7 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
|||||||
assertThat(calls).isEqualTo(0)
|
assertThat(calls).isEqualTo(0)
|
||||||
testClock.advanceBy(1.days)
|
testClock.advanceBy(1.days)
|
||||||
backgroundExecutor.shutdown()
|
backgroundExecutor.shutdown()
|
||||||
backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS)
|
assertTrue(backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS))
|
||||||
countDown.await()
|
countDown.await()
|
||||||
assertThat(calls).isEqualTo(1)
|
assertThat(calls).isEqualTo(1)
|
||||||
}
|
}
|
||||||
@ -180,7 +181,7 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
|||||||
countDown.await()
|
countDown.await()
|
||||||
assertThat(calls).isEqualTo(3)
|
assertThat(calls).isEqualTo(3)
|
||||||
backgroundExecutor.shutdown()
|
backgroundExecutor.shutdown()
|
||||||
backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS)
|
assertTrue(backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -193,14 +194,13 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
|||||||
assertThat(calls).isEqualTo(0)
|
assertThat(calls).isEqualTo(0)
|
||||||
scheduleTX(time + 1.days, 3)
|
scheduleTX(time + 1.days, 3)
|
||||||
|
|
||||||
backgroundExecutor.execute { schedulerGatedExecutor.waitAndRun() }
|
|
||||||
testClock.advanceBy(1.days)
|
testClock.advanceBy(1.days)
|
||||||
countDown.await()
|
countDown.await()
|
||||||
assertThat(calls).isEqualTo(1)
|
assertThat(calls).isEqualTo(1)
|
||||||
testClock.advanceBy(1.days)
|
|
||||||
backgroundExecutor.execute { schedulerGatedExecutor.waitAndRun() }
|
backgroundExecutor.execute { schedulerGatedExecutor.waitAndRun() }
|
||||||
|
testClock.advanceBy(1.days)
|
||||||
backgroundExecutor.shutdown()
|
backgroundExecutor.shutdown()
|
||||||
backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS)
|
assertTrue(backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -217,7 +217,7 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
|||||||
countDown.await()
|
countDown.await()
|
||||||
assertThat(calls).isEqualTo(1)
|
assertThat(calls).isEqualTo(1)
|
||||||
backgroundExecutor.shutdown()
|
backgroundExecutor.shutdown()
|
||||||
backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS)
|
assertTrue(backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -236,7 +236,7 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
|||||||
countDown.await()
|
countDown.await()
|
||||||
assertThat(calls).isEqualTo(3)
|
assertThat(calls).isEqualTo(3)
|
||||||
backgroundExecutor.shutdown()
|
backgroundExecutor.shutdown()
|
||||||
backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS)
|
assertTrue(backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -251,7 +251,7 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() {
|
|||||||
testClock.advanceBy(1.days)
|
testClock.advanceBy(1.days)
|
||||||
assertThat(calls).isEqualTo(0)
|
assertThat(calls).isEqualTo(0)
|
||||||
backgroundExecutor.shutdown()
|
backgroundExecutor.shutdown()
|
||||||
backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS)
|
assertTrue(backgroundExecutor.awaitTermination(60, TimeUnit.SECONDS))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scheduleTX(instant: Instant, increment: Int = 1): ScheduledStateRef? {
|
private fun scheduleTX(instant: Instant, increment: Int = 1): ScheduledStateRef? {
|
||||||
|
Loading…
Reference in New Issue
Block a user