-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EG-1856: Allow users to specify Dockerform ports (#305)
* Allow users to specify Dockerform ports * Updated changelog * Addressing PR comments * Added unit tests to validate correct parsing * Addressed PR comments Co-authored-by: Andrei Palade <[email protected]>
- Loading branch information
Showing
9 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
cordformation/src/main/kotlin/net/corda/plugins/ConfigurationUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package net.corda.plugins | ||
|
||
import org.gradle.api.InvalidUserDataException | ||
import java.net.URI | ||
import java.net.URISyntaxException | ||
|
||
class ConfigurationUtils { | ||
|
||
companion object { | ||
|
||
fun parsePort(address: String): Int { | ||
return try { | ||
URI(null, address, null, null, null).port | ||
} catch (ex: URISyntaxException) { | ||
throw InvalidUserDataException("Invalid host and port syntax for RPC address, expected host:port") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
cordformation/src/test/kotlin/net/corda/plugins/ConfigurationUtilsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.corda.plugins | ||
|
||
|
||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
|
||
class ConfigurationUtilsTest { | ||
|
||
@Test | ||
fun `check correct port value parsing`() { | ||
assertEquals(10000, ConfigurationUtils.parsePort("localhost:10000")) | ||
} | ||
|
||
@Test | ||
fun `missing port value correctly identified in valid address`() { | ||
assertEquals(-1, ConfigurationUtils.parsePort("localhost")) | ||
} | ||
|
||
@Test | ||
fun `missing port value correctly identified in invalid address`() { | ||
assertEquals(-1, ConfigurationUtils.parsePort("localhost!")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
cordformation/src/test/resources/net/corda/plugins/DeployTwoNodeCordappWithDocker.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
plugins { | ||
id 'net.corda.plugins.cordformation' | ||
} | ||
|
||
apply from: 'repositories.gradle' | ||
|
||
dependencies { | ||
cordaRuntime "$corda_group:corda:$corda_release_version" | ||
cordaRuntime "$corda_group:corda-node-api:$corda_release_version" | ||
cordapp "$corda_group:corda-finance-contracts:$corda_release_version" | ||
cordapp "$corda_group:corda-finance-workflows:$corda_release_version" | ||
} | ||
|
||
task prepareDockerNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar']) { | ||
nodeDefaults { | ||
|
||
cordapps = ["$corda_group:corda-finance-contracts:$corda_release_version", | ||
"$corda_group:corda-finance-workflows:$corda_release_version"] | ||
|
||
projectCordapp { | ||
deploy false | ||
} | ||
} | ||
node { | ||
name "O=Notary Service,L=London,C=GB" | ||
notary = [validating : false] | ||
p2pPort 10002 | ||
rpcSettings { | ||
address("localhost:10003") | ||
adminAddress("localhost:10043") | ||
} | ||
} | ||
node { | ||
name "O=BankOfCorda,L=London,C=GB" | ||
p2pPort 10005 | ||
rpcSettings { | ||
address("localhost:10006") | ||
adminAddress("localhost:10046") | ||
} | ||
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] | ||
} | ||
} |