Skip to content

Commit

Permalink
rudimentary e2e-test (#51)
Browse files Browse the repository at this point in the history
Signed-off-by: Malte Muench <[email protected]>
Co-authored-by: Malte Muench <[email protected]>
  • Loading branch information
mxmxchere and Malte Muench authored Apr 28, 2024
1 parent 45e0183 commit 6f8f707
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
14 changes: 14 additions & 0 deletions e2e-test/e2e-test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
100,none,e2e-test/none
101,16bool2ascii,e2e-test/16bool2ascii
102,uint82ascii,e2e-test/uint82ascii
103,uint162ascii,e2e-test/uint162ascii
104,uint322ascii,e2e-test/uint322ascii
105,uint642ascii,e2e-test/uint642ascii
106,2uint322ascii,e2e-test/2uint322ascii
107,4uint162ascii,e2e-test/4uint162ascii
108,4int162ascii,e2e-test/4int162ascii
109,4uint82ascii,e2e-test/4uint82ascii
110,8uint82ascii,e2e-test/8uint82ascii
111,bytecolor2colorcode,e2e-test/bytecolor2colorcode
112,pixelbin2ascii,e2e-test/pixelbin2ascii
523453525,none,e2e-test/largeidtest
73 changes: 73 additions & 0 deletions e2e-test/e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash

# Build
go build -C ../src -o ../e2e-test/can2mqtt

# Setup Virtual CAN Interface
# TODO find something that does not require root privileges
sudo ip link add dev vcan0 type vcan
sudo ip link set vcan0 up

# Setup local MQTT Server
# TODO find something that does not require root privileges, and is more system independent, probably a docker container
sudo systemctl start mosquitto.service

# Clean & Create logging directory
rm -rf logs
mkdir logs

# Start can2mqtt
./can2mqtt -c vcan0 -f e2e-test.csv > logs/can2mqtt 2>&1 &

# Start can-logging
candump vcan0 > logs/can 2>&1 &

# Start mqtt logging
mosquitto_sub -h localhost -v -t 'e2e-test/#' > logs/mqtt 2>&1 &

# Run tests
# Publish MQTT-Tests
mosquitto_pub -h localhost -m "test" -t e2e-test/none
mosquitto_pub -h localhost -m "0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 1" -t e2e-test/16bool2ascii
mosquitto_pub -h localhost -m "test" -t e2e-test/uint82ascii
mosquitto_pub -h localhost -m "test" -t e2e-test/uint162ascii
mosquitto_pub -h localhost -m "test" -t e2e-test/uint322ascii
mosquitto_pub -h localhost -m "test" -t e2e-test/uint642ascii
mosquitto_pub -h localhost -m "0 123441234" -t e2e-test/2uint322ascii
mosquitto_pub -h localhost -m "12 89 1234 4" -t e2e-test/4uint162ascii
mosquitto_pub -h localhost -m "-1234 42 1243 2" -t e2e-test/4int162ascii
mosquitto_pub -h localhost -m "12 2 21 2" -t e2e-test/4uint82ascii
mosquitto_pub -h localhost -m "1 2 3 4 5 6 7 8" -t e2e-test/8uint82ascii
mosquitto_pub -h localhost -m "test" -t e2e-test/bytecolor2colorcode
mosquitto_pub -h localhost -m "12 #00ff00" -t e2e-test/pixelbin2ascii

# Send CAN-Tests
cansend vcan0 "064#ABCD"
cansend vcan0 "065#ABCD"
cansend vcan0 "066#ABCD"
cansend vcan0 "067#ABCD"
cansend vcan0 "068#ABCD"
cansend vcan0 "069#ABCD"
cansend vcan0 "06a#ABCD"
cansend vcan0 "06b#ABCD"
cansend vcan0 "06c#ABCD"
cansend vcan0 "06d#ABCD"
cansend vcan0 "06e#ABCD"
cansend vcan0 "06f#ABCD"
cansend vcan0 "070#ABCD"

#
sleep 5
# Check results
md5sum logs/can
md5sum logs/mqtt

# Cleanup
pkill can2mqtt
pkill candump
pkill mosquitto_sub
cat logs/*
rm -rf logs
rm can2mqtt
sudo ip link delete vcan0
sudo systemctl stop mosquitto.service

0 comments on commit 6f8f707

Please sign in to comment.