Skip to content

Commit 57a41b3

Browse files
authored
remove eclipse broker and use local broker for tests instead (#22)
* remove eclipse broker and use local broker for tests instead * update travis to use token to deploy
1 parent 2272ba9 commit 57a41b3

File tree

6 files changed

+19
-34
lines changed

6 files changed

+19
-34
lines changed

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@ language: python
22
services:
33
- docker
44
dist:
5-
- 'xenial'
5+
- xenial
66
python:
77
- '2.7'
88
- '3.7'
99
before_install:
1010
- docker pull eclipse-mosquitto
11-
- docker run -d -p 1883:1883 -p 9001:9001 -v $(pwd)/mosquitto:/mosquitto/config eclipse-mosquitto
11+
- docker run -d -p 11883:1883 -p 9001:9001 -v $(pwd)/mosquitto:/mosquitto/config eclipse-mosquitto
12+
- docker run -d -p 1883:1883 eclipse-mosquitto
1213
install:
1314
- pip install -r requirements.txt
1415
script:
1516
- robot -P src tests
1617
deploy:
18+
matrix:
1719
- provider: pypi
18-
user: randomsync
20+
user: __token__
1921
password:
20-
secure: bbHK7u+MEnJ4YifZuSsF+O5HmIMvlfHaVd1u31k2Xdbj1aYsIz1tpD+iH4mYsinJ7YpnmfJAGArSPlemLEJC2kdRcnlSRQONtpUuooLG2PPQbwIgVtJh3gpxA06L1GxVoMeRWnCfqDttFSMIs7NTxA52UtalZbER5ALXB8StHn0=
21-
distributions: "sdist bdist_wheel"
22+
secure: RS3D0zpd+1+AnwtJUpeU+XssZOSZXly1MRaU6Eo6P0ziZp1dXV+83vANPaFT7Ik7KhO/I6BuNdNrgcbLMXIi0I1Pj9ZrZq0iJ9J6PH5U2BfoXDu7XIdep5fxch5k1FMLCNl2GAnam/NFmpB0sU5+aWgpwK4o5npQ6LKWwg4BhGebFnEc4O4O8erliqoiaC1W/WvZOSLRv9WQod+Hfwbcd13tiA43i4ZkrUWGD62hB0jFaaX9CaQRcYpYzTOUe7Npbt7vw9ZavZVQ9mEklG2ttiSMfMuYuUo9lZCGssMxQP4ghTspjdMiII4rkwV0SGib4mECY/qhbzUqmFzEUe4CTrn5WOhjW8zunQbQB3+nf5w0MsxJ3/Qu1N635Acinl4njPFrxkuYOU1Wnj+Nqy6i6LBdcUVXQ1E6kSSk1g/JaqSdbae+EhpybNOKZRVfkjgG8idKotmCqQxF7JyFmdstPB9dhUcMx8q3ubjmL49ju+qI2hrIrN7Dr/Y1AWCxVJb38dSNktEG2WCc3MUgpnKPLWuzuJn+zHo9S9rLL58m/nSiejZ9XUgi3gOzrFeovAOCWSp4ZLea2c43CTBeNBhQtrKyVFzUaxyqAlJsr4oK0LapvF117eiCy1smvBuflFMb99e7qjemYRZTcV04d4RCSsDgNLy+Xxz4Vi0DTWVCdAk=
23+
distributions: sdist bdist_wheel
2224
skip_cleanup: true
2325
on:
2426
repo: randomsync/robotframework-mqttlibrary

README.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ Contributing
7171

7272
The keywords in this library are based on some of the methods available in eclipse paho client library. If you'd like to add keywords, see instructions_ on creating/updating libraries for Robot Framework.
7373

74-
The tests are in ``tests`` folder and make use of Robot Framework itself. They are run automatically through travis when code is pushed to a branch. Most of the tests rely on the public mqtt broker at iot.eclipse.org, but some that validate authentication rely on a local broker. You can start a local broker with the provided configuration. You can then run the tests locally::
74+
The tests are in ``tests`` folder and make use of Robot Framework itself. They are run automatically through travis when code is pushed to a branch. When run locally, these tests rely on locally running mqtt brokers. We need 2 running brokers, one without auth that is used by most of the tests, and the other one with auth (configuration file is provided). You'll need to start them before running the tests. You can then run the tests locally::
7575

7676
docker pull eclipse-mosquitto
77-
docker run -d -p 1883:1883 -p 9001:9001 -v $(pwd)/mosquitto:/mosquitto/config eclipse-mosquitto
78-
pybot -P src tests
77+
docker run -d -p 1883:1883 eclipse-mosquitto
78+
docker run -d -p 11883:1883 -p 9001:9001 -v $(pwd)/mosquitto:/mosquitto/config eclipse-mosquitto
79+
robot -P src tests
7980

8081

8182
Make sure to stop the docker container when it is no longer needed.

tests/connect.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
*** Variables ***
8-
| ${broker.uri} | mqtt.eclipse.org
8+
| ${broker.uri} | 127.0.0.1
99
| ${broker.port} | 1883
1010
| ${client.id} | test.client
1111

tests/keywords.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
| Library | BuiltIn
44

55
| *Variables* | *Value*
6-
| ${broker.uri} | mqtt.eclipse.org
7-
#| ${broker.uri} | 127.0.0.1
6+
#| ${broker.uri} | mqtt.eclipse.org
7+
| ${broker.uri} | 127.0.0.1
88
| ${broker.port} | 1883
99
| ${client.id} | mqtt.test.client
1010
| ${topic} | test/mqtt_test

tests/publish.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| Test Timeout | 30 seconds
55

66
*** Variables ***
7-
| ${broker.uri} | mqtt.eclipse.org
7+
| ${broker.uri} | 127.0.0.1
88
| ${broker.port} | 1883
99
| ${client.id} | mqtt.test.client
1010
| ${topic} | test/mqtt_test

tests/pubsub.robot

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
| | Subscribe to MQTT Broker and Validate | client.id=${client} | topic=${topic} | message=${message}
2323

2424
| Publish multiple messages and confirm that validation succeeds only after correct message is published
25-
| | Sleep | 1s
2625
| | ${time} | Get Time | epoch
2726
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
2827
| | ${topic} | Set Variable | test/mqtt_test_sub
@@ -39,7 +38,6 @@
3938
| | Subscribe to MQTT Broker and Validate | client.id=${client} | topic=${topic} | message=${message}
4039

4140
| Publish an empty message with QOS 1 and validate
42-
| | Sleep | 1s
4341
| | ${time} | Get Time | epoch
4442
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
4543
| | ${topic} | Set Variable | test/mqtt_test_sub
@@ -49,7 +47,6 @@
4947
| | Subscribe to MQTT Broker and Validate | client.id=${client} | topic=${topic}
5048

5149
| Publish and validate with regular expression
52-
| | Sleep | 1s
5350
| | ${time} | Get Time | epoch
5451
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
5552
| | ${topic} | Set Variable | test/mqtt_test_sub
@@ -61,7 +58,6 @@
6158
| | Subscribe to MQTT Broker and Validate | client.id=${client} | topic=${topic} | message=${regex}
6259

6360
| Subscribe for the first time and validate that no messages are received
64-
| | Sleep | 1s
6561
| | ${time} | Get Time | epoch
6662
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
6763
| | ${topic} | Set Variable | test/mqtt_test_sub
@@ -70,7 +66,6 @@
7066
| | Length Should Be | ${messages} | 0
7167

7268
| Subscribe, publish 1 message and validate it is received
73-
| | Sleep | 1s
7469
| | ${time} | Get Time | epoch
7570
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
7671
| | ${topic} | Set Variable | test/mqtt_test_sub
@@ -82,7 +77,6 @@
8277
| | Should Be Equal As Strings | ${messages}[0] | test message
8378

8479
| Subscribe with no limit, publish multiple messages and validate they are received
85-
| | Sleep | 1s
8680
| | ${time} | Get Time | epoch
8781
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
8882
| | ${topic} | Set Variable | test/mqtt_test_sub
@@ -98,7 +92,6 @@
9892
| | Should Be Equal As Strings | ${messages}[2] | test message3
9993

10094
| Subscribe with limit
101-
| | Sleep | 1s
10295
| | ${time} | Get Time | epoch
10396
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
10497
| | ${topic} | Set Variable | test/mqtt_test_sub
@@ -117,7 +110,6 @@
117110
| | Should Be Equal As Strings | ${messages}[1] | test message3
118111

119112
| Unsubscribe and validate no messages are received
120-
| | Sleep | 1s
121113
| | ${time} | Get Time | epoch
122114
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
123115
| | ${topic} | Set Variable | test/mqtt_test_sub
@@ -137,12 +129,12 @@
137129
| | ${message} | Set Variable | subscription test message
138130
| | Set username and password | authuser1 | password1
139131
| | Run Keyword And Expect Error | The expected payload didn't arrive in the topic
140-
| | ... | Subscribe to MQTT Broker and Validate | broker.uri=127.0.0.1 | client.id=${client}
132+
| | ... | Subscribe to MQTT Broker and Validate | broker.uri=127.0.0.1 | port=11883 | client.id=${client}
141133
| | ... | topic=${topic} | message=${message}
142-
| | Connect | 127.0.0.1
134+
| | Connect | 127.0.0.1 | 11883
143135
| | Publish | ${topic} | test message with username and password | qos=1
144136
| | Subscribe to MQTT Broker and Validate
145-
| | ... | broker.uri=127.0.0.1 | client.id=${client} | topic=${topic} | message=test message with username and password
137+
| | ... | broker.uri=127.0.0.1 | port=11883 | client.id=${client} | topic=${topic} | message=test message with username and password
146138
| | [Teardown] | Disconnect
147139

148140
| Publish to a broker that requires authentication with invalid password
@@ -152,35 +144,29 @@
152144
| | ${topic} | Set Variable | test
153145
| | Set username and password | authuser1 | invalidpwd
154146
| | Run Keyword and expect error | The client disconnected unexpectedly
155-
| | ... | Connect | 127.0.0.1 | 1883 | ${client}
147+
| | ... | Connect | 127.0.0.1 | 11883 | ${client}
156148
| | [Teardown] | Disconnect
157149

158150
| Subscribe async, publish 1 message, listen for and validate it is received
159-
| | Sleep | 1s
160151
| | ${time} | Get Time | epoch
161152
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
162153
| | ${topic} | Set Variable | test/mqtt_test_sub
163154
| | Subscribe Async | client.id=${client} | topic=${topic}
164155
| | Publish to MQTT Broker | topic=${topic} | message=test message | qos=1
165-
| | Sleep | 5s
166156
| | @{messages} | Listen and Get Messages | topic=${topic}
167157
| | LOG | ${messages}
168158
| | Length Should Be | ${messages} | 1
169159
| | Should Be Equal As Strings | ${messages}[0] | test message
170160
| | [Teardown] | Unsubscribe and Disconnect | ${topic}
171161

172162
| Subscribe async, publish several messages, listen for and validate they are received
173-
| | Sleep | 1s
174163
| | ${time} | Get Time | epoch
175164
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
176165
| | ${topic} | Set Variable | test/mqtt_test_sub
177166
| | Subscribe Async | client.id=${client} | topic=${topic}
178167
| | Publish to MQTT Broker | topic=${topic} | message=test message1 | qos=1
179-
| | Sleep | 1s
180168
| | Publish to MQTT Broker | topic=${topic} | message=test message2 | qos=1
181-
| | Sleep | 1s
182169
| | Publish to MQTT Broker | topic=${topic} | message=test message3 | qos=1
183-
| | Sleep | 5s
184170
| | @{messages} | Listen and Get Messages | topic=${topic} | limit=0
185171
| | LOG | ${messages}
186172
| | Length Should Be | ${messages} | 3
@@ -190,7 +176,6 @@
190176
| | [Teardown] | Unsubscribe and Disconnect | ${topic}
191177

192178
| Subscribe async to multiple topics, publish several messages, listen for them and validate they are received
193-
| | Sleep | 1s
194179
| | ${time} | Get Time | epoch
195180
| | ${client1} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
196181
| | ${client2} | Catenate | SEPARATOR=. | robot.mqtt | ${time+1}
@@ -199,11 +184,8 @@
199184
| | Subscribe Async | client.id=${client1} | topic=${topic1}
200185
| | Subscribe Async | client.id=${client2} | topic=${topic2}
201186
| | Publish to MQTT Broker | topic=${topic2} | message=test message1 | qos=1
202-
| | Sleep | 1s
203187
| | Publish to MQTT Broker | topic=${topic1} | message=test message2 | qos=1
204-
| | Sleep | 1s
205188
| | Publish to MQTT Broker | topic=${topic2} | message=test message3 | qos=1
206-
| | Sleep | 5s
207189
| | @{messages1} | Listen and Get Messages | topic=${topic1} | limit=0
208190
| | @{messages2} | Listen and Get Messages | topic=${topic2} | limit=0
209191
| | LOG | ${messages1}

0 commit comments

Comments
 (0)