Skip to content

Commit fed1032

Browse files
authored
Merge pull request #250 from kuzzleio/2-dev
## 2.0.0-rc38 - [breaking] Change the measures property in API and data model to be more intuitive #246 - Add asset historization #247 - [breaking] Remove Measures controller pushAsset action #248
2 parents 6e446ad + 968288d commit fed1032

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1232
-695
lines changed

features/Asset/Controller.feature

Lines changed: 16 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ Feature: Asset Controller
88
| body.reference | "A1" |
99
| body.metadata.height | 5 |
1010
Then The document "engine-kuzzle":"assets":"Container-A1" content match:
11-
| metadata.height | 5 |
12-
| metadata.weight | null |
13-
| measures.temperatureExt.type | "temperature" |
14-
| measures.temperatureInt.type | "temperature" |
15-
| measures.position.type | "position" |
16-
| linkedDevices | [] |
11+
| metadata.height | 5 |
12+
| metadata.weight | null |
13+
| measures.temperatureExt | null |
14+
| measures.temperatureInt | null |
15+
| measures.position | null |
16+
| linkedDevices | [] |
17+
| _kuzzle_info.author | "-1" |
18+
# Update metadata
1719
When I successfully execute the action "device-manager/assets":"update" with args:
1820
| engineId | "engine-kuzzle" |
1921
| _id | "Container-A1" |
2022
| body.metadata.weight | 1250 |
2123
Then The document "engine-kuzzle":"assets":"Container-A1" content match:
22-
| metadata.height | 5 |
23-
| metadata.weight | 1250 |
24+
| metadata.height | 5 |
25+
| metadata.weight | 1250 |
26+
| _kuzzle_info.updater | "-1" |
2427
# Get
2528
When I successfully execute the action "device-manager/assets":"get" with args:
2629
| engineId | "engine-kuzzle" |
@@ -42,11 +45,11 @@ Feature: Asset Controller
4245
Then I should receive a "hits" array of objects matching:
4346
| _id |
4447
| "Container-A1" |
45-
# Delete
46-
When I successfully execute the action "device-manager/assets":"delete" with args:
47-
| engineId | "engine-kuzzle" |
48-
| _id | "Container-A1" |
49-
Then The document "engine-kuzzle":"assets":"Container-A1" does not exists
48+
# Delete
49+
When I successfully execute the action "device-manager/assets":"delete" with args:
50+
| engineId | "engine-kuzzle" |
51+
| _id | "Container-A1" |
52+
Then The document "engine-kuzzle":"assets":"Container-A1" does not exists
5053

5154
Scenario: Error when creating Asset from unknown model
5255
When I execute the action "device-manager/assets":"create" with args:
@@ -81,49 +84,3 @@ Feature: Asset Controller
8184
| _source.values.temperature | _source.asset._id | _source.origin._id | _source.asset.model |
8285
| 40 | "Container-linked1" | "DummyTemp-linked1" | "Container" |
8386
| 41 | "Container-linked1" | "DummyTemp-linked1" | "Container" |
84-
85-
Scenario: Push a measures in the asset, an other with different name and an older one
86-
When I successfully execute the action "device-manager/measures":"push" with args:
87-
| engineId | "engine-ayse" |
88-
| body.assetId | "Container-unlinked1" |
89-
| body.measure.type | "temperature" |
90-
| body.measure.values.temperature | 26 |
91-
| body.measure.type | "temperature" |
92-
| body.measure.name | "temperatureExt" |
93-
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
94-
| measures.temperatureExt.type | "temperature" |
95-
| measures.temperatureExt.values.temperature | 26 |
96-
When I successfully execute the action "device-manager/measures":"push" with args:
97-
| engineId | "engine-ayse" |
98-
| body.assetId | "Container-unlinked1" |
99-
| body.measure.type | "temperature" |
100-
| body.measure.values.temperature | -5 |
101-
| body.measure.type | "temperature" |
102-
| body.measure.name | "temperatureInt" |
103-
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
104-
| measures.temperatureInt.type | "temperature" |
105-
| measures.temperatureInt.values.temperature | -5 |
106-
| measures.temperatureExt.type | "temperature" |
107-
| measures.temperatureExt.values.temperature | 26 |
108-
When I successfully execute the action "device-manager/measures":"push" with args:
109-
| engineId | "engine-ayse" |
110-
| body.assetId | "Container-unlinked1" |
111-
| body.measure.type | "temperature" |
112-
| body.measure.values.temperature | 31 |
113-
| body.measure.type | "temperature" |
114-
| body.measure.name | "temperatureExt" |
115-
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
116-
| measures.temperatureExt.values.temperature | 31 |
117-
Then I count 3 documents in "engine-ayse":"measures"
118-
119-
Scenario: Push a measure without name use measure type as name
120-
When I successfully execute the action "device-manager/measures":"push" with args:
121-
| engineId | "engine-ayse" |
122-
| body.assetId | "Container-unlinked1" |
123-
| body.measure.type | "temperature" |
124-
| body.measure.values.temperature | 70 |
125-
| body.measure.name | "temperatureExt" |
126-
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
127-
| measures.temperatureExt.type | "temperature" |
128-
| measures.temperatureExt.name | "temperatureExt" |
129-
| measures.temperatureExt.values.temperature | 70 |

features/Asset/History.feature

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Feature: Asset Historization
2+
3+
Scenario: Historize asset after creation and metadata update
4+
When I successfully execute the action "device-manager/assets":"create" with args:
5+
| engineId | "engine-kuzzle" |
6+
| body.model | "Container" |
7+
| body.reference | "A1" |
8+
| body.metadata.height | 5 |
9+
And I successfully execute the action "device-manager/assets":"update" with args:
10+
| engineId | "engine-kuzzle" |
11+
| _id | "Container-A1" |
12+
| body.metadata.weight | 1250 |
13+
And I refresh the collection "engine-kuzzle":"assets-history"
14+
Then I successfully execute the action "document":"search" with args:
15+
| index | "engine-kuzzle" |
16+
| collection | "assets-history" |
17+
| body.sort | {"_kuzzle_info.createdAt": "desc"} |
18+
And I should receive a result matching:
19+
| hits.length | 2 |
20+
| hits[0]._source.id | "Container-A1" |
21+
| hits[0]._source.event.name | "metadata" |
22+
| hits[0]._source.event.metadata.names | ["weight"] |
23+
| hits[0]._source.asset.metadata.height | 5 |
24+
| hits[0]._source.asset.metadata.weight | 1250 |
25+
| hits[1]._source.id | "Container-A1" |
26+
| hits[1]._source.event.name | "metadata" |
27+
| hits[1]._source.event.metadata.names | ["weight", "height"] |
28+
| hits[1]._source.asset.metadata.height | 5 |
29+
| hits[1]._source.asset.metadata.weight | null |
30+
31+
Scenario: Historize asset after being linked and unlinked
32+
When I successfully execute the action "device-manager/devices":"linkAsset" with args:
33+
| _id | "DummyTemp-unlinked1" |
34+
| assetId | "Container-unlinked1" |
35+
| engineId | "engine-ayse" |
36+
| body.measureNames[0].device | "temperature" |
37+
| body.measureNames[0].asset | "temperatureExt" |
38+
And I execute the action "device-manager/devices":"unlinkAsset" with args:
39+
| engineId | "engine-ayse" |
40+
| _id | "DummyTemp-unlinked1" |
41+
And I refresh the collection "engine-ayse":"assets-history"
42+
Then I successfully execute the action "document":"search" with args:
43+
| index | "engine-ayse" |
44+
| collection | "assets-history" |
45+
| body.sort | {"_kuzzle_info.createdAt": "desc"} |
46+
And I should receive a result matching:
47+
| hits.length | 2 |
48+
| hits[0]._source.id | "Container-unlinked1" |
49+
| hits[0]._source.event.name | "unlink" |
50+
| hits[0]._source.event.unlink.deviceId | "DummyTemp-unlinked1" |
51+
| hits[0]._source.asset.linkedDevices | [] |
52+
| hits[1]._source.id | "Container-unlinked1" |
53+
| hits[1]._source.event.name | "link" |
54+
| hits[1]._source.event.link.deviceId | "DummyTemp-unlinked1" |
55+
| hits[1]._source.asset.linkedDevices[0]._id | "DummyTemp-unlinked1" |
56+
57+
Scenario: Historize asset after receiving a new measure
58+
When I send the following "dummy-temp" payloads:
59+
| deviceEUI | temperature |
60+
| "linked1" | 42.2 |
61+
And I refresh the collection "engine-ayse":"assets-history"
62+
Then I successfully execute the action "document":"search" with args:
63+
| index | "engine-ayse" |
64+
| collection | "assets-history" |
65+
| body.sort | {"_kuzzle_info.createdAt": "desc"} |
66+
And I should receive a result matching:
67+
| hits.length | 1 |
68+
| hits[0]._source.id | "Container-linked1" |
69+
| hits[0]._source.event.name | "measure" |
70+
| hits[0]._source.event.measure.names | ["temperatureExt"] |
71+
| hits[0]._source.event.metadata | "_UNDEFINED_" |
72+
| hits[0]._source.asset.measures.temperatureExt.values.temperature | 42.2 |
73+
74+
Scenario: Historize asset when metadata have been updated when receiving a measure
75+
# A pipe will set the asset "weight" metadata to 42042
76+
When I send the following "dummy-temp" payloads:
77+
| deviceEUI | temperature | metadata.color |
78+
| "linked1" | 42.2 | "test-metadata-history-with-measure" |
79+
And I refresh the collection "engine-ayse":"assets-history"
80+
Then I successfully execute the action "document":"search" with args:
81+
| index | "engine-ayse" |
82+
| collection | "assets-history" |
83+
| body.sort | {"_kuzzle_info.createdAt": "desc"} |
84+
And I should receive a result matching:
85+
| hits.length | 1 |
86+
| hits[0]._source.id | "Container-linked1" |
87+
| hits[0]._source.event.name | "measure" |
88+
| hits[0]._source.event.measure.names | ["temperatureExt"] |
89+
| hits[0]._source.event.metadata.names | ["weight"] |
90+
| hits[0]._source.asset.measures.temperatureExt.values.temperature | 42.2 |
91+
| hits[0]._source.asset.metadata.weight | 42042 |

features/Decoder/PayloadController.feature

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ Feature: Payloads Controller
3636
| valid | false |
3737
And The document "device-manager":"devices":"DummyTemp-12345" does not exists
3838

39-
Scenario: Receive a payload with 3 measures
39+
Scenario: Receive a payload with 3 measures but only 2 are propagated to the asset
4040
Given I send the following "dummy-temp-position" payloads:
4141
| deviceEUI | temperature | location.lat | location.lon | location.accuracy | battery |
42-
| "12345" | 21 | 42.2 | 2.42 | 2100 | 0.8 |
43-
Then The document "device-manager":"devices":"DummyTempPosition-12345" content match:
44-
| reference | "12345" |
42+
| "linked2" | 21 | 42.2 | 2.42 | 2100 | 0.8 |
43+
Then The document "device-manager":"devices":"DummyTempPosition-linked2" content match:
44+
| reference | "linked2" |
4545
| model | "DummyTempPosition" |
4646
| measures.temperature.type | "temperature" |
4747
| measures.temperature.measuredAt | "_DATE_NOW_" |
@@ -54,22 +54,38 @@ Feature: Payloads Controller
5454
| measures.battery.type | "battery" |
5555
| measures.battery.measuredAt | "_DATE_NOW_" |
5656
| measures.battery.values.battery | 80 |
57-
| engineId | null |
58-
| assetId | null |
57+
| engineId | "engine-ayse" |
58+
| assetId | "Container-linked2" |
59+
Then The document "engine-ayse":"assets":"Container-linked2" content match:
60+
| measures.temperatureExt.values.temperature | 21 |
61+
| measures.position.values.position.lat | 42.2 |
62+
| measures.position.values.position.lon | 2.42 |
63+
| measures.battery | "_UNDEFINED_" |
64+
And I refresh the collection "engine-ayse":"assets-history"
65+
Then I successfully execute the action "document":"search" with args:
66+
| index | "engine-ayse" |
67+
| collection | "assets-history" |
68+
| body.sort | {"_kuzzle_info.createdAt": "desc"} |
69+
And I should receive a result matching:
70+
| hits.length | 1 |
71+
| hits[0]._source.id | "Container-linked2" |
72+
| hits[0]._source.event.name | "measure" |
73+
| hits[0]._source.event.measure.names | ["temperatureExt", "position"] |
74+
5975

6076
Scenario: Historize the measures with device and asset context
6177
Given I send the following "dummy-temp" payloads:
62-
| deviceEUI | "12345" |
63-
| "linked1" | 42.2 |
78+
| deviceEUI | temperature |
79+
| "linked1" | 42.2 |
6480
And I refresh the collection "engine-ayse":"measures"
6581
Then When I successfully execute the action "document":"search" with args:
6682
| index | "engine-ayse" |
6783
| collection | "measures" |
6884
And I should receive a result matching:
6985
| hits[0]._source.type | "temperature" |
86+
| hits[0]._source.values.temperature | 42.2 |
7087
| hits[0]._source.measuredAt | "_DATE_NOW_" |
7188
| hits[0]._source.origin._id | "DummyTemp-linked1" |
72-
| hits[0]._source.origin.type | "device" |
7389
| hits[0]._source.origin.measureName | "temperature" |
7490
| hits[0]._source.origin.deviceModel | "DummyTemp" |
7591
| hits[0]._source.origin.reference | "linked1" |

features/Device/Controller/AttachEngine.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ Feature: Attach device to engine
55
| _id | "DummyTemp-detached1" |
66
| engineId | "engine-kuzzle" |
77
Then The document "device-manager":"devices":"DummyTemp-detached1" content match:
8-
| engineId | "engine-kuzzle" |
8+
| engineId | "engine-kuzzle" |
9+
| _kuzzle_info.updater | "-1" |
910
Then The document "engine-kuzzle":"devices":"DummyTemp-detached1" content match:
10-
| engineId | "engine-kuzzle" |
11+
| engineId | "engine-kuzzle" |
12+
| _kuzzle_info.author | "-1" |
1113
When I send the following "dummy-temp" payloads:
1214
| deviceEUI | temperature |
1315
| "detached1" | 21 |

features/Device/Controller/DetachEngine.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Feature: Detach device from engine
88
| engineId | "engine-kuzzle" |
99
| _id | "DummyTemp-detached1" |
1010
Then The document "device-manager":"devices":"DummyTemp-detached1" content match:
11-
| engineId | null |
11+
| engineId | null |
12+
| _kuzzle_info.updater | "-1" |
1213
And The document "engine-kuzzle":"devices":"DummyTemp-detached1" does not exists
1314

1415
Scenario: Error if device is not attached

0 commit comments

Comments
 (0)