Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(tools): fix Corda AIO flowdb image: JVM upgrade, flow permissions #3386

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,10 @@ export const SAMPLE_CORDAPP_DATA = Object.freeze({
[SampleCordappEnum.BASIC_FLOW]: {
rootDir: "/samples-kotlin/Basic/flow-database-access/",
cordappDirPartyA:
"/samples-kotlin/Basic/flow-database-access/build/nodes/ParticipantA/cordapps",
cordappDirPartyB:
"/samples-kotlin/Basic/flow-database-access/build/nodes/ParticipantB/cordapps",
cordappDirPartyC:
"/samples-kotlin/Basic/flow-database-access/build/nodes/ParticipantC/cordapps",
cordappDirNotary:
"/samples-kotlin/Basic/flow-database-access/build/nodes/Notary/cordapps",
"/samples-kotlin/Basic/flow-database-access/build/nodes/PartyA/cordapps",
cordappDirPartyB: "-",
cordappDirPartyC: "-",
cordappDirNotary: "-",
jars: [
{
jarRelativePath: "workflows/build/libs/workflows-0.1.jar",
Expand Down
65 changes: 22 additions & 43 deletions tools/docker/corda-all-in-one/corda-v4_8-flowdb/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
FROM docker:24.0.2-dind

ARG SAMPLES_KOTLIN_SHA=30fd841dd035934bae75ab8910da3b6e3d5d6ee7
ARG SAMPLES_KOTLIN_FLOWDB_SUB_DIR_PATH="./Basic/flow-database-access/"
ARG CORDA_TOOLS_SHELL_CLI_VERSION=4.8

WORKDIR /

RUN apk update

# Install dependencies of Docker Compose
RUN apk add py-pip python3-dev libffi-dev openssl-dev gcc libc-dev make

# Install git so we can check out the kotlin-samples repo of Corda
RUN apk add --no-cache git

# Fabric Samples needs bash, sh is not good enough here
RUN apk add --no-cache bash

# Need curl to run healthchecks
RUN apk add --no-cache curl

# The file binary is used to inspect exectubles when debugging container image issues
RUN apk add --no-cache file

RUN apk add --no-cache openjdk8

# Need gradle to execute the corda sample app setup commands
RUN apk add --no-cache gradle
# Delete openssh packages to avoid conflicting with versions that Alpine ships with
# py-pip python3-dev libffi-dev openssl-dev gcc libc-dev make: Dependencies of Docker Compose
# git: so we can check out the kotlin-samples repo of Corda
# curl: to run healthchecks
# file: binary is used to inspect exectubles when debugging container image issues
# augeas: - need it for editing config files
RUN apk del openssh* && apk update && apk add --no-cache \
py-pip python3-dev libffi-dev openssl-dev gcc libc-dev make \
git \
bash \
curl \
file \
augeas \
openssh \
openjdk17

ENV CACTUS_CFG_PATH=/etc/hyperledger/cactus
RUN mkdir -p $CACTUS_CFG_PATH

# OpenSSH - need to have it so we can shell in and install/instantiate contracts and troubleshoot
RUN apk add --no-cache openssh augeas

# Configure the OpenSSH server we just installed
RUN augtool 'set /files/etc/ssh/sshd_config/AuthorizedKeysFile ".ssh/authorized_keys /etc/authorized_keys/%u"'
RUN augtool 'set /files/etc/ssh/sshd_config/PermitRootLogin yes'
Expand All @@ -59,14 +46,19 @@ RUN cp $CACTUS_CFG_PATH/corda-aio-image.pub ~/.ssh/authorized_keys
# RUN cat /root-password.txt | chpasswd
RUN echo "root:root" | chpasswd

ARG CORDA_TOOLS_SHELL_CLI_VERSION=4.8
RUN curl https://download.corda.net/maven/corda-releases/net/corda/corda-tools-shell-cli/${CORDA_TOOLS_SHELL_CLI_VERSION}/corda-tools-shell-cli-${CORDA_TOOLS_SHELL_CLI_VERSION}-all.jar --output /corda-tools-shell-cli-all.jar
# This is what makes the "corda-shell" alias avaialble on the terminal
RUN java -jar /corda-tools-shell-cli-all.jar install-shell-extensions

RUN git clone https://github.com/corda/samples-kotlin.git
WORKDIR /samples-kotlin

ARG SAMPLES_KOTLIN_SHA=b7f814b2d6d57c654716ac572a307c3868dacf6d
RUN git checkout ${SAMPLES_KOTLIN_SHA}

ARG SAMPLES_KOTLIN_FLOWDB_SUB_DIR_PATH="./Basic/flow-database-access/"

COPY build.gradle /samples-kotlin/${SAMPLES_KOTLIN_FLOWDB_SUB_DIR_PATH}/build.gradle

WORKDIR /samples-kotlin/${SAMPLES_KOTLIN_FLOWDB_SUB_DIR_PATH}
Expand Down Expand Up @@ -105,31 +97,18 @@ EXPOSE 7005 7006 7007 7008

COPY supervisord.conf /etc/supervisord.conf
COPY run-party-a-server.sh /
COPY run-party-b-server.sh /
COPY run-party-c-server.sh /
COPY run-party-a-node.sh /
COPY run-party-b-node.sh /
COPY run-party-c-node.sh /
COPY run-notary-node.sh /
COPY healthcheck.sh /

# By default we only run the absolute minimum which is a single party's node.
# By default we only run the absolute minimum which is a single node.
# For more complex tests everything else can also be enabled via the env vars
# below so that if needed there is 2 parties, a notary and a dedicated web server
# for all 3 of those nodes.
# "Web server" => the same one as in the official corda samples-kotlin repo
ENV PARTY_A_NODE_ENABLED="true"
ENV PARTY_A_WEB_SRV_ENABLED="false"

ENV PARTY_B_NODE_ENABLED="true"
ENV PARTY_B_WEB_SRV_ENABLED="false"

ENV PARTY_C_NODE_ENABLED="true"
ENV PARTY_C_WEB_SRV_ENABLED="false"

ENV NOTARY_NODE_ENABLED="true"

# Extend the parent image's entrypoint
# Extend the entrypoint of the image
# https://superuser.com/questions/1459466/can-i-add-an-additional-docker-entrypoint-script
ENTRYPOINT ["/usr/bin/supervisord"]
CMD ["--configuration", "/etc/supervisord.conf", "--nodaemon"]
Expand Down
110 changes: 51 additions & 59 deletions tools/docker/corda-all-in-one/corda-v4_8-flowdb/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import static org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
import static org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9

buildscript { //properties that you need to build the project

Properties constants = new Properties()
Expand All @@ -14,7 +17,15 @@ buildscript { //properties that you need to build the project
quasar_version = constants.getProperty("quasarVersion")
log4j_version = constants.getProperty("log4jVersion")
slf4j_version = constants.getProperty("slf4jVersion")
corda_shell_version = constants.getProperty("cordaShellVersion")
corda_platform_version = constants.getProperty("platformVersion").toInteger()

testJvmArgs = ['--add-opens', 'java.base/java.time=ALL-UNNAMED', '--add-opens', 'java.base/java.io=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED', '--add-opens', 'java.base/java.net=ALL-UNNAMED',
'--add-opens', 'java.base/java.nio=ALL-UNNAMED', '--add-opens', 'java.base/java.lang.invoke=ALL-UNNAMED',
'--add-opens', 'java.base/java.security.cert=ALL-UNNAMED', '--add-opens', 'java.base/java.security=ALL-UNNAMED',
'--add-opens', 'java.base/javax.net.ssl=ALL-UNNAMED', '--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.util.concurrent=ALL-UNNAMED', '--add-opens', 'java.sql/java.sql=ALL-UNNAMED',]
}

repositories {
Expand All @@ -32,21 +43,17 @@ buildscript { //properties that you need to build the project
}

allprojects { //Properties that you need to compile your project (The application)
apply plugin: 'kotlin'

repositories {
mavenLocal()
mavenCentral()
maven { url 'https://download.corda.net/maven/corda' }
maven { url 'https://jitpack.io' }
}
apply from: "${rootProject.projectDir}/../repositories.gradle"
apply plugin: 'org.jetbrains.kotlin.jvm'

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
languageVersion = "1.2"
apiVersion = "1.2"
jvmTarget = "1.8"
compilerOptions {
languageVersion = KOTLIN_1_9
apiVersion = KOTLIN_1_9
jvmTarget = JVM_17
javaParameters = true // Useful for reflection.
freeCompilerArgs = ['-Xjvm-default=all-compatibility']
allWarningsAsErrors = true
}
}

Expand All @@ -69,19 +76,24 @@ sourceSets {
}
}

//Module dependencis
//Module dependencies
dependencies {
// Corda dependencies.
cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version"
cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version"
cordaRuntime "$corda_release_group:corda:$corda_release_version"
cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version"
corda "$corda_release_group:corda:$corda_release_version"

// CorDapp dependencies.
cordapp project(":workflows")

cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}"
cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}"
cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version"
cordaProvided "$corda_core_release_group:corda-core:$corda_core_release_version"
cordaProvided "org.apache.logging.log4j:log4j-slf4j2-impl:${log4j_version}"
cordaProvided "org.apache.logging.log4j:log4j-web:${log4j_version}"
cordaProvided "org.slf4j:jul-to-slf4j:$slf4j_version"
cordaDriver "net.corda:corda-shell:$corda_shell_version"
}

cordapp {
targetPlatformVersion corda_platform_version.toInteger()
}

task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
Expand All @@ -90,48 +102,28 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
deploy = false
}
cordapp project(':workflows')
rpcUsers = [[ user: "user1", "password": "password", "permissions": ["ALL"]]]
runSchemaMigration = true
runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid
//problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change
//it to false for quicker project compiling time.
}
node {
name "O=Notary,L=London,C=GB"
notary = [validating: false]
p2pPort 10002
name "O=PartyA,L=London,C=GB"
p2pPort 10005
rpcSettings {
useSsl false
standAloneBroker false
address "0.0.0.0:10003"
adminAddress "0.0.0.0:10103"
}
}
node {
name "O=ParticipantA,L=London,C=GB"
p2pPort 10007
rpcSettings {
useSsl false
standAloneBroker false
address "0.0.0.0:10008"
adminAddress "0.0.0.0:10108"
}
}
node {
name "O=ParticipantB,L=New York,C=US"
p2pPort 10010
rpcSettings {
useSsl false
standAloneBroker false
address "0.0.0.0:10011"
adminAddress "0.0.0.0:10111"
}
}
node {
name "O=ParticipantC,L=Paris,C=FR"
p2pPort 10013
rpcSettings {
useSsl false
standAloneBroker false
address "0.0.0.0:10014"
adminAddress "0.0.0.0:10114"
address("0.0.0.0:10006")
adminAddress("0.0.0.0:10046")
}
rpcUsers = [[user: "user1", "password": "test", "permissions": [
"StartFlow.com.flowdb.AddTokenValueFlow",
"StartFlow.com.flowdb.UpdateTokenValueFlow",
"StartFlow.com.flowdb.QueryTokenValueFlow",
// Without this, the connector cannot connect - fails with the error logs below"
// Permission Exception establishing connection: User not authorized to perform RPC call public abstract net.corda.core.node.NodeInfo net.corda.core.messaging.CordaRPCOps.nodeInfo() with target []'
"InvokeRpc.nodeInfo",

// net.corda.client.rpc.PermissionException: User not authorized to perform RPC call public abstract java.util.List net.corda.core.messaging.CordaRPCOps.registeredFlows() with target []
"InvokeRpc.registeredFlows",
"InvokeRpc.startFlowDynamic"
]]]
}
}
}
20 changes: 0 additions & 20 deletions tools/docker/corda-all-in-one/corda-v4_8-flowdb/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,8 @@ then
curl -vv -i -X OPTIONS http://127.0.0.1:10009/web/iou/
fi

if [ "$PARTY_B_WEB_SRV_ENABLED" = "true" ]
then
curl -vv -i -X OPTIONS http://127.0.0.1:10012/web/iou/
fi

if [ "$PARTY_C_WEB_SRV_ENABLED" = "true" ]
then
curl -vv -i -X OPTIONS http://127.0.0.1:10015/web/iou/
fi


if [ "$PARTY_A_NODE_ENABLED" = "true" ]
then
curl -v 'http://localhost:7005/jolokia/exec/org.apache.activemq.artemis:address=%22rpc.server%22,broker=%22RPC%22,component=addresses,queue=%22rpc.server%22,routing-type=%22multicast%22,subcomponent=queues/countMessages()/'
fi

if [ "$PARTY_B_NODE_ENABLED" = "true" ]
then
curl -v 'http://localhost:7006/jolokia/exec/org.apache.activemq.artemis:address=%22rpc.server%22,broker=%22RPC%22,component=addresses,queue=%22rpc.server%22,routing-type=%22multicast%22,subcomponent=queues/countMessages()/'
fi

if [ "$PARTY_C_NODE_ENABLED" = "true" ]
then
curl -v 'http://localhost:7007/jolokia/exec/org.apache.activemq.artemis:address=%22rpc.server%22,broker=%22RPC%22,component=addresses,queue=%22rpc.server%22,routing-type=%22multicast%22,subcomponent=queues/countMessages()/'
fi

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

if [ "$PARTY_A_NODE_ENABLED" = "true" ]
then
java -Dcapsule.jvm.args="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -javaagent:drivers/jolokia-jvm-1.6.0-agent.jar=port=7005,logHandlerClass=net.corda.node.JolokiaSlf4jAdapter" -Dname=ParticipantA -jar /samples-kotlin/Basic/flow-database-access/build/nodes/ParticipantA/corda.jar
java -Dcapsule.jvm.args="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -javaagent:drivers/jolokia-jvm-1.6.2-agent.jar=port=7005,logHandlerClass=net.corda.node.JolokiaSlf4jAdapter" -Dname=PartyA -jar /samples-kotlin/Basic/flow-database-access/build/nodes/PartyA/corda.jar
else
sleep infinity
fi

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading