forked from vibesrc/mqttconformance
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_conformance_test.sh
More file actions
executable file
·68 lines (56 loc) · 1.57 KB
/
run_conformance_test.sh
File metadata and controls
executable file
·68 lines (56 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
#
# run the MQTT 3.1.1 + 5.0 conformance tests for a given broker.
#
# the broker is expected to allow anonymous access on unencrypted port 1883
#
function usage {
printf "Usage:\n"
printf "$0 --hostname|-h <broker_hostname>\n"
exit 1
}
function argparse {
echo "Parameters: $*"
if [ $# -eq 0 ]; then
usage
fi
while [ $# -gt 0 ]; do
case "$1" in
--hostname|-h)
# the hostname of the MQTT broker
export BROKER_HOSTNAME="${2}"
shift
;;
*)
printf "ERROR: Parameters invalid\n"
usage
esac
shift
done
}
#
# init
export BROKER_HOSTNAME=localhost
export REPORT_FILE_MQTT_3=conformance-report-mqtt311.txt
export REPORT_FILE_MQTT_5=conformance-report-mqtt5.txt
argparse $*
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
CONFORMANCE_TEST_BINARY=${SCRIPT_DIR}/target/release/mqtt-conformance
if [ -z "${CONFORMANCE_TEST_BINARY}" ]; then
printf "Test binary not available: '${CONFORMANCE_TEST_BINARY}', please compile it first.\n"
fi
#
# create reports
printf "💥 Creating MQTT 3.1.1 report..."
MQTT_VERSION=3
${CONFORMANCE_TEST_BINARY} run \
-H ${BROKER_HOSTNAME} -p 1883 \
--username admin --password admin \
-v ${MQTT_VERSION} -V | tee ${SCRIPT_DIR}/${REPORT_FILE_MQTT_3}
printf "💥 Creating MQTT 5.0 report..."
MQTT_VERSION=5
${CONFORMANCE_TEST_BINARY} run \
-H ${BROKER_HOSTNAME} -p 1883 \
--username admin --password admin \
-v ${MQTT_VERSION} -V | tee ${SCRIPT_DIR}/${REPORT_FILE_MQTT_5}
printf "✅ MQTT conformance reports created."