Avoiding starting notaries in driver-based integration tests to speed them up (#3544)

This commit is contained in:
Shams Asari 2018-07-11 11:36:36 +01:00 committed by GitHub
parent 26d44eedf5
commit 2833ec2a88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 96 additions and 80 deletions

View File

@ -29,7 +29,7 @@ class BlacklistKotlinClosureTest {
@Test @Test
fun `closure sent via RPC`() { fun `closure sent via RPC`() {
driver(DriverParameters(startNodesInProcess = true)) { driver(DriverParameters(startNodesInProcess = true, notarySpecs = emptyList())) {
val rpc = startNode(providedName = ALICE_NAME).getOrThrow().rpc val rpc = startNode(providedName = ALICE_NAME).getOrThrow().rpc
val packet = Packet { EVIL } val packet = Packet { EVIL }
assertThatExceptionOfType(RPCException::class.java) assertThatExceptionOfType(RPCException::class.java)

View File

@ -30,7 +30,7 @@ class FlowsExecutionModeRpcTest {
assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win")) assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win"))
val user = User("mark", "dadada", setOf(invokeRpc("setFlowsDrainingModeEnabled"), invokeRpc("isFlowsDrainingModeEnabled"))) val user = User("mark", "dadada", setOf(invokeRpc("setFlowsDrainingModeEnabled"), invokeRpc("isFlowsDrainingModeEnabled")))
driver(DriverParameters(inMemoryDB = false, startNodesInProcess = true)) { driver(DriverParameters(inMemoryDB = false, startNodesInProcess = true, notarySpecs = emptyList())) {
val nodeName = { val nodeName = {
val nodeHandle = startNode(rpcUsers = listOf(user)).getOrThrow() val nodeHandle = startNode(rpcUsers = listOf(user)).getOrThrow()
val nodeName = nodeHandle.nodeInfo.chooseIdentity().name val nodeName = nodeHandle.nodeInfo.chooseIdentity().name

View File

@ -16,7 +16,7 @@ import org.junit.Test
class CashExceptionSerialisationTest { class CashExceptionSerialisationTest {
@Test @Test
fun `cash exception with a cause can be serialised with AMQP`() { fun `cash exception with a cause can be serialised with AMQP`() {
driver(DriverParameters(startNodesInProcess = true)) { driver(DriverParameters(startNodesInProcess = true, notarySpecs = emptyList())) {
val node = startNode(rpcUsers = listOf(User("mark", "dadada", setOf(all())))).getOrThrow() val node = startNode(rpcUsers = listOf(User("mark", "dadada", setOf(all())))).getOrThrow()
val action = { node.rpc.startFlow(::CashExceptionThrowingFlow).returnValue.getOrThrow() } val action = { node.rpc.startFlow(::CashExceptionThrowingFlow).returnValue.getOrThrow() }
assertThatThrownBy(action).isInstanceOfSatisfying(CashException::class.java) { thrown -> assertThatThrownBy(action).isInstanceOfSatisfying(CashException::class.java) { thrown ->

View File

@ -4,6 +4,7 @@ import net.corda.core.messaging.startFlow
import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.getOrThrow
import net.corda.finance.EUR import net.corda.finance.EUR
import net.corda.finance.USD import net.corda.finance.USD
import net.corda.testing.driver.DriverParameters
import net.corda.testing.driver.driver import net.corda.testing.driver.driver
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.Test import org.junit.Test
@ -11,7 +12,7 @@ import org.junit.Test
class CashConfigDataFlowTest { class CashConfigDataFlowTest {
@Test @Test
fun `issuable currencies are read in from node config`() { fun `issuable currencies are read in from node config`() {
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val node = startNode(customOverrides = mapOf("custom" to mapOf("issuableCurrencies" to listOf("EUR", "USD")))).getOrThrow() val node = startNode(customOverrides = mapOf("custom" to mapOf("issuableCurrencies" to listOf("EUR", "USD")))).getOrThrow()
val config = node.rpc.startFlow(::CashConfigDataFlow).returnValue.getOrThrow() val config = node.rpc.startFlow(::CashConfigDataFlow).returnValue.getOrThrow()
assertThat(config.issuableCurrencies).containsExactly(EUR, USD) assertThat(config.issuableCurrencies).containsExactly(EUR, USD)

View File

@ -22,10 +22,9 @@ import java.io.*
import kotlin.test.assertEquals import kotlin.test.assertEquals
class BootTests { class BootTests {
@Test @Test
fun `java deserialization is disabled`() { fun `java deserialization is disabled`() {
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val user = User("u", "p", setOf(startFlow<ObjectInputStreamFlow>())) val user = User("u", "p", setOf(startFlow<ObjectInputStreamFlow>()))
val future = CordaRPCClient(startNode(rpcUsers = listOf(user)).getOrThrow().rpcAddress). val future = CordaRPCClient(startNode(rpcUsers = listOf(user)).getOrThrow().rpcAddress).
start(user.username, user.password).proxy.startFlow(::ObjectInputStreamFlow).returnValue start(user.username, user.password).proxy.startFlow(::ObjectInputStreamFlow).returnValue

View File

@ -12,6 +12,7 @@ import net.corda.node.services.Permissions.Companion.startFlow
import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.BOB_NAME import net.corda.testing.core.BOB_NAME
import net.corda.testing.core.singleIdentity import net.corda.testing.core.singleIdentity
import net.corda.testing.driver.DriverParameters
import net.corda.testing.driver.driver import net.corda.testing.driver.driver
import net.corda.testing.node.User import net.corda.testing.node.User
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
@ -22,7 +23,7 @@ class CordappScanningDriverTest {
fun `sub-classed initiated flow pointing to the same initiating flow as its super-class`() { fun `sub-classed initiated flow pointing to the same initiating flow as its super-class`() {
val user = User("u", "p", setOf(startFlow<ReceiveFlow>())) val user = User("u", "p", setOf(startFlow<ReceiveFlow>()))
// The driver will automatically pick up the annotated flows below // The driver will automatically pick up the annotated flows below
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val (alice, bob) = listOf( val (alice, bob) = listOf(
startNode(providedName = ALICE_NAME, rpcUsers = listOf(user)), startNode(providedName = ALICE_NAME, rpcUsers = listOf(user)),
startNode(providedName = BOB_NAME)).transpose().getOrThrow() startNode(providedName = BOB_NAME)).transpose().getOrThrow()

View File

@ -8,29 +8,28 @@ import net.corda.core.utilities.getOrThrow
import net.corda.testing.core.DUMMY_BANK_A_NAME import net.corda.testing.core.DUMMY_BANK_A_NAME
import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.DriverParameters
import net.corda.testing.driver.driver import net.corda.testing.driver.driver
import org.junit.Assert import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
class NodeUnloadHandlerTests { class NodeUnloadHandlerTests {
companion object { companion object {
val latch = CountDownLatch(1) val latch = CountDownLatch(1)
} }
@Test @Test
fun `should be able to register run on stop lambda`() { fun `should be able to register run on stop lambda`() {
driver(DriverParameters(startNodesInProcess = true, extraCordappPackagesToScan = listOf("net.corda.node"))) { driver(DriverParameters(startNodesInProcess = true, extraCordappPackagesToScan = listOf("net.corda.node"), notarySpecs = emptyList())) {
startNode(providedName = DUMMY_BANK_A_NAME).getOrThrow() startNode(providedName = DUMMY_BANK_A_NAME).getOrThrow()
// just want to fall off the end of this for the mo... // just want to fall off the end of this for the mo...
} }
Assert.assertTrue("Timed out waiting for AbstractNode to invoke the test service shutdown callback", latch.await(30, TimeUnit.SECONDS)) assertTrue("Timed out waiting for AbstractNode to invoke the test service shutdown callback", latch.await(30, TimeUnit.SECONDS))
} }
@Suppress("unused")
@CordaService @CordaService
class RunOnStopTestService(serviceHub: ServiceHub) : SingletonSerializeAsToken() { class RunOnStopTestService(serviceHub: ServiceHub) : SingletonSerializeAsToken() {
companion object { companion object {
private val log = contextLogger() private val log = contextLogger()
} }
@ -39,7 +38,7 @@ class NodeUnloadHandlerTests {
serviceHub.registerUnloadHandler(this::shutdown) serviceHub.registerUnloadHandler(this::shutdown)
} }
fun shutdown() { private fun shutdown() {
log.info("shutting down") log.info("shutting down")
latch.countDown() latch.countDown()
} }

View File

@ -36,9 +36,11 @@ class FlowRetryTest {
val numSessions = 2 val numSessions = 2
val numIterations = 10 val numIterations = 10
val user = User("mark", "dadada", setOf(Permissions.startFlow<InitiatorFlow>())) val user = User("mark", "dadada", setOf(Permissions.startFlow<InitiatorFlow>()))
val result: Any? = driver(DriverParameters(startNodesInProcess = isQuasarAgentSpecified(), val result: Any? = driver(DriverParameters(
portAllocation = RandomFree)) { startNodesInProcess = isQuasarAgentSpecified(),
portAllocation = RandomFree,
notarySpecs = emptyList()
)) {
val nodeAHandle = startNode(rpcUsers = listOf(user)).getOrThrow() val nodeAHandle = startNode(rpcUsers = listOf(user)).getOrThrow()
val nodeBHandle = startNode(rpcUsers = listOf(user)).getOrThrow() val nodeBHandle = startNode(rpcUsers = listOf(user)).getOrThrow()

View File

@ -52,9 +52,7 @@ class P2PFlowsDrainingModeTest {
@Test @Test
fun `flows draining mode suspends consumption of initial session messages`() { fun `flows draining mode suspends consumption of initial session messages`() {
driver(DriverParameters(startNodesInProcess = false, portAllocation = portAllocation, notarySpecs = emptyList())) {
driver(DriverParameters(startNodesInProcess = false, portAllocation = portAllocation)) {
val initiatedNode = startNode(providedName = ALICE_NAME).getOrThrow() val initiatedNode = startNode(providedName = ALICE_NAME).getOrThrow()
val initiating = startNode(providedName = BOB_NAME, rpcUsers = users).getOrThrow().rpc val initiating = startNode(providedName = BOB_NAME, rpcUsers = users).getOrThrow().rpc
val counterParty = initiatedNode.nodeInfo.singleIdentity() val counterParty = initiatedNode.nodeInfo.singleIdentity()
@ -84,9 +82,7 @@ class P2PFlowsDrainingModeTest {
@Test @Test
fun `clean shutdown by draining`() { fun `clean shutdown by draining`() {
driver(DriverParameters(startNodesInProcess = true, portAllocation = portAllocation, notarySpecs = emptyList())) {
driver(DriverParameters(startNodesInProcess = true, portAllocation = portAllocation)) {
val nodeA = startNode(providedName = ALICE_NAME, rpcUsers = users).getOrThrow() val nodeA = startNode(providedName = ALICE_NAME, rpcUsers = users).getOrThrow()
val nodeB = startNode(providedName = BOB_NAME, rpcUsers = users).getOrThrow() val nodeB = startNode(providedName = BOB_NAME, rpcUsers = users).getOrThrow()
var successful = false var successful = false

View File

@ -23,11 +23,8 @@ class RpcFlowsDrainingModeTest {
@Test @Test
fun `flows draining mode rejects start flows commands through rpc`() { fun `flows draining mode rejects start flows commands through rpc`() {
driver(DriverParameters(startNodesInProcess = false, portAllocation = portAllocation, notarySpecs = emptyList())) {
driver(DriverParameters(startNodesInProcess = false, portAllocation = portAllocation)) {
startNode(rpcUsers = users).getOrThrow().rpc.apply { startNode(rpcUsers = users).getOrThrow().rpc.apply {
setFlowsDrainingModeEnabled(true) setFlowsDrainingModeEnabled(true)
val error: Throwable? = catchThrowable { startFlow(RpcFlowsDrainingModeTest::NoOpFlow) } val error: Throwable? = catchThrowable { startFlow(RpcFlowsDrainingModeTest::NoOpFlow) }
@ -40,10 +37,8 @@ class RpcFlowsDrainingModeTest {
@StartableByRPC @StartableByRPC
class NoOpFlow : FlowLogic<Unit>() { class NoOpFlow : FlowLogic<Unit>() {
@Suspendable @Suspendable
override fun call() { override fun call() {
println("NO OP!") println("NO OP!")
} }
} }

View File

@ -112,25 +112,28 @@ class AttachmentLoadingTests {
} }
@Test @Test
fun `test that attachments retrieved over the network are not used for code`() = withoutTestSerialization { fun `test that attachments retrieved over the network are not used for code`() {
driver(DriverParameters(startNodesInProcess = true)) { withoutTestSerialization {
installIsolatedCordappTo(bankAName) driver(DriverParameters(startNodesInProcess = true, notarySpecs = emptyList())) {
val (bankA, bankB) = createTwoNodes() installIsolatedCordappTo(bankAName)
assertFailsWith<CordaRuntimeException>("Party C=CH,L=Zurich,O=BankB rejected session request: Don't know net.corda.finance.contracts.isolated.IsolatedDummyFlow\$Initiator") { val (bankA, bankB) = createTwoNodes()
bankA.rpc.startFlowDynamic(flowInitiatorClass, bankB.nodeInfo.legalIdentities.first()).returnValue.getOrThrow() assertFailsWith<CordaRuntimeException>("Party C=CH,L=Zurich,O=BankB rejected session request: Don't know net.corda.finance.contracts.isolated.IsolatedDummyFlow\$Initiator") {
bankA.rpc.startFlowDynamic(flowInitiatorClass, bankB.nodeInfo.legalIdentities.first()).returnValue.getOrThrow()
}
} }
Unit
} }
Unit
} }
@Test @Test
fun `tests that if the attachment is loaded on both sides already that a flow can run`() = withoutTestSerialization { fun `tests that if the attachment is loaded on both sides already that a flow can run`() {
driver { withoutTestSerialization {
installIsolatedCordappTo(bankAName) driver {
installIsolatedCordappTo(bankBName) installIsolatedCordappTo(bankAName)
val (bankA, bankB) = createTwoNodes() installIsolatedCordappTo(bankBName)
bankA.rpc.startFlowDynamic(flowInitiatorClass, bankB.nodeInfo.legalIdentities.first()).returnValue.getOrThrow() val (bankA, bankB) = createTwoNodes()
bankA.rpc.startFlowDynamic(flowInitiatorClass, bankB.nodeInfo.legalIdentities.first()).returnValue.getOrThrow()
}
} }
Unit
} }
} }

View File

@ -221,6 +221,7 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
portAllocation = portAllocation, portAllocation = portAllocation,
compatibilityZone = compatibilityZone, compatibilityZone = compatibilityZone,
initialiseSerialization = false, initialiseSerialization = false,
notarySpecs = emptyList(),
systemProperties = mapOf("net.corda.node.internal.nodeinfo.publish.interval" to 1.seconds.toString()) systemProperties = mapOf("net.corda.node.internal.nodeinfo.publish.interval" to 1.seconds.toString())
) { ) {
val aliceNode = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow() val aliceNode = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow()

View File

@ -46,7 +46,7 @@ class RpcSslTest {
val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert) val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert)
val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password") val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password")
driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree)) { driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, notarySpecs = emptyList())) {
val node = startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow() val node = startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow()
val client = CordaRPCClient.createWithSsl(node.rpcAddress, sslConfiguration = clientSslOptions) val client = CordaRPCClient.createWithSsl(node.rpcAddress, sslConfiguration = clientSslOptions)
val connection = client.start(user.username, user.password) val connection = client.start(user.username, user.password)
@ -84,7 +84,7 @@ class RpcSslTest {
val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert1) val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert1)
val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password") val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password")
driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree)) { driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, notarySpecs = emptyList())) {
val node = startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow() val node = startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow()
Assertions.assertThatThrownBy { Assertions.assertThatThrownBy {
val connection = CordaRPCClient.createWithSsl(node.rpcAddress, sslConfiguration = clientSslOptions).start(user.username, user.password) val connection = CordaRPCClient.createWithSsl(node.rpcAddress, sslConfiguration = clientSslOptions).start(user.username, user.password)
@ -104,7 +104,7 @@ class RpcSslTest {
fun `RPC client not using ssl can run commands`() { fun `RPC client not using ssl can run commands`() {
val user = User("mark", "dadada", setOf(all())) val user = User("mark", "dadada", setOf(all()))
var successful = false var successful = false
driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree)) { driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, notarySpecs = emptyList())) {
val node = startNode(rpcUsers = listOf(user)).getOrThrow() val node = startNode(rpcUsers = listOf(user)).getOrThrow()
val connection = CordaRPCClient(node.rpcAddress).start(user.username, user.password) val connection = CordaRPCClient(node.rpcAddress).start(user.username, user.password)
connection.proxy.apply { connection.proxy.apply {
@ -124,7 +124,7 @@ class RpcSslTest {
val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert) val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert)
val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password") val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password")
driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree)) { driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, notarySpecs = emptyList())) {
val node = startNode(customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow() val node = startNode(customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow()
val client = CordaRPCClient.createWithSsl(node.rpcAddress, sslConfiguration = clientSslOptions) val client = CordaRPCClient.createWithSsl(node.rpcAddress, sslConfiguration = clientSslOptions)

View File

@ -30,7 +30,7 @@ import kotlin.test.assertEquals
class HardRestartTest { class HardRestartTest {
@StartableByRPC @StartableByRPC
@InitiatingFlow @InitiatingFlow
class Ping(val pongParty: Party, val times: Int) : FlowLogic<Unit>() { class Ping(private val pongParty: Party, val times: Int) : FlowLogic<Unit>() {
@Suspendable @Suspendable
override fun call() { override fun call() {
val pongSession = initiateFlow(pongParty) val pongSession = initiateFlow(pongParty)
@ -43,7 +43,7 @@ class HardRestartTest {
} }
@InitiatedBy(Ping::class) @InitiatedBy(Ping::class)
class Pong(val pingSession: FlowSession) : FlowLogic<Unit>() { class Pong(private val pingSession: FlowSession) : FlowLogic<Unit>() {
@Suspendable @Suspendable
override fun call() { override fun call() {
val times = pingSession.sendAndReceive<Int>(Unit).unwrap { it } val times = pingSession.sendAndReceive<Int>(Unit).unwrap { it }
@ -61,7 +61,12 @@ class HardRestartTest {
@Test @Test
fun restartShortPingPongFlowRandomly() { fun restartShortPingPongFlowRandomly() {
val demoUser = User("demo", "demo", setOf(Permissions.startFlow<Ping>(), Permissions.all())) val demoUser = User("demo", "demo", setOf(Permissions.startFlow<Ping>(), Permissions.all()))
driver(DriverParameters(startNodesInProcess = false, inMemoryDB = false, systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString()))) { driver(DriverParameters(
startNodesInProcess = false,
inMemoryDB = false,
notarySpecs = emptyList(),
systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString())
)) {
val (a, b) = listOf( val (a, b) = listOf(
startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:30000")), startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:30000")),
startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:40000")) startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:40000"))
@ -93,7 +98,12 @@ class HardRestartTest {
@Test @Test
fun restartLongPingPongFlowRandomly() { fun restartLongPingPongFlowRandomly() {
val demoUser = User("demo", "demo", setOf(Permissions.startFlow<Ping>(), Permissions.all())) val demoUser = User("demo", "demo", setOf(Permissions.startFlow<Ping>(), Permissions.all()))
driver(DriverParameters(startNodesInProcess = false, inMemoryDB = false, systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString()))) { driver(DriverParameters(
startNodesInProcess = false,
inMemoryDB = false,
notarySpecs = emptyList(),
systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString())
)) {
val (a, b) = listOf( val (a, b) = listOf(
startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:30000")), startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:30000")),
startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:40000")) startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:40000"))
@ -125,7 +135,12 @@ class HardRestartTest {
@Test @Test
fun softRestartLongPingPongFlowRandomly() { fun softRestartLongPingPongFlowRandomly() {
val demoUser = User("demo", "demo", setOf(Permissions.startFlow<Ping>(), Permissions.all())) val demoUser = User("demo", "demo", setOf(Permissions.startFlow<Ping>(), Permissions.all()))
driver(DriverParameters(startNodesInProcess = false, inMemoryDB = false, systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString()))) { driver(DriverParameters(
startNodesInProcess = false,
inMemoryDB = false,
notarySpecs = emptyList(),
systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString())
)) {
val (a, b) = listOf( val (a, b) = listOf(
startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:30000")), startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:30000")),
startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:40000")) startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:40000"))
@ -188,20 +203,25 @@ class HardRestartTest {
@InitiatingFlow @InitiatingFlow
@InitiatedBy(RecursiveA::class) @InitiatedBy(RecursiveA::class)
class RecursiveB(val otherSession: FlowSession) : FlowLogic<Unit>() { class RecursiveB(private val otherSession: FlowSession) : FlowLogic<Unit>() {
@Suspendable @Suspendable
override fun call() { override fun call() {
val depth = otherSession.receive<Int>().unwrap { it } val depth = otherSession.receive<Int>().unwrap { it }
val newSession = initiateFlow(otherSession.counterparty) val newSession = initiateFlow(otherSession.counterparty)
val string = newSession.sendAndReceive<String>(depth - 1).unwrap { it } val string = newSession.sendAndReceive<String>(depth - 1).unwrap { it }
otherSession.send(string + ":" + depth) otherSession.send("$string:$depth")
} }
} }
@Test @Test
fun restartRecursiveFlowRandomly() { fun restartRecursiveFlowRandomly() {
val demoUser = User("demo", "demo", setOf(Permissions.startFlow<RecursiveA>(), Permissions.all())) val demoUser = User("demo", "demo", setOf(Permissions.startFlow<RecursiveA>(), Permissions.all()))
driver(DriverParameters(startNodesInProcess = false, inMemoryDB = false, systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString()))) { driver(DriverParameters(
startNodesInProcess = false,
inMemoryDB = false,
notarySpecs = emptyList(),
systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString())
)) {
val (a, b) = listOf( val (a, b) = listOf(
startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:30000")), startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:30000")),
startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:40000")) startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = listOf(demoUser), customOverrides = mapOf("p2pAddress" to "localhost:40000"))

View File

@ -54,7 +54,7 @@ class DriverTests {
@Test @Test
fun `simple node startup and shutdown`() { fun `simple node startup and shutdown`() {
val handle = driver { val handle = driver(DriverParameters(notarySpecs = emptyList())) {
val node = startNode(providedName = DUMMY_REGULATOR_NAME) val node = startNode(providedName = DUMMY_REGULATOR_NAME)
nodeMustBeUp(node) nodeMustBeUp(node)
} }

View File

@ -34,17 +34,16 @@ import javax.security.auth.x500.X500Principal
import kotlin.test.assertTrue import kotlin.test.assertTrue
class InteractiveShellIntegrationTest { class InteractiveShellIntegrationTest {
@Rule @Rule
@JvmField @JvmField
val tempFolder = TemporaryFolder() val tempFolder = TemporaryFolder()
val testName = X500Principal("CN=Test,O=R3 Ltd,L=London,C=GB") private val testName = X500Principal("CN=Test,O=R3 Ltd,L=London,C=GB")
@Test @Test
fun `shell should not log in with invalid credentials`() { fun `shell should not log in with invalid credentials`() {
val user = User("u", "p", setOf()) val user = User("u", "p", setOf())
driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree)) { driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, notarySpecs = emptyList())) {
val nodeFuture = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), startInSameProcess = true) val nodeFuture = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), startInSameProcess = true)
val node = nodeFuture.getOrThrow() val node = nodeFuture.getOrThrow()
@ -60,7 +59,7 @@ class InteractiveShellIntegrationTest {
@Test @Test
fun `shell should log in with valid credentials`() { fun `shell should log in with valid credentials`() {
val user = User("u", "p", setOf()) val user = User("u", "p", setOf())
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val nodeFuture = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), startInSameProcess = true) val nodeFuture = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), startInSameProcess = true)
val node = nodeFuture.getOrThrow() val node = nodeFuture.getOrThrow()
@ -85,7 +84,7 @@ class InteractiveShellIntegrationTest {
val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert) val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert)
val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password") val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password")
driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree)) { driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, notarySpecs = emptyList())) {
startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow().use { node -> startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow().use { node ->
val conf = ShellConfiguration(commandsDirectory = Files.createTempDir().toPath(), val conf = ShellConfiguration(commandsDirectory = Files.createTempDir().toPath(),
@ -113,7 +112,7 @@ class InteractiveShellIntegrationTest {
val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert1) val trustStorePath = saveToTrustStore(tempFolder.root.toPath() / "truststore.jks", cert1)
val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password") val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password")
driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree)) { driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, notarySpecs = emptyList())) {
startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow().use { node -> startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow().use { node ->
val conf = ShellConfiguration(commandsDirectory = Files.createTempDir().toPath(), val conf = ShellConfiguration(commandsDirectory = Files.createTempDir().toPath(),
@ -130,7 +129,7 @@ class InteractiveShellIntegrationTest {
@Test @Test
fun `internal shell user should not be able to connect if node started with devMode=false`() { fun `internal shell user should not be able to connect if node started with devMode=false`() {
driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree)) { driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, notarySpecs = emptyList())) {
startNode().getOrThrow().use { node -> startNode().getOrThrow().use { node ->
val conf = (node as NodeHandleInternal).configuration.toShellConfig() val conf = (node as NodeHandleInternal).configuration.toShellConfig()
InteractiveShell.startShellInternal(conf) InteractiveShell.startShellInternal(conf)
@ -145,7 +144,7 @@ class InteractiveShellIntegrationTest {
val user = User("u", "p", setOf(Permissions.startFlow<SSHServerTest.FlowICanRun>(), val user = User("u", "p", setOf(Permissions.startFlow<SSHServerTest.FlowICanRun>(),
Permissions.invokeRpc(CordaRPCOps::registeredFlows), Permissions.invokeRpc(CordaRPCOps::registeredFlows),
Permissions.invokeRpc(CordaRPCOps::nodeInfo))) Permissions.invokeRpc(CordaRPCOps::nodeInfo)))
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val nodeFuture = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), startInSameProcess = true) val nodeFuture = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), startInSameProcess = true)
val node = nodeFuture.getOrThrow() val node = nodeFuture.getOrThrow()
@ -196,7 +195,7 @@ class InteractiveShellIntegrationTest {
val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password") val clientSslOptions = ClientRpcSslOptions(trustStorePath, "password")
var successful = false var successful = false
driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree)) { driver(DriverParameters(startNodesInProcess = true, portAllocation = RandomFree, notarySpecs = emptyList())) {
startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow().use { node -> startNode(rpcUsers = listOf(user), customOverrides = brokerSslOptions.useSslRpcOverrides()).getOrThrow().use { node ->
val conf = ShellConfiguration(commandsDirectory = Files.createTempDir().toPath(), val conf = ShellConfiguration(commandsDirectory = Files.createTempDir().toPath(),

View File

@ -16,24 +16,22 @@ import net.corda.node.services.Permissions.Companion.invokeRpc
import net.corda.node.services.Permissions.Companion.startFlow import net.corda.node.services.Permissions.Companion.startFlow
import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.ALICE_NAME
import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.DriverParameters
import net.corda.testing.node.User
import net.corda.testing.driver.driver import net.corda.testing.driver.driver
import net.corda.testing.node.User
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.bouncycastle.util.io.Streams import org.bouncycastle.util.io.Streams
import org.junit.Ignore import org.junit.Ignore
import org.junit.Test import org.junit.Test
import java.lang.Thread.sleep
import java.net.ConnectException import java.net.ConnectException
import kotlin.test.assertTrue import kotlin.test.assertTrue
import kotlin.test.fail import kotlin.test.fail
class SSHServerTest { class SSHServerTest {
@Test
@Test()
fun `ssh server does not start be default`() { fun `ssh server does not start be default`() {
val user = User("u", "p", setOf()) val user = User("u", "p", setOf())
// The driver will automatically pick up the annotated flows below // The driver will automatically pick up the annotated flows below
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user)) val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user))
node.getOrThrow() node.getOrThrow()
@ -44,7 +42,7 @@ class SSHServerTest {
try { try {
session.connect() session.connect()
fail() fail()
} catch (e:JSchException) { } catch (e: JSchException) {
assertTrue(e.cause is ConnectException) assertTrue(e.cause is ConnectException)
} }
} }
@ -54,7 +52,7 @@ class SSHServerTest {
fun `ssh server starts when configured`() { fun `ssh server starts when configured`() {
val user = User("u", "p", setOf()) val user = User("u", "p", setOf())
// The driver will automatically pick up the annotated flows below // The driver will automatically pick up the annotated flows below
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user),
customOverrides = mapOf("sshd" to mapOf("port" to 2222)) /*, startInSameProcess = true */) customOverrides = mapOf("sshd" to mapOf("port" to 2222)) /*, startInSameProcess = true */)
node.getOrThrow() node.getOrThrow()
@ -73,7 +71,7 @@ class SSHServerTest {
fun `ssh server verify credentials`() { fun `ssh server verify credentials`() {
val user = User("u", "p", setOf()) val user = User("u", "p", setOf())
// The driver will automatically pick up the annotated flows below // The driver will automatically pick up the annotated flows below
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user),
customOverrides = mapOf("sshd" to mapOf("port" to 2222))) customOverrides = mapOf("sshd" to mapOf("port" to 2222)))
node.getOrThrow() node.getOrThrow()
@ -97,7 +95,7 @@ class SSHServerTest {
val user = User("u", "p", setOf(startFlow<FlowICanRun>(), val user = User("u", "p", setOf(startFlow<FlowICanRun>(),
invokeRpc(CordaRPCOps::wellKnownPartyFromX500Name))) invokeRpc(CordaRPCOps::wellKnownPartyFromX500Name)))
// The driver will automatically pick up the annotated flows below // The driver will automatically pick up the annotated flows below
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user),
customOverrides = mapOf("sshd" to mapOf("port" to 2222))) customOverrides = mapOf("sshd" to mapOf("port" to 2222)))
node.getOrThrow() node.getOrThrow()
@ -126,7 +124,7 @@ class SSHServerTest {
fun `ssh runs flows`() { fun `ssh runs flows`() {
val user = User("u", "p", setOf(startFlow<FlowICanRun>())) val user = User("u", "p", setOf(startFlow<FlowICanRun>()))
// The driver will automatically pick up the annotated flows below // The driver will automatically pick up the annotated flows below
driver { driver(DriverParameters(notarySpecs = emptyList())) {
val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user), val node = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user),
customOverrides = mapOf("sshd" to mapOf("port" to 2222))) customOverrides = mapOf("sshd" to mapOf("port" to 2222)))
node.getOrThrow() node.getOrThrow()
@ -171,9 +169,10 @@ class SSHServerTest {
override val progressTracker: ProgressTracker? = ProgressTracker(HELLO_STEP) override val progressTracker: ProgressTracker? = ProgressTracker(HELLO_STEP)
} }
@Suppress("unused")
@StartableByRPC @StartableByRPC
@InitiatingFlow @InitiatingFlow
class FlowICannotRun(val otherParty: Party) : FlowLogic<String>() { class FlowICannotRun(private val otherParty: Party) : FlowLogic<String>() {
@Suspendable @Suspendable
override fun call(): String = initiateFlow(otherParty).receive<String>().unwrap { it } override fun call(): String = initiateFlow(otherParty).receive<String>().unwrap { it }

View File

@ -5,6 +5,7 @@ package net.corda.webserver
import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.NetworkHostAndPort
import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.getOrThrow
import net.corda.testing.core.DUMMY_BANK_A_NAME import net.corda.testing.core.DUMMY_BANK_A_NAME
import net.corda.testing.driver.DriverParameters
import net.corda.testing.driver.WebserverHandle import net.corda.testing.driver.WebserverHandle
import net.corda.testing.node.internal.addressMustBeBound import net.corda.testing.node.internal.addressMustBeBound
import net.corda.testing.node.internal.addressMustNotBeBound import net.corda.testing.node.internal.addressMustNotBeBound
@ -28,7 +29,7 @@ class WebserverDriverTests {
@Test @Test
fun `starting a node and independent web server works`() { fun `starting a node and independent web server works`() {
val addr = driver { val addr = driver(DriverParameters(notarySpecs = emptyList())) {
val node = startNode(providedName = DUMMY_BANK_A_NAME).getOrThrow() val node = startNode(providedName = DUMMY_BANK_A_NAME).getOrThrow()
val webserverHandle = startWebserver(node).getOrThrow() val webserverHandle = startWebserver(node).getOrThrow()
webserverMustBeUp(webserverHandle) webserverMustBeUp(webserverHandle)