Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
test(e2e): set random data only once
Browse files Browse the repository at this point in the history
So retries eventually pick up the right data
  • Loading branch information
coderbyheart committed Jan 8, 2021
1 parent ced3866 commit 7ff3882
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
30 changes: 17 additions & 13 deletions features/DeviceBatchData.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@ Feature: Device: Batch Data
Background:

Given I am run after the "Device: Update Shadow" feature
Given I store "$millis()" into "ts1"
And I store "$millis()+(120*1000)" into "ts2"
And I store "$random() * 180" into "lng1"
And I store "$random() * 180" into "lng2"

Scenario: Devices can publish batch data

Given I store "$millis()" into "ts"
And I store "$millis()+(120*1000)" into "ts2"
Then the cat tracker publishes this message to the topic {cat:id}/batch
Given the cat tracker publishes this message to the topic {cat:id}/batch
"""
{
"gps": [
{
"v": {
"lng": 8.669555,
"lng": {lng1},
"lat": 50.109177,
"acc": 28.032738,
"alt": 204.623276,
"spd": 0.698944,
"hdg": 0
},
"ts": {ts}
"ts": {ts1}
},
{
"v": {
"lng": 10.424793,
"lng": {lng2},
"lat": 63.422975,
"acc": 12.276645,
"alt": 137.319351,
Expand All @@ -40,8 +42,7 @@ Feature: Device: Batch Data
]
}
"""

Given I am authenticated with Cognito
And I am authenticated with Cognito
When I run this Timestream query
"""
SELECT measure_value::double AS value
Expand All @@ -50,17 +51,20 @@ Feature: Device: Batch Data
AND measure_name='gps.lng'
AND measure_value::double IS NOT NULL
ORDER BY time DESC
LIMIT 2
"""
Then "timestreamQueryResult" should match this JSON
# The values are string because they have not yet run through the formatter
"""
[
{
"value": 8.669555
},
"value": {lng1}
}
]
"""
And "timestreamQueryResult" should match this JSON
"""
[
{
"value": 10.424793
"value": {lng2}
}
]
"""
12 changes: 8 additions & 4 deletions features/DeviceMessages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Feature: Device: Messages
Background:

Given I am run after the "Device: Update Shadow" feature
And I store "$floor($random() * 1024)" into "button1"
And I store "$floor($random() * 1024)" into "button2"

Scenario: Devices publishes that a button was pressed

Given I store "$millis()" into "ts"
And I store "$floor($random() * 1024)" into "button1"
And I store "$floor($random() * 1024)" into "button2"
Then the cat tracker publishes this message to the topic {cat:id}/messages
"""
{
Expand All @@ -37,14 +37,18 @@ Feature: Device: Messages
FROM "{historicaldataDatabaseName}"."{historicaldataTableName}"
WHERE deviceId='{cat:id}' AND measure_name='btn' AND measure_value::double IS NOT NULL
ORDER BY time DESC
LIMIT 2
"""
Then "timestreamQueryResult" should match this JSON
"""
[
{
"value": {button1}
},
}
]
"""
Then "timestreamQueryResult" should match this JSON
"""
[
{
"value": {button2}
}
Expand Down

0 comments on commit 7ff3882

Please sign in to comment.