diff options
author | MS <ms@taler.net> | 2023-07-24 10:42:15 +0200 |
---|---|---|
committer | MS <ms@taler.net> | 2023-07-24 10:42:44 +0200 |
commit | 6144444b239ecf57aaf8878d294bee007654c207 (patch) | |
tree | 2d01d94b42bd2a649c36c6a57ed509f27ce2baa3 | |
parent | da000d1aa75575a194870c890b39c994271e58d2 (diff) | |
download | deployment-6144444b239ecf57aaf8878d294bee007654c207.tar.gz deployment-6144444b239ecf57aaf8878d294bee007654c207.tar.bz2 deployment-6144444b239ecf57aaf8878d294bee007654c207.zip |
NLnet task 5 delivery, draft.
-rw-r--r-- | nlnet/task5/date-range/Dockerfile | 13 | ||||
-rw-r--r-- | nlnet/task5/date-range/start.sh | 19 | ||||
-rw-r--r-- | nlnet/task5/long-poll/Dockerfile | 14 | ||||
-rw-r--r-- | nlnet/task5/long-poll/start.sh | 44 | ||||
-rw-r--r-- | nlnet/task5/performance/Dockerfile | 14 | ||||
-rw-r--r-- | nlnet/task5/performance/start.sh | 99 |
6 files changed, 203 insertions, 0 deletions
diff --git a/nlnet/task5/date-range/Dockerfile b/nlnet/task5/date-range/Dockerfile new file mode 100644 index 0000000..c2a7353 --- /dev/null +++ b/nlnet/task5/date-range/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:stable + +RUN apt-get update +RUN apt-get install -y openjdk-17-jre git python3-pip curl jq sqlite3 postgresql python3-requests python3-click sudo + +# Installation +RUN git clone git://git.taler.net/libeufin +WORKDIR /libeufin +RUN git fetch && git checkout 4bc5f38f571a45d427f73813ec3846bf59413afa +RUN ./bootstrap +RUN ./configure --prefix=/usr/local +RUN make install +ENTRYPOINT ["/start.sh"] diff --git a/nlnet/task5/date-range/start.sh b/nlnet/task5/date-range/start.sh new file mode 100644 index 0000000..c7018ea --- /dev/null +++ b/nlnet/task5/date-range/start.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Draft. + +# 0, setup and start services. +libeufin-sandbox make-transaction $PARAMS +# 1, set artificial time for the transaction at $PAST. +# 2, retrieve the $PAST transaction via Nexus. +libeufin-cli \ + connections \ + fetch-transactions \ + --range-type=time-frame \ + --start $START \ + --end $END +# 3, show ingested transactions, where only $PATH appears. +libeufin-cli + accounts + list-payments + $OTHER_ARGS diff --git a/nlnet/task5/long-poll/Dockerfile b/nlnet/task5/long-poll/Dockerfile new file mode 100644 index 0000000..46eebdb --- /dev/null +++ b/nlnet/task5/long-poll/Dockerfile @@ -0,0 +1,14 @@ +FROM debian:stable + +RUN apt-get update +RUN apt-get install -y openjdk-17-jre git python3-pip curl jq sqlite3 postgresql python3-requests python3-click sudo + +# Installation +RUN git clone git://git.taler.net/libeufin +WORKDIR /libeufin +RUN git fetch && git checkout 4bc5f38f571a45d427f73813ec3846bf59413afa +RUN ./bootstrap +RUN ./configure --prefix=/usr/local +RUN make install +COPY start.sh / +ENTRYPOINT ["/start.sh"] diff --git a/nlnet/task5/long-poll/start.sh b/nlnet/task5/long-poll/start.sh new file mode 100644 index 0000000..35edd9c --- /dev/null +++ b/nlnet/task5/long-poll/start.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +wire_transfer () { + /libeufin/cli/tests/wire-transfer.sh +} + +(/libeufin/cli/tests/launch_services_with_xlibeufinbank.sh &> /dev/null) & +# Wait Nexus to be online: +OK="0" +echo -n "Waiting for Nexus ..." +for n in $(seq 1 100); do + echo -n "." + sleep 1 + wget --timeout=1 \ + --tries=3 \ + --waitretry=0 \ + -o /dev/null \ + -O /dev/null \ + http://localhost:5001 || continue + OK="1" + break +done +if [ "1" != "$OK" ] +then + echo "Failed to launch services." + exit 1 +fi +echo "OK" + +echo +echo Services are online! The following shell offers a 'wire-transfer.sh' +echo command that wires money to Nexus 'test-user'. Give it after having +echo connected an HTTP client that long-polls to Nexus. +echo + +cd /usr/bin/ +ln -s /libeufin/cli/tests/wire-transfer.sh +bash + +# This command has 100 seconds long-polling. It can be +# used before the user create any wire transfer to 'test-user' +# to show how those then actually make Neuxs respond to +# the long-poller. +# curl -v -u test-user:x "http://localhost:5001/facades/test-facade/taler-wire-gateway/history/incoming?delta=5&long_poll_ms=100000" diff --git a/nlnet/task5/performance/Dockerfile b/nlnet/task5/performance/Dockerfile new file mode 100644 index 0000000..46eebdb --- /dev/null +++ b/nlnet/task5/performance/Dockerfile @@ -0,0 +1,14 @@ +FROM debian:stable + +RUN apt-get update +RUN apt-get install -y openjdk-17-jre git python3-pip curl jq sqlite3 postgresql python3-requests python3-click sudo + +# Installation +RUN git clone git://git.taler.net/libeufin +WORKDIR /libeufin +RUN git fetch && git checkout 4bc5f38f571a45d427f73813ec3846bf59413afa +RUN ./bootstrap +RUN ./configure --prefix=/usr/local +RUN make install +COPY start.sh / +ENTRYPOINT ["/start.sh"] diff --git a/nlnet/task5/performance/start.sh b/nlnet/task5/performance/start.sh new file mode 100644 index 0000000..317c52a --- /dev/null +++ b/nlnet/task5/performance/start.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# This script shows, via runnuing the benchmark, how +# the LibEuFin database connections are significantly +# shorter than the benchmark total time. + +# For this reason, it can only be that LibEuFin opens +# and closes many PostgreSQL connections, as it is required +# by milestone #3. + +set -eux + +# Converts AA:BB:CC.DDD to milliseconds. +convert_pg_time_to_ms () { + awk -F[.:] '{SECS=(60*60*$1)+(60*$2)+$3; MILLI=$4; TOTAL_MS=(SECS*1000)+MILLI; print TOTAL_MS}' +} + +createdb talercheck + +prepare_and_run () { + (taler-unified-setup.sh \ + -emwtns \ + -c /exchange/src/benchmark/benchmark-cs.conf \ + -u exchange-account-2 &> /check_ready.txt) & + + # Wait that the prep. went through. + echo -n Waiting the unified setup to complete.. + READY="NO" + for i in `seq 100` true; do + if grep "<<READY>>" /check_ready.txt; then + READY="YES" + break + fi + echo -n "."; sleep 0.5 + done + + if test $READY = "YES"; then + echo "DONE" + else + cat /check_ready.txt + echo FAIL + exit 1 + fi + + NEXUS_PID=$(cat /libeufin-nexus.pid) + SANDBOX_PID=$(cat /libeufin-sandbox.pid) + + if test -z $NEXUS_PID; then + echo Could not find Nexus PID, failing. + exit 1 + fi + + if test -z $SANDBOX_PID; then + echo Could not find Sandbox PID, failing. + exit 1 + fi + + echo Running the benchmark.. + taler-exchange-benchmark \ + -c /exchange/src/benchmark/benchmark-cs.conf.edited \ + -u exchange-account-2 \ # Which exchange account to pick from the config. + -L WARNING \ + -n1 \ # How many coins per reserve. + -r100 # How many reserves per client. +} + +/usr/bin/time -o /benchmark-wall-clock-time.txt --format=%e prepare_and_run + +# Convert the wall clock time to milliseconds, to make +# it compatible with the format as GREPped through Postgres logs. +BENCHMARK_TOT_MS=$(awk -F. '{t=($1 * 1000 + $2 * 10)} END {print t}' /benchmark-wall-clock-time.txt) + +NEXUS_LONGEST_DB_SESSION=$(grep disconnection < /var/log/postgresql/postgresql-14-main.log \ + | grep $NEXUS_PID | convert_pg_time_to_ms | sort | head -1) + +SANDBOX_LONGEST_DB_SESSION=$(grep disconnection < /var/log/postgresql/postgresql-14-main.log \ + | grep $SANDBOX_PID | convert_pg_time_to_ms | sort | head -1) + +if test $NEXUS_LONGEST_DB_SESSION -gt $BENCHMARK_TOT_MS; then + echo Nexus had a DB session longer than the benchmark itself, failing. + exit 1 +fi + +if test $SANDBOX_LONGEST_DB_SESSION -gt $BENCHMARK_TOT_MS; then + echo Sandbox had a DB session longer than the benchmark itself, failing. + exit 1 +fi + +NEXUS_TIME_FRACTION=$(echo "$BENCHMARK_TOT_MS / $NEXUS_LONGEST_DB_SESSION" | bc -lq) +SANDBOX_TIME_FRACTION=$(echo "$BENCHMARK_TOT_MS / $SANDBOX_LONGEST_DB_SESSION" | bc -lq) + +# Here: the further from 1 the better. +echo Nexus longest DB session is $NEXUS_TIME_FRACTION of the total benchmark time. +echo Sandbox longest DB session is $SANDBOX_TIME_FRACTION of the total benchmark time. + +# Now show the total space occupied by the database. +# Although that's a _total_ estimate, it'll anyhow show +# that _also_ libeufin has reasonable data usage. +echo "SELECT pg_size_pretty(pg_database_size('libeufincheck'))" | psql -d libeufincheck |