forked from telefonicaid/fiware-orion
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
218 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
207 changes: 207 additions & 0 deletions
207
test/functionalTest/cases/0000_ngsild/ngsild_showChanges_issue_1393.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
# Copyright 2023 FIWARE Foundation e.V. | ||
# | ||
# This file is part of Orion-LD Context Broker. | ||
# | ||
# Orion-LD Context Broker is free software: you can redistribute it and/or | ||
# modify it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# Orion-LD Context Broker is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero | ||
# General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. | ||
# | ||
# For those usages not covered by this license please contact with | ||
# orionld at fiware dot org | ||
|
||
# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh | ||
|
||
--NAME-- | ||
showChanges in Subscription - provoke a notification and see the previousValue | ||
|
||
--SHELL-INIT-- | ||
dbInit CB | ||
orionldStart CB -experimental -triggerOperation | ||
accumulatorStart --pretty-print | ||
|
||
--SHELL-- | ||
|
||
# | ||
# 01. Create E1 with an attribute A1 == 1 | ||
# 02. Create a matching subscription S1, with showChanges set to true | ||
# 03. See S1 in the database - make sure showChanges is there | ||
# 04. Update urn:E1/attrs/A1, using upsert update, setting its value to 4 | ||
# 05. Dump/Reset accumulator, see A1's value and previousValue | ||
# | ||
|
||
echo "01. Create E1 with an attribute A1 == 1" | ||
echo "=======================================" | ||
payload='{ | ||
"id": "urn:E1", | ||
"type": "Device", | ||
"A1": 1 | ||
}' | ||
orionCurl --url /ngsi-ld/v1/entities --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
echo "02. Create a matching subscription S1, with showChanges set to true" | ||
echo "===================================================================" | ||
payload='{ | ||
"id": "urn:ngsi-ld:subs:S1", | ||
"type": "Subscription", | ||
"entities": [ | ||
{ | ||
"id": "urn:E1", | ||
"type": "Device" | ||
} | ||
], | ||
"notification": { | ||
"endpoint": { | ||
"uri": "http://127.0.0.1:'${LISTENER_PORT}'/notify" | ||
}, | ||
"showChanges": true | ||
} | ||
}' | ||
orionCurl --url /ngsi-ld/v1/subscriptions --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
echo "03. See S1 in the database - make sure showChanges is there" | ||
echo "===========================================================" | ||
mongoCmd2 ftest "db.csubs.findOne()" | ||
echo | ||
echo | ||
|
||
|
||
echo "04. Update urn:E1/attrs/A1, using upsert update, setting its value to 4" | ||
echo "=======================================================================" | ||
payload='[{ | ||
"id": "urn:E1", | ||
"A1":{ | ||
"value": 4 | ||
} | ||
}]' | ||
orionCurl --url /ngsi-ld/v1/entityOperations/upsert/?options=update --payload "$payload" -X POST | ||
echo | ||
echo | ||
|
||
|
||
echo "05. Dump/Reset accumulator, see A1's value and previousValue" | ||
echo "============================================================" | ||
accumulatorDump | ||
accumulatorReset | ||
echo | ||
echo | ||
|
||
|
||
|
||
|
||
--REGEXPECT-- | ||
01. Create E1 with an attribute A1 == 1 | ||
======================================= | ||
HTTP/1.1 201 Created | ||
Content-Length: 0 | ||
Date: REGEX(.*) | ||
Location: /ngsi-ld/v1/entities/urn:E1 | ||
|
||
|
||
|
||
02. Create a matching subscription S1, with showChanges set to true | ||
=================================================================== | ||
HTTP/1.1 201 Created | ||
Content-Length: 0 | ||
Date: REGEX(.*) | ||
Location: /ngsi-ld/v1/subscriptions/urn:ngsi-ld:subs:S1 | ||
|
||
|
||
|
||
03. See S1 in the database - make sure showChanges is there | ||
=========================================================== | ||
MongoDB shell version REGEX(.*) | ||
connecting to: REGEX(.*) | ||
MongoDB server version: REGEX(.*) | ||
{ | ||
"_id" : "urn:ngsi-ld:subs:S1", | ||
"entities" : [ | ||
{ | ||
"id" : "urn:E1", | ||
"type" : "https://uri.etsi.org/ngsi-ld/default-context/Device", | ||
"isPattern" : "false", | ||
"isTypePattern" : false | ||
} | ||
], | ||
"createdAt" : REGEX(.*), | ||
"modifiedAt" : REGEX(.*), | ||
"throttling" : 0, | ||
"expression" : { | ||
"geometry" : "", | ||
"coords" : "", | ||
"georel" : "", | ||
"geoproperty" : "", | ||
"q" : "", | ||
"mq" : "" | ||
}, | ||
"reference" : "http://REGEX(.*)/notify", | ||
"mimeType" : "application/json", | ||
"showChanges" : true, | ||
"attrs" : [ ], | ||
"format" : "normalized", | ||
"conditions" : [ ], | ||
"status" : "active", | ||
"custom" : false, | ||
"servicePath" : "/#", | ||
"blacklist" : false, | ||
"ldContext" : "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld" | ||
} | ||
bye | ||
|
||
|
||
04. Update urn:E1/attrs/A1, using upsert update, setting its value to 4 | ||
======================================================================= | ||
HTTP/1.1 204 No Content | ||
Date: REGEX(.*) | ||
|
||
|
||
|
||
05. Dump/Reset accumulator, see A1's value and previousValue | ||
============================================================ | ||
POST http://REGEX(.*)/notify?subscriptionId=urn:ngsi-ld:subs:S1 | ||
Content-Length: 318 | ||
User-Agent: orionld/REGEX(.*) | ||
Host: REGEX(.*) | ||
Accept: application/json | ||
Content-Type: application/json | ||
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*) | ||
Ngsild-Attribute-Format: Normalized | ||
|
||
{ | ||
"data": [ | ||
{ | ||
"A1": { | ||
"previousValue": 1, | ||
"type": "Property", | ||
"value": 4 | ||
}, | ||
"id": "urn:E1", | ||
"type": "Device" | ||
} | ||
], | ||
"id": "urn:ngsi-ld:Notification:REGEX(.*)", | ||
"notifiedAt": "20REGEX(.*)Z", | ||
"subscriptionId": "urn:ngsi-ld:subs:S1", | ||
"trigger": "POST /ngsi-ld/v1/entityOperations/upsert", | ||
"type": "Notification" | ||
} | ||
======================================= | ||
|
||
|
||
--TEARDOWN-- | ||
brokerStop CB | ||
dbDrop CB |