Skip to content

Commit 2da05fe

Browse files
reubenmillerdidier-wenzek
authored andcommitted
refactor system tests to used mqtt logger for assertions
Signed-off-by: reubenmiller <reuben.d.miller@gmail.com>
1 parent cd64017 commit 2da05fe

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

tests/RobotFramework/tests/tedge_flows/tedge_flows.robot

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*** Settings ***
2+
Library JSONLibrary
23
Library ThinEdgeIO
34

45
Suite Setup Custom Setup
@@ -111,8 +112,9 @@ Consuming messages from a process stdout, periodically
111112

112113
Consuming messages from the tail of file
113114
# Assuming the flow tail-named-pipe.toml has been properly installed
114-
Execute Command (for i in $(seq 10); do sleep 1; echo hello>/tmp/events; done)&
115-
Execute Command tedge mqtt sub log/events --duration 2s | grep hello
115+
${start} Get Unix Timestamp
116+
Execute Command echo hello>/tmp/events
117+
Should Have MQTT Messages topic=log/events message_contains=hello minimum=1 date_from=${start}
116118

117119
Consuming messages from a file, periodically
118120
# Assuming the flow read-file-periodically.toml has been properly installed
@@ -135,12 +137,32 @@ Appending messages to a file
135137

136138
Publishing transformation errors
137139
# Assuming the flow publish-js-errors.toml has been properly installed
138-
Execute Command (for i in $(seq 3); do sleep 1; tedge mqtt pub collectd/foo 12345:6789; done)&
139-
Execute Command tedge mqtt sub test/errors --duration 2s | grep 'Error: Not a collectd topic'
140-
Execute Command (for i in $(seq 3); do sleep 1; tedge mqtt pub collectd/a/b/c foo,bar; done)&
141-
Execute Command tedge mqtt sub test/errors --duration 2s | grep 'Error: Not a collectd payload'
142-
Execute Command (for i in $(seq 3); do sleep 1; tedge mqtt pub collectd/a/b/c 12345:6789; done)&
143-
Execute Command tedge mqtt sub test/output --duration 2s | grep '{"time": 12345, "b": {"c": 6789}}'
140+
${start} Get Unix Timestamp
141+
Execute Command tedge mqtt pub collectd/foo 12345:6789
142+
Should Have MQTT Messages
143+
... topic=test/errors
144+
... minimum=1
145+
... message_contains=Error: Not a collectd topic
146+
... date_from=${start}
147+
148+
${start} Get Unix Timestamp
149+
Execute Command tedge mqtt pub collectd/a/b/c foo,bar
150+
Should Have MQTT Messages
151+
... topic=test/errors
152+
... minimum=1
153+
... message_contains=Error: Not a collectd payload
154+
... date_from=${start}
155+
156+
${start} Get Unix Timestamp
157+
Execute Command tedge mqtt pub collectd/a/b/c 12345:6789
158+
${messages} Should Have MQTT Messages
159+
... topic=test/output
160+
... minimum=1
161+
... message_contains=time
162+
... date_from=${start}
163+
${message} JSONLibrary.Convert String To Json ${messages[0]}
164+
Should Be Equal As Integers ${message["time"]} 12345
165+
Should Be Equal As Integers ${message["b"]["c"]} 6789
144166

145167

146168
*** Keywords ***

0 commit comments

Comments
 (0)