From 1f7c2a710da4e03c7bdc053809550c6d9a1c7b94 Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Wed, 22 Nov 2023 12:29:42 +0100 Subject: [PATCH] Adding new 'db-postgres-hammer' service to stress PostgreSQL DB --- docker/docker-compose-manual-binaries.yml | 16 +++++++++++++++ docker/run_database_hammer.sh | 25 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 docker/run_database_hammer.sh diff --git a/docker/docker-compose-manual-binaries.yml b/docker/docker-compose-manual-binaries.yml index bed5abe..7cf0523 100644 --- a/docker/docker-compose-manual-binaries.yml +++ b/docker/docker-compose-manual-binaries.yml @@ -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 diff --git a/docker/run_database_hammer.sh b/docker/run_database_hammer.sh new file mode 100644 index 0000000..a845a80 --- /dev/null +++ b/docker/run_database_hammer.sh @@ -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