CORDA-540: Ensure that registration of a test node was a success prior to performing further testing with it (#1379)

Registration may fail due to low level serialization problems especially when running in AMQP mode
Also some minor improvements for exceptions reporting and test coverage
This commit is contained in:
Viktor Kolomeyko
2017-08-31 18:38:29 +01:00
committed by GitHub
parent 9a8e7294e7
commit 485c2feb83
13 changed files with 64 additions and 7 deletions

View File

@ -605,8 +605,8 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
val address: SingleMessageRecipient = networkMapAddress ?:
network.getAddressOfParty(PartyInfo.Node(info)) as SingleMessageRecipient
// Register for updates, even if we're the one running the network map.
return sendNetworkMapRegistration(address).flatMap { (error) ->
check(error == null) { "Unable to register with the network map service: $error" }
return sendNetworkMapRegistration(address).flatMap { response: RegistrationResponse ->
check(response.error == null) { "Unable to register with the network map service: ${response.error}" }
// The future returned addMapService will complete on the same executor as sendNetworkMapRegistration, namely the one used by net
services.networkMapCache.addMapService(network, address, true, null)
}

View File

@ -330,7 +330,9 @@ open class Node(override val configuration: FullNodeConfiguration,
_startupComplete.set(Unit)
}
}, {})
},
{ th -> logger.error("Unexpected exception", th)}
)
shutdownHook = addShutdownHook {
stop()
}

View File

@ -117,7 +117,10 @@ open class NodeStartup(val args: Array<String>) {
logger.error("Shell failed to start", e)
}
}
}, {})
},
{
th -> logger.error("Unexpected exception during registration", th)
})
node.run()
}

View File

@ -35,6 +35,7 @@ import net.corda.node.services.network.NetworkMapService.Companion.SUBSCRIPTION_
import net.corda.node.utilities.AddOrRemove
import net.corda.node.utilities.AddOrRemove.ADD
import net.corda.node.utilities.AddOrRemove.REMOVE
import java.io.IOException
import java.security.PublicKey
import java.security.SignatureException
import java.time.Instant
@ -243,6 +244,10 @@ abstract class AbstractNetworkMapService(services: ServiceHubInternal,
request.wireReg.verified()
} catch (e: SignatureException) {
return RegistrationResponse("Invalid signature on request")
} catch (e: IOException) {
val msg = "Unexpected IO exception: ${e.message}"
logger.error(msg, e)
return RegistrationResponse(msg)
}
val node = change.node