forked from wolfSSL/wolfMQTT
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (106 loc) · 3.94 KB
/
websocket-test.yml
File metadata and controls
122 lines (106 loc) · 3.94 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: WebSocket Client Test
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
jobs:
test-websocket:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential autoconf automake libtool
sudo apt-get install -y libwebsockets-dev mosquitto mosquitto-clients
- uses: actions/checkout@master
with:
repository: wolfssl/wolfssl
path: wolfssl
- name: wolfssl autogen
working-directory: ./wolfssl
run: ./autogen.sh
- name: wolfssl configure with coexist for default libwebsocket
working-directory: ./wolfssl
run: ./configure --enable-opensslcoexist
- name: wolfssl make
working-directory: ./wolfssl
run: make
- name: wolfssl make install
working-directory: ./wolfssl
run: sudo make install
- uses: actions/checkout@master
- name: wolfmqtt autogen
run: ./autogen.sh
- name: Configure and build wolfMQTT
run: |
./autogen.sh
./configure --enable-websocket
make
- name: Create Mosquitto config
run: |
echo "listener 11883" > mosquitto.conf
echo "protocol mqtt" >> mosquitto.conf
echo "listener 18080" >> mosquitto.conf
echo "protocol websockets" >> mosquitto.conf
echo "listener 18081" >> mosquitto.conf
echo "protocol websockets" >> mosquitto.conf
echo "cafile scripts/broker_test/ca-cert.pem" >> mosquitto.conf
echo "certfile scripts/broker_test/server-cert.pem" >> mosquitto.conf
echo "keyfile scripts/broker_test/server-key.pem" >> mosquitto.conf
echo "allow_anonymous true" >> mosquitto.conf
- name: Start Mosquitto broker
run: |
mosquitto -c mosquitto.conf -v -d
# Wait for broker to start
sleep 2
- name: Verify broker is running
run: |
# Check if mosquitto is running
pgrep mosquitto || (echo "Mosquitto failed to start" && exit 1)
# Check if port 18080 is open
nc -z localhost 18080 || (echo "WebSocket port 18080 is not open" && exit 1)
- name: Publish test message
run: |
# Start a background process to publish messages
(
# Wait for client to connect and subscribe
sleep 5
# Publish a test message
mosquitto_pub -t "test/topic" -m "Hello from WebSocket test" -p 11883
# Publish a few more messages
for i in {1..5}; do
sleep 1
mosquitto_pub -t "test/topic" -m "Test message $i" -p 11883
done
) &
- name: Run WebSocket client
run: |
# Run the client with a timeout
timeout 15s ./examples/websocket/websocket_client -h localhost -p 18080 || exit_code=$?
# Check if client received messages (exit code 124 means timeout occurred, which is expected)
if [ "$exit_code" -eq 124 ]; then
echo "Client ran successfully until timeout"
exit 0
elif [ "$exit_code" -ne 0 ]; then
echo "Client failed with exit code $exit_code"
exit 1
fi
- name: Run Secure WebSocket client
run: |
# Run the client with a timeout
timeout 15s ./examples/websocket/websocket_client -t -h localhost -p 18081 -A scripts/broker_test/ca-cert.pem || exit_code=$?
# Check if client received messages (exit code 124 means timeout occurred, which is expected)
if [ "$exit_code" -eq 124 ]; then
echo "Client ran successfully until timeout"
exit 0
elif [ "$exit_code" -ne 0 ]; then
echo "Client failed with exit code $exit_code"
exit 1
fi
- name: Stop Mosquitto broker
run: |
sudo killall mosquitto