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

Small PR to address missing content for docker builds #461

Merged
merged 2 commits into from
Jan 17, 2024
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
1 change: 1 addition & 0 deletions docker/pdo_ccf_base.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ARG ADD_APT_PKGS=
ENV DEBIAN_FRONTEND "noninteractive"
RUN apt-get update \
&& apt-get install -y -q \
lsof \
python \
python3-dev \
python3-venv \
Expand Down
12 changes: 7 additions & 5 deletions docker/tools/start_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SCRIPT_NAME=$(basename ${BASH_SOURCE[-1]} )
# -----------------------------------------------------------------
# Process command line arguments
# -----------------------------------------------------------------
F_COUNT=5
F_LOGLEVEL=
F_MODE=build
F_REGISTER=no
Expand All @@ -36,8 +37,8 @@ F_LEDGER_URL=
F_USAGE='-c|--count -i|--interface [hostname] -1|--ledger [url] "
F_USAGE+="--loglevel [debug|info|warn] -m|--mode [build|copy|skip] -r|--register'

SHORT_OPTS='i:l:m:r'
LONG_OPTS='interface:,ledger:,loglevel:,mode:,register'
SHORT_OPTS='c:i:l:m:r'
LONG_OPTS='count:,interface:,ledger:,loglevel:,mode:,register'

TEMP=$(getopt -o ${SHORT_OPTS} --long ${LONG_OPTS} -n "${SCRIPT_NAME}" -- "$@")
if [ $? != 0 ] ; then echo "Usage: ${SCRIPT_NAME} ${F_USAGE}" >&2 ; exit 1 ; fi
Expand Down Expand Up @@ -73,18 +74,19 @@ export PDO_LEDGER_ADDRESS=$(force_to_ip ${PDO_HOSTNAME})
export PDO_LEDGER_URL=${PDO_LEDGER_URL:-http://${PDO_LEDGER_ADDRESS}:6600}
if [ ! -z "${F_LEDGER_URL}" ] ; then
export PDO_LEDGER_URL=${F_LEDGER_URL}
export PDO_LEDGER_ADDRESS=$( echo $PDO_LEDGER_URL | awk -F[/:] '{print $4}' )
fi

export no_proxy=$PDO_HOSTNAME,$no_proxy
export NO_PROXY=$PDO_HOSTNAME,$NO_PROXY
export no_proxy=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$no_proxy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already doing it for PDO_HOSTNAME and for most folks this will result with the "right" thing but for somebody having a proxy and one of the services outside of proxy, this could lead to unexpected behaviour given how hidden this is here? Don't immediately have a good alternative but we could mention it in the ready and/or add a log output here? No strong feeling in leaving it as is, though, either ...

export NO_PROXY=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$NO_PROXY

# -----------------------------------------------------------------
# Handle the configuration of the services
# -----------------------------------------------------------------
if [ "${F_MODE,,}" == "build" ]; then
yell configure services for host $PDO_HOSTNAME and ledger $PDO_LEDGER_URL
try ${PDO_INSTALL_ROOT}/bin/pdo-configure-services -t ${PDO_SOURCE_ROOT}/build/template -o ${PDO_HOME}\
--count 5 5 5
--count ${F_COUNT} ${F_COUNT} ${F_COUNT}
elif [ "${F_MODE,,}" == "copy" ]; then
yell copy the configuration from xfer/services/etc and xfer/services/keys
try mkdir -p ${PDO_HOME}/etc ${PDO_HOME}/keys
Expand Down
2 changes: 1 addition & 1 deletion ledgers/ccf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ $(PYTHON_DIR) :
install : install-pdo-tp

PDO_BASH_SCRIPTS=start_ccf_network.sh stop_cchost.sh
PDO_PYTHON_SCRIPTS=configure_ccf_network.py generate_ledger_authority.py fetch_ledger_authority.py register_enclave_attestation_verification_policy.py utils.py
PDO_PYTHON_SCRIPTS=configure_ccf_network.py generate_ledger_authority.py fetch_ledger_authority.py register_enclave_attestation_verification_policy.py

install-pdo-tp : build-pdo-tp
@ cd $(BLDDIR) && $(NINJA) install
Expand Down
2 changes: 1 addition & 1 deletion ledgers/ccf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ at the end of the test.

```bash
source $PDO_HOME/ccf/bin/activate
${PDO_SOURCE_ROOT}/ledgers/ccf/scripts/ping_test.py
${PDO_SOURCE_ROOT}/ledgers/ccf/scripts/ping_test.py --url ${PDO_LEDGER_URL} --cert ${PDO_LEDGER_KEY_ROOT}/networkcert.pem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing, i noticed that PDO_LEDGER_KEY_ROOT is not defined in client docker image. There are though also a few other docker stuff i've noticed, will address in separate PR ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run start_client.sh... it will invoke environment.sh which sets all variables.
start_client.sh plays an explicit role of .bashrc

```

While invoking the test from a remote machine, be sure to 1) copy the
Expand Down
55 changes: 29 additions & 26 deletions ledgers/ccf/scripts/ping_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,11 @@
import os
import sys
import time
import toml
from urllib.parse import urlparse

from ccf.clients import CCFClient

from utils import parse_ledger_url
# pick up the logger used by the rest of CCF
from loguru import logger as LOG

## -----------------------------------------------------------------
ContractHome = os.environ.get("PDO_HOME") or os.path.realpath("/opt/pdo")
CCF_Etc = os.path.join(ContractHome, "ccf", "etc")
CCF_Keys = os.environ.get("PDO_LEDGER_KEY_ROOT") or os.path.join(ContractHome, "ccf", "keys")

# -----------------------------------------------------------------
def ping_test(client, options):
num_pings = options.num_pings
Expand All @@ -47,38 +38,50 @@ def ping_test(client, options):
total_time = end_time - start_time
txn_throuput = num_pings/total_time

LOG.info("Performed {0} pings. Average txn_throuput is {1} pings per second".format(num_pings, txn_throuput))
if options.verbose :
LOG.warning("Performed {0} pings. Average throughput is {1} pings per second".format(num_pings, txn_throuput))

# -----------------------------------------------------------------
def Main() :
parser = argparse.ArgumentParser(description='Script to enable the CCF network')

parser.add_argument('--logfile', help='Name of the log file, __screen__ for standard output', type=str)
parser.add_argument('--loglevel', help='Logging level', default='INFO', type=str)
parser.add_argument('--user-name', help="Name of the user being added", default = "userccf", type=str)
parser.add_argument("--num-pings", help="Number of ping operations to do", default = 100, type=int)

parser = argparse.ArgumentParser(description='Test the connection to a CCF server')

parser.add_argument('--loglevel', help='Logging level', default='WARNING', type=str)
parser.add_argument("--num-pings", help="Number of ping operations to do", default = 1, type=int)
parser.add_argument('--url', type=str, required=True)
parser.add_argument('--cert', type=str, required=True)
group = parser.add_mutually_exclusive_group()
group.add_argument('--verbose', action='store_true', default=True)
group.add_argument('--quiet', action='store_false', dest='verbose')
options = parser.parse_args()

# -----------------------------------------------------------------
LOG.remove()
LOG.add(sys.stderr, level=options.loglevel)

# -----------------------------------------------------------------
network_cert = os.path.join(CCF_Keys, "networkcert.pem")

host, port = parse_ledger_url()
try :
(host, port) = urlparse(options.url).netloc.split(':')
except Exception as e:
if options.verbose :
LOG.error('failed to parse ledger URL: {}'.format(str(e)))
sys.exit(-1)

try :
user_client = CCFClient(
host,
port,
network_cert)
user_client = CCFClient(host, port, options.cert)
except Exception as e:
LOG.error('failed to connect to CCF service: {}'.format(str(e)))
if options.verbose :
LOG.error('failed to connect to CCF service: {}'.format(str(e)))
sys.exit(-1)

ping_test(user_client, options)
try :
ping_test(user_client, options)
except Exception as e:
# this just lets the script get back to the original error
# that caused the execption
if options.verbose :
while e.__context__ : e = e.__context__
LOG.error('ping test failed: {}', str(e))
sys.exit(-1)

sys.exit(0)

Expand Down
38 changes: 0 additions & 38 deletions ledgers/ccf/scripts/utils.py

This file was deleted.

Loading