mirror of
https://github.com/corda/corda.git
synced 2025-06-03 08:00:57 +00:00
Post-review updates; added integration tests
This commit is contained in:
parent
b76fc7de59
commit
500be9cbcd
@ -0,0 +1,8 @@
|
|||||||
|
package net.corda.nodeapi.internal
|
||||||
|
|
||||||
|
enum class NodeStatus {
|
||||||
|
WAITING_TO_START,
|
||||||
|
STARTING,
|
||||||
|
STARTED,
|
||||||
|
STOPPING
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package net.corda.node.jmx
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
|
import net.corda.nodeapi.internal.NodeStatus
|
||||||
|
import net.corda.testing.driver.DriverParameters
|
||||||
|
import net.corda.testing.driver.JmxPolicy
|
||||||
|
import net.corda.testing.driver.driver
|
||||||
|
import org.junit.Test
|
||||||
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.HttpURLConnection.*
|
||||||
|
import java.net.URL
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class NodeStatus {
|
||||||
|
|
||||||
|
@Test(timeout=300_000)
|
||||||
|
fun `node status is published via JMX`() {
|
||||||
|
driver(DriverParameters(notarySpecs = emptyList(), jmxPolicy = JmxPolicy.defaultEnabled())) {
|
||||||
|
val jmxAddress = startNode().get().jmxAddress.toString()
|
||||||
|
val nodeStatusURL = URL("http://$jmxAddress/jolokia/read/net.corda:name=Status,type=Node")
|
||||||
|
var jmxInfo = ""
|
||||||
|
|
||||||
|
with(nodeStatusURL.openConnection() as HttpURLConnection) {
|
||||||
|
requestMethod = "GET"
|
||||||
|
inputStream.bufferedReader().use {
|
||||||
|
it.lines().forEach { line ->
|
||||||
|
jmxInfo += line
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue {
|
||||||
|
jmxInfo.isNotEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
|
val jsonTree = ObjectMapper().readTree(jmxInfo)
|
||||||
|
val httpStatus = jsonTree.get("status").asInt()
|
||||||
|
val nodeStatus = jsonTree.get("value").get("Value").asText()
|
||||||
|
|
||||||
|
assertEquals(httpStatus, HTTP_OK)
|
||||||
|
assertEquals(nodeStatus, NodeStatus.STARTED.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package net.corda.node.jmx
|
||||||
|
|
||||||
|
import net.corda.testing.driver.DriverParameters
|
||||||
|
import net.corda.testing.driver.JmxPolicy
|
||||||
|
import net.corda.testing.driver.driver
|
||||||
|
import org.junit.Test
|
||||||
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.URL
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class Publish {
|
||||||
|
|
||||||
|
@Test(timeout=300_000)
|
||||||
|
fun `node publishes node information via JMX when configured to do so`() {
|
||||||
|
driver(DriverParameters(notarySpecs = emptyList(), jmxPolicy = JmxPolicy.defaultEnabled())) {
|
||||||
|
val jmxAddress = startNode().get().jmxAddress.toString()
|
||||||
|
val nodeStatusURL = URL("http://$jmxAddress/jolokia/read/net.corda:*")
|
||||||
|
var httpResponse = HttpURLConnection.HTTP_NOT_FOUND
|
||||||
|
with(nodeStatusURL.openConnection() as HttpURLConnection) {
|
||||||
|
requestMethod = "GET"
|
||||||
|
httpResponse = responseCode
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue {
|
||||||
|
httpResponse == HttpURLConnection.HTTP_OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -147,6 +147,7 @@ import net.corda.node.utilities.BindableNamedCacheFactory
|
|||||||
import net.corda.node.utilities.NamedThreadFactory
|
import net.corda.node.utilities.NamedThreadFactory
|
||||||
import net.corda.node.utilities.NotaryLoader
|
import net.corda.node.utilities.NotaryLoader
|
||||||
import net.corda.nodeapi.internal.NodeInfoAndSigned
|
import net.corda.nodeapi.internal.NodeInfoAndSigned
|
||||||
|
import net.corda.nodeapi.internal.NodeStatus
|
||||||
import net.corda.nodeapi.internal.SignedNodeInfo
|
import net.corda.nodeapi.internal.SignedNodeInfo
|
||||||
import net.corda.nodeapi.internal.cordapp.CordappLoader
|
import net.corda.nodeapi.internal.cordapp.CordappLoader
|
||||||
import net.corda.nodeapi.internal.cryptoservice.CryptoService
|
import net.corda.nodeapi.internal.cryptoservice.CryptoService
|
||||||
@ -384,13 +385,7 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
|||||||
|
|
||||||
protected val keyStoreHandler = KeyStoreHandler(configuration, cryptoService)
|
protected val keyStoreHandler = KeyStoreHandler(configuration, cryptoService)
|
||||||
|
|
||||||
enum class NodeStatus {
|
@Volatile
|
||||||
WAITING_TO_START,
|
|
||||||
STARTING,
|
|
||||||
STARTED,
|
|
||||||
STOPPING
|
|
||||||
}
|
|
||||||
|
|
||||||
private var nodeStatus = NodeStatus.WAITING_TO_START
|
private var nodeStatus = NodeStatus.WAITING_TO_START
|
||||||
|
|
||||||
private fun <T : Any> T.tokenize(): T {
|
private fun <T : Any> T.tokenize(): T {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user