mirror of
https://github.com/corda/corda.git
synced 2025-02-06 19:19:19 +00:00
Pat remove stability test randomness (#891)
* Remove randomness from stability test * address PR issues
This commit is contained in:
parent
88c8f4b351
commit
1c2265d3b7
@ -33,7 +33,7 @@ data class LoadTestConfiguration(
|
|||||||
val remoteSystemdServiceName: String,
|
val remoteSystemdServiceName: String,
|
||||||
val seed: Long?,
|
val seed: Long?,
|
||||||
val mode: TestMode = TestMode.LOAD_TEST,
|
val mode: TestMode = TestMode.LOAD_TEST,
|
||||||
val executionFrequency: Int = 20,
|
val executionFrequency: Int = 2,
|
||||||
val generateCount: Int = 10000,
|
val generateCount: Int = 10000,
|
||||||
val parallelism: Int = ForkJoinPool.getCommonPoolParallelism())
|
val parallelism: Int = ForkJoinPool.getCommonPoolParallelism())
|
||||||
|
|
||||||
|
@ -133,17 +133,17 @@ private fun runLoadTest(loadTestConfiguration: LoadTestConfiguration) {
|
|||||||
|
|
||||||
private fun runStabilityTest(loadTestConfiguration: LoadTestConfiguration) {
|
private fun runStabilityTest(loadTestConfiguration: LoadTestConfiguration) {
|
||||||
runLoadTests(loadTestConfiguration, listOf(
|
runLoadTests(loadTestConfiguration, listOf(
|
||||||
// Self issue cash.
|
// Self issue cash. This is a pre test step to make sure vault have enough cash to work with.
|
||||||
StabilityTest.selfIssueTest to LoadTest.RunParameters(
|
StabilityTest.selfIssueTest(100) to LoadTest.RunParameters(
|
||||||
parallelism = loadTestConfiguration.parallelism,
|
parallelism = loadTestConfiguration.parallelism,
|
||||||
generateCount = loadTestConfiguration.generateCount,
|
generateCount = 1000,
|
||||||
clearDatabaseBeforeRun = false,
|
clearDatabaseBeforeRun = false,
|
||||||
executionFrequency = loadTestConfiguration.executionFrequency,
|
executionFrequency = 50,
|
||||||
gatherFrequency = 100,
|
gatherFrequency = 100,
|
||||||
disruptionPatterns = listOf(listOf()) // no disruptions
|
disruptionPatterns = listOf(listOf()) // no disruptions
|
||||||
),
|
),
|
||||||
// Send cash to a random party or exit cash, commands are generated randomly.
|
// Send cash to a random party or exit cash, commands are generated randomly.
|
||||||
StabilityTest.crossCashTest to LoadTest.RunParameters(
|
StabilityTest.crossCashTest(100) to LoadTest.RunParameters(
|
||||||
parallelism = loadTestConfiguration.parallelism,
|
parallelism = loadTestConfiguration.parallelism,
|
||||||
generateCount = loadTestConfiguration.generateCount,
|
generateCount = loadTestConfiguration.generateCount,
|
||||||
clearDatabaseBeforeRun = false,
|
clearDatabaseBeforeRun = false,
|
||||||
|
@ -1,29 +1,26 @@
|
|||||||
package net.corda.loadtest.tests
|
package net.corda.loadtest.tests
|
||||||
|
|
||||||
import net.corda.client.mock.Generator
|
import net.corda.client.mock.Generator
|
||||||
import net.corda.client.mock.pickOne
|
import net.corda.core.contracts.Amount
|
||||||
import net.corda.client.mock.replicatePoisson
|
|
||||||
import net.corda.core.contracts.USD
|
import net.corda.core.contracts.USD
|
||||||
import net.corda.core.failure
|
import net.corda.core.failure
|
||||||
import net.corda.core.flows.FlowException
|
import net.corda.core.flows.FlowException
|
||||||
import net.corda.core.getOrThrow
|
import net.corda.core.getOrThrow
|
||||||
|
import net.corda.core.serialization.OpaqueBytes
|
||||||
import net.corda.core.success
|
import net.corda.core.success
|
||||||
import net.corda.core.utilities.loggerFor
|
import net.corda.core.utilities.loggerFor
|
||||||
|
import net.corda.flows.CashFlowCommand
|
||||||
import net.corda.loadtest.LoadTest
|
import net.corda.loadtest.LoadTest
|
||||||
|
|
||||||
object StabilityTest {
|
object StabilityTest {
|
||||||
private val log = loggerFor<StabilityTest>()
|
private val log = loggerFor<StabilityTest>()
|
||||||
val crossCashTest = LoadTest<CrossCashCommand, Unit>(
|
fun crossCashTest(replication: Int) = LoadTest<CrossCashCommand, Unit>(
|
||||||
"Creating Cash transactions randomly",
|
"Creating Cash transactions",
|
||||||
generate = { _, _ ->
|
generate = { _, _ ->
|
||||||
val nodeMap = simpleNodes.associateBy { it.info.legalIdentity }
|
val payments = simpleNodes.flatMap { payer -> simpleNodes.map { payer to it } }
|
||||||
Generator.sequence(simpleNodes.map { node ->
|
.filter { it.first != it.second }
|
||||||
val possibleRecipients = nodeMap.keys.toList()
|
.map { (payer, payee) -> CrossCashCommand(CashFlowCommand.PayCash(Amount(1, USD), payee.info.legalIdentity, anonymous = true), payer) }
|
||||||
val moves = 0.5 to generateMove(1, USD, node.info.legalIdentity, possibleRecipients, anonymous = true)
|
Generator.pure(List(replication) { payments }.flatten())
|
||||||
val exits = 0.5 to generateExit(1, USD)
|
|
||||||
val command = Generator.frequency(listOf(moves, exits))
|
|
||||||
command.map { CrossCashCommand(it, nodeMap[node.info.legalIdentity]!!) }
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
interpret = { _, _ -> },
|
interpret = { _, _ -> },
|
||||||
execute = { command ->
|
execute = { command ->
|
||||||
@ -38,24 +35,16 @@ object StabilityTest {
|
|||||||
gatherRemoteState = {}
|
gatherRemoteState = {}
|
||||||
)
|
)
|
||||||
|
|
||||||
val selfIssueTest = LoadTest<SelfIssueCommand, Unit>(
|
fun selfIssueTest(replication: Int) = LoadTest<SelfIssueCommand, Unit>(
|
||||||
"Self issuing cash randomly",
|
"Self issuing lot of cash",
|
||||||
generate = { _, parallelism ->
|
generate = { _, _ ->
|
||||||
val generateIssue = Generator.pickOne(simpleNodes).bind { node ->
|
// Self issue cash is fast, its ok to flood the node with this command.
|
||||||
generateIssue(1000, USD, notary.info.notaryIdentity, listOf(node.info.legalIdentity), anonymous = true).map {
|
val generateIssue =
|
||||||
SelfIssueCommand(it, node)
|
simpleNodes.map { issuer ->
|
||||||
}
|
SelfIssueCommand(CashFlowCommand.IssueCash(Amount(100000, USD), OpaqueBytes.of(0), issuer.info.legalIdentity, notary.info.notaryIdentity, anonymous = true), issuer)
|
||||||
}
|
}
|
||||||
Generator.replicatePoisson(parallelism.toDouble(), generateIssue).bind {
|
Generator.pure(List(replication) { generateIssue }.flatten())
|
||||||
// We need to generate at least one
|
|
||||||
if (it.isEmpty()) {
|
|
||||||
Generator.sequence(listOf(generateIssue))
|
|
||||||
} else {
|
|
||||||
Generator.pure(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
interpret = { _, _ -> },
|
interpret = { _, _ -> },
|
||||||
execute = { command ->
|
execute = { command ->
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user