From fe7061a21eb14395e723402face755c826077aec Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Mon, 21 Aug 2023 16:35:29 +0200 Subject: [PATCH] Adding bash script to stress inserts operation --- README.md | 26 +++++++++++-- Makefile => go/Makefile | 0 go.mod => go/go.mod | 0 go.sum => go/go.sum | 0 main_test.go => go/main_test.go | 0 setup_test.go => go/setup_test.go | 0 utils_test.go => go/utils_test.go | 0 postgres-docker-compose.yml | 10 +++++ sh/README.md | 61 +++++++++++++++++++++++++++++++ sh/publish_multiple_clients.sh | 18 +++++++++ sh/publish_one_client.sh | 18 +++++++++ 11 files changed, 130 insertions(+), 3 deletions(-) rename Makefile => go/Makefile (100%) rename go.mod => go/go.mod (100%) rename go.sum => go/go.sum (100%) rename main_test.go => go/main_test.go (100%) rename setup_test.go => go/setup_test.go (100%) rename utils_test.go => go/utils_test.go (100%) create mode 100644 postgres-docker-compose.yml create mode 100644 sh/README.md create mode 100644 sh/publish_multiple_clients.sh create mode 100644 sh/publish_one_client.sh diff --git a/README.md b/README.md index ca662ff..518696d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,23 @@ -``` -make -``` \ No newline at end of file + +## Summary +This repo contains tools for analysing performance around the Store protocol + +### Golang tool + +The Golang project is aimed to setup `go-waku` clients that publish messages +and later make requests trough the _Store_ protocol to retrieve the stored +messages + +To run the tests, go to the `go` folder and run the `make` command. +Notice that the `go` tool expects a running `nwaku` node(s) to be running with +_Store_ protocol mounted, and a running postgres database. + +### Bash tool + +Simple script that allows to publish messages from different clients. + +`BASH`(n clients) --json-rpc--> `nwaku_A` <--relay--> `nwaku_B` <---> `database` + +Notice that the bash script expects two `nwaku` nodes that communicate through +the _Relay_ protocol and the `nwaku_B` has the _Store_ protocol mounted and +is connected to the `postgres_DB`. diff --git a/Makefile b/go/Makefile similarity index 100% rename from Makefile rename to go/Makefile diff --git a/go.mod b/go/go.mod similarity index 100% rename from go.mod rename to go/go.mod diff --git a/go.sum b/go/go.sum similarity index 100% rename from go.sum rename to go/go.sum diff --git a/main_test.go b/go/main_test.go similarity index 100% rename from main_test.go rename to go/main_test.go diff --git a/setup_test.go b/go/setup_test.go similarity index 100% rename from setup_test.go rename to go/setup_test.go diff --git a/utils_test.go b/go/utils_test.go similarity index 100% rename from utils_test.go rename to go/utils_test.go diff --git a/postgres-docker-compose.yml b/postgres-docker-compose.yml new file mode 100644 index 0000000..99f93e6 --- /dev/null +++ b/postgres-docker-compose.yml @@ -0,0 +1,10 @@ +version: "3.8" + +services: + db: + image: postgres:9.6-alpine + restart: always + environment: + POSTGRES_PASSWORD: test123 + ports: + - "5432:5432" diff --git a/sh/README.md b/sh/README.md new file mode 100644 index 0000000..cd6e982 --- /dev/null +++ b/sh/README.md @@ -0,0 +1,61 @@ + +### Summary + +This simple script stress the _Store_ protocol from a different approach. + +The setup needs to have two [`nwaku`](https://github.com/waku-org/nwaku) +running, A & B. + +Content of "cfg_node_a.txt" file: +```code +ports-shift = 1 +pubsub-topic = [ "/waku/2/default-waku/proto" "/waku/2/testing-store" "/waku/2/dev-waku/proto" ] +staticnode = [ "/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmVFXtAfSj4EiR7mL2KvL4EE2wztuQgUSBoj2Jx2KeXFLN" ] +storenode = "/ip4/127.0.0.1/tcp/60000/p2p/16Uiu2HAmVFXtAfSj4EiR7mL2KvL4EE2wztuQgUSBoj2Jx2KeXFLN" +log-level = "DEBUG" +nodekey = "364d111d729a6eb6d2e6113e163f017b5ef03a6f94c9b5b7bb1bb36fa5cb07a9" +rest = true +lightpush = true +discv5-discovery = true +discv5-udp-port = 9000 +discv5-enr-auto-update = false +rpc-admin = true +metrics-server = true +``` + +Content of "cfg_node_b.txt" file: +```code +ports-shift = 0 +pubsub-topic = [ "/waku/2/default-waku/proto" "/waku/2/testing-store" ] +staticnode = [ "/ip4/0.0.0.0/tcp/60001/p2p/16Uiu2HAm2eqzqp6xn32fzgGi8K4BuF88W4Xy6yxsmDcW8h1gj6ie" ] +log-level = "DEBUG" +nodekey = "0d714a1fada214dead6dc9c7274585eca0ff292451866e7d6d677dc818e8ccd2" +lightpush = true +store = true +store-message-db-url = "postgres://postgres:test123@localhost:5432/postgres" +#store-message-db-url = "sqlite://sqlite_folder/store.sqlite3" +store-message-retention-policy = "time:6000" +rpc-admin=true +metrics-server = true +``` + +### Setup + +#### Start a Postgres database +`docker compose -f postgres-docker-compose.yml up -d` + +#### Run node A +1. Open one terminal and go to the root folder of the [`nwaku`](https://github.com/waku-org/nwaku) repo. +2. Run `./build/wakunode2 --config-file=cfg_node_a.txt` + +#### Run node B +1. Open one terminal and go to the root folder of the [`nwaku`](https://github.com/waku-org/nwaku) repo. +2. Run `./build/wakunode2 --config-file=cfg_node_b.txt` + +( notice that node B is connected to a database ) + +#### Send messages to node A + +The next example will start 25 processes that each will send 300 messages. + +`bash sh/publish_multiple_clients.sh 25 300` diff --git a/sh/publish_multiple_clients.sh b/sh/publish_multiple_clients.sh new file mode 100644 index 0000000..66b125c --- /dev/null +++ b/sh/publish_multiple_clients.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +## This script allows to publish multiple messages from multiple processes. + +## Params +## $1 - The first parameter passed represents the number of clients. +## $2 - The second parameter has the # of messages each client will publish. + +for i in $(seq $1); do + bash sh/publish_one_client.sh $2 & + pids[${i}]=$! +done + +# wait for all pids +for pid in ${pids[*]}; do + echo Waiting for ${pid} + wait $pid +done diff --git a/sh/publish_one_client.sh b/sh/publish_one_client.sh new file mode 100644 index 0000000..78a42e8 --- /dev/null +++ b/sh/publish_one_client.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# This script just sends rpc 'post_waku_v2_relay_v1_message' requests to +# http://localhost:8546 + +# Therefore, there should be an `nwaku` node listening to rpc requests. + +# The number of messages is specified by the first parameter. + +target='http://localhost:8546' + +for i in $( seq $1 ) +do + echo $i + curl -d "{\"jsonrpc\":\"2.0\",\"id\":"$(date +%s%N)",\"method\":\"post_waku_v2_relay_v1_message\", \"params\":[\"/waku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