Skip to content

Commit

Permalink
[breaking] Fixes for iot backend (#245)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
Adrien Maret committed Dec 20, 2022
1 parent f9a5cef commit 860621e
Show file tree
Hide file tree
Showing 34 changed files with 220 additions and 106 deletions.
55 changes: 29 additions & 26 deletions features/Asset/Controller.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,34 @@ Feature: Asset Controller
# Create
When I successfully execute the action "device-manager/assets":"create" with args:
| engineId | "engine-kuzzle" |
| body.model | "container" |
| body.model | "Container" |
| body.reference | "A1" |
| body.metadata.height | 5 |
Then The document "engine-kuzzle":"assets":"container-A1" content match:
| metadata.height | 5 |
| metadata.weight | null |
| linkedDevices | [] |
Then The document "engine-kuzzle":"assets":"Container-A1" content match:
| metadata.height | 5 |
| metadata.weight | null |
| measures.temperatureExt.type | "temperature" |
| measures.temperatureInt.type | "temperature" |
| measures.position.type | "position" |
| linkedDevices | [] |
When I successfully execute the action "device-manager/assets":"update" with args:
| engineId | "engine-kuzzle" |
| _id | "container-A1" |
| _id | "Container-A1" |
| body.metadata.weight | 1250 |
Then The document "engine-kuzzle":"assets":"container-A1" content match:
Then The document "engine-kuzzle":"assets":"Container-A1" content match:
| metadata.height | 5 |
| metadata.weight | 1250 |
# Get
When I successfully execute the action "device-manager/assets":"get" with args:
| engineId | "engine-kuzzle" |
| _id | "container-A1" |
| _id | "Container-A1" |
Then I should receive a result matching:
| _source.metadata.height | 5 |
| _source.reference | "A1" |
# Search
Given I successfully execute the action "device-manager/assets":"create" with args:
| engineId | "engine-kuzzle" |
| body.model | "container" |
| body.model | "Container" |
| body.reference | "B2" |
And I refresh the collection "engine-kuzzle":"assets"
When I successfully execute the action "device-manager/assets":"search" with args:
Expand All @@ -38,12 +41,12 @@ Feature: Asset Controller
| lang | "koncorde" |
Then I should receive a "hits" array of objects matching:
| _id |
| "container-A1" |
| "Container-A1" |
# Delete
When I successfully execute the action "device-manager/assets":"delete" with args:
| engineId | "engine-kuzzle" |
| _id | "container-A1" |
Then The document "engine-kuzzle":"assets":"container-A1" does not exists
| _id | "Container-A1" |
Then The document "engine-kuzzle":"assets":"Container-A1" does not exists

Scenario: Error when creating Asset from unknown model
When I execute the action "device-manager/assets":"create" with args:
Expand All @@ -56,8 +59,8 @@ Feature: Asset Controller
Scenario: Update linked device when deleting asset
When I successfully execute the action "device-manager/assets":"delete" with args:
| engineId | "engine-ayse" |
| _id | "container-linked1" |
Then The document "engine-ayse":"assets":"container-linked1" does not exist:
| _id | "Container-linked1" |
Then The document "engine-ayse":"assets":"Container-linked1" does not exist:
And The document "device-manager":"devices":"DummyTemp-linked1" content match:
| assetId | null |
And The document "engine-ayse":"devices":"DummyTemp-linked1" content match:
Expand All @@ -72,55 +75,55 @@ Feature: Asset Controller
And I refresh the collection "engine-ayse":"measures"
When I successfully execute the action "device-manager/assets":"getMeasures" with args:
| engineId | "engine-ayse" |
| _id | "container-linked1" |
| _id | "Container-linked1" |
| size | 2 |
Then I should receive a "measures" array of objects matching:
| _source.values.temperature | _source.asset._id | _source.origin._id | _source.asset.model |
| 40 | "container-linked1" | "DummyTemp-linked1" | "container" |
| 41 | "container-linked1" | "DummyTemp-linked1" | "container" |
| _source.values.temperature | _source.asset._id | _source.origin._id | _source.asset.model |
| 40 | "Container-linked1" | "DummyTemp-linked1" | "Container" |
| 41 | "Container-linked1" | "DummyTemp-linked1" | "Container" |

Scenario: Push a measures in the asset, an other with different name and an older one
When I successfully execute the action "device-manager/measures":"push" with args:
| engineId | "engine-ayse" |
| body.assetId | "container-unlinked1" |
| body.assetId | "Container-unlinked1" |
| body.measure.type | "temperature" |
| body.measure.values.temperature | 26 |
| body.measure.type | "temperature" |
| body.measure.name | "temperatureExt" |
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
| measures.temperatureExt.type | "temperature" |
| measures.temperatureExt.values.temperature | 26 |
When I successfully execute the action "device-manager/measures":"push" with args:
| engineId | "engine-ayse" |
| body.assetId | "container-unlinked1" |
| body.assetId | "Container-unlinked1" |
| body.measure.type | "temperature" |
| body.measure.values.temperature | -5 |
| body.measure.type | "temperature" |
| body.measure.name | "temperatureInt" |
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
| measures.temperatureInt.type | "temperature" |
| measures.temperatureInt.values.temperature | -5 |
| measures.temperatureExt.type | "temperature" |
| measures.temperatureExt.values.temperature | 26 |
When I successfully execute the action "device-manager/measures":"push" with args:
| engineId | "engine-ayse" |
| body.assetId | "container-unlinked1" |
| body.assetId | "Container-unlinked1" |
| body.measure.type | "temperature" |
| body.measure.values.temperature | 31 |
| body.measure.type | "temperature" |
| body.measure.name | "temperatureExt" |
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
| measures.temperatureExt.values.temperature | 31 |
Then I count 3 documents in "engine-ayse":"measures"

Scenario: Push a measure without name use measure type as name
When I successfully execute the action "device-manager/measures":"push" with args:
| engineId | "engine-ayse" |
| body.assetId | "container-unlinked1" |
| body.assetId | "Container-unlinked1" |
| body.measure.type | "temperature" |
| body.measure.values.temperature | 70 |
| body.measure.name | "temperatureExt" |
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
| measures.temperatureExt.type | "temperature" |
| measures.temperatureExt.name | "temperatureExt" |
| measures.temperatureExt.values.temperature | 70 |
16 changes: 8 additions & 8 deletions features/Decoder/DefaultRights.feature
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Feature: Device Manager Decoders

Scenario: Creates default roles, profiles and users
Then I am able to get a role with id "payload-gateway.dummy-temp"
Then I am able to get a role with id "payload-gateway.dummy-temp-position"
Then I am able to get a profile with id "payload-gateway.dummy-temp"
Then I am able to get a profile with id "payload-gateway.dummy-temp-position"
Then I am able to get a profile with id "payload-gateway"
Then The user "payload-gateway.dummy-temp" exists
Then The user "payload-gateway.dummy-temp-position" exists
Then The user "payload-gateway" exists
Then I am able to get a role with id "payload_gateway.dummy_temp"
Then I am able to get a role with id "payload_gateway.dummy_temp_position"
Then I am able to get a profile with id "payload_gateway.dummy_temp"
Then I am able to get a profile with id "payload_gateway.dummy_temp_position"
Then I am able to get a profile with id "payload_gateway"
Then The user "payload_gateway.dummy_temp" exists
Then The user "payload_gateway.dummy_temp_position" exists
Then The user "payload_gateway" exists
2 changes: 1 addition & 1 deletion features/Decoder/PayloadController.feature
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Feature: Payloads Controller
| hits[0]._source.origin.measureName | "temperature" |
| hits[0]._source.origin.deviceModel | "DummyTemp" |
| hits[0]._source.origin.reference | "linked1" |
| hits[0]._source.asset._id | "container-linked1" |
| hits[0]._source.asset._id | "Container-linked1" |
| hits[0]._source.asset.measureName | "temperatureExt" |
| hits[0]._source.asset.metadata.weight | 10 |
| hits[0]._source.asset.metadata.height | 11 |
Expand Down
2 changes: 1 addition & 1 deletion features/Device/Controller/DetachEngine.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: Detach device from engine
When I successfully execute the action "device-manager/devices":"detachEngine" with args:
| engineId | "engine-ayse" |
| _id | "DummyTemp-linked1" |
Then The document "engine-ayse":"assets":"container-linked1" content match:
Then The document "engine-ayse":"assets":"Container-linked1" content match:
| linkedDevices | [] |
Then The document "device-manager":"devices":"DummyTemp-linked1" content match:
| assetId | null |
24 changes: 12 additions & 12 deletions features/Device/Controller/LinkAsset.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ Feature: LinkAsset
Scenario: Link devices to an asset
When I successfully execute the action "device-manager/devices":"linkAsset" with args:
| _id | "DummyTemp-unlinked1" |
| assetId | "container-unlinked1" |
| assetId | "Container-unlinked1" |
| engineId | "engine-ayse" |
| body.measureNames.temperature | "temperatureExt" |
Then The document "device-manager":"devices":"DummyTemp-unlinked1" content match:
| assetId | "container-unlinked1" |
| assetId | "Container-unlinked1" |
And The document "engine-ayse":"devices":"DummyTemp-unlinked1" content match:
| assetId | "container-unlinked1" |
And The document "engine-ayse":"assets":"container-unlinked1" content match:
| assetId | "Container-unlinked1" |
And The document "engine-ayse":"assets":"Container-unlinked1" content match:
| linkedDevices[0]._id | "DummyTemp-unlinked1" |
| linkedDevices[0].measures.temperature | "temperatureExt" |
When I successfully execute the action "device-manager/devices":"linkAsset" with args:
| _id | "DummyTemp-unlinked2" |
| assetId | "container-unlinked1" |
| assetId | "Container-unlinked1" |
| engineId | "engine-ayse" |
| body.measureNames.temperature | "temperatureInt" |
And The document "engine-ayse":"assets":"container-unlinked1" content match:
And The document "engine-ayse":"assets":"Container-unlinked1" content match:
| linkedDevices[0]._id | "DummyTemp-unlinked1" |
| linkedDevices[0].measures.temperature | "temperatureExt" |
| linkedDevices[1]._id | "DummyTemp-unlinked2" |
Expand All @@ -27,7 +27,7 @@ Feature: LinkAsset
Scenario: Error when device is already linked
When I execute the action "device-manager/devices":"linkAsset" with args:
| _id | "DummyTemp-linked1" |
| assetId | "container-unlinked1" |
| assetId | "Container-unlinked1" |
| engineId | "engine-ayse" |
| body.measureNames.temperature | "temperatureExt" |
Then I should receive an error matching:
Expand All @@ -36,7 +36,7 @@ Feature: LinkAsset
Scenario: Error when linking a device and using an already used measure name
When I execute the action "device-manager/devices":"linkAsset" with args:
| _id | "DummyTemp-unlinked1" |
| assetId | "container-linked1" |
| assetId | "Container-linked1" |
| engineId | "engine-ayse" |
| body.measureNames.temperature | "temperatureExt" |
Then I should receive an error matching:
Expand All @@ -45,7 +45,7 @@ Feature: LinkAsset
Scenario: Error when device is not attached to an engine
When I execute the action "device-manager/devices":"linkAsset" with args:
| _id | "DummyTemp-detached1" |
| assetId | "container-unlinked1" |
| assetId | "Container-unlinked1" |
| engineId | "engine-ayse" |
| body.measureNames.temperature | "temperatureExt" |
Then I should receive an error matching:
Expand All @@ -54,7 +54,7 @@ Feature: LinkAsset
Scenario: Error when device is attached to wrong engine
When I execute the action "device-manager/devices":"linkAsset" with args:
| _id | "DummyTemp-unlinked1" |
| assetId | "container-unlinked1" |
| assetId | "Container-unlinked1" |
| engineId | "engine-kuzzle" |
| body.measureNames.temperature | "temperatureExt" |
Then I should receive an error matching:
Expand All @@ -63,8 +63,8 @@ Feature: LinkAsset
Scenario: Error when device is linked to non-existing asset
When I execute the action "device-manager/devices":"linkAsset" with args:
| _id | "DummyTemp-unlinked1" |
| assetId | "container-nonexisting" |
| assetId | "Container-nonexisting" |
| engineId | "engine-ayse" |
| body.measureNames.temperature | "temperatureExt" |
Then I should receive an error matching:
| message | "Document \"container-nonexisting\" not found in \"engine-ayse\":\"assets\"." |
| message | "Document \"Container-nonexisting\" not found in \"engine-ayse\":\"assets\"." |
2 changes: 1 addition & 1 deletion features/Device/Controller/UnlinkAsset.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: UnlinkAsset
| assetId | null |
And The document "engine-ayse":"devices":"DummyTemp-linked1" content match:
| assetId | null |
And The document "engine-ayse":"assets":"container-linked1" content match:
And The document "engine-ayse":"assets":"Container-linked1" content match:
| linkedDevices.length | 0 |

Scenario: Error when the device was not linked
Expand Down
6 changes: 3 additions & 3 deletions features/Measure/IngestionPipeline.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: Ingestion Pipeline Events
| body.reference | "enrich_me_master" |
Given I successfully execute the action "device-manager/devices":"linkAsset" with args:
| _id | "DummyTemp-enrich_me_master" |
| assetId | "container-unlinked1" |
| assetId | "Container-unlinked1" |
| engineId | "engine-ayse" |
| body.measureNames.temperature | "temperatureExt" |
Given I send the following "dummy-temp" payloads:
Expand All @@ -18,7 +18,7 @@ Feature: Ingestion Pipeline Events
Then When I successfully execute the action "document":"search" with args:
| index | "engine-ayse" |
| collection | "measures" |
| body | { query: { term:{"asset._id":"container-unlinked1"}}} |
| body | { query: { term:{"asset._id":"Container-unlinked1"}}} |
# temperature has been multiplied by 2
And I should receive a result matching:
| hits[0]._source.type | "temperature" |
Expand All @@ -27,5 +27,5 @@ Feature: Ingestion Pipeline Events
| measures.temperature.values.temperature | 42 |
Then The document "engine-ayse":"devices":"DummyTemp-enrich_me_master" content match:
| measures.temperature.values.temperature | 42 |
Then The document "engine-ayse":"assets":"container-unlinked1" content match:
Then The document "engine-ayse":"assets":"Container-unlinked1" content match:
| measures.temperatureExt.values.temperature | 42 |
Loading

0 comments on commit 860621e

Please sign in to comment.