Skip to content

Commit 4e314c9

Browse files
committed
chore: adjust E2E for both macOSes (AArch64, x86_64)
LW-8192
1 parent c9b6eab commit 4e314c9

File tree

10 files changed

+93
-48
lines changed

10 files changed

+93
-48
lines changed

compose/smash/Dockerfile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@ ARG UBUNTU_VERSION=20.04
33
FROM ubuntu:${UBUNTU_VERSION}
44

55
ARG DBSYNC_BINARY_URL="https://update-cardano-mainnet.iohk.io/cardano-db-sync/cardano-db-sync-${CARDANO_DB_SYNC_VERSION:-13.1.0.0}-linux.tar.gz"
6+
ARG DBSYNC_BINARY_URL_ARM64="https://github.com/input-output-hk/ogmios-tracker/releases/download/0.1.0/cardano-db-sync-${CARDANO_DB_SYNC_VERSION:-13.1.0.0}-aarch64-linux.tar.gz"
67
ENV NETWORK=${NETWORK:-"mainnet"}
78

89
RUN apt-get update && apt-get install curl -y
9-
RUN curl ${DBSYNC_BINARY_URL} --output /tmp/dbsync-binary.tar.gz &&\
10-
tar --extract --file /tmp/dbsync-binary.tar.gz --directory /bin ./cardano-smash-server &&\
11-
rm /tmp/dbsync-binary.tar.gz
10+
11+
RUN set -x ; if [ "$(uname -m)" = "aarch64" ] ; then \
12+
curl -sfL "${DBSYNC_BINARY_URL_ARM64}" --output /tmp/dbsync-binary.tar.gz &&\
13+
mkdir -p /opt/cardano-db-sync &&\
14+
tar -xzf /tmp/dbsync-binary.tar.gz -C /opt/cardano-db-sync &&\
15+
rm /tmp/dbsync-binary.tar.gz &&\
16+
ln -sf /opt/cardano-db-sync/bin/* /bin/ ;\
17+
else \
18+
curl -sfL "${DBSYNC_BINARY_URL}" --output /tmp/dbsync-binary.tar.gz &&\
19+
tar --extract --file /tmp/dbsync-binary.tar.gz --directory /bin ./cardano-smash-server &&\
20+
rm /tmp/dbsync-binary.tar.gz ;\
21+
fi
1222

1323
COPY packages/cardano-services/config/network/${NETWORK}/cardano-db-sync /config/
1424

compose/smash/init.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,9 @@ USER=$(cat /run/secrets/postgres_user)
66

77
echo "postgres:5432:${DB}:${USER}:${PASSWORD}" >/config/pgpass
88

9-
_term() {
10-
kill $CHILD
11-
}
9+
export PGPASSFILE=/config/pgpass
1210

13-
trap _term SIGTERM
14-
15-
PGPASSFILE=/config/pgpass cardano-smash-server \
11+
exec cardano-smash-server \
1612
--config /config/config.json \
1713
--port 3100 \
18-
--admins /config/smash-admins.txt &
19-
20-
CHILD=$!
21-
wait "$CHILD"
14+
--admins /config/smash-admins.txt

packages/cardano-services/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"cleanup:nm": "rm -rf node_modules",
3030
"cleanup": "rm -rf dist node_modules",
3131
"cli": "ts-node --transpile-only src/cli.ts",
32-
"compose:up": "docker compose --env-file environments/.env.$NETWORK -p cardano-services-$NETWORK -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/pg-agent.yml -f ../../compose/$(uname -m).yml ${FILES:-} up",
32+
"compose:up": "__FIX_UMASK__=$(chmod -R a+r ../../compose/placeholder-secrets) docker compose --env-file environments/.env.$NETWORK -p cardano-services-$NETWORK -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/pg-agent.yml -f ../../compose/$(uname -m).yml ${FILES:-} up",
3333
"compose:down": "docker compose -p cardano-services-$NETWORK -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/pg-agent.yml -f ../../compose/$(uname -m).yml down -t 120",
3434
"coverage": "yarn test --coverage || true",
3535
"circular-deps:check": "madge --circular dist/cjs",

packages/e2e/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ node_modules
99
dist
1010
coverage
1111
.env
12+
13+
*-old-state.*/

packages/e2e/docker-compose.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ services:
2222
ports:
2323
- 3001:3001
2424
volumes:
25-
- ./local-network/network-files/node-sp1/:/root/network-files/node-sp1
25+
# This breaks running in Docker Desktop for macOS, is it *really* needed? I see no usage of cardano-cli in the repo
26+
#- ./local-network/network-files/node-sp1/:/root/network-files/node-sp1
2627
- ./local-network/config:/root/config
2728
- sdk-ipc:/sdk-ipc
2829

@@ -37,7 +38,9 @@ services:
3738
NGINX_PORT: 80
3839
healthcheck:
3940
test: ['CMD-SHELL', 'wget -O /dev/null http://localhost || exit 1']
40-
timeout: 10s
41+
start_period: 5s
42+
interval: 5s
43+
timeout: 2s
4144

4245
cardano-node:
4346
depends_on:
@@ -65,6 +68,9 @@ services:
6568
- ./local-network/config/network:/config
6669

6770
cardano-submit-api:
71+
depends_on:
72+
local-testnet:
73+
condition: service_healthy
6874
volumes:
6975
- ./local-network/config/network:/config
7076

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/

packages/e2e/local-network/Dockerfile

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,39 @@ ENV DEBIAN_FRONTEND=nonintercative
66

77
WORKDIR /build
88
ARG CARDANO_NODE_BUILD_URL=https://github.com/IntersectMBO/cardano-node/releases/download/8.9.1/cardano-node-8.9.1-linux.tar.gz
9+
ARG CARDANO_NODE_BUILD_URL_ARM64=https://github.com/input-output-hk/ogmios-tracker/releases/download/0.1.0/cardano-node-8.9.1-aarch64-linux.tar.gz
10+
911
RUN apt-get update -y && \
10-
apt-get install -y wget tar && \
11-
wget $CARDANO_NODE_BUILD_URL -O cardano-node.tar.gz && \
12-
mkdir -p bin && \
13-
tar -xzf cardano-node.tar.gz
12+
apt-get install -y wget tar curl && \
13+
if [ "$(uname -m)" = "aarch64" ] ; then \
14+
curl -fsSL "$CARDANO_NODE_BUILD_URL_ARM64" >cardano-node.tar.gz ;\
15+
else \
16+
curl -fsSL "$CARDANO_NODE_BUILD_URL" >cardano-node.tar.gz ;\
17+
fi && \
18+
mkdir -p cardano-node && \
19+
tar -xzf cardano-node.tar.gz -C cardano-node
1420

1521
FROM ubuntu:${UBUNTU_VERSION}
1622

17-
ENV TINI_VERSION v0.19.0
18-
1923
WORKDIR /root
2024
RUN apt-get update -y && \
21-
apt-get install -y tzdata ca-certificates jq coreutils curl
25+
apt-get install -y tzdata ca-certificates jq coreutils curl wget
2226

2327
HEALTHCHECK --interval=5s --timeout=1s --retries=2000 --start-period=100ms \
2428
CMD /root/scripts/get-epoch.sh | awk '{ if ($0 >= "3") exit 0; else exit 1}'
2529

2630
STOPSIGNAL SIGINT
27-
COPY --from=builder /build/bin ./bin
28-
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
29-
RUN chmod +x /tini
30-
31-
COPY . .
31+
COPY --from=builder /build/cardano-node /opt/cardano-node
32+
ARG TINI_VERSION=v0.19.0
33+
RUN mkdir -p ./bin && ln -s /opt/cardano-node/bin/* ./bin/ &&\
34+
if [ "$(uname -m)" = "aarch64" ] ; then \
35+
TINI_VARIANT=static-arm64 ;\
36+
else \
37+
TINI_VARIANT=static-amd64 ;\
38+
fi &&\
39+
curl -fsSL >/tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TINI_VARIANT} &&\
40+
chmod +x /tini
41+
42+
COPY scripts scripts
43+
COPY templates templates
3244
ENTRYPOINT ["/tini", "-g", "--", "/root/scripts/start.sh" ]

packages/e2e/local-network/scripts/make-babbage.sh

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,29 @@ export PATH=$PWD/bin:$PATH
1414

1515
source ./scripts/nodes-configuration.sh
1616

17-
UNAME=$(uname -s) SED=
18-
case $UNAME in
19-
Darwin) SED="gsed" ;;
20-
Linux) SED="sed" ;;
21-
esac
17+
# We need this when running in Docker Desktop on macOS. `sed -i` doesn’t work well with VOLUMEs
18+
# there, unless it can create its temporary files outside of a VOLUME, which requires $TMPDIR.
19+
export TMPDIR="${TMPDIR:-/tmp}"
20+
export TMP="${TMP:-/tmp}"
21+
22+
UNAME=$(uname -s)
23+
24+
# Normal `sed -i` is a bit stubborn, and really wants to create its temporary files in the
25+
# directory of the target file. It is not a true in-place edit, and often braks permissions.
26+
# Let’s use this wrapper instead.
27+
sed_i() {
28+
local tmpfile=$(mktemp)
29+
local sed_bin=sed
30+
if [ "$UNAME" == "Darwin" ] ; then sed_bin=gsed ; fi
31+
if $sed_bin "$@" >"$tmpfile"; then
32+
cat "$tmpfile" >"${@: -1}" # Replace the last argument file (in-place file) with tmpfile content
33+
rm "$tmpfile"
34+
else
35+
echo "sed failed." >&2
36+
rm "$tmpfile"
37+
return 1
38+
fi
39+
}
2240

2341
case $(uname) in
2442
Darwin) date='gdate' ;;
@@ -109,7 +127,7 @@ cp templates/babbage/alonzo-babbage-test-genesis.json "${ROOT}/genesis.alonzo.sp
109127
cp templates/babbage/conway-babbage-test-genesis.json "${ROOT}/genesis.conway.spec.json"
110128
cp templates/babbage/byron-configuration.yaml "${ROOT}/configuration.yaml"
111129

112-
$SED -i "${ROOT}/configuration.yaml" \
130+
sed_i \
113131
-e 's/Protocol: RealPBFT/Protocol: Cardano/' \
114132
-e 's|GenesisFile: genesis.json|ByronGenesisFile: genesis/byron/genesis.json|' \
115133
-e '/ByronGenesisFile/ aShelleyGenesisFile: genesis/shelley/genesis.json' \
@@ -119,7 +137,8 @@ $SED -i "${ROOT}/configuration.yaml" \
119137
-e 's/LastKnownBlockVersion-Major: 0/LastKnownBlockVersion-Major: 6/' \
120138
-e 's/LastKnownBlockVersion-Minor: 2/LastKnownBlockVersion-Minor: 0/' \
121139
-e "s/minSeverity: Info/minSeverity: ${CARDANO_NODE_LOG_LEVEL}/" \
122-
-e "s/cardano.node.ChainDB: Notice/cardano.node.ChainDB: ${CARDANO_NODE_CHAINDB_LOG_LEVEL}/"
140+
-e "s/cardano.node.ChainDB: Notice/cardano.node.ChainDB: ${CARDANO_NODE_CHAINDB_LOG_LEVEL}/" \
141+
"${ROOT}/configuration.yaml"
123142

124143
echo "" >>"${ROOT}/configuration.yaml"
125144
echo "PBftSignatureThreshold: 0.6" >>"${ROOT}/configuration.yaml"
@@ -248,8 +267,8 @@ for NODE in ${SP_NODES}; do
248267
done
249268

250269
echo "Update start time in genesis files"
251-
$SED -i -E "s/\"startTime\": [0-9]+/\"startTime\": ${timeUnix}/" ${ROOT}/genesis/byron/genesis.json
252-
$SED -i -E "s/\"systemStart\": \".*\"/\"systemStart\": \"${timeISO}\"/" ${ROOT}/genesis/shelley/genesis.json
270+
sed_i -E "s/\"startTime\": [0-9]+/\"startTime\": ${timeUnix}/" ${ROOT}/genesis/byron/genesis.json
271+
sed_i -E "s/\"systemStart\": \".*\"/\"systemStart\": \"${timeISO}\"/" ${ROOT}/genesis/shelley/genesis.json
253272

254273
byronGenesisHash=$(cardano-cli byron genesis print-genesis-hash --genesis-json ${ROOT}/genesis/byron/genesis.json)
255274
shelleyGenesisHash=$(cardano-cli genesis hash --genesis ${ROOT}/genesis/shelley/genesis.json)
@@ -261,10 +280,10 @@ echo "Shelley genesis hash: $shelleyGenesisHash"
261280
echo "Alonzo genesis hash: $alonzoGenesisHash"
262281
echo "Conway genesis hash: $conwayGenesisHash"
263282

264-
$SED -i -E "s/ByronGenesisHash: '.*'/ByronGenesisHash: '${byronGenesisHash}'/" ${ROOT}/configuration.yaml
265-
$SED -i -E "s/ShelleyGenesisHash: '.*'/ShelleyGenesisHash: '${shelleyGenesisHash}'/" ${ROOT}/configuration.yaml
266-
$SED -i -E "s/AlonzoGenesisHash: '.*'/AlonzoGenesisHash: '${alonzoGenesisHash}'/" ${ROOT}/configuration.yaml
267-
$SED -i -E "s/ConwayGenesisHash: '.*'/ConwayGenesisHash: '${conwayGenesisHash}'/" ${ROOT}/configuration.yaml
283+
sed_i -E "s/ByronGenesisHash: '.*'/ByronGenesisHash: '${byronGenesisHash}'/" ${ROOT}/configuration.yaml
284+
sed_i -E "s/ShelleyGenesisHash: '.*'/ShelleyGenesisHash: '${shelleyGenesisHash}'/" ${ROOT}/configuration.yaml
285+
sed_i -E "s/AlonzoGenesisHash: '.*'/AlonzoGenesisHash: '${alonzoGenesisHash}'/" ${ROOT}/configuration.yaml
286+
sed_i -E "s/ConwayGenesisHash: '.*'/ConwayGenesisHash: '${conwayGenesisHash}'/" ${ROOT}/configuration.yaml
268287

269288
# Create config folder
270289
rm -rf ./config/*
@@ -277,15 +296,17 @@ cp ./templates/babbage/db-sync-config.json ./config/network/cardano-db-sync/conf
277296
cp ./templates/babbage/node-config.json ./config/network/cardano-node/config.json
278297
cp ./templates/babbage/submit-api-config.json ./config/network/cardano-submit-api/config.json
279298

280-
$SED -i -E "s/\"ByronGenesisHash\": \".*\"/\"ByronGenesisHash\": \"${byronGenesisHash}\"/" ./config/network/cardano-node/config.json
281-
$SED -i -E "s/\"ShelleyGenesisHash\": \".*\"/\"ShelleyGenesisHash\": \"${shelleyGenesisHash}\"/" ./config/network/cardano-node/config.json
282-
$SED -i -E "s/\"AlonzoGenesisHash\": \".*\"/\"AlonzoGenesisHash\": \"${alonzoGenesisHash}\"/" ./config/network/cardano-node/config.json
283-
$SED -i -E "s/\"ConwayGenesisHash\": \".*\"/\"ConwayGenesisHash\": \"${conwayGenesisHash}\"/" ./config/network/cardano-node/config.json
299+
sed_i -E "s/\"ByronGenesisHash\": \".*\"/\"ByronGenesisHash\": \"${byronGenesisHash}\"/" ./config/network/cardano-node/config.json
300+
sed_i -E "s/\"ShelleyGenesisHash\": \".*\"/\"ShelleyGenesisHash\": \"${shelleyGenesisHash}\"/" ./config/network/cardano-node/config.json
301+
sed_i -E "s/\"AlonzoGenesisHash\": \".*\"/\"AlonzoGenesisHash\": \"${alonzoGenesisHash}\"/" ./config/network/cardano-node/config.json
302+
sed_i -E "s/\"ConwayGenesisHash\": \".*\"/\"ConwayGenesisHash\": \"${conwayGenesisHash}\"/" ./config/network/cardano-node/config.json
284303

285304
cp ./templates/babbage/topology.json ./config/network/cardano-node/topology.json
286305
# docker hostname in topology.json isn't working, so need to specify ip of local network
287306
CONTAINER_IP=$(hostname -I | xargs)
288-
$SED -i "s/172.17.0.1/$CONTAINER_IP/g" ./config/network/cardano-node/topology.json
307+
sed_i "s/172.17.0.1/$CONTAINER_IP/g" ./config/network/cardano-node/topology.json
308+
# Note: for some reason, the first cardano-node (on port 3001) isn’t immediately responsive to the outside world, so:
309+
sed_i "s/3001/3002/g" ./config/network/cardano-node/topology.json
289310

290311
cp "${ROOT}"/genesis/byron/genesis.json ./config/network/cardano-node/genesis/byron.json
291312
cp "${ROOT}"/genesis/byron/genesis.json ./config/network/genesis/byron.json

packages/e2e/local-network/scripts/ogmios-start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
while [ -f /sdk-ipc/prevent_ogmios ]; do sleep 10; done
1111

1212
# Start the ogmios as normal
13-
/bin/ogmios "$@"
13+
exec /bin/ogmios "$@"

packages/e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"test:web-extension:watch:run": "yarn test:web-extension:run --watch",
4545
"test:web-extension:watch": "run-s test:web-extension:build test:web-extension:watch:bg",
4646
"test:web-extension:watch:bg": "run-p test:web-extension:watch:build test:web-extension:watch:run",
47-
"local-network:common": "DISABLE_DB_CACHE=${DISABLE_DB_CACHE:-true} SUBMIT_API_ARGS='--testnet-magic 888' USE_BLOCKFROST=false docker compose -p local-network-e2e -f docker-compose.yml -f ../../compose/common.yml $FILES up",
47+
"local-network:common": "DISABLE_DB_CACHE=${DISABLE_DB_CACHE:-true} SUBMIT_API_ARGS='--testnet-magic 888' USE_BLOCKFROST=false __FIX_UMASK__=$(chmod -R a+r ../../compose/placeholder-secrets) docker compose -p local-network-e2e -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/$(uname -m).yml $FILES up",
4848
"local-network:up": "FILES='' yarn local-network:common",
4949
"local-network:dev": "FILES='-f ../../compose/dev.yml' yarn local-network:common",
5050
"local-network:profile:up": "FILES='-f ../../compose/pg-agent.yml' yarn local-network:common",

0 commit comments

Comments
 (0)