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