Skip to content

Commit

Permalink
Update nwaku image on scripts, add extra parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroCabeza committed Jun 21, 2024
1 parent 95d7c47 commit a6aa0fd
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ services:
rest-traffic:
image: alrevuelta/rest-traffic:d936446
command:
--multiple-nodes=http://waku-simulator_nwaku_[1..${NUM_NWAKU_NODES:-5}]:8645
--multiple-nodes=http://waku-simulator_nwaku_[1..${TRAFFIC_NUM_NWAKU_NODES:-5}]:8645
--msg-size-kbytes=${MSG_SIZE_KBYTES:-10}
--delay-seconds=${TRAFFIC_DELAY_SECONDS:-15}
networks:
Expand Down
53 changes: 51 additions & 2 deletions run_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ usage() {
}

# Default values
DEFAULT_NWAKU_IMAGE="quay.io/wakuorg/nwaku-pr:2759-rln-v2"
DEFAULT_NWAKU_IMAGE="harbor.status.im/wakuorg/nwaku:v0.30.0-rc.0"
DEFAULT_NUM_NWAKU_NODES=5
DEFAULT_TRAFFIC_NUM_NWAKU_NODES=$DEFAULT_NUM_NWAKU_NODES
DEFAULT_SPAM_NUM_NWAKU_NODES=0
DEFAULT_TRAFFIC_DELAY_SECONDS=60
DEFAULT_MSG_SIZE_KBYTES=10
DEFAULT_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
Expand All @@ -19,6 +21,8 @@ DEFAULT_RLN_RELAY_MSG_LIMIT=1
# Initialize variables
NWAKU_IMAGE=$DEFAULT_NWAKU_IMAGE
NUM_NWAKU_NODES=$DEFAULT_NUM_NWAKU_NODES
SPAM_NUM_NWAKU_NODES=$DEFAULT_SPAM_NUM_NWAKU_NODES
TRAFFIC_NUM_NWAKU_NODES=$DEFAULT_TRAFFIC_NUM_NWAKU_NODES
TRAFFIC_DELAY_SECONDS=$DEFAULT_TRAFFIC_DELAY_SECONDS
MSG_SIZE_KBYTES=$DEFAULT_MSG_SIZE_KBYTES
PRIVATE_KEY=$DEFAULT_PRIVATE_KEY
Expand All @@ -37,6 +41,14 @@ while [[ "$#" -gt 0 ]]; do
NUM_NWAKU_NODES="$2"
shift 2
;;
--traffic-num-nwaku-nodes)
TRAFFIC_NUM_NWAKU_NODES="$2"
shift 2
;;
--spam-num-nwaku-nodes)
SPAM_NUM_NWAKU_NODES="$2"
shift 2
;;
--traffic-delay-seconds)
TRAFFIC_DELAY_SECONDS="$2"
shift 2
Expand Down Expand Up @@ -74,6 +86,30 @@ if ! [[ "$NUM_NWAKU_NODES" =~ ^[0-9]+$ ]]; then
exit 1
fi

# Validate traffic-num-nwaku-nodes is an integer
if ! [[ "$TRAFFIC_NUM_NWAKU_NODES" =~ ^[0-9]+$ ]]; then
echo "Error: --num-nwaku-nodes must be an integer."
exit 1
fi

# Validate traffic-num-nwaku-nodes is less or equal than num-nwaku-nodes
if ! [[ "$TRAFFIC_NUM_NWAKU_NODES" -le "$NUM_NWAKU_NODES" ]]; then
echo "Error: --traffic-num-nwaku-nodes must be less or equal than --num-nwaku-nodes."
exit 1
fi

# Validate spam-num-nwaku-nodes is an integer
if ! [[ "$SPAM_NUM_NWAKU_NODES" =~ ^[0-9]+$ ]]; then
echo "Error: --spam-num-nwaku-nodes must be an integer."
exit 1
fi

# Validate spam-num-nwaku-nodoes is less or equal than num-nwaku-nodes
if ! [[ "$SPAM_NUM_NWAKU_NODES" -le "$NUM_NWAKU_NODES" ]]; then
echo "Error: --spam-num-nwaku-nodes must be less or equal than --num-nwaku-nodes."
exit 1
fi

# Validate traffic-delay-seconds is an integer
if ! [[ "$TRAFFIC_DELAY_SECONDS" =~ ^[0-9]+$ ]]; then
echo "Error: --traffic-delay-seconds must be an integer."
Expand Down Expand Up @@ -107,6 +143,14 @@ if [[ "$NUM_NWAKU_NODES" -eq "$DEFAULT_NUM_NWAKU_NODES" ]]; then
echo "Warning: Using default value for --num-nwaku-nodes: $DEFAULT_NUM_NWAKU_NODES"
fi

if [[ "$TRAFFIC_NUM_NWAKU_NODES" -eq "$DEFAULT_TRAFFIC_NUM_NWAKU_NODES" ]]; then
echo "Warning: Using default value for --num-nwaku-nodes: $DEFAULT_TRAFFIC_NUM_NWAKU_NODES"
fi

if [[ "$SPAM_NUM_NWAKU_NODES" -eq "$DEFAULT_SPAM_NUM_NWAKU_NODES" ]]; then
echo "Warning: Using default value for --spam-num-nwaku-nodes: $DEFAULT_SPAM_NUM_NWAKU_NODES"
fi

if [[ "$TRAFFIC_DELAY_SECONDS" -eq "$DEFAULT_TRAFFIC_DELAY_SECONDS" ]]; then
echo "Warning: Using default value for --traffic-delay-seconds: $DEFAULT_TRAFFIC_DELAY_SECONDS"
fi
Expand Down Expand Up @@ -137,7 +181,10 @@ echo "==========================================================================
echo " Summary of Parameters "
echo "================================================================================================="
echo "- Nwaku Image: ${NWAKU_IMAGE}"
echo "- Number of Nwaku Nodes: ${NUM_NWAKU_NODES}"
echo "- Nodes"
echo " | Total: ${NUM_NWAKU_NODES}"
echo " | Traffic Injection: ${TRAFFIC_NUM_NWAKU_NODES}"
echo " | Spam Injection: ${SPAM_NUM_NWAKU_NODES}"
echo "- Message Publishing Delay: ${TRAFFIC_DELAY_SECONDS}s"
echo "- Message Size: ${MSG_SIZE_KBYTES}KB"
echo "- Private Key: ${PRIVATE_KEY}"
Expand All @@ -154,6 +201,8 @@ echo ""
# Export parameters and run compose
export NWAKU_IMAGE
export NUM_NWAKU_NODES
export TRAFFIC_NUM_NWAKU_NODES
export SPAM_NUM_NWAKU_NODES
export TRAFFIC_DELAY_SECONDS
export MSG_SIZE_KBYTES
export PRIVATE_KEY
Expand Down

0 comments on commit a6aa0fd

Please sign in to comment.