-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dkijania
committed
May 30, 2024
1 parent
d556421
commit 5d7370f
Showing
1 changed file
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
|
||
TEST_DIR=/workdir/src/app/replayer/ | ||
|
||
set -eox pipefail | ||
|
||
echo "Updating apt, installing packages" | ||
apt-get update | ||
|
||
# Don't prompt for answers during apt-get install | ||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
apt-get install -y git apt-transport-https ca-certificates curl wget | ||
|
||
git config --global --add safe.directory $BUILDKITE_BUILD_CHECKOUT_PATH | ||
|
||
source buildkite/scripts/export-git-env-vars.sh | ||
|
||
DB=archive | ||
DOCKER_IMAGE=12.4-alpine | ||
CONTAINER_FILE=docker.container | ||
|
||
PG_PORT=5433 | ||
PG_PASSWORD=somepassword | ||
DOCKER_IMAGE=12.4-alpine | ||
CONTAINER_FILE=docker.container | ||
|
||
function cleanup () { | ||
CONTAINER=`cat $CONTAINER_FILE` | ||
|
||
if [[ ! -z $CONTAINER ]] ; then | ||
echo "Killing, removing docker container" | ||
for action in kill rm; do | ||
docker container $action $CONTAINER | ||
done | ||
fi | ||
|
||
rm -f $CONTAINER_FILE | ||
} | ||
|
||
docker network create replayer || true | ||
|
||
# -v mounts dir with Unix socket on host | ||
echo "Starting docker with Postgresql" | ||
docker run \ | ||
--network replayer \ | ||
--volume $BUILDKITE_BUILD_CHECKOUT_PATH:/workdir \ | ||
--name replayer-postgres -d -p $PG_PORT:5432 \ | ||
-e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=$PG_PASSWORD -e POSTGRES_DB=$DB postgres:$DOCKER_IMAGE > $CONTAINER_FILE | ||
|
||
trap "cleanup; exit 1" SIGINT | ||
|
||
# wait for Postgresql to become available | ||
sleep 5 | ||
|
||
echo "Populating archive database" | ||
|
||
NETWORK_GATEWAY=$(docker network inspect -f "{{(index .IPAM.Config 0).Gateway}}" replayer) | ||
|
||
PG_CONN="postgres://postgres:$PG_PASSWORD@$NETWORK_GATEWAY:$PG_PORT/$DB" | ||
|
||
|
||
docker exec replayer-postgres psql $PG_CONN -f $TEST_DIR/test/archive_db.sql | ||
|
||
docker run --network replayer --volume $BUILDKITE_BUILD_CHECKOUT_PATH:/workdir gcr.io/o1labs-192920/mina-rosetta:$MINA_DOCKER_TAG mina-indexer-test --archive_uri $PG_CONN | ||
|
||
cleanup |