loadtest: Fix config loading, add missing fields

This commit is contained in:
Andras Slemmer 2017-02-27 11:35:29 +00:00
parent 298c45c314
commit 986bd548fa
3 changed files with 27 additions and 29 deletions

View File

@ -1,12 +1,16 @@
package net.corda.loadtest
import com.typesafe.config.Config
import java.nio.file.Path
import net.corda.node.services.config.*
/**
* @param sshUser The UNIX username to use for SSH auth.
* @param localCertificatesBaseDirectory The base directory to put node certificates in.
* @param localTunnelStartingPort The local starting port to allocate tunneling ports from.
* @param nodeHosts The nodes' resolvable addresses.
* @param rpcUsername The RPC user's name to establish the RPC connection as.
* @param rpcPassword The RPC user's password.
* @param remoteNodeDirectory The remote node directory.
* @param remoteMessagingPort The remote Artemis messaging port.
* @param remoteSystemdServiceName The name of the node's systemd service
@ -16,14 +20,16 @@ import java.nio.file.Path
* for disruptions.
*/
data class LoadTestConfiguration(
val sshUser: String,
val localCertificatesBaseDirectory: Path,
val localTunnelStartingPort: Int,
val nodeHosts: List<String>,
val rpcUsername: String,
val rpcPassword: String,
val remoteNodeDirectory: Path,
val remoteMessagingPort: Int,
val remoteSystemdServiceName: String,
val seed: Long?
)
val config: Config
) {
val sshUser: String by config
val localCertificatesBaseDirectory: Path by config
val localTunnelStartingPort: Int by config
val nodeHosts: List<String> = config.getStringList("nodeHosts")
val rpcUsername: String by config
val rpcPassword: String by config
val remoteNodeDirectory: Path by config
val remoteMessagingPort: Int by config
val remoteSystemdServiceName: String by config
val seed: Long? by config
}

View File

@ -44,26 +44,16 @@ import java.nio.file.Paths
*/
fun main(args: Array<String>) {
if (args.isEmpty()) {
throw IllegalArgumentException("Usage: <binary> PATH_TO_CONFIG")
}
val defaultConfig = ConfigFactory.parseResources("loadtest-reference.conf", ConfigParseOptions.defaults().setAllowMissing(false))
val customConfig = ConfigFactory.parseFile(File(args[0]), ConfigParseOptions.defaults().setAllowMissing(false))
val resolvedConfig = customConfig.withFallback(defaultConfig).resolve()
val loadTestConfiguration = LoadTestConfiguration(
sshUser = if (resolvedConfig.hasPath("sshUser")) resolvedConfig.getString("sshUser") else System.getProperty("user.name"),
localCertificatesBaseDirectory = Paths.get(resolvedConfig.getString("localCertificatesBaseDirectory")),
localTunnelStartingPort = resolvedConfig.getInt("localTunnelStartingPort"),
nodeHosts = resolvedConfig.getStringList("nodeHosts"),
rpcUsername = "corda",
rpcPassword = "rgb",
remoteNodeDirectory = Paths.get("/opt/corda"),
remoteMessagingPort = 10002,
remoteSystemdServiceName = "corda",
seed = if (resolvedConfig.hasPath("seed")) resolvedConfig.getLong("seed") else null
val defaultSshUserConfig = ConfigFactory.parseMap(
if (defaultConfig.hasPath("sshUser")) emptyMap() else mapOf("sshUser" to System.getProperty("user.name"))
)
val customConfig = ConfigFactory.parseFile(File(args[0]), ConfigParseOptions.defaults().setAllowMissing(false))
val resolvedConfig = customConfig.withFallback(defaultConfig).withFallback(defaultSshUserConfig).resolve()
val loadTestConfiguration = LoadTestConfiguration(resolvedConfig)
if (loadTestConfiguration.nodeHosts.isEmpty()) {
throw IllegalArgumentException("Please specify at least one node host")

View File

@ -2,6 +2,8 @@
# sshUser = "someusername", by default it uses the System property "user.name"
localCertificatesBaseDirectory = "build/load-test/certificates"
localTunnelStartingPort = 10000
remoteNodeDirectory = "/opt/r3cev"
remoteMessagingPort = 31337
remoteSystemdServiceName = "r3cev-node"
remoteNodeDirectory = "/opt/corda"
remoteMessagingPort = 10002
remoteSystemdServiceName = "corda"
rpcUsername = "corda"
rpcPassword = "rgb"