mirror of
https://github.com/corda/corda.git
synced 2025-06-16 14:18:20 +00:00
Merge remote-tracking branch 'open/master' into colljos-os-merge-rc01
This commit is contained in:
@ -31,8 +31,8 @@ import static net.corda.finance.Currencies.DOLLARS;
|
||||
import static net.corda.finance.contracts.GetBalances.getCashBalance;
|
||||
import static net.corda.node.services.Permissions.invokeRpc;
|
||||
import static net.corda.node.services.Permissions.startFlow;
|
||||
import static net.corda.testing.TestConstants.getALICE_NAME;
|
||||
import static net.corda.testing.TestConstants.getDUMMY_NOTARY_NAME;
|
||||
import static net.corda.testing.TestConstants.ALICE_NAME;
|
||||
import static net.corda.testing.TestConstants.DUMMY_NOTARY_NAME;
|
||||
|
||||
public class CordaRPCJavaClientTest extends NodeBasedTest {
|
||||
public CordaRPCJavaClientTest() {
|
||||
@ -41,7 +41,7 @@ public class CordaRPCJavaClientTest extends NodeBasedTest {
|
||||
|
||||
@ClassRule
|
||||
public static IntegrationTestSchemas databaseSchemas = new IntegrationTestSchemas(IntegrationTestKt.toDatabaseSchemaName(getALICE_NAME()),
|
||||
IntegrationTestKt.toDatabaseSchemaName(getDUMMY_NOTARY_NAME()));
|
||||
IntegrationTestKt.toDatabaseSchemaName(DUMMY_NOTARY_NAME));
|
||||
|
||||
private List<String> perms = Arrays.asList(
|
||||
startFlow(CashPaymentFlow.class),
|
||||
@ -65,7 +65,7 @@ public class CordaRPCJavaClientTest extends NodeBasedTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
node = startNode(getALICE_NAME(), 1, singletonList(rpcUser));
|
||||
node = startNode(ALICE_NAME, 1, singletonList(rpcUser));
|
||||
client = new CordaRPCClient(requireNonNull(node.getInternals().getConfiguration().getRpcAddress()));
|
||||
}
|
||||
|
||||
|
54
client/rpc/src/test/kotlin/net/corda/client/rpc/Measure.kt
Normal file
54
client/rpc/src/test/kotlin/net/corda/client/rpc/Measure.kt
Normal file
@ -0,0 +1,54 @@
|
||||
package net.corda.client.rpc
|
||||
|
||||
import net.corda.core.internal.uncheckedCast
|
||||
import kotlin.reflect.KCallable
|
||||
import kotlin.reflect.jvm.reflect
|
||||
|
||||
/**
|
||||
* These functions may be used to run measurements of a function where the parameters are chosen from corresponding
|
||||
* [Iterable]s in a lexical manner. An example use case would be benchmarking the speed of a certain function call using
|
||||
* different combinations of parameters.
|
||||
*/
|
||||
|
||||
fun <A : Any, R> measure(a: Iterable<A>, f: (A) -> R) =
|
||||
measure(listOf(a), f.reflect()!!) { f(uncheckedCast(it[0])) }
|
||||
|
||||
fun <A : Any, B : Any, R> measure(a: Iterable<A>, b: Iterable<B>, f: (A, B) -> R) =
|
||||
measure(listOf(a, b), f.reflect()!!) { f(uncheckedCast(it[0]), uncheckedCast(it[1])) }
|
||||
|
||||
fun <A : Any, B : Any, C : Any, R> measure(a: Iterable<A>, b: Iterable<B>, c: Iterable<C>, f: (A, B, C) -> R) =
|
||||
measure(listOf(a, b, c), f.reflect()!!) { f(uncheckedCast(it[0]), uncheckedCast(it[1]), uncheckedCast(it[2])) }
|
||||
|
||||
fun <A : Any, B : Any, C : Any, D : Any, R> measure(a: Iterable<A>, b: Iterable<B>, c: Iterable<C>, d: Iterable<D>, f: (A, B, C, D) -> R) =
|
||||
measure(listOf(a, b, c, d), f.reflect()!!) { f(uncheckedCast(it[0]), uncheckedCast(it[1]), uncheckedCast(it[2]), uncheckedCast(it[3])) }
|
||||
|
||||
private fun <R> measure(paramIterables: List<Iterable<Any?>>, kCallable: KCallable<R>, call: (Array<Any?>) -> R): Iterable<MeasureResult<R>> {
|
||||
val kParameters = kCallable.parameters
|
||||
return iterateLexical(paramIterables).map { params ->
|
||||
MeasureResult(
|
||||
// For example an underscore param in a lambda does not have a name:
|
||||
parameters = params.mapIndexed { index, param -> Pair(kParameters[index].name, param) },
|
||||
result = call(params.toTypedArray())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class MeasureResult<out R>(
|
||||
val parameters: List<Pair<String?, Any?>>,
|
||||
val result: R
|
||||
)
|
||||
|
||||
fun <A> iterateLexical(iterables: List<Iterable<A>>): Iterable<List<A>> {
|
||||
val result = ArrayList<List<A>>()
|
||||
fun iterateLexicalHelper(index: Int, list: List<A>) {
|
||||
if (index < iterables.size) {
|
||||
iterables[index].forEach {
|
||||
iterateLexicalHelper(index + 1, list + it)
|
||||
}
|
||||
} else {
|
||||
result.add(list)
|
||||
}
|
||||
}
|
||||
iterateLexicalHelper(0, emptyList())
|
||||
return result
|
||||
}
|
@ -9,9 +9,9 @@ import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.core.utilities.millis
|
||||
import net.corda.node.services.messaging.RPCServerConfiguration
|
||||
import net.corda.testing.internal.testThreadFactory
|
||||
import net.corda.testing.node.internal.RPCDriverDSL
|
||||
import net.corda.testing.node.internal.rpcDriver
|
||||
import net.corda.testing.internal.testThreadFactory
|
||||
import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet
|
||||
import org.junit.After
|
||||
import org.junit.Test
|
||||
|
@ -12,7 +12,6 @@ import net.corda.testing.node.internal.performance.startPublishingFixedRateInjec
|
||||
import net.corda.testing.node.internal.performance.startReporter
|
||||
import net.corda.testing.node.internal.performance.startTightLoopInjector
|
||||
import net.corda.testing.node.internal.rpcDriver
|
||||
import net.corda.testing.measure
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
@ -1,6 +1,9 @@
|
||||
package net.corda.client.rpc
|
||||
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.messaging.RPCOps
|
||||
import net.corda.node.services.Permissions
|
||||
import net.corda.node.services.messaging.rpcContext
|
||||
import net.corda.nodeapi.internal.config.User
|
||||
import net.corda.testing.node.internal.RPCDriverDSL
|
||||
|
Reference in New Issue
Block a user