-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15664 from MinaProtocol/dkijania/introduce_postgr…
…es_side_docker_job Introduce new Command in Dhall to run job along with postgres docker
- Loading branch information
Showing
13 changed files
with
184 additions
and
126 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 |
---|---|---|
@@ -1,67 +1,3 @@ | ||
#!/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-archive:$MINA_DOCKER_TAG /workdir/scripts/replayer-test.sh -d $TEST_DIR -a mina-replayer -p $PG_CONN | ||
|
||
cleanup | ||
source scripts/replayer-test.sh -i src/test/archive/sample_db/replayer_input_file.json -p $PG_CONN -a mina-replayer |
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
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,58 @@ | ||
let Prelude = ../External/Prelude.dhall | ||
let P = Prelude | ||
let Text/concatMap = P.Text.concatMap | ||
|
||
let Cmd = ../Lib/Cmds.dhall | ||
let Mina = ../Command/Mina.dhall | ||
let S = ../Lib/SelectFiles.dhall | ||
let ContainerImages = ../Constants/ContainerImages.dhall | ||
let Artifacts= ../Constants/Artifacts.dhall | ||
|
||
let r = Cmd.run | ||
|
||
let runInDockerWithPostgresConn : List Text -> Text -> Artifacts.Type -> Text -> Cmd.Type = | ||
\(environment : List Text) -> | ||
\(initScript: Text ) -> | ||
\(docker: Artifacts.Type) -> | ||
\(innerScript : Text) -> | ||
-- port is used only in pg_conn variable. By using --network host we are disabling | ||
-- any control over postgres port | ||
let port="5432" | ||
let user="postgres" | ||
let password="postgres" | ||
let postgresDockerName="postgres" | ||
let dockerVersion= ContainerImages.postgres | ||
let dbName="archive" | ||
let pg_conn="postgres://${user}:${password}@localhost:${port}/${dbName}" | ||
|
||
let envVars = | ||
Text/concatMap | ||
Text | ||
(\(var : Text) -> " --env ${var}") | ||
([ | ||
"PG_PORT=${port}", | ||
"POSTGRES_USER=${user}", | ||
"POSTGRES_PASSWORD=${password}", | ||
"POSTGRES_DB=${dbName}", | ||
"PG_CONN=${pg_conn}" | ||
] # environment) | ||
in | ||
|
||
let outerDir : Text = | ||
"\\\$BUILDKITE_BUILD_CHECKOUT_PATH" | ||
in | ||
|
||
Cmd.chain [ | ||
"( docker stop ${postgresDockerName} && docker rm ${postgresDockerName} ) || true", | ||
"source buildkite/scripts/export-git-env-vars.sh", | ||
"docker run --network host --volume ${outerDir}:/workdir --workdir /workdir --name ${postgresDockerName} -d -e POSTGRES_USER=${user} -e POSTGRES_PASSWORD=${password} -e POSTGRES_PASSWORD=${password} -e POSTGRES_DB=${dbName} ${dockerVersion}", | ||
"sleep 5", | ||
"docker exec ${postgresDockerName} psql ${pg_conn} -f /workdir/${initScript}", | ||
"docker run --network host --volume ${outerDir}:/workdir --workdir /workdir ${envVars} gcr.io/o1labs-192920/${Artifacts.dockerName docker}:\\\$MINA_DOCKER_TAG ${innerScript}" | ||
] | ||
|
||
in | ||
|
||
{ | ||
runInDockerWithPostgresConn = runInDockerWithPostgresConn | ||
} |
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
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
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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 |
---|---|---|
|
@@ -9878,4 +9878,3 @@ ALTER TABLE ONLY public.zkapp_verification_keys | |
-- | ||
-- PostgreSQL database dump complete | ||
-- | ||
|
File renamed without changes.
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,54 @@ | ||
{ | ||
"genesis": { | ||
"genesis_state_timestamp": "2023-12-05T21:59:37+0100", | ||
"k": 24 | ||
}, | ||
"ledger": { | ||
"name": "release", | ||
"num_accounts": 250, | ||
"accounts": [ | ||
{ | ||
"pk": "B62qo5raDfFWM6oaooevrgMxMXmp3NnxMGbus3yubqaexzNodKDmock", | ||
"sk": null, | ||
"balance": "5.000000000", | ||
"delegate": null | ||
}, | ||
{ | ||
"pk": "B62qpXKjMPqNsUBPeAGhpjao8BE8FqdYdk8zS2RwxaEBadByS3nbfD1", | ||
"sk": null, | ||
"balance": "65500.000000000", | ||
"delegate": "B62qov6t5ahQQMdoanV8tgeS8ddpqsL5MCntfh8qzr1aNqGsgnhhvV5" | ||
}, | ||
{ | ||
"pk": "B62qov6t5ahQQMdoanV8tgeS8ddpqsL5MCntfh8qzr1aNqGsgnhhvV5", | ||
"sk": null, | ||
"delegate": null, | ||
"balance": "500.000000000" | ||
}, | ||
{ | ||
"pk": "B62qmYXqVz13eCpiHEEbvkWDU7jQAwfuf6zv4HLfiRthmLMZMQDXLPi", | ||
"sk": null, | ||
"balance": "11550000.000000000", | ||
"delegate": "B62qr7HhRDB6Me7FFXme5MFcoqRa452etDR4mNgT9Zi6U73R238ytmz" | ||
}, | ||
{ | ||
"pk": "B62qr7HhRDB6Me7FFXme5MFcoqRa452etDR4mNgT9Zi6U73R238ytmz", | ||
"sk": null, | ||
"balance": "0.000000000", | ||
"delegate": null | ||
}, | ||
{ | ||
"pk": "B62qkXPw6LbqeY3kaEYHrc6MeP6Wi7wcDc5fzbegn5yRoj2UvyCoe7M", | ||
"sk": null, | ||
"balance": "11550000.000000000", | ||
"delegate": "B62qmQsYKF97qxFVUuwHdmJySUM6F6qNnNYvxfrvYDPdLPzBspCPYLS" | ||
}, | ||
{ | ||
"pk": "B62qmQsYKF97qxFVUuwHdmJySUM6F6qNnNYvxfrvYDPdLPzBspCPYLS", | ||
"sk": null, | ||
"balance": "0.000000000", | ||
"delegate": null | ||
} | ||
] | ||
} | ||
} |
Binary file not shown.
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,50 @@ | ||
{ | ||
"genesis_ledger": { | ||
"name": "release", | ||
"num_accounts": 250, | ||
"accounts": [ | ||
{ | ||
"pk": "B62qo5raDfFWM6oaooevrgMxMXmp3NnxMGbus3yubqaexzNodKDmock", | ||
"sk": null, | ||
"balance": "5.000000000", | ||
"delegate": null | ||
}, | ||
{ | ||
"pk": "B62qpXKjMPqNsUBPeAGhpjao8BE8FqdYdk8zS2RwxaEBadByS3nbfD1", | ||
"sk": null, | ||
"balance": "65500.000000000", | ||
"delegate": "B62qov6t5ahQQMdoanV8tgeS8ddpqsL5MCntfh8qzr1aNqGsgnhhvV5" | ||
}, | ||
{ | ||
"pk": "B62qov6t5ahQQMdoanV8tgeS8ddpqsL5MCntfh8qzr1aNqGsgnhhvV5", | ||
"sk": null, | ||
"delegate": null, | ||
"balance": "500.000000000" | ||
}, | ||
{ | ||
"pk": "B62qmYXqVz13eCpiHEEbvkWDU7jQAwfuf6zv4HLfiRthmLMZMQDXLPi", | ||
"sk": null, | ||
"balance": "11550000.000000000", | ||
"delegate": "B62qr7HhRDB6Me7FFXme5MFcoqRa452etDR4mNgT9Zi6U73R238ytmz" | ||
}, | ||
{ | ||
"pk": "B62qr7HhRDB6Me7FFXme5MFcoqRa452etDR4mNgT9Zi6U73R238ytmz", | ||
"sk": null, | ||
"balance": "0.000000000", | ||
"delegate": null | ||
}, | ||
{ | ||
"pk": "B62qkXPw6LbqeY3kaEYHrc6MeP6Wi7wcDc5fzbegn5yRoj2UvyCoe7M", | ||
"sk": null, | ||
"balance": "11550000.000000000", | ||
"delegate": "B62qmQsYKF97qxFVUuwHdmJySUM6F6qNnNYvxfrvYDPdLPzBspCPYLS" | ||
}, | ||
{ | ||
"pk": "B62qmQsYKF97qxFVUuwHdmJySUM6F6qNnNYvxfrvYDPdLPzBspCPYLS", | ||
"sk": null, | ||
"balance": "0.000000000", | ||
"delegate": null | ||
} | ||
] | ||
} | ||
} |