Skip to content

Commit 860621e

Browse files
author
Adrien Maret
authored
[breaking] Fixes for iot backend (#245)
Asset and Device models must be PascalCase (breaking) Harmonize and rename default payload-gateway roles (breaking): - Role `payload-gateway.dummy-temp-position` => `payload_gateway.dummy_temp_position` - Profile `payload-gateway.dummy.temp` => `payload_gateway.dummy_temp` payload_gateway.dummy_temp" - User `payload-gateway.dummy-temp` => `payload_gateway.dummy_temp`
1 parent f9a5cef commit 860621e

34 files changed

+220
-106
lines changed

features/Asset/Controller.feature

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,34 @@ Feature: Asset Controller
44
# Create
55
When I successfully execute the action "device-manager/assets":"create" with args:
66
| engineId | "engine-kuzzle" |
7-
| body.model | "container" |
7+
| body.model | "Container" |
88
| body.reference | "A1" |
99
| body.metadata.height | 5 |
10-
Then The document "engine-kuzzle":"assets":"container-A1" content match:
11-
| metadata.height | 5 |
12-
| metadata.weight | null |
13-
| linkedDevices | [] |
10+
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 | [] |
1417
When I successfully execute the action "device-manager/assets":"update" with args:
1518
| engineId | "engine-kuzzle" |
16-
| _id | "container-A1" |
19+
| _id | "Container-A1" |
1720
| body.metadata.weight | 1250 |
18-
Then The document "engine-kuzzle":"assets":"container-A1" content match:
21+
Then The document "engine-kuzzle":"assets":"Container-A1" content match:
1922
| metadata.height | 5 |
2023
| metadata.weight | 1250 |
2124
# Get
2225
When I successfully execute the action "device-manager/assets":"get" with args:
2326
| engineId | "engine-kuzzle" |
24-
| _id | "container-A1" |
27+
| _id | "Container-A1" |
2528
Then I should receive a result matching:
2629
| _source.metadata.height | 5 |
2730
| _source.reference | "A1" |
2831
# Search
2932
Given I successfully execute the action "device-manager/assets":"create" with args:
3033
| engineId | "engine-kuzzle" |
31-
| body.model | "container" |
34+
| body.model | "Container" |
3235
| body.reference | "B2" |
3336
And I refresh the collection "engine-kuzzle":"assets"
3437
When I successfully execute the action "device-manager/assets":"search" with args:
@@ -38,12 +41,12 @@ Feature: Asset Controller
3841
| lang | "koncorde" |
3942
Then I should receive a "hits" array of objects matching:
4043
| _id |
41-
| "container-A1" |
44+
| "Container-A1" |
4245
# Delete
4346
When I successfully execute the action "device-manager/assets":"delete" with args:
4447
| engineId | "engine-kuzzle" |
45-
| _id | "container-A1" |
46-
Then The document "engine-kuzzle":"assets":"container-A1" does not exists
48+
| _id | "Container-A1" |
49+
Then The document "engine-kuzzle":"assets":"Container-A1" does not exists
4750

4851
Scenario: Error when creating Asset from unknown model
4952
When I execute the action "device-manager/assets":"create" with args:
@@ -56,8 +59,8 @@ Feature: Asset Controller
5659
Scenario: Update linked device when deleting asset
5760
When I successfully execute the action "device-manager/assets":"delete" with args:
5861
| engineId | "engine-ayse" |
59-
| _id | "container-linked1" |
60-
Then The document "engine-ayse":"assets":"container-linked1" does not exist:
62+
| _id | "Container-linked1" |
63+
Then The document "engine-ayse":"assets":"Container-linked1" does not exist:
6164
And The document "device-manager":"devices":"DummyTemp-linked1" content match:
6265
| assetId | null |
6366
And The document "engine-ayse":"devices":"DummyTemp-linked1" content match:
@@ -72,55 +75,55 @@ Feature: Asset Controller
7275
And I refresh the collection "engine-ayse":"measures"
7376
When I successfully execute the action "device-manager/assets":"getMeasures" with args:
7477
| engineId | "engine-ayse" |
75-
| _id | "container-linked1" |
78+
| _id | "Container-linked1" |
7679
| size | 2 |
7780
Then I should receive a "measures" array of objects matching:
78-
| _source.values.temperature | _source.asset._id | _source.origin._id | _source.asset.model |
79-
| 40 | "container-linked1" | "DummyTemp-linked1" | "container" |
80-
| 41 | "container-linked1" | "DummyTemp-linked1" | "container" |
81+
| _source.values.temperature | _source.asset._id | _source.origin._id | _source.asset.model |
82+
| 40 | "Container-linked1" | "DummyTemp-linked1" | "Container" |
83+
| 41 | "Container-linked1" | "DummyTemp-linked1" | "Container" |
8184

8285
Scenario: Push a measures in the asset, an other with different name and an older one
8386
When I successfully execute the action "device-manager/measures":"push" with args:
8487
| engineId | "engine-ayse" |
85-
| body.assetId | "container-unlinked1" |
88+
| body.assetId | "Container-unlinked1" |
8689
| body.measure.type | "temperature" |
8790
| body.measure.values.temperature | 26 |
8891
| body.measure.type | "temperature" |
8992
| body.measure.name | "temperatureExt" |
90-
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
93+
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
9194
| measures.temperatureExt.type | "temperature" |
9295
| measures.temperatureExt.values.temperature | 26 |
9396
When I successfully execute the action "device-manager/measures":"push" with args:
9497
| engineId | "engine-ayse" |
95-
| body.assetId | "container-unlinked1" |
98+
| body.assetId | "Container-unlinked1" |
9699
| body.measure.type | "temperature" |
97100
| body.measure.values.temperature | -5 |
98101
| body.measure.type | "temperature" |
99102
| body.measure.name | "temperatureInt" |
100-
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
103+
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
101104
| measures.temperatureInt.type | "temperature" |
102105
| measures.temperatureInt.values.temperature | -5 |
103106
| measures.temperatureExt.type | "temperature" |
104107
| measures.temperatureExt.values.temperature | 26 |
105108
When I successfully execute the action "device-manager/measures":"push" with args:
106109
| engineId | "engine-ayse" |
107-
| body.assetId | "container-unlinked1" |
110+
| body.assetId | "Container-unlinked1" |
108111
| body.measure.type | "temperature" |
109112
| body.measure.values.temperature | 31 |
110113
| body.measure.type | "temperature" |
111114
| body.measure.name | "temperatureExt" |
112-
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
115+
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
113116
| measures.temperatureExt.values.temperature | 31 |
114117
Then I count 3 documents in "engine-ayse":"measures"
115118

116119
Scenario: Push a measure without name use measure type as name
117120
When I successfully execute the action "device-manager/measures":"push" with args:
118121
| engineId | "engine-ayse" |
119-
| body.assetId | "container-unlinked1" |
122+
| body.assetId | "Container-unlinked1" |
120123
| body.measure.type | "temperature" |
121124
| body.measure.values.temperature | 70 |
122125
| body.measure.name | "temperatureExt" |
123-
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
126+
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
124127
| measures.temperatureExt.type | "temperature" |
125128
| measures.temperatureExt.name | "temperatureExt" |
126129
| measures.temperatureExt.values.temperature | 70 |
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Feature: Device Manager Decoders
22

33
Scenario: Creates default roles, profiles and users
4-
Then I am able to get a role with id "payload-gateway.dummy-temp"
5-
Then I am able to get a role with id "payload-gateway.dummy-temp-position"
6-
Then I am able to get a profile with id "payload-gateway.dummy-temp"
7-
Then I am able to get a profile with id "payload-gateway.dummy-temp-position"
8-
Then I am able to get a profile with id "payload-gateway"
9-
Then The user "payload-gateway.dummy-temp" exists
10-
Then The user "payload-gateway.dummy-temp-position" exists
11-
Then The user "payload-gateway" exists
4+
Then I am able to get a role with id "payload_gateway.dummy_temp"
5+
Then I am able to get a role with id "payload_gateway.dummy_temp_position"
6+
Then I am able to get a profile with id "payload_gateway.dummy_temp"
7+
Then I am able to get a profile with id "payload_gateway.dummy_temp_position"
8+
Then I am able to get a profile with id "payload_gateway"
9+
Then The user "payload_gateway.dummy_temp" exists
10+
Then The user "payload_gateway.dummy_temp_position" exists
11+
Then The user "payload_gateway" exists

features/Decoder/PayloadController.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Feature: Payloads Controller
7373
| hits[0]._source.origin.measureName | "temperature" |
7474
| hits[0]._source.origin.deviceModel | "DummyTemp" |
7575
| hits[0]._source.origin.reference | "linked1" |
76-
| hits[0]._source.asset._id | "container-linked1" |
76+
| hits[0]._source.asset._id | "Container-linked1" |
7777
| hits[0]._source.asset.measureName | "temperatureExt" |
7878
| hits[0]._source.asset.metadata.weight | 10 |
7979
| hits[0]._source.asset.metadata.height | 11 |

features/Device/Controller/DetachEngine.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Feature: Detach device from engine
2222
When I successfully execute the action "device-manager/devices":"detachEngine" with args:
2323
| engineId | "engine-ayse" |
2424
| _id | "DummyTemp-linked1" |
25-
Then The document "engine-ayse":"assets":"container-linked1" content match:
25+
Then The document "engine-ayse":"assets":"Container-linked1" content match:
2626
| linkedDevices | [] |
2727
Then The document "device-manager":"devices":"DummyTemp-linked1" content match:
2828
| assetId | null |

features/Device/Controller/LinkAsset.feature

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ Feature: LinkAsset
33
Scenario: Link devices to an asset
44
When I successfully execute the action "device-manager/devices":"linkAsset" with args:
55
| _id | "DummyTemp-unlinked1" |
6-
| assetId | "container-unlinked1" |
6+
| assetId | "Container-unlinked1" |
77
| engineId | "engine-ayse" |
88
| body.measureNames.temperature | "temperatureExt" |
99
Then The document "device-manager":"devices":"DummyTemp-unlinked1" content match:
10-
| assetId | "container-unlinked1" |
10+
| assetId | "Container-unlinked1" |
1111
And The document "engine-ayse":"devices":"DummyTemp-unlinked1" content match:
12-
| assetId | "container-unlinked1" |
13-
And The document "engine-ayse":"assets":"container-unlinked1" content match:
12+
| assetId | "Container-unlinked1" |
13+
And The document "engine-ayse":"assets":"Container-unlinked1" content match:
1414
| linkedDevices[0]._id | "DummyTemp-unlinked1" |
1515
| linkedDevices[0].measures.temperature | "temperatureExt" |
1616
When I successfully execute the action "device-manager/devices":"linkAsset" with args:
1717
| _id | "DummyTemp-unlinked2" |
18-
| assetId | "container-unlinked1" |
18+
| assetId | "Container-unlinked1" |
1919
| engineId | "engine-ayse" |
2020
| body.measureNames.temperature | "temperatureInt" |
21-
And The document "engine-ayse":"assets":"container-unlinked1" content match:
21+
And The document "engine-ayse":"assets":"Container-unlinked1" content match:
2222
| linkedDevices[0]._id | "DummyTemp-unlinked1" |
2323
| linkedDevices[0].measures.temperature | "temperatureExt" |
2424
| linkedDevices[1]._id | "DummyTemp-unlinked2" |
@@ -27,7 +27,7 @@ Feature: LinkAsset
2727
Scenario: Error when device is already linked
2828
When I execute the action "device-manager/devices":"linkAsset" with args:
2929
| _id | "DummyTemp-linked1" |
30-
| assetId | "container-unlinked1" |
30+
| assetId | "Container-unlinked1" |
3131
| engineId | "engine-ayse" |
3232
| body.measureNames.temperature | "temperatureExt" |
3333
Then I should receive an error matching:
@@ -36,7 +36,7 @@ Feature: LinkAsset
3636
Scenario: Error when linking a device and using an already used measure name
3737
When I execute the action "device-manager/devices":"linkAsset" with args:
3838
| _id | "DummyTemp-unlinked1" |
39-
| assetId | "container-linked1" |
39+
| assetId | "Container-linked1" |
4040
| engineId | "engine-ayse" |
4141
| body.measureNames.temperature | "temperatureExt" |
4242
Then I should receive an error matching:
@@ -45,7 +45,7 @@ Feature: LinkAsset
4545
Scenario: Error when device is not attached to an engine
4646
When I execute the action "device-manager/devices":"linkAsset" with args:
4747
| _id | "DummyTemp-detached1" |
48-
| assetId | "container-unlinked1" |
48+
| assetId | "Container-unlinked1" |
4949
| engineId | "engine-ayse" |
5050
| body.measureNames.temperature | "temperatureExt" |
5151
Then I should receive an error matching:
@@ -54,7 +54,7 @@ Feature: LinkAsset
5454
Scenario: Error when device is attached to wrong engine
5555
When I execute the action "device-manager/devices":"linkAsset" with args:
5656
| _id | "DummyTemp-unlinked1" |
57-
| assetId | "container-unlinked1" |
57+
| assetId | "Container-unlinked1" |
5858
| engineId | "engine-kuzzle" |
5959
| body.measureNames.temperature | "temperatureExt" |
6060
Then I should receive an error matching:
@@ -63,8 +63,8 @@ Feature: LinkAsset
6363
Scenario: Error when device is linked to non-existing asset
6464
When I execute the action "device-manager/devices":"linkAsset" with args:
6565
| _id | "DummyTemp-unlinked1" |
66-
| assetId | "container-nonexisting" |
66+
| assetId | "Container-nonexisting" |
6767
| engineId | "engine-ayse" |
6868
| body.measureNames.temperature | "temperatureExt" |
6969
Then I should receive an error matching:
70-
| message | "Document \"container-nonexisting\" not found in \"engine-ayse\":\"assets\"." |
70+
| message | "Document \"Container-nonexisting\" not found in \"engine-ayse\":\"assets\"." |

features/Device/Controller/UnlinkAsset.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Feature: UnlinkAsset
88
| assetId | null |
99
And The document "engine-ayse":"devices":"DummyTemp-linked1" content match:
1010
| assetId | null |
11-
And The document "engine-ayse":"assets":"container-linked1" content match:
11+
And The document "engine-ayse":"assets":"Container-linked1" content match:
1212
| linkedDevices.length | 0 |
1313

1414
Scenario: Error when the device was not linked

features/Measure/IngestionPipeline.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Feature: Ingestion Pipeline Events
88
| body.reference | "enrich_me_master" |
99
Given I successfully execute the action "device-manager/devices":"linkAsset" with args:
1010
| _id | "DummyTemp-enrich_me_master" |
11-
| assetId | "container-unlinked1" |
11+
| assetId | "Container-unlinked1" |
1212
| engineId | "engine-ayse" |
1313
| body.measureNames.temperature | "temperatureExt" |
1414
Given I send the following "dummy-temp" payloads:
@@ -18,7 +18,7 @@ Feature: Ingestion Pipeline Events
1818
Then When I successfully execute the action "document":"search" with args:
1919
| index | "engine-ayse" |
2020
| collection | "measures" |
21-
| body | { query: { term:{"asset._id":"container-unlinked1"}}} |
21+
| body | { query: { term:{"asset._id":"Container-unlinked1"}}} |
2222
# temperature has been multiplied by 2
2323
And I should receive a result matching:
2424
| hits[0]._source.type | "temperature" |
@@ -27,5 +27,5 @@ Feature: Ingestion Pipeline Events
2727
| measures.temperature.values.temperature | 42 |
2828
Then The document "engine-ayse":"devices":"DummyTemp-enrich_me_master" content match:
2929
| measures.temperature.values.temperature | 42 |
30-
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
30+
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
3131
| measures.temperatureExt.values.temperature | 42 |

0 commit comments

Comments
 (0)