mirror of
https://github.com/corda/corda.git
synced 2025-01-28 15:14:48 +00:00
BUILD: Try to fix flaky FailNodeOnNotMigratedAttachmentContractsTableNameTests.
* Ensure that this test stops nodes that it starts. * Also ensure that random ephemeral ports can be reused.
This commit is contained in:
parent
866f07c741
commit
f378f0eba6
@ -14,7 +14,6 @@ import net.corda.testing.driver.DriverParameters
|
||||
import net.corda.testing.driver.driver
|
||||
import net.corda.testing.driver.internal.RandomFree
|
||||
import net.corda.testing.node.User
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.Test
|
||||
import java.nio.file.Path
|
||||
@ -36,19 +35,19 @@ class FailNodeOnNotMigratedAttachmentContractsTableNameTests {
|
||||
val user = User("mark", "dadada", setOf(Permissions.startFlow<SendMessageFlow>(), Permissions.invokeRpc("vaultQuery")))
|
||||
val message = Message("Hello world!")
|
||||
val baseDir: Path = driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, extraCordappPackagesToScan = listOf(MessageState::class.packageName))) {
|
||||
// Just start a node to make this test less flaky.
|
||||
startNode(rpcUsers = listOf(user)).getOrThrow()
|
||||
|
||||
val (nodeName, baseDir) = {
|
||||
val (nodeName, baseDir) = run {
|
||||
defaultNotaryNode.getOrThrow()
|
||||
val nodeHandle = startNode(rpcUsers = listOf(user)).getOrThrow()
|
||||
val nodeName = nodeHandle.nodeInfo.singleIdentity().name
|
||||
CordaRPCClient(nodeHandle.rpcAddress).start(user.username, user.password).use {
|
||||
it.proxy.startFlow(::SendMessageFlow, message, defaultNotaryIdentity).returnValue.getOrThrow()
|
||||
val nodeName = try {
|
||||
CordaRPCClient(nodeHandle.rpcAddress).start(user.username, user.password).use {
|
||||
it.proxy.startFlow(::SendMessageFlow, message, defaultNotaryIdentity).returnValue.getOrThrow()
|
||||
}
|
||||
nodeHandle.nodeInfo.singleIdentity().name
|
||||
} finally {
|
||||
nodeHandle.stop()
|
||||
}
|
||||
nodeHandle.stop()
|
||||
Pair(nodeName, nodeHandle.baseDirectory)
|
||||
}()
|
||||
}
|
||||
|
||||
// replace the correct table name with one from the former release
|
||||
DriverManager.getConnection("jdbc:h2:file://$baseDir/persistence", "sa", "").use {
|
||||
|
@ -81,6 +81,7 @@ val InProcess.internalServices: StartedNodeServices get() = services as StartedN
|
||||
object RandomFree : PortAllocation() {
|
||||
override fun nextPort(): Int {
|
||||
return ServerSocket().use {
|
||||
it.reuseAddress = true
|
||||
it.bind(InetSocketAddress(0))
|
||||
it.localPort
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user