simplification of database hammer code base

This commit is contained in:
Ivan Folgueira Bande 2023-11-22 23:30:21 +01:00
parent 1f7c2a710d
commit 7bb415eeae
No known key found for this signature in database
GPG Key ID: 3C117481F89E24A7
2 changed files with 11 additions and 11 deletions

View File

@ -120,12 +120,15 @@ services:
volumes:
- ./run_database_hammer.sh:/opt/run_database_hammer.sh:Z
entrypoint: sh
replicas: 3
deploy:
mode: replicated
replicas: 1
command:
- /opt/run_database_hammer.sh
depends_on:
- nwaku_postgres
- nwaku_sqlite
- postgres
networks:
- simulation
waku-store-query-generator:
image: ivansete/waku-store-request-maker:19e645

View File

@ -3,23 +3,20 @@
## This script is aimed to generate traffic to the database and simulate
## simulate multiple Waku nodes connected to the same database.
## Install the `dig` command
apk --no-cache add bind-tools
## Install postgresql-client for psql command
apk --no-cache add postgresql-client
## The port numbers and host names are defined in the 'docker-compose.yml' file
nwaku-postgres-IP=$(dig +short postgres)
target-postgres="http://${nwaku-postgres-IP}:5432"
echo "This is publisher: ${target-postgres}; ${target_sqlite}"
echo "This is database hammer"
export PGPASSWORD=test123
QUERY_LAST_FIVE_MINUTES=$(echo 'SELECT * FROM messages ORDER BY storedAt DESC LIMIT 100;')
query-last-five-minutes="SELECT storedAt, contentTopic, payload, pubsubTopic, version, timestamp, id FROM messages WHERE storedAt >= EXTRACT(EPOCH FROM (NOW() - INTERVAL '5 minutes')) * 1000 ORDER BY storedAt DESC;"
while true
do
echo "Before making query"
psql -h ${nwaku-postgres-IP} -U postgres -W test123 -U postgres -c "${query-last-five-minutes}"
psql -h postgres -p 5432 -U postgres -U postgres -w -c "${QUERY_LAST_FIVE_MINUTES}"
sleep 10
done