Improve performance of NodeStatePersistenceTests (#2921)

Packages re-jig was meant to reduce the size of the jars that are being produced by the
node driver. E.g. previously `MessageState` was in package `net.corda` which resulted in jar file
of around 2MB to be created. Same for `NodeStatePersistenceTests` which was in `net.corda.node`
This commit is contained in:
Viktor Kolomeyko 2018-04-05 09:33:03 +01:00 committed by GitHub
parent e5b54a07c4
commit 9a1c27e3e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 17 deletions

View File

@ -1,10 +1,10 @@
package net.corda.node.modes.draining
import co.paralleluniverse.fibers.Suspendable
import net.corda.MESSAGE_CONTRACT_PROGRAM_ID
import net.corda.Message
import net.corda.MessageContract
import net.corda.MessageState
import net.corda.testMessage.MESSAGE_CONTRACT_PROGRAM_ID
import net.corda.testMessage.Message
import net.corda.testMessage.MessageContract
import net.corda.testMessage.MessageState
import net.corda.core.contracts.Command
import net.corda.core.contracts.StateAndContract
import net.corda.core.flows.*

View File

@ -1,10 +1,10 @@
package net.corda.node
package net.corda.node.persistence
import co.paralleluniverse.fibers.Suspendable
import net.corda.MESSAGE_CONTRACT_PROGRAM_ID
import net.corda.Message
import net.corda.MessageContract
import net.corda.MessageState
import net.corda.testMessage.MESSAGE_CONTRACT_PROGRAM_ID
import net.corda.testMessage.Message
import net.corda.testMessage.MessageContract
import net.corda.testMessage.MessageState
import net.corda.client.rpc.CordaRPCClient
import net.corda.core.contracts.Command
import net.corda.core.contracts.StateAndContract
@ -35,13 +35,10 @@ import kotlin.test.assertNotNull
class NodeStatePersistenceTests {
@Test
fun `persistent state survives node restart`() {
// Temporary disable this test when executed on Windows. It is known to be sporadically failing.
// More investigation is needed to establish why.
assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win"))
val user = User("mark", "dadada", setOf(startFlow<SendMessageFlow>(), invokeRpc("vaultQuery")))
val message = Message("Hello world!")
val stateAndRef: StateAndRef<MessageState>? = driver(DriverParameters(isDebug = true, startNodesInProcess = isQuasarAgentSpecified(), portAllocation = RandomFree, extraCordappPackagesToScan = listOf(MessageState::class.packageName))) {
val stateAndRef: StateAndRef<MessageState>? = driver(DriverParameters(isDebug = true, startNodesInProcess = isQuasarAgentSpecified(),
portAllocation = RandomFree, extraCordappPackagesToScan = listOf(MessageState::class.packageName))) {
val nodeName = {
val nodeHandle = startNode(rpcUsers = listOf(user)).getOrThrow()
val nodeName = nodeHandle.nodeInfo.singleIdentity().name
@ -104,7 +101,7 @@ class NodeStatePersistenceTests {
fun isQuasarAgentSpecified(): Boolean {
val jvmArgs = ManagementFactory.getRuntimeMXBean().inputArguments
return jvmArgs.any { it.startsWith("-javaagent:") && it.endsWith("quasar.jar") }
return jvmArgs.any { it.startsWith("-javaagent:") && it.contains("quasar") }
}
@StartableByRPC

View File

@ -1,4 +1,4 @@
package net.corda
package net.corda.testMessage
import net.corda.core.contracts.*
import net.corda.core.identity.AbstractParty
@ -48,7 +48,7 @@ object MessageSchemaV1 : MappedSchema(
) : PersistentState()
}
const val MESSAGE_CONTRACT_PROGRAM_ID = "net.corda.MessageContract"
const val MESSAGE_CONTRACT_PROGRAM_ID = "net.corda.testMessage.MessageContract"
open class MessageContract : Contract {
override fun verify(tx: LedgerTransaction) {

View File

@ -218,8 +218,11 @@ abstract class AbstractNode(val configuration: NodeConfiguration,
identityService.loadIdentities(nodeInfo.legalIdentitiesAndCerts)
val metrics = MetricRegistry()
val transactionStorage = makeTransactionStorage(database, configuration.transactionCacheSizeBytes)
log.debug("Transaction storage created")
attachments = NodeAttachmentService(metrics, configuration.attachmentContentCacheSizeBytes, configuration.attachmentCacheBound)
log.debug("Attachment service created")
val cordappProvider = CordappProviderImpl(cordappLoader, CordappConfigFileProvider(), attachments, networkParameters.whitelistedContractImplementations)
log.debug("Cordapp provider created")
val servicesForResolution = ServicesForResolutionImpl(identityService, attachments, cordappProvider, networkParameters, transactionStorage)
val nodeProperties = NodePropertiesPersistentStore(StubbedNodeUniqueIdProvider::value, database)
val nodeServices = makeServices(

View File

@ -110,6 +110,7 @@ class PersistentIdentityService(override val trustRoot: X509Certificate,
confidentialIdentities.forEach {
principalToParties.addWithDuplicatesAllowed(it.name, mapToKey(it), false)
}
log.debug("Identities loaded")
}
@Throws(CertificateExpiredException::class, CertificateNotYetValidException::class, InvalidAlgorithmParameterException::class)