mirror of
https://github.com/corda/corda.git
synced 2025-05-28 05:04:22 +00:00
CORDA-649: Second attempt to make PersistentNetworkMapCacheTest more stable (#1738)
This commit is contained in:
parent
f961412396
commit
33e8105a29
@ -27,7 +27,6 @@ buildscript {
|
||||
ext.jersey_version = '2.25'
|
||||
ext.jolokia_version = '2.0.0-M3'
|
||||
ext.assertj_version = '3.6.1'
|
||||
ext.kotlintest_version = '2.0.5'
|
||||
ext.slf4j_version = '1.7.25'
|
||||
ext.log4j_version = '2.7'
|
||||
ext.bouncycastle_version = constants.getProperty("bouncycastleVersion")
|
||||
|
@ -127,7 +127,6 @@ dependencies {
|
||||
// Unit testing helpers.
|
||||
testCompile "junit:junit:$junit_version"
|
||||
testCompile "org.assertj:assertj-core:${assertj_version}"
|
||||
testCompile "io.kotlintest:kotlintest:${kotlintest_version}"
|
||||
testCompile project(':test-utils')
|
||||
testCompile project(':client:jfx')
|
||||
testCompile project(':finance')
|
||||
|
@ -1,8 +1,6 @@
|
||||
package net.corda.node.services.network
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import io.kotlintest.eventually
|
||||
import io.kotlintest.milliseconds
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.flows.FlowSession
|
||||
import net.corda.core.flows.InitiatedBy
|
||||
@ -17,8 +15,8 @@ import net.corda.testing.*
|
||||
import net.corda.testing.node.NodeBasedTest
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import java.time.Duration
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFails
|
||||
import kotlin.test.assertTrue
|
||||
@ -114,7 +112,6 @@ class PersistentNetworkMapCacheTest : NodeBasedTest() {
|
||||
assertFails { startNode(CHARLIE.name, noNetworkMap = true).getOrThrow(2.seconds) }
|
||||
}
|
||||
|
||||
@Ignore("Unstable test that needs more work")
|
||||
@Test
|
||||
fun `new node joins network without network map started`() {
|
||||
|
||||
@ -146,9 +143,11 @@ class PersistentNetworkMapCacheTest : NodeBasedTest() {
|
||||
|
||||
// This is prediction of the longest time it will take to get the cluster into a stable state such that further
|
||||
// testing can be performed upon it
|
||||
val maxInstabilityInterval = BRIDGE_RETRY_MS * allTheStartedNodesPopulation.size * 2
|
||||
val maxInstabilityInterval = BRIDGE_RETRY_MS * allTheStartedNodesPopulation.size * 30
|
||||
logger.info("Instability interval is set to: $maxInstabilityInterval ms")
|
||||
|
||||
eventually(maxInstabilityInterval.milliseconds) {
|
||||
// TODO: Re-visit this sort of re-try for stable cluster once network map redesign is finished.
|
||||
eventually<AssertionError, Unit>(Duration.ofMillis(maxInstabilityInterval)) {
|
||||
logger.info("Checking connectivity")
|
||||
checkConnectivity(listOf(otherNodes[0], nms)) // Checks connectivity from A to NMS.
|
||||
logger.info("Loading caches")
|
||||
|
@ -0,0 +1,24 @@
|
||||
package net.corda.testing
|
||||
|
||||
import java.time.Duration
|
||||
|
||||
/**
|
||||
* Ideas borrowed from "io.kotlintest" with some improvements made
|
||||
* This is meant for use from Kotlin code use only mainly due to it's inline/reified nature
|
||||
*/
|
||||
inline fun <reified E : Throwable, R>eventually(duration: Duration, f: () -> R): R {
|
||||
val end = System.nanoTime() + duration.toNanos()
|
||||
var times = 0
|
||||
while (System.nanoTime() < end) {
|
||||
try {
|
||||
return f()
|
||||
} catch (e: Throwable) {
|
||||
when(e) {
|
||||
is E -> {}// ignore and continue
|
||||
else -> throw e // unexpected exception type - rethrow
|
||||
}
|
||||
}
|
||||
times++
|
||||
}
|
||||
throw AssertionError("Test failed after $duration; attempted $times times")
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user