-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADD upsert operation #3217
Merged
Merged
ADD upsert operation #3217
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8274d17
ADD upsert operation
fgalan d818512
ADD additional .test
fgalan 6566b8a
FIX issues raised in documentation review
fgalan 1da11d4
ADD missing .test
fgalan f01b3c3
FIX issue raised in doc review
fgalan 83a1879
Merge branch 'master' into feature/3215_upsert_op
fgalan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
- Add: upsert option for the POST /v2/entities operation (#3215) | ||
- Add: transient entities functionality (new reserved attribute: dateExpires) (#3000) | ||
- Add: "attrs" field in POST /v2/op/query (making "attributes" obsolete) (#2604) | ||
- Add: "expression" field in POST /v2/op/query (#2706) | ||
- Remove: "scopes" field in POST /v2/op/query (#2706) | ||
- Remove: "scopes" field in POST /v2/op/query (#2706) |
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
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
92 changes: 92 additions & 0 deletions
92
test/functionalTest/cases/3215_upsert_op/upsert_op_as_create.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,92 @@ | ||
# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U | ||
# | ||
# This file is part of Orion Context Broker. | ||
# | ||
# Orion 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 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 Context Broker. If not, see http://www.gnu.org/licenses/. | ||
# | ||
# For those usages not covered by this license please contact with | ||
# iot_support at tid dot es | ||
|
||
# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh | ||
|
||
--NAME-- | ||
Upsert operation as create | ||
|
||
--SHELL-INIT-- | ||
dbInit CB | ||
brokerStart CB 0 | ||
|
||
--SHELL-- | ||
|
||
# | ||
# 01. Creating entity POST /v2/entities?options=upsert E with attribute A=1, see error | ||
# 02. Get entity, see A=1 | ||
# | ||
|
||
|
||
echo "01. Creating entity POST /v2/entities?options=upsert E with attribute A=1" | ||
echo "=========================================================================" | ||
payload='{ | ||
"id": "E", | ||
"type": "T", | ||
"A": { | ||
"value": 1, | ||
"type": "Number" | ||
} | ||
}' | ||
orionCurl --url '/v2/entities?options=upsert' --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
echo "02. Get entity, see A=1" | ||
echo "=======================" | ||
orionCurl --url /v2/entities/E | ||
echo | ||
echo | ||
|
||
|
||
--REGEXPECT-- | ||
01. Creating entity POST /v2/entities?options=upsert E with attribute A=1 | ||
========================================================================= | ||
HTTP/1.1 204 No Content | ||
Content-Length: 0 | ||
Location: /v2/entities/E?type=T | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Date: REGEX(.*) | ||
|
||
|
||
|
||
02. Get entity, see A=1 | ||
======================= | ||
HTTP/1.1 200 OK | ||
Content-Length: 67 | ||
Content-Type: application/json | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Date: REGEX(.*) | ||
|
||
{ | ||
"A": { | ||
"metadata": {}, | ||
"type": "Number", | ||
"value": 1 | ||
}, | ||
"id": "E", | ||
"type": "T" | ||
} | ||
|
||
|
||
--TEARDOWN-- | ||
brokerStop CB | ||
dbDrop CB |
153 changes: 153 additions & 0 deletions
153
test/functionalTest/cases/3215_upsert_op/upsert_op_as_update.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,153 @@ | ||
# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U | ||
# | ||
# This file is part of Orion Context Broker. | ||
# | ||
# Orion 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 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 Context Broker. If not, see http://www.gnu.org/licenses/. | ||
# | ||
# For those usages not covered by this license please contact with | ||
# iot_support at tid dot es | ||
|
||
# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh | ||
|
||
--NAME-- | ||
Upsert operation as update | ||
|
||
--SHELL-INIT-- | ||
dbInit CB | ||
brokerStart CB 0 | ||
|
||
--SHELL-- | ||
|
||
# | ||
# 01. Creating entity POST /v2/entities E with attribute A=1 | ||
# 02. Get entity, see A=1 | ||
# 03. Update entity using POST /v2/entity?options=upsert attributes A=2 B=3 | ||
# 04. Get entity, see A=2 B=3 | ||
# | ||
|
||
echo "01. Creating entity POST /v2/entities E with attribute A=1" | ||
echo "==========================================================" | ||
payload='{ | ||
"id": "E", | ||
"type": "T", | ||
"A": { | ||
"value": 1, | ||
"type": "Number" | ||
} | ||
}' | ||
orionCurl --url '/v2/entities' --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
echo "02. Get entity, see A=1" | ||
echo "=======================" | ||
orionCurl --url /v2/entities/E | ||
echo | ||
echo | ||
|
||
|
||
echo "03. Update entity using POST /v2/entity?options=upsert attributes A=2 B=3" | ||
echo "=========================================================================" | ||
payload='{ | ||
"id": "E", | ||
"type": "T", | ||
"A": { | ||
"value": 2, | ||
"type": "Number" | ||
}, | ||
"B": { | ||
"value": 3, | ||
"type": "Number" | ||
} | ||
}' | ||
orionCurl --url '/v2/entities?options=upsert' --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
echo "04. Get entity, see A=2 B=3" | ||
echo "===========================" | ||
orionCurl --url /v2/entities/E | ||
echo | ||
echo | ||
|
||
|
||
--REGEXPECT-- | ||
01. Creating entity POST /v2/entities E with attribute A=1 | ||
========================================================== | ||
HTTP/1.1 201 Created | ||
Content-Length: 0 | ||
Location: /v2/entities/E?type=T | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Date: REGEX(.*) | ||
|
||
|
||
|
||
02. Get entity, see A=1 | ||
======================= | ||
HTTP/1.1 200 OK | ||
Content-Length: 67 | ||
Content-Type: application/json | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Date: REGEX(.*) | ||
|
||
{ | ||
"A": { | ||
"metadata": {}, | ||
"type": "Number", | ||
"value": 1 | ||
}, | ||
"id": "E", | ||
"type": "T" | ||
} | ||
|
||
|
||
03. Update entity using POST /v2/entity?options=upsert attributes A=2 B=3 | ||
========================================================================= | ||
HTTP/1.1 204 No Content | ||
Content-Length: 0 | ||
Location: /v2/entities/E?type=T | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Date: REGEX(.*) | ||
|
||
|
||
|
||
04. Get entity, see A=2 B=3 | ||
=========================== | ||
HTTP/1.1 200 OK | ||
Content-Length: 113 | ||
Content-Type: application/json | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Date: REGEX(.*) | ||
|
||
{ | ||
"A": { | ||
"metadata": {}, | ||
"type": "Number", | ||
"value": 2 | ||
}, | ||
"B": { | ||
"metadata": {}, | ||
"type": "Number", | ||
"value": 3 | ||
}, | ||
"id": "E", | ||
"type": "T" | ||
} | ||
|
||
|
||
--TEARDOWN-- | ||
brokerStop CB | ||
dbDrop CB |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use backtick for
422 Unprocessable Entity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f01b3c3