feat: start re-working stress testing

This commit is contained in:
siiky 2025-03-10 14:16:42 +00:00
parent 7d11bfacb0
commit 6fb2b29bcb
18 changed files with 454 additions and 463 deletions

View file

@ -6,19 +6,12 @@ if [ $# -eq 0 ]
echo "usage: ./build-machines [number_of_machines] /path/to/server/cert/lamassu_op_root_ca.pem /path/to/machine/" && exit 1
fi
case $1 in
''|*[!0-9]*) echo "usage: ./build-machines [number_of_machines] /path/to/server/cert/lamassu_op_root_ca.pem /path/to/machine/" && exit 1;;
esac
SERVER_CERT=$(perl -pe 's/\n/\\n/' < $2)
if [ -z "$SERVER_CERT" ]
then
echo "Lamassu-op-root-ca.pem is empty" && exit 1
fi
# Remove old folders
rm -rf ./machines/*
# Create stress database
sudo -u postgres psql postgres -c "drop database if exists lamassu_stress"
sudo -u postgres psql postgres -c "create database lamassu_stress with template lamassu"
@ -33,16 +26,12 @@ do
cp "$3"/data/client.sample.pem ./machines/$NUMBER/
cp "$3"/data/client.sample.key ./machines/$NUMBER/
cat > ./machines/$NUMBER/connection_info.json << EOL
{"host":"localhost","ca":"$SERVER_CERT"}
EOL
echo 'Generating certs...'
node ./utils/init-cert.js $NUMBER
cat > ./machines/$NUMBER/connection_info.json << EOF
{"host":"localhost","ca":"$SERVER_CERT"}
EOF
# Get device_id
DEVICE_ID=`openssl x509 -outform der -in ./machines/$NUMBER/client.pem | sha256sum | cut -d " " -f 1`
DEVICE_ID=`openssl x509 -outform der -in ./machines/$NUMBER/client.pem | sha256sum | cut -d ' ' -f 1`
# Update db config
NEW_CONFIG=$(node ./utils/save-config.js $NUMBER $DEVICE_ID)