From 7e43d800d36660404b7a47ed02c43cf7fb1e3c96 Mon Sep 17 00:00:00 2001 From: jforge Date: Mon, 24 Jun 2024 11:13:47 +0200 Subject: [PATCH] Fixed keepAlive default to 5 (seconds), mqtt library update to avoid a keepAlive 1 issue with paho.mqtt (#20) * Fixed keepAlive default to 5 (seconds), sanitized some docs * updated dependency to paho mqtt library to version 1.4.3 (fixes an issue with keepAlive 1) --- README.md | 5 +++-- cmd/checker/main.go | 6 +++--- cmd/load_generator/main.go | 8 ++++---- cmd/stdout/main.go | 2 +- go.mod | 2 +- go.sum | 2 ++ 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3af0fce..3a4c691 100644 --- a/README.md +++ b/README.md @@ -67,15 +67,16 @@ Here are a few methods of running the image in a Kubernetes cluster ### Running the load generator ```bash -kubectl run mqtt-load-generator --image=jforge/mqtt-load-generator \ +kubectl run mqtt-load-generator --image=ghcr.io/pablitovicente/mqtt-load-generator:v1.0.7 \ -- -h -p 1883 -u secret -P mega_secret \ -c 1000 -s 1000 -t /golang/pub -i 1 -n 100 ``` + ### Running the load checker ```bash -kubectl run mqtt-load-checker --image=pgschk/mqtt-load-generator --command \ +kubectl run mqtt-load-checker --image=ghcr.io/pablitovicente/mqtt-load-generator:v1.0.7 --command \ -- /checker -h -p 1883 -u secret -P mega_secret \ -t /golang/pub --disable-bar ``` diff --git a/cmd/checker/main.go b/cmd/checker/main.go index 16c236c..926eecd 100644 --- a/cmd/checker/main.go +++ b/cmd/checker/main.go @@ -20,17 +20,17 @@ func main() { password := flag.String("P", "", "MQTT password") host := flag.String("h", "localhost", "MQTT host") port := flag.Int("p", 1883, "MQTT port") - qos := flag.Int("q", 1, "MQTT QoS used by all clients") + qos := flag.Int("q", 1, "MQTT QoS level used by all clients") disableBar := flag.Bool("disable-bar", false, "Disable interactive mode to display statistics as log messages instead of interactive output") resetTime := flag.Float64("reset-after", 30, "Reset counter after seconds without a message") cert := flag.String("cert", "", "Path to TLS certificate file") ca := flag.String("ca", "", "Path to TLS CA file") - key := flag.String("key", "", "Path to TLS key file") + key := flag.String("key", "", "Path to TLS private key file") insecure := flag.Bool("insecure", false, "Set to true to allow self signed certificates") mqtts := flag.Bool("mqtts", false, "Set to true to use MQTTS") cleanSession := flag.Bool("cleanSession", true, "Set to true for clean MQTT sessions or false to keep session") clientID := flag.String("clientID", "", "Custom MQTT clientID") - keepAliveTimeout := flag.Int64("keepAliveTimeout", 5000, "Set the amount of time (in seconds) that the client should wait before sending a PING request to the broker") + keepAliveTimeout := flag.Int64("keepAliveTimeout", 5, "Set the amount of time (in seconds) the client should wait for, before sending a PING request to the broker") flag.Parse() diff --git a/cmd/load_generator/main.go b/cmd/load_generator/main.go index d428a1f..9df7991 100644 --- a/cmd/load_generator/main.go +++ b/cmd/load_generator/main.go @@ -16,7 +16,7 @@ func main() { messageCount := flag.Int("c", 1000, "Number of messages to send") messageSize := flag.Int("s", 100, "Size in bytes of the message payload") interval := flag.Int("i", 1, "Milliseconds to wait between messages") - schedule := flag.String("z", "normal", "Distribution of time between messages: 'flat': always wait Interval between messages, 'normal': wait a random amount between messages with mean equal to the interval and stdev to half interval, 'random': wait a random amount between messages with mean equal to the interval.") + schedule := flag.String("z", "normal", "Distribution of time between messages: 'flat': always wait interval between messages, 'normal': wait a random amount between messages with mean equal to the interval and stdev to half the interval, 'random': wait a random amount between messages with mean equal to the interval.") targetTopic := flag.String("t", "/load", "Target MQTT topic to publish messages to") username := flag.String("u", "", "MQTT username") password := flag.String("P", "", "MQTT password") @@ -24,15 +24,15 @@ func main() { port := flag.Int("p", 1883, "MQTT port") numberOfClients := flag.Int("n", 1, "Number of concurrent MQTT clients") idAsSubTopic := flag.Bool("suffix", false, "If set to true integers will be used as sub-topic to the topic specified by 't'. The range goes from 1 to N where N is the max number of configured concurrent clients.") - qos := flag.Int("q", 1, "MQTT QoS used by all clients") + qos := flag.Int("q", 1, "MQTT QoS level used by all clients") cert := flag.String("cert", "", "Path to TLS certificate file") ca := flag.String("ca", "", "Path to TLS CA file") - key := flag.String("key", "", "Path to TLS key file") + key := flag.String("key", "", "Path to TLS private key file") insecure := flag.Bool("insecure", false, "Set to true to allow self signed certificates") mqtts := flag.Bool("mqtts", false, "Set to true to use MQTTS") cleanSession := flag.Bool("cleanSession", true, "Set to true for clean MQTT sessions or false to keep session") clientID := flag.String("clientID", "", "Custom MQTT clientID") - keepAliveTimeout := flag.Int64("keepAliveTimeout", 5000, "Set the amount of time (in seconds) that the client should wait before sending a PING request to the broker") + keepAliveTimeout := flag.Int64("keepAliveTimeout", 5, "Set the amount of time (in seconds) the client should wait for, before sending a PING request to the broker") flag.Parse() diff --git a/cmd/stdout/main.go b/cmd/stdout/main.go index b3c0531..91e8df6 100644 --- a/cmd/stdout/main.go +++ b/cmd/stdout/main.go @@ -19,7 +19,7 @@ func main() { password := flag.String("P", "", "MQTT password") host := flag.String("h", "localhost", "MQTT host") port := flag.Int("p", 1883, "MQTT port") - qos := flag.Int("q", 1, "MQTT QoS used by all clients") + qos := flag.Int("q", 1, "MQTT QoS level used by all clients") flag.Parse() diff --git a/go.mod b/go.mod index 60c5cf4..e806ee2 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/pablitovicente/mqtt-load-generator go 1.19 require ( - github.com/eclipse/paho.mqtt.golang v1.4.2 + github.com/eclipse/paho.mqtt.golang v1.4.3 github.com/google/uuid v1.3.0 github.com/paulbellamy/ratecounter v0.2.0 github.com/schollz/progressbar/v3 v3.13.1 diff --git a/go.sum b/go.sum index 47bcb20..d2af4cc 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ github.com/eclipse/paho.mqtt.golang v1.4.1 h1:tUSpviiL5G3P9SZZJPC4ZULZJsxQKXxfEN github.com/eclipse/paho.mqtt.golang v1.4.1/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA= github.com/eclipse/paho.mqtt.golang v1.4.2 h1:66wOzfUHSSI1zamx7jR6yMEI5EuHnT1G6rNA5PM12m4= github.com/eclipse/paho.mqtt.golang v1.4.2/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA= +github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik= +github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=