mirror of
https://github.com/corda/corda.git
synced 2025-02-01 16:58:27 +00:00
Update smoke tests to run correctly on Windows. (#684)
This commit is contained in:
parent
e61a8a7b09
commit
e995eac5d0
@ -5,7 +5,6 @@ import net.corda.client.rpc.CordaRPCClient
|
|||||||
import net.corda.client.rpc.CordaRPCConnection
|
import net.corda.client.rpc.CordaRPCConnection
|
||||||
import net.corda.core.utilities.loggerFor
|
import net.corda.core.utilities.loggerFor
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URI
|
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
@ -22,7 +21,7 @@ class NodeProcess(
|
|||||||
private companion object {
|
private companion object {
|
||||||
val log = loggerFor<NodeProcess>()
|
val log = loggerFor<NodeProcess>()
|
||||||
val javaPath: Path = Paths.get(System.getProperty("java.home"), "bin", "java")
|
val javaPath: Path = Paths.get(System.getProperty("java.home"), "bin", "java")
|
||||||
val corda: URI = this::class.java.getResource("/corda.jar").toURI()
|
val corda = File(this::class.java.getResource("/corda.jar").toURI())
|
||||||
val buildDir: Path = Paths.get(System.getProperty("build.dir"))
|
val buildDir: Path = Paths.get(System.getProperty("build.dir"))
|
||||||
val capsuleDir: Path = buildDir.resolve("capsule")
|
val capsuleDir: Path = buildDir.resolve("capsule")
|
||||||
}
|
}
|
||||||
@ -33,9 +32,12 @@ class NodeProcess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
|
log.info("Stopping node '${config.commonName}'")
|
||||||
node.destroy()
|
node.destroy()
|
||||||
val isDead = node.waitFor(60, SECONDS)
|
if (!node.waitFor(60, SECONDS)) {
|
||||||
assertTrue(isDead, "Node '${config.commonName}' has not shutdown correctly")
|
log.warn("Node '${config.commonName}' has not shutdown correctly")
|
||||||
|
node.destroyForcibly()
|
||||||
|
}
|
||||||
|
|
||||||
log.info("Deleting Artemis directories, because they're large!")
|
log.info("Deleting Artemis directories, because they're large!")
|
||||||
nodeDir.resolve("artemis").toFile().deleteRecursively()
|
nodeDir.resolve("artemis").toFile().deleteRecursively()
|
||||||
@ -43,7 +45,7 @@ class NodeProcess(
|
|||||||
|
|
||||||
class Factory(val nodesDir: Path) {
|
class Factory(val nodesDir: Path) {
|
||||||
init {
|
init {
|
||||||
assertTrue(nodesDir.toFile().forceDirectory(), "Nodes directory does not exist")
|
assertTrue(nodesDir.toFile().forceDirectory(), "Directory '$nodesDir' does not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun create(config: NodeConfig): NodeProcess {
|
fun create(config: NodeConfig): NodeProcess {
|
||||||
@ -61,6 +63,10 @@ class NodeProcess(
|
|||||||
try {
|
try {
|
||||||
setupExecutor.scheduleWithFixedDelay({
|
setupExecutor.scheduleWithFixedDelay({
|
||||||
try {
|
try {
|
||||||
|
if (!process.isAlive) {
|
||||||
|
log.error("Node '${config.commonName}' has died.")
|
||||||
|
return@scheduleWithFixedDelay
|
||||||
|
}
|
||||||
val conn = client.start(user.username, user.password)
|
val conn = client.start(user.username, user.password)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@ -72,9 +78,9 @@ class NodeProcess(
|
|||||||
}, 5, 1, SECONDS)
|
}, 5, 1, SECONDS)
|
||||||
|
|
||||||
val setupOK = setupExecutor.awaitTermination(120, SECONDS)
|
val setupOK = setupExecutor.awaitTermination(120, SECONDS)
|
||||||
assertTrue(setupOK, "Failed to create RPC connection")
|
assertTrue(setupOK && process.isAlive, "Failed to create RPC connection")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
process.destroy()
|
process.destroyForcibly()
|
||||||
throw e
|
throw e
|
||||||
} finally {
|
} finally {
|
||||||
setupExecutor.shutdownNow()
|
setupExecutor.shutdownNow()
|
||||||
|
@ -6,6 +6,7 @@ import java.nio.file.Path
|
|||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.time.Duration.ofSeconds
|
import java.time.Duration.ofSeconds
|
||||||
import java.util.Currency
|
import java.util.Currency
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import net.corda.client.rpc.CordaRPCConnection
|
import net.corda.client.rpc.CordaRPCConnection
|
||||||
import net.corda.client.rpc.notUsed
|
import net.corda.client.rpc.notUsed
|
||||||
@ -33,6 +34,7 @@ class StandaloneCordaRPClientTest {
|
|||||||
val nodesDir: Path = buildDir.resolve("nodes")
|
val nodesDir: Path = buildDir.resolve("nodes")
|
||||||
val user = User("user1", "test", permissions = setOf("ALL"))
|
val user = User("user1", "test", permissions = setOf("ALL"))
|
||||||
val factory = NodeProcess.Factory(nodesDir)
|
val factory = NodeProcess.Factory(nodesDir)
|
||||||
|
val port = AtomicInteger(15000)
|
||||||
const val attachmentSize = 2116
|
const val attachmentSize = 2116
|
||||||
const val timeout = 60L
|
const val timeout = 60L
|
||||||
}
|
}
|
||||||
@ -44,9 +46,9 @@ class StandaloneCordaRPClientTest {
|
|||||||
|
|
||||||
private val notaryConfig = NodeConfig(
|
private val notaryConfig = NodeConfig(
|
||||||
party = DUMMY_NOTARY,
|
party = DUMMY_NOTARY,
|
||||||
p2pPort = 10002,
|
p2pPort = port.andIncrement,
|
||||||
rpcPort = 10003,
|
rpcPort = port.andIncrement,
|
||||||
webPort = 10004,
|
webPort = port.andIncrement,
|
||||||
extraServices = listOf("corda.notary.validating"),
|
extraServices = listOf("corda.notary.validating"),
|
||||||
users = listOf(user)
|
users = listOf(user)
|
||||||
)
|
)
|
||||||
@ -61,14 +63,16 @@ class StandaloneCordaRPClientTest {
|
|||||||
|
|
||||||
@After
|
@After
|
||||||
fun done() {
|
fun done() {
|
||||||
connection.close()
|
try {
|
||||||
notary.close()
|
connection.close()
|
||||||
|
} finally {
|
||||||
|
notary.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test attachment upload`() {
|
fun `test attachment upload`() {
|
||||||
val attachment = sizedInputStreamAndHash(attachmentSize)
|
val attachment = sizedInputStreamAndHash(attachmentSize)
|
||||||
|
|
||||||
assertFalse(rpcProxy.attachmentExists(attachment.sha256))
|
assertFalse(rpcProxy.attachmentExists(attachment.sha256))
|
||||||
val id = WrapperStream(attachment.inputStream).use { rpcProxy.uploadAttachment(it) }
|
val id = WrapperStream(attachment.inputStream).use { rpcProxy.uploadAttachment(it) }
|
||||||
assertEquals(id, attachment.sha256, "Attachment has incorrect SHA256 hash")
|
assertEquals(id, attachment.sha256, "Attachment has incorrect SHA256 hash")
|
||||||
@ -138,7 +142,7 @@ class StandaloneCordaRPClientTest {
|
|||||||
val cashBalance = rpcProxy.getCashBalances()
|
val cashBalance = rpcProxy.getCashBalances()
|
||||||
log.info("Cash Balances: $cashBalance")
|
log.info("Cash Balances: $cashBalance")
|
||||||
assertEquals(1, cashBalance.size)
|
assertEquals(1, cashBalance.size)
|
||||||
assertEquals(629.POUNDS, cashBalance.get(Currency.getInstance("GBP")))
|
assertEquals(629.POUNDS, cashBalance[Currency.getInstance("GBP")])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user