add configuration option to enable compatibility zone whilst running devMode

* add configuration option to enable compatibility zone whilst running devMode

* add documentation about allowCompatibilityZone

* address review comments

* remove extra doc lines

* add changelog entry

* Update changelog.rst
This commit is contained in:
Stefano Franz
2018-06-12 11:03:32 +01:00
committed by GitHub
parent dc220ef18e
commit 0f3453d1c7
4 changed files with 34 additions and 18 deletions

View File

@ -7,6 +7,8 @@ release, see :doc:`upgrade-notes`.
Unreleased Unreleased
========== ==========
* Add ``devModeOptions.allowCompatibilityZone`` to re-enable the use of a compatibility zone and ``devMode``
* Fixed an issue where ``trackBy`` was returning ``ContractStates`` from a transaction that were not being tracked. The * Fixed an issue where ``trackBy`` was returning ``ContractStates`` from a transaction that were not being tracked. The
unrelated ``ContractStates`` will now be filtered out from the returned ``Vault.Update``. unrelated ``ContractStates`` will now be filtered out from the returned ``Vault.Update``.

View File

@ -187,6 +187,12 @@ absolute path to the node's base directory.
.. note:: Only one of ``compatibilityZoneURL`` or ``networkServices`` should be used. .. note:: Only one of ``compatibilityZoneURL`` or ``networkServices`` should be used.
:devModeOptions: Allows modification of certain ``devMode`` features
:allowCompatibilityZone: Allows a node configured to operate in development mode to connect to a compatibility zone.
.. note:: This is an unsupported configuration.
:jvmArgs: An optional list of JVM args, as strings, which replace those inherited from the command line when launching via ``corda.jar`` :jvmArgs: An optional list of JVM args, as strings, which replace those inherited from the command line when launching via ``corda.jar``
only. e.g. ``jvmArgs = [ "-Xmx220m", "-Xms220m", "-XX:+UseG1GC" ]`` only. e.g. ``jvmArgs = [ "-Xmx220m", "-Xms220m", "-XX:+UseG1GC" ]``

View File

@ -78,7 +78,7 @@ interface NodeConfiguration : NodeSSLConfiguration {
} }
} }
data class DevModeOptions(val disableCheckpointChecker: Boolean = false) data class DevModeOptions(val disableCheckpointChecker: Boolean = false, val allowCompatibilityZone: Boolean = false)
fun NodeConfiguration.shouldCheckCheckpoints(): Boolean { fun NodeConfiguration.shouldCheckCheckpoints(): Boolean {
return this.devMode && this.devModeOptions?.disableCheckpointChecker != true return this.devMode && this.devModeOptions?.disableCheckpointChecker != true
@ -255,16 +255,19 @@ data class NodeConfigurationImpl(
private fun validateDevModeOptions(): List<String> { private fun validateDevModeOptions(): List<String> {
if (devMode) { if (devMode) {
compatibilityZoneURL?.let { compatibilityZoneURL?.let {
return listOf("'compatibilityZoneURL': present. Property cannot be set when 'devMode' is true.") if (devModeOptions?.allowCompatibilityZone != true) {
return listOf("'compatibilityZoneURL': present. Property cannot be set when 'devMode' is true unless devModeOptions.allowCompatibilityZone is also true")
}
} }
// if compatibiliZoneURL is set then it will be copied into the networkServices field and thus skipping // if compatibiliZoneURL is set then it will be copied into the networkServices field and thus skipping
// this check by returning above is fine. // this check by returning above is fine.
networkServices?.let { networkServices?.let {
return listOf("'networkServices': present. Property cannot be set when 'devMode' is true.") if (devModeOptions?.allowCompatibilityZone != true) {
return listOf("'networkServices': present. Property cannot be set when 'devMode' is true unless devModeOptions.allowCompatibilityZone is also true")
}
} }
} }
return emptyList() return emptyList()
} }

View File

@ -1,21 +1,15 @@
package net.corda.node.services.config package net.corda.node.services.config
import com.typesafe.config.Config import com.typesafe.config.*
import com.typesafe.config.ConfigException
import com.typesafe.config.ConfigFactory
import com.typesafe.config.ConfigParseOptions
import com.typesafe.config.ConfigValueFactory
import net.corda.core.internal.toPath import net.corda.core.internal.toPath
import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.NetworkHostAndPort
import net.corda.core.utilities.seconds import net.corda.core.utilities.seconds
import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.ALICE_NAME
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
import net.corda.tools.shell.SSHDConfiguration import net.corda.tools.shell.SSHDConfiguration
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.*
import org.assertj.core.api.Assertions.assertThatCode
import org.assertj.core.api.Assertions.assertThatThrownBy
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Test import org.junit.Test
import java.net.URI import java.net.URI
import java.net.URL import java.net.URL
@ -138,6 +132,17 @@ class NodeConfigurationImplTest {
assertThat(errors).hasOnlyOneElementSatisfying { error -> error.contains("compatibilityZoneURL") && error.contains("devMode") } assertThat(errors).hasOnlyOneElementSatisfying { error -> error.contains("compatibilityZoneURL") && error.contains("devMode") }
} }
@Test
fun `validation succeeds when compatibilityZoneURL is present and devMode is true and allowCompatibilityZoneURL is set`() {
val configuration = testConfiguration.copy(
devMode = true,
compatibilityZoneURL = URL("https://r3.com"),
devModeOptions = DevModeOptions(allowCompatibilityZone = true))
val errors = configuration.validate()
assertThat(errors).isEmpty()
}
@Test @Test
fun `errors for nested config keys contain path`() { fun `errors for nested config keys contain path`() {
var rawConfig = ConfigFactory.parseResources("working-config.conf", ConfigParseOptions.defaults().setAllowMissing(false)) var rawConfig = ConfigFactory.parseResources("working-config.conf", ConfigParseOptions.defaults().setAllowMissing(false))