-
Notifications
You must be signed in to change notification settings - Fork 204
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
Docker local-testnet scripts #5998
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5998 +/- ##
==========================================
- Coverage 80.21% 80.17% -0.04%
==========================================
Files 709 709
Lines 94166 94166
==========================================
- Hits 75535 75501 -34
- Misses 13284 13316 +32
- Partials 5347 5349 +2 ☔ View full report in Codecov by Sentry. |
90b5a51
to
41d8908
Compare
scripts/docker-testnet/start.sh
Outdated
|
||
copyConfig | ||
|
||
copySeednodeConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, so you actually use a lot of the existing testnet scripts configuration functions 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, it's mostly the same configuration. The only difference in configuration are the ports and the ip addresses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I've noticed that: the first question was: how was possible to function if all nodes run on the same ports. But then I've saw the IPs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will test this ASAP
scripts/docker-testnet/build.sh
Outdated
@@ -0,0 +1,6 @@ | |||
pushd ../.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add #!/usr/bin/env bash
here also? i think pushd is bash specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this script intended to be run separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it is. I could have added the build step inside the ./start.sh
script, but it was easier for me to debug, since it didn't build the images at every run. Don't have a strong opinion on this, I can add it to the wrapper script instead. I was planning on adding a README.md
nevertheless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better that we keep the build separate from the run script. Not a strong opinion, thus.
scripts/docker-testnet/functions.sh
Outdated
--network ${DOCKER_NETWORK_NAME} \ | ||
seednode:dev \ | ||
--rest-api-interface=0.0.0.0:10000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
scripts/docker-testnet/functions.sh
Outdated
-v $TESTNETDIR/node/config:/go/mx-chain-go/cmd/node/config \ | ||
--network ${DOCKER_NETWORK_NAME} \ | ||
node:dev \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use same indentation pattern for the entire script and remove unnecessary empty lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope it's fixed.
} | ||
|
||
createDockerNetwork() { | ||
docker network create -d bridge --subnet=${DOCKER_NETWORK_SUBNET} ${DOCKER_NETWORK_NAME} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe check if network DOCKER_NETWOR_NAME
already exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added set -u
. Unbound variables will throw an error now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here I was referring to the fact that if the network is already created, it will fail because it is not able to create docker network again
scripts/docker-testnet/clean.sh
Outdated
echo "Stopping all containers..." | ||
docker stop $(docker ps -a -q) | ||
|
||
echo "Removing all containers..." | ||
docker container prune -f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the scripts will most probably be used in development environment where there might be also other local containers running, i don't think it's fine to stop and prune all containers, we should stop only the intended containers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
scripts/docker-testnet/variables.sh
Outdated
if [ "$TESTNETMODE" == "trace" ]; then | ||
LOGLEVEL="*:TRACE" | ||
fi | ||
## Use tmux or not. If set to 1, only 2 terminal windows will be opened, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented code. Can use a local.sh file instead. We have exceptions for it in the .gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed altogether. not needed in our context.
git clone [email protected]:multiversx/mx-chain-deploy-go.git || true | ||
git clone [email protected]:multiversx/mx-chain-proxy-go.git || true | ||
fi | ||
cd $(dirname $MULTIVERSXDIR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? Does this function will always clone the proxy and deploy repos?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it will. But if the repository already exists, it won't clone them again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmed that is working properly 👍
git clone [email protected]:multiversx/mx-chain-deploy-go.git || true
fatal: destination path 'mx-chain-deploy-go' already exists and is not an empty directory.
scripts/docker-testnet/README.md
Outdated
./build.sh # (Optional) Can be ignored if you already have the images stored in the local registry. | ||
./start.sh # Will start the local-testnet. | ||
./clean.sh # Will stop and remove the containers related to the local-testnet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that a good flow here is to have also a stop
step, in order to be able to have the following development flow:
- initially:
build
- multiple times:
start
,stop
- and finally:
clean
i think is not very good to have to clean everything on each run, sometimes we just wan't to stop the squad and start it again, with the same/setup configuration, later on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is also related to the docker network create comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This intended workflow adds some complexity. The start.sh
uses the docker run
command. If you stop all containers, they will only start again withdocker start
instead, otherwise it will throw an error. I don't see much of a benefit to this behaviour, as I need to persists all the containerIds/containerNames
between stopping and restarting. One can achieve this manually by leveraging already available commands in the clean.sh
script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested locally with system-tests-go and worked perfectly
scripts/docker-testnet/start.sh
Outdated
docker start $line | ||
done < "$file_path" | ||
|
||
rmdir ./tmp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add empty line?
for CONTAINER_ID in $CONTAINER_IDS; do | ||
docker stop "$CONTAINER_ID" | ||
echo "$CONTAINER_ID" >> ./tmp/stopped_containers | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add empty line?
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?