mirror of
https://github.com/corda/corda.git
synced 2025-01-02 19:26:47 +00:00
CORDA-5985 Simplify network map test (#6618)
Remove parameterization from NetworkMapTest as it doesn't actually significantly improve coverage, and costs 6 and a half minutes on every build.
This commit is contained in:
parent
80685041e1
commit
9965af180e
@ -31,13 +31,10 @@ import org.junit.Assert.assertThat
|
|||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.junit.runners.Parameterized
|
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
@RunWith(Parameterized::class)
|
class NetworkMapTest {
|
||||||
class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneParams) {
|
|
||||||
@Rule
|
@Rule
|
||||||
@JvmField
|
@JvmField
|
||||||
val testSerialization = SerializationEnvironmentRule(true)
|
val testSerialization = SerializationEnvironmentRule(true)
|
||||||
@ -48,40 +45,18 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
|
|||||||
private lateinit var networkMapServer: NetworkMapServer
|
private lateinit var networkMapServer: NetworkMapServer
|
||||||
private lateinit var compatibilityZone: CompatibilityZoneParams
|
private lateinit var compatibilityZone: CompatibilityZoneParams
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmStatic
|
|
||||||
@Parameterized.Parameters(name = "{0}")
|
|
||||||
fun runParams() = listOf(
|
|
||||||
{
|
|
||||||
addr: URL,
|
|
||||||
nms: NetworkMapServer -> SharedCompatibilityZoneParams(
|
|
||||||
addr,
|
|
||||||
pnm = null,
|
|
||||||
publishNotaries = {
|
|
||||||
nms.networkParameters = testNetworkParameters(it, modifiedTime = Instant.ofEpochMilli(random63BitValue()), epoch = 2)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
addr: URL,
|
|
||||||
nms: NetworkMapServer -> SplitCompatibilityZoneParams (
|
|
||||||
doormanURL = URL("http://I/Don't/Exist"),
|
|
||||||
networkMapURL = addr,
|
|
||||||
pnm = null,
|
|
||||||
publishNotaries = {
|
|
||||||
nms.networkParameters = testNetworkParameters(it, modifiedTime = Instant.ofEpochMilli(random63BitValue()), epoch = 2)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun start() {
|
fun start() {
|
||||||
networkMapServer = NetworkMapServer(cacheTimeout, portAllocation.nextHostAndPort())
|
networkMapServer = NetworkMapServer(cacheTimeout, portAllocation.nextHostAndPort())
|
||||||
val address = networkMapServer.start()
|
val address = networkMapServer.start()
|
||||||
compatibilityZone = initFunc(URL("http://$address"), networkMapServer)
|
compatibilityZone = SplitCompatibilityZoneParams(
|
||||||
|
doormanURL = URL("https://example.org/does/not/exist"),
|
||||||
|
networkMapURL = URL("http://$address"),
|
||||||
|
pnm = null,
|
||||||
|
publishNotaries = {
|
||||||
|
networkMapServer.networkParameters = testNetworkParameters(it, modifiedTime = Instant.ofEpochMilli(random63BitValue()), epoch = 2)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@ -211,27 +186,6 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 300_000)
|
|
||||||
fun `Can not hotload parameters if notary and a non-hotloadable parameter changes and the node will shut down`() {
|
|
||||||
internalDriver(
|
|
||||||
portAllocation = portAllocation,
|
|
||||||
compatibilityZone = compatibilityZone,
|
|
||||||
notarySpecs = emptyList(),
|
|
||||||
allowHibernateToManageAppSchema = false
|
|
||||||
) {
|
|
||||||
|
|
||||||
val oldParams = networkMapServer.networkParameters
|
|
||||||
val notary: Party = TestIdentity.fresh("test notary").party
|
|
||||||
val paramsWithUpdatedMaxMessageSizeAndNotary = oldParams.copy(
|
|
||||||
epoch = 3,
|
|
||||||
modifiedTime = Instant.ofEpochMilli(random63BitValue()),
|
|
||||||
maxMessageSize = oldParams.maxMessageSize + 1).addNotary(notary)
|
|
||||||
startNodeAndRunFlagDay(paramsWithUpdatedMaxMessageSizeAndNotary).use { alice ->
|
|
||||||
eventually { assertThatThrownBy { alice.rpc.networkParameters }.hasMessageContaining("Connection failure detected") }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun DriverDSLImpl.startNodeAndRunFlagDay(newParams: NetworkParameters): NodeHandleInternal {
|
private fun DriverDSLImpl.startNodeAndRunFlagDay(newParams: NetworkParameters): NodeHandleInternal {
|
||||||
|
|
||||||
val alice = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow() as NodeHandleInternal
|
val alice = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow() as NodeHandleInternal
|
||||||
@ -322,7 +276,8 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
|
|||||||
val nodeInfosDir = baseDirectory / NODE_INFO_DIRECTORY
|
val nodeInfosDir = baseDirectory / NODE_INFO_DIRECTORY
|
||||||
if (nodeInfosDir.exists()) {
|
if (nodeInfosDir.exists()) {
|
||||||
assertThat(nodeInfosDir.list().size, `is`(1))
|
assertThat(nodeInfosDir.list().size, `is`(1))
|
||||||
assertThat(nodeInfosDir.list().single().readObject<SignedNodeInfo>().verified().legalIdentities.first(), `is`( this.nodeInfo.legalIdentities.first()))
|
assertThat(nodeInfosDir.list().single().readObject<SignedNodeInfo>()
|
||||||
|
.verified().legalIdentities.first(), `is`(this.nodeInfo.legalIdentities.first()))
|
||||||
}
|
}
|
||||||
assertThat(rpc.networkMapSnapshot()).containsOnly(*nodes)
|
assertThat(rpc.networkMapSnapshot()).containsOnly(*nodes)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user