mirror of
https://github.com/corda/corda.git
synced 2024-12-27 08:22:35 +00:00
Reduce the dependencies of the JMeter project by copying (#118)
one function and listing required explicit dependencies instead of depending on loadtest
This commit is contained in:
parent
08d3361381
commit
4d19a594d6
@ -7,7 +7,16 @@ mainClassName = 'com.r3.corda.jmeter.Launcher'
|
||||
dependencies {
|
||||
compile project(':client:rpc')
|
||||
compile project(':finance')
|
||||
compile project(':tools:loadtest')
|
||||
|
||||
// https://mvnrepository.com/artifact/com.jcraft/jsch
|
||||
compile group: 'com.jcraft', name: 'jsch', version: '0.1.54'
|
||||
compile group: 'com.jcraft', name: 'jsch.agentproxy.core', version: '0.0.9'
|
||||
compile group: 'com.jcraft', name: 'jsch.agentproxy.sshagent', version: '0.0.9'
|
||||
compile group: 'com.jcraft', name: 'jsch.agentproxy.usocket-jna', version: '0.0.9'
|
||||
|
||||
// Log4J: logging framework (with SLF4J bindings)
|
||||
compile "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
|
||||
compile "org.apache.logging.log4j:log4j-core:$log4j_version"
|
||||
|
||||
// JMeter
|
||||
ext.jmVersion = "3.3"
|
||||
|
@ -0,0 +1,58 @@
|
||||
package com.r3.corda.jmeter
|
||||
|
||||
import com.jcraft.jsch.Buffer
|
||||
import com.jcraft.jsch.Identity
|
||||
import com.jcraft.jsch.IdentityRepository
|
||||
import com.jcraft.jsch.JSch
|
||||
import com.jcraft.jsch.agentproxy.AgentProxy
|
||||
import com.jcraft.jsch.agentproxy.connector.SSHAgentConnector
|
||||
import com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
|
||||
private val log = LoggerFactory.getLogger(Ssh::class.java)
|
||||
|
||||
/**
|
||||
* Creates a new [JSch] instance with identities loaded from the running SSH agent.
|
||||
*/
|
||||
fun setupJSchWithSshAgent(): JSch {
|
||||
val connector = SSHAgentConnector(JNAUSocketFactory())
|
||||
val agentProxy = AgentProxy(connector)
|
||||
val identities = agentProxy.identities
|
||||
require(identities.isNotEmpty()) { "No SSH identities found, please add one to the agent" }
|
||||
require(identities.size == 1) { "Multiple SSH identities found, don't know which one to pick" }
|
||||
val identity = identities[0]
|
||||
log.info("Using SSH identity ${String(identity.comment)}")
|
||||
|
||||
return JSch().apply {
|
||||
identityRepository = object : IdentityRepository {
|
||||
override fun getStatus(): Int {
|
||||
if (connector.isAvailable) {
|
||||
return IdentityRepository.RUNNING
|
||||
} else {
|
||||
return IdentityRepository.UNAVAILABLE
|
||||
}
|
||||
}
|
||||
|
||||
override fun getName() = connector.name
|
||||
override fun getIdentities(): Vector<Identity> = Vector(listOf(
|
||||
object : Identity {
|
||||
override fun clear() {}
|
||||
override fun getAlgName() = String(Buffer(identity.blob).string)
|
||||
override fun getName() = String(identity.comment)
|
||||
override fun isEncrypted() = false
|
||||
override fun getSignature(data: ByteArray?) = agentProxy.sign(identity.blob, data)
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
override fun decrypt() = true
|
||||
|
||||
override fun getPublicKeyBlob() = identity.blob
|
||||
override fun setPassphrase(passphrase: ByteArray?) = true
|
||||
}
|
||||
))
|
||||
|
||||
override fun remove(blob: ByteArray?) = throw UnsupportedOperationException()
|
||||
override fun removeAll() = throw UnsupportedOperationException()
|
||||
override fun add(bytes: ByteArray?) = throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package com.r3.corda.jmeter
|
||||
import com.jcraft.jsch.JSch
|
||||
import com.jcraft.jsch.Session
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.loadtest.setupJSchWithSshAgent
|
||||
import net.corda.nodeapi.internal.addShutdownHook
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.BufferedReader
|
||||
|
Loading…
Reference in New Issue
Block a user