Adding new 'db-postgres-hammer' service to stress PostgreSQL DB

This commit is contained in:
Ivan Folgueira Bande 2023-11-22 12:29:42 +01:00 committed by Ivan FB
parent d8ed7607b2
commit 6236cc3d54
2 changed files with 41 additions and 0 deletions

View File

@ -111,6 +111,22 @@ services:
networks:
- simulation
db-postgres-hammer:
## This service is aimed to mimick other nodes interacting with the same database
image: alpine:3.16
restart: on-failure
logging:
driver: "none"
volumes:
- ./run_database_hammer.sh:/opt/run_database_hammer.sh:Z
entrypoint: sh
replicas: 3
command:
- /opt/run_database_hammer.sh
depends_on:
- nwaku_postgres
- nwaku_sqlite
waku-store-query-generator:
image: ivansete/waku-store-request-maker:19e645
restart: on-failure

View File

@ -0,0 +1,25 @@
#!/bin/sh
## 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}"
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}"
sleep 10
done