From 5e1bff6d4476dd98425694724595b6d06f99f7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 17 May 2023 16:46:15 +0200 Subject: [PATCH 01/44] FIX mongo:4.4 -> mongo:6.0 in GitActions --- .github/workflows/functional.yml | 2 +- .github/workflows/unit.yml | 2 +- .github/workflows/valgrind-nocache.yml | 2 +- .github/workflows/valgrind.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 47ef6b7aa5..bc158f8bd2 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -23,7 +23,7 @@ jobs: services: mongodb: - image: mongo:4.4 + image: mongo:6.0 ports: - 27017:27017 diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 89f0f9a6eb..d90ffd8603 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -22,7 +22,7 @@ jobs: services: mongodb: - image: mongo:4.4 + image: mongo:6.0 ports: - 27017:27017 diff --git a/.github/workflows/valgrind-nocache.yml b/.github/workflows/valgrind-nocache.yml index 4acdc6c9e3..65401e45db 100644 --- a/.github/workflows/valgrind-nocache.yml +++ b/.github/workflows/valgrind-nocache.yml @@ -26,7 +26,7 @@ jobs: services: mongodb: - image: mongo:4.4 + image: mongo:6.0 ports: - 27017:27017 diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 55fc6c5861..37c3ef4f09 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -23,7 +23,7 @@ jobs: services: mongodb: - image: mongo:4.4 + image: mongo:6.0 ports: - 27017:27017 From a446f514dd984c7b10fca54e30ad26f5c353f1b4 Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Thu, 22 Jun 2023 15:40:19 +0200 Subject: [PATCH 02/44] Switch from Docker to Quay --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 47282d99be..159b0b8693 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![FIWARE Core Context Management](https://nexus.lab.fiware.org/repository/raw/public/badges/chapters/core.svg)](https://www.fiware.org/developers/catalogue/) [![License badge](https://img.shields.io/github/license/telefonicaid/fiware-orion.svg)](https://opensource.org/licenses/AGPL-3.0) -[![Docker badge](https://img.shields.io/docker/pulls/fiware/orion.svg)](https://hub.docker.com/r/fiware/orion/) +[![Docker badge](https://img.shields.io/badge/quay.io-fiware%2Forion-grey?logo=red%20hat&labelColor=EE0000)](https://quay.io/repository/fiware/orion) [![Support badge](https://img.shields.io/badge/tag-fiware--orion-orange.svg?logo=stackoverflow)](http://stackoverflow.com/questions/tagged/fiware-orion) [![NGSI v2](https://img.shields.io/badge/NGSI-V2-red.svg)](doc/manuals/orion-api.md)
@@ -34,7 +34,7 @@ This project is part of [FIWARE](https://www.fiware.org/). For more information check the FIWARE Catalogue entry for [Core Context Management](https://github.com/Fiware/catalogue/tree/master/core). -| :books: [Documentation](https://fiware-orion.rtfd.io) | :mortar_board: [Academy](https://fiware-academy.readthedocs.io/en/latest/core/orion) | :whale: [Docker Hub](https://hub.docker.com/r/fiware/orion/) | :dart: [Roadmap](doc/roadmap.md) | +| :books: [Documentation](https://fiware-orion.rtfd.io) | :mortar_board: [Academy](https://fiware-academy.readthedocs.io/en/latest/core/orion) | [quay.io](https://quay.io/repository/fiware/orion) | :dart: [Roadmap](doc/roadmap.md) | |---|---|---|---| ## Content @@ -263,6 +263,9 @@ version 3](./LICENSE). © 2023 Telefonica Investigación y Desarrollo, S.A.U +
+Further information on the use of the AGPL open source license + ### Are there any legal issues with AGPL 3.0? Is it safe for me to use? There is absolutely no problem in using a product licensed under AGPL 3.0. Issues with GPL @@ -280,3 +283,4 @@ wish to make a clarifying public statement as follows: > unmodified version of existing software is not considered a derivative work, and therefore > it does not need to be released as under the same license, or even released as open source. +
From 7fd4d75f89b8e5777c91fae8a4ade73cb491ac95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 6 Sep 2023 20:53:11 +0200 Subject: [PATCH 03/44] FIX phony commit to stimulate tests --- .github/workflows/functional.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index bc158f8bd2..14c3088ac6 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -1,4 +1,4 @@ -name: Functional Tests +name: Functional Tests on: push: From 98c6761f62801cd5e41ea5a9ead6318ce4c9c253 Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Fri, 15 Sep 2023 13:39:23 +0200 Subject: [PATCH 04/44] Update README.md Co-authored-by: mapedraza <40356341+mapedraza@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 159b0b8693..28a0143180 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ This project is part of [FIWARE](https://www.fiware.org/). For more information check the FIWARE Catalogue entry for [Core Context Management](https://github.com/Fiware/catalogue/tree/master/core). -| :books: [Documentation](https://fiware-orion.rtfd.io) | :mortar_board: [Academy](https://fiware-academy.readthedocs.io/en/latest/core/orion) | [quay.io](https://quay.io/repository/fiware/orion) | :dart: [Roadmap](doc/roadmap.md) | +| :books: [Documentation](https://fiware-orion.rtfd.io) | :mortar_board: [Academy](https://fiware-academy.readthedocs.io/en/latest/core/orion) | [quay.io](https://quay.io/repository/fiware/orion) | :whale: [Docker Hub](https://registry.hub.docker.com/r/telefonicaiot/fiware-orion) | :dart: [Roadmap](doc/roadmap.md) | |---|---|---|---| ## Content From b6cfddc680652a0a133d879baa695e46bf5fbb2f Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Fri, 15 Sep 2023 13:39:30 +0200 Subject: [PATCH 05/44] Update README.md Co-authored-by: mapedraza <40356341+mapedraza@users.noreply.github.com> --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 28a0143180..dfcba5bbc7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ [![FIWARE Core Context Management](https://nexus.lab.fiware.org/repository/raw/public/badges/chapters/core.svg)](https://www.fiware.org/developers/catalogue/) [![License badge](https://img.shields.io/github/license/telefonicaid/fiware-orion.svg)](https://opensource.org/licenses/AGPL-3.0) -[![Docker badge](https://img.shields.io/badge/quay.io-fiware%2Forion-grey?logo=red%20hat&labelColor=EE0000)](https://quay.io/repository/fiware/orion) +[![Quay badge](https://img.shields.io/badge/quay.io-fiware%2Forion-grey?logo=red%20hat&labelColor=EE0000)](https://quay.io/repository/fiware/orion) +[![Docker badge](https://img.shields.io/badge/docker-telefonicaiot%2Ffiware--orion-blue?logo=docker)](https://registry.hub.docker.com/r/telefonicaiot/fiware-orion) [![Support badge](https://img.shields.io/badge/tag-fiware--orion-orange.svg?logo=stackoverflow)](http://stackoverflow.com/questions/tagged/fiware-orion) [![NGSI v2](https://img.shields.io/badge/NGSI-V2-red.svg)](doc/manuals/orion-api.md)
From 999f859679dcf6a41df5179c36ba0b02b79b6ff0 Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Fri, 15 Sep 2023 13:41:01 +0200 Subject: [PATCH 06/44] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dfcba5bbc7..71526c8105 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ check the FIWARE Catalogue entry for [Core Context Management](https://github.com/Fiware/catalogue/tree/master/core). | :books: [Documentation](https://fiware-orion.rtfd.io) | :mortar_board: [Academy](https://fiware-academy.readthedocs.io/en/latest/core/orion) | [quay.io](https://quay.io/repository/fiware/orion) | :whale: [Docker Hub](https://registry.hub.docker.com/r/telefonicaiot/fiware-orion) | :dart: [Roadmap](doc/roadmap.md) | -|---|---|---|---| +|---|---|---|---|--| ## Content From 7e9ed2339038651a774fc9fee88c2c075a4720ee Mon Sep 17 00:00:00 2001 From: mapedraza <40356341+mapedraza@users.noreply.github.com> Date: Wed, 27 Sep 2023 17:22:44 +0200 Subject: [PATCH 07/44] Add geofencing example --- doc/manuals/orion-api.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/manuals/orion-api.md b/doc/manuals/orion-api.md index 23ecd1f5c0..e17222de01 100644 --- a/doc/manuals/orion-api.md +++ b/doc/manuals/orion-api.md @@ -3877,7 +3877,9 @@ Example: "condition": { "attrs": [ "temperature" ], "expression": { - "q": "temperature>40" + "georel": "near;maxDistance:15000", + "geometry": "point", + "coords": "coords": "37.407804, -6.004552" } } }, From 0778b6099c6d57a45ca5e8cbaf60613ce9ee0ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 4 Oct 2023 13:02:08 +0200 Subject: [PATCH 08/44] FIX typos --- doc/manuals/orion-api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manuals/orion-api.md b/doc/manuals/orion-api.md index 23ecd1f5c0..1a2d2877df 100644 --- a/doc/manuals/orion-api.md +++ b/doc/manuals/orion-api.md @@ -2131,11 +2131,11 @@ For instance: ### Text based payload If `payload` is used in `httpCustom` or `mqttCustom` the following considerations apply. -Note that only one of the following can be used a the same time: `payload`, `json` or `ngsi. +Note that only one of the following can be used a the same time: `payload`, `json` or `ngsi`. * [General syntax restrictions](#general-syntax-restrictions) also apply to the `httpCustom.payload` field in the API operations, such as `POST /v2/subscription` or `GET /v2/subscriptions`. An example - is shown below. + is shown below. However, at notification time, any URL encoded characters in `payload` is decoded. * `Content-Type` header is set to `text/plain`, except if overwritten by `headers` field Example: From f53bf077399891c5f0e4d139785eb846c86c4bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 4 Oct 2023 13:03:18 +0200 Subject: [PATCH 09/44] Update orion-api.md --- doc/manuals/orion-api.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/manuals/orion-api.md b/doc/manuals/orion-api.md index 1a2d2877df..6ac35dae42 100644 --- a/doc/manuals/orion-api.md +++ b/doc/manuals/orion-api.md @@ -2134,8 +2134,9 @@ If `payload` is used in `httpCustom` or `mqttCustom` the following consideration Note that only one of the following can be used a the same time: `payload`, `json` or `ngsi`. * [General syntax restrictions](#general-syntax-restrictions) also apply to the `httpCustom.payload` - field in the API operations, such as `POST /v2/subscription` or `GET /v2/subscriptions`. An example - is shown below. However, at notification time, any URL encoded characters in `payload` is decoded. + field in the API operations, such as `POST /v2/subscription` or `GET /v2/subscriptions`. However, + at notification time, any URL encoded characters in `payload` is decoded. An example + is shown below. * `Content-Type` header is set to `text/plain`, except if overwritten by `headers` field Example: From 3f52f59909e4eb0c35c2b517f7a1b0c51efeaf3c Mon Sep 17 00:00:00 2001 From: Kazuhito Suda Date: Wed, 4 Oct 2023 21:01:03 +0900 Subject: [PATCH 10/44] (JP) FIX typos (#4432) --- doc/manuals.jp/orion-api.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/manuals.jp/orion-api.md b/doc/manuals.jp/orion-api.md index b2687f966b..2653b3fd81 100644 --- a/doc/manuals.jp/orion-api.md +++ b/doc/manuals.jp/orion-api.md @@ -2125,7 +2125,8 @@ Content-Length: 0 同時に使用できるのは、`payload`, `json` また `ngsi` のうちの1つだけであることに注意してください。 - [一般的な構文制限](#general-syntax-restrictions) は、`POST /v2/subscription` や `GET /v2/subscriptions` - などの API オペレーションの `httpCustom.payload` フィールドにも適用されます。以下に例を示します + などの API オペレーションの `httpCustom.payload` フィールドにも適用されます。ただし、通知時には、`payload` + 内の URL エンコードされた文字はすべてデコードされます。以下に例を示します - `headers` フィールドによって上書きされる場合を除き、`Content-Type` ヘッダは `text/plain` に設定されます 例: From e2fe2770084a7827fe82c40f4caf7f76fe5b0046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Mon, 16 Oct 2023 14:28:25 +0200 Subject: [PATCH 11/44] FIX DateTime and geo:json support in custom notifications using ngsi patching --- CHANGES_NEXT_RELEASE | 1 + src/lib/jsonParseV2/jsonRequestTreat.cpp | 2 +- src/lib/jsonParseV2/parseContextAttribute.cpp | 16 +- src/lib/jsonParseV2/parseContextAttribute.h | 5 +- src/lib/jsonParseV2/parseEntity.cpp | 2 +- src/lib/jsonParseV2/parseEntityObject.cpp | 2 +- src/lib/jsonParseV2/parseSubscription.cpp | 2 +- .../ngsi_patching_special_attr_types.test | 255 ++++++++++++++++++ 8 files changed, 272 insertions(+), 13 deletions(-) create mode 100644 test/functionalTest/cases/4435_ngsi_patching_special_attr_types/ngsi_patching_special_attr_types.test diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index c3b7ccea03..7c55d0ee44 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,5 +1,6 @@ - Add: servicePath field to builtin attributes (#2877) - Add: notification.mqtt.retain and notification.mqttCustom.retain flag for MQTT retain in notifications (#4388) +- Fix: DateTime and geo:json types were not supported in custom notifications using ngsi patching (#4435) - Fix: logDeprecate not working correctly (`geo:json` wrongly considered as deprecated) - Fix: improve error traces (#4387) - Add: CLI parameter -dbUri / env var ORION_MONGO_URI (#3794) diff --git a/src/lib/jsonParseV2/jsonRequestTreat.cpp b/src/lib/jsonParseV2/jsonRequestTreat.cpp index f0cb326947..def0d2b519 100644 --- a/src/lib/jsonParseV2/jsonRequestTreat.cpp +++ b/src/lib/jsonParseV2/jsonRequestTreat.cpp @@ -102,7 +102,7 @@ std::string jsonRequestTreat case EntityAttributeRequest: releaseP->attribute = &parseDataP->attr.attribute; releaseP->attribute->name = compV[4]; - answer = parseContextAttribute(ciP, &parseDataP->attr.attribute); + answer = parseContextAttribute(ciP, &parseDataP->attr.attribute, true); if (answer != "OK") { return answer; diff --git a/src/lib/jsonParseV2/parseContextAttribute.cpp b/src/lib/jsonParseV2/parseContextAttribute.cpp index 95bb1a26dd..751dfb66d3 100644 --- a/src/lib/jsonParseV2/parseContextAttribute.cpp +++ b/src/lib/jsonParseV2/parseContextAttribute.cpp @@ -105,7 +105,8 @@ static std::string parseContextAttributeObject ( const rapidjson::Value& start, ContextAttribute* caP, - bool* compoundVector + bool* compoundVector, + bool checkAttrSpecialTypes ) { // This is NGSIv2 parsing and in NGSIv2, no value means implicit null. Note that @@ -215,7 +216,7 @@ static std::string parseContextAttributeObject } // Is it a (not null) date? - if (((caP->type == DATE_TYPE) || (caP->type == DATE_TYPE_ALT)) && (caP->valueType != orion::ValueTypeNull)) + if (checkAttrSpecialTypes && ((caP->type == DATE_TYPE) || (caP->type == DATE_TYPE_ALT)) && (caP->valueType != orion::ValueTypeNull)) { caP->numberValue = parse8601Time(caP->stringValue); @@ -230,7 +231,7 @@ static std::string parseContextAttributeObject } // It is a safe GeoJSON? - if (caP->type == GEO_JSON) + if (checkAttrSpecialTypes && caP->type == GEO_JSON) { std::string r = checkGeoJson(caP); if (r != "OK") @@ -252,7 +253,8 @@ std::string parseContextAttribute ( ConnectionInfo* ciP, const rapidjson::Value::ConstMemberIterator& iter, - ContextAttribute* caP + ContextAttribute* caP, + bool checkAttrSpecialTypes ) { std::string name = iter->name.GetString(); @@ -354,7 +356,7 @@ std::string parseContextAttribute // Attribute has a regular structure, in which 'value' is mandatory (except in v2) if (iter->value.HasMember("value") || ciP->apiVersion == V2) { - std::string r = parseContextAttributeObject(iter->value, caP, &compoundVector); + std::string r = parseContextAttributeObject(iter->value, caP, &compoundVector, checkAttrSpecialTypes); if (r == "max deep reached") { alarmMgr.badInput(clientIp, "max deep reached", "found in ContextAttributeObject::Object"); @@ -398,7 +400,7 @@ std::string parseContextAttribute * * parseContextAttribute - */ -std::string parseContextAttribute(ConnectionInfo* ciP, ContextAttribute* caP) +std::string parseContextAttribute(ConnectionInfo* ciP, ContextAttribute* caP, bool checkAttrSpecialTypes) { rapidjson::Document document; @@ -426,7 +428,7 @@ std::string parseContextAttribute(ConnectionInfo* ciP, ContextAttribute* caP) } bool compoundVector = false; - std::string r = parseContextAttributeObject(document, caP, &compoundVector); + std::string r = parseContextAttributeObject(document, caP, &compoundVector, checkAttrSpecialTypes); if (r == "max deep reached") { diff --git a/src/lib/jsonParseV2/parseContextAttribute.h b/src/lib/jsonParseV2/parseContextAttribute.h index ac92ad5eaa..e3210e9403 100644 --- a/src/lib/jsonParseV2/parseContextAttribute.h +++ b/src/lib/jsonParseV2/parseContextAttribute.h @@ -41,7 +41,8 @@ extern std::string parseContextAttribute ( ConnectionInfo* ciP, const rapidjson::Value::ConstMemberIterator& iter, - ContextAttribute* caP + ContextAttribute* caP, + bool checkAttrSpecialTypes ); @@ -50,6 +51,6 @@ extern std::string parseContextAttribute * * parseContextAttribute - */ -extern std::string parseContextAttribute(ConnectionInfo* ciP, ContextAttribute* caP); +extern std::string parseContextAttribute(ConnectionInfo* ciP, ContextAttribute* caP, bool checkAttrSpecialTypes); #endif // SRC_LIB_JSONPARSEV2_PARSECONTEXTATTRIBUTE_H_ diff --git a/src/lib/jsonParseV2/parseEntity.cpp b/src/lib/jsonParseV2/parseEntity.cpp index 46b9909314..c47c3116a8 100644 --- a/src/lib/jsonParseV2/parseEntity.cpp +++ b/src/lib/jsonParseV2/parseEntity.cpp @@ -235,7 +235,7 @@ std::string parseEntity(ConnectionInfo* ciP, Entity* eP, bool eidInURL) eP->attributeVector.push_back(caP); - std::string r = parseContextAttribute(ciP, iter, caP); + std::string r = parseContextAttribute(ciP, iter, caP, true); if (r == "max deep reached") { OrionError oe(SccBadRequest, ERROR_DESC_PARSE_MAX_JSON_NESTING, ERROR_PARSE); diff --git a/src/lib/jsonParseV2/parseEntityObject.cpp b/src/lib/jsonParseV2/parseEntityObject.cpp index 9d54d5e7ca..aa6cc8b665 100644 --- a/src/lib/jsonParseV2/parseEntityObject.cpp +++ b/src/lib/jsonParseV2/parseEntityObject.cpp @@ -157,7 +157,7 @@ std::string parseEntityObject ContextAttribute* caP = new ContextAttribute(); - r = parseContextAttribute(ciP, iter, caP); + r = parseContextAttribute(ciP, iter, caP, true); if (r == "OK") { eP->attributeVector.push_back(caP); diff --git a/src/lib/jsonParseV2/parseSubscription.cpp b/src/lib/jsonParseV2/parseSubscription.cpp index f68e11c259..3724528ba1 100644 --- a/src/lib/jsonParseV2/parseSubscription.cpp +++ b/src/lib/jsonParseV2/parseSubscription.cpp @@ -546,7 +546,7 @@ static std::string parseCustomPayload ngsi->attributeVector.push_back(caP); - std::string r = parseContextAttribute(ciP, iter, caP); + std::string r = parseContextAttribute(ciP, iter, caP, false); if (r == "max deep reached") { diff --git a/test/functionalTest/cases/4435_ngsi_patching_special_attr_types/ngsi_patching_special_attr_types.test b/test/functionalTest/cases/4435_ngsi_patching_special_attr_types/ngsi_patching_special_attr_types.test new file mode 100644 index 0000000000..4b7a6b9a39 --- /dev/null +++ b/test/functionalTest/cases/4435_ngsi_patching_special_attr_types/ngsi_patching_special_attr_types.test @@ -0,0 +1,255 @@ +# Copyright 2023 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-- +Custom notification NGSI patching special attr types + +--SHELL-INIT-- +dbInit CB +brokerStart CB 0-255 + +--SHELL-- + +# +# 01. Create custom subscription with ngsi patching with DateTime and geo:json +# 02. Get subscription +# 03. Update custom subscription with ngsi patching with DateTime and geo:json +# 04. Get subscription +# + +echo "01. Create custom subscription with ngsi patching with DateTime and geo:json" +echo "============================================================================" +payload='{ + "description": "DateTime test", + "status": "active", + "subject": { + "entities": [ + { + "idPattern": ".*", + "type": "NoiseLevelObserved" + } + ], + "condition": { + "attrs": [ + "TimeInstant" + ], + "notifyOnMetadataChange": true + } + }, + "notification": { + "attrs": [ + "dateobservedto", + "location" + ], + "onlyChangedAttrs": false, + "attrsFormat": "normalized", + "httpCustom": { + "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify", + "ngsi": { + "dateobservedto": { + "type": "DateTime", + "value": "${TimeInstant}" + }, + "mylocation": { + "type": "geo:json", + "value": "${location}" + } + } + } + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + + +SUB_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") + + +echo "02. Get subscriptions" +echo "=====================" +orionCurl --url /v2/subscriptions/$SUB_ID +echo +echo + + +echo "03. Update custom subscription with ngsi patching with DateTime and geo:json" +echo "============================================================================" +payload='{ + "notification": { + "attrs": [ + "dateobservedto", + "location" + ], + "onlyChangedAttrs": false, + "attrsFormat": "normalized", + "httpCustom": { + "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify", + "ngsi": { + "dateobservedto2": { + "type": "DateTime", + "value": "${TimeInstant}" + }, + "mylocation2": { + "type": "geo:json", + "value": "${location}" + } + } + } + } +}' +orionCurl --url /v2/subscriptions/$SUB_ID -X PATCH --payload "$payload" +echo +echo + + +echo "04. Get subscriptions" +echo "=====================" +orionCurl --url /v2/subscriptions/$SUB_ID +echo +echo + + +--REGEXPECT-- +01. Create custom subscription with ngsi patching with DateTime and geo:json +============================================================================ +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/subscriptions/REGEX([0-9a-f]{24}) +Content-Length: 0 + + + +02. Get subscriptions +===================== +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 522 + +{ + "description": "DateTime test", + "id": "REGEX([0-9a-f]{24})", + "notification": { + "attrs": [ + "dateobservedto", + "location" + ], + "attrsFormat": "normalized", + "covered": false, + "httpCustom": { + "ngsi": { + "dateobservedto": { + "type": "DateTime", + "value": "${TimeInstant}" + }, + "mylocation": { + "type": "geo:json", + "value": "${location}" + } + }, + "url": "http://127.0.0.1:9997/notify" + }, + "onlyChangedAttrs": false + }, + "status": "active", + "subject": { + "condition": { + "attrs": [ + "TimeInstant" + ], + "notifyOnMetadataChange": true + }, + "entities": [ + { + "idPattern": ".*", + "type": "NoiseLevelObserved" + } + ] + } +} + + +03. Update custom subscription with ngsi patching with DateTime and geo:json +============================================================================ +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +04. Get subscriptions +===================== +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 524 + +{ + "description": "DateTime test", + "id": "REGEX([0-9a-f]{24})", + "notification": { + "attrs": [ + "dateobservedto", + "location" + ], + "attrsFormat": "normalized", + "covered": false, + "httpCustom": { + "ngsi": { + "dateobservedto2": { + "type": "DateTime", + "value": "${TimeInstant}" + }, + "mylocation2": { + "type": "geo:json", + "value": "${location}" + } + }, + "url": "http://127.0.0.1:9997/notify" + }, + "onlyChangedAttrs": false + }, + "status": "active", + "subject": { + "condition": { + "attrs": [ + "TimeInstant" + ], + "notifyOnMetadataChange": true + }, + "entities": [ + { + "idPattern": ".*", + "type": "NoiseLevelObserved" + } + ] + } +} + + +--TEARDOWN-- +brokerStop CB +dbDrop CB From 5de3e4655ae51728eb2e5823d85a1d99ffa5049b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 17 Oct 2023 09:51:34 +0200 Subject: [PATCH 12/44] FIX Flask dependency in CI --- ci/deb/build-dep.sh | 1 + doc/manuals.jp/admin/build_source.md | 2 +- doc/manuals/admin/build_source.md | 2 +- doc/manuals/user/walkthrough_apiv2.md | 4 ++-- test/functionalTest/README.jp.md | 2 ++ test/functionalTest/README.md | 3 ++- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ci/deb/build-dep.sh b/ci/deb/build-dep.sh index 5ee98b8e5e..6b7f76fac4 100755 --- a/ci/deb/build-dep.sh +++ b/ci/deb/build-dep.sh @@ -64,6 +64,7 @@ echo "INSTALL: python special dependencies" \ && python3 -m venv /opt/ft_env \ && . /opt/ft_env/bin/activate \ && pip install Flask==2.0.2 \ +&& pip install Werkzeug==2.0.2 \ && pip install paho-mqtt==1.6.1 \ && pip install amqtt==0.11.0b1 \ && deactivate diff --git a/doc/manuals.jp/admin/build_source.md b/doc/manuals.jp/admin/build_source.md index ee4a300150..8b6936c127 100644 --- a/doc/manuals.jp/admin/build_source.md +++ b/doc/manuals.jp/admin/build_source.md @@ -132,7 +132,7 @@ aarch64 アーキテクチャの場合、apt-get を使用して libxslt をイ . scripts/testEnv.sh python3 -m venv /opt/ft_env # or 'virtualenv /opt/ft_env --python=/usr/bin/python3' in some systems . /opt/ft_env/bin/activate - pip install Flask==2.0.2 paho-mqtt==1.6.1 amqtt==0.11.0b1 + pip install Flask==2.0.2 Werkzeug==2.0.2 paho-mqtt==1.6.1 amqtt==0.11.0b1 * この環境でテスト・ハーネスを実行してください (時間がかかりますので、気をつけてください) diff --git a/doc/manuals/admin/build_source.md b/doc/manuals/admin/build_source.md index 38bbca42cc..d839243cb8 100644 --- a/doc/manuals/admin/build_source.md +++ b/doc/manuals/admin/build_source.md @@ -131,7 +131,7 @@ In the case of the aarch64 architecture, install libxslt using apt-get, and run . scripts/testEnv.sh python3 -m venv /opt/ft_env # or 'virtualenv /opt/ft_env --python=/usr/bin/python3' in some systems . /opt/ft_env/bin/activate - pip install Flask==2.0.2 paho-mqtt==1.6.1 amqtt==0.11.0b1 + pip install Flask==2.0.2 Werkzeug==2.0.2 paho-mqtt==1.6.1 amqtt==0.11.0b1 * Run test harness in this environment (it takes some time, please be patient). diff --git a/doc/manuals/user/walkthrough_apiv2.md b/doc/manuals/user/walkthrough_apiv2.md index 65b4baf8cd..9ffbf6407a 100644 --- a/doc/manuals/user/walkthrough_apiv2.md +++ b/doc/manuals/user/walkthrough_apiv2.md @@ -123,8 +123,8 @@ command: # ./accumulator-server.py --port 1028 --url /accumulate --host ::1 --pretty-print -v ``` -Note this script requires Flask version 2.0.2 and paho-mqtt version 1.6.1, which can be installed using -`pip install Flask==2.0.2` and `pip install paho-mqtt==1.6.1`. In addition, it is recommended to use +Note this script requires Flask version 2.0.2 (along with Werkzeug 2.0.2) and paho-mqtt version 1.6.1, which can be installed using +`pip install Flask==2.0.2 Werkzeug==2.0.2` and `pip install paho-mqtt==1.6.1` respectively. In addition, it is recommended to use Python 3.10.x In case of conflict with your base operating system Python installation, we recommend to use [virtualenv](https://virtualenv.pypa.io/en/latest/). More information about installing the accumulator (including an alternative based in docker) can be checked diff --git a/test/functionalTest/README.jp.md b/test/functionalTest/README.jp.md index b744839cea..6d039e8d71 100644 --- a/test/functionalTest/README.jp.md +++ b/test/functionalTest/README.jp.md @@ -27,6 +27,7 @@ virtualenv --python=/usr/bin/python3 /path/to/ft_env ``` pip install Flask==2.0.2 +pip install Werkzeug==2.0.2 pip install paho-mqtt==1.6.1 pip install amqtt==0.11.0b1 # Not actually an accumulator-server.py dependency, but needed by some tests ``` @@ -55,6 +56,7 @@ RUN apt-get update -y RUN apt-get install -y python3 RUN apt-get install -y python3-pip RUN pip install Flask==2.0.2 +RUN pip install Werkzeug==2.0.2 RUN pip install paho-mqtt==1.6.1 COPY . /app WORKDIR /app diff --git a/test/functionalTest/README.md b/test/functionalTest/README.md index 541e1f02bc..8fbe8e57d8 100644 --- a/test/functionalTest/README.md +++ b/test/functionalTest/README.md @@ -25,6 +25,7 @@ Next install accumulator-server.py depencencies: ``` pip install Flask==2.0.2 +pip install Werkzeug==2.0.2 pip install paho-mqtt==1.6.1 pip install amqtt==0.11.0b1 # Not actually an accumulator-server.py dependency, but needed by some tests ``` @@ -57,7 +58,7 @@ RUN python3 -m venv /venv ENV PATH="/venv/bin:$PATH" # Install required packages within the virtual environment -RUN pip install Flask==2.0.2 paho-mqtt==1.6.1 +RUN pip install Flask==2.0.2 Werkzeug==2.0.2 paho-mqtt==1.6.1 COPY . /app WORKDIR /app From 0691d2aa688358a7b4daf452ac0eb9978dd1087d Mon Sep 17 00:00:00 2001 From: Kazuhito Suda Date: Tue, 17 Oct 2023 19:07:04 +0900 Subject: [PATCH 13/44] (JP) Sync with English document --- test/functionalTest/README.jp.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/functionalTest/README.jp.md b/test/functionalTest/README.jp.md index 6d039e8d71..2af29f123f 100644 --- a/test/functionalTest/README.jp.md +++ b/test/functionalTest/README.jp.md @@ -53,11 +53,15 @@ accumulator-server.py -u ``` FROM debian:stable RUN apt-get update -y -RUN apt-get install -y python3 -RUN apt-get install -y python3-pip -RUN pip install Flask==2.0.2 -RUN pip install Werkzeug==2.0.2 -RUN pip install paho-mqtt==1.6.1 +RUN apt-get install -y python3 python3-venv python3-pip + +# Create a virtual environment +RUN python3 -m venv /venv +ENV PATH="/venv/bin:$PATH" + +# Install required packages within the virtual environment +RUN pip install Flask==2.0.2 Werkzeug==2.0.2 paho-mqtt==1.6.1 + COPY . /app WORKDIR /app ENTRYPOINT [ "python3", "./accumulator-server.py"] From d3601a6e4cc842e730bd446f97efa2a68d94a851 Mon Sep 17 00:00:00 2001 From: Kazuhito Suda Date: Tue, 17 Oct 2023 19:10:05 +0900 Subject: [PATCH 14/44] (JP) ADD documentation about Flask dependency (#4437) --- doc/manuals.jp/user/walkthrough_apiv2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manuals.jp/user/walkthrough_apiv2.md b/doc/manuals.jp/user/walkthrough_apiv2.md index 20be5b6399..433f3231b0 100644 --- a/doc/manuals.jp/user/walkthrough_apiv2.md +++ b/doc/manuals.jp/user/walkthrough_apiv2.md @@ -92,8 +92,8 @@ broker を再起動するには、*root* として実行するか、`sudo` コ # ./accumulator-server.py --port 1028 --url /accumulate --host ::1 --pretty-print -v ``` -このスクリプトには Flask version 2.0.2 と paho-mqtt version 1.6.1 が必要であることに注意してください。 -これらは、`pip install Flask==2.0.2` と `pip install paho-mqtt==1.6.1` を使用してインストールできます。 +このスクリプトには Flask version 2.0.2 (Werkzeug 2.0.2 とともに) と paho-mqtt version 1.6.1 が必要であることに注意してください。 +これらは、それぞれ、`pip install Flask==2.0.2 Werkzeug==2.0.2` と `pip install paho-mqtt==1.6.1` を使用してインストールできます。 さらに、Python 3.10.x を使用することをお勧めします。ベース・オペレーティングシステムの Python インストールと競合する場合は、[virtualenv](https://virtualenv.pypa.io/en/latest/) を使用することを お勧めします。 From 470932c9a248f1dff6a7519be09e6efcab4aecf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 17 Oct 2023 12:21:54 +0200 Subject: [PATCH 15/44] FIX slight fix in .test --- .../ngsi_patching_special_attr_types.test | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/functionalTest/cases/4435_ngsi_patching_special_attr_types/ngsi_patching_special_attr_types.test b/test/functionalTest/cases/4435_ngsi_patching_special_attr_types/ngsi_patching_special_attr_types.test index 4b7a6b9a39..8352a77b7b 100644 --- a/test/functionalTest/cases/4435_ngsi_patching_special_attr_types/ngsi_patching_special_attr_types.test +++ b/test/functionalTest/cases/4435_ngsi_patching_special_attr_types/ngsi_patching_special_attr_types.test @@ -58,7 +58,7 @@ payload='{ "notification": { "attrs": [ "dateobservedto", - "location" + "mylocation" ], "onlyChangedAttrs": false, "attrsFormat": "normalized", @@ -97,8 +97,8 @@ echo "========================================================================== payload='{ "notification": { "attrs": [ - "dateobservedto", - "location" + "dateobservedto2", + "mylocation2" ], "onlyChangedAttrs": false, "attrsFormat": "normalized", @@ -146,7 +146,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 522 +Content-Length: 524 { "description": "DateTime test", @@ -154,7 +154,7 @@ Content-Length: 522 "notification": { "attrs": [ "dateobservedto", - "location" + "mylocation" ], "attrsFormat": "normalized", "covered": false, @@ -205,15 +205,15 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 524 +Content-Length: 528 { "description": "DateTime test", "id": "REGEX([0-9a-f]{24})", "notification": { "attrs": [ - "dateobservedto", - "location" + "dateobservedto2", + "mylocation2" ], "attrsFormat": "normalized", "covered": false, From db847fae3e2ea7666e487de0572aeeea43956f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 19 Oct 2023 15:22:06 +0200 Subject: [PATCH 16/44] ADD entry to short term section in roadmap.md --- doc/roadmap.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/roadmap.md b/doc/roadmap.md index 9dbf7b976f..e6fddd6c9d 100644 --- a/doc/roadmap.md +++ b/doc/roadmap.md @@ -32,7 +32,8 @@ Disclaimer: The following list of features are planned to be addressed in the short term, and incorporated into the coming release(s) of the product: -- MQTT Retain flag [#4388](https://github.com/telefonicaid/fiware-orion/issues/4388) +- MQTT Retain flag ([#4388](https://github.com/telefonicaid/fiware-orion/issues/4388)) +- MQTT notification retrial ([#4431](https://github.com/telefonicaid/fiware-orion/pull/4431)) - Allow multiple types in entity to support UNE 178503 requirements ([#3638](https://github.com/telefonicaid/fiware-orion/issues/3638)) - Pattern/filter batch updates ([#2389](https://github.com/telefonicaid/fiware-orion/issues/2389)) - Notification endpoint alias ([#3655](https://github.com/telefonicaid/fiware-orion/issues/3655)) From e768a2af86acaf9959ac84d178e453f590cc491d Mon Sep 17 00:00:00 2001 From: mapedraza <40356341+mapedraza@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:58:04 +0200 Subject: [PATCH 17/44] Fix from suggestions --- doc/manuals/orion-api.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/doc/manuals/orion-api.md b/doc/manuals/orion-api.md index e17222de01..d04f9e8e6e 100644 --- a/doc/manuals/orion-api.md +++ b/doc/manuals/orion-api.md @@ -3651,7 +3651,7 @@ A `condition` contains the following subfields: | Parameter | Optional | Type | Description | |--------------|----------|-------|-------------------------------------------------------------------------------------------------------------------------------| | `attrs` | ✓ | array | Array of attribute names that will trigger the notification. Empty list is not allowed. | -| `expression` | ✓ | object| An expression composed of `q`, `mq`, `georel`, `geometry` and `coords` (see [List Entities](#list-entities-get-v2entities) operation above about this field). `expression` and sub elements (i.e. `q`) must have content, i.e. `{}` or `""` is not allowed | +| `expression` | ✓ | object| An expression composed of `q`, `mq`, `georel`, `geometry` and `coords` (see [List Entities](#list-entities-get-v2entities) operation above about this field). `expression` and sub elements (i.e. `q`) must have content, i.e. `{}` or `""` is not allowed. `georel`, `geometry` and `coords` have to be used together (i.e. "all or nothing"). Check the example using geoquery as expression [above](#create-subscription-post-v2subscriptions).| | `alterationTypes` | ✓ | array | Specify under which alterations (entity creation, entity modification, etc.) the subscription is triggered (see section [Subscriptions based in alteration type](#subscriptions-based-in-alteration-type)) | | `notifyOnMetadataChange` | ✓ | boolean | If `true` then metadata is considered part of the value of the attribute in the context of notification, so if the value doesn't change but the metadata changes, then a notification is triggered. If `false` then the metadata is not considered part of the value of the attribute in the context of notification, so if the value doesn't change but the metadata changes, then a notification is not triggered. Default value is `true`. | @@ -3864,6 +3864,37 @@ format (described in ["Subscription payload datamodel](#subscription-payload-dat Example: +```json +{ + "description": "One subscription to rule them all", + "subject": { + "entities": [ + { + "idPattern": ".*", + "type": "Room" + } + ], + "condition": { + "attrs": [ "temperature" ], + "expression": { + "q": "temperature>40" + + } + } + }, + "notification": { + "http": { + "url": "http://localhost:1234" + }, + "attrs": ["temperature", "humidity"] + }, + "expires": "2025-04-05T14:00:00.00Z", + "throttling": 5 +} +``` + +Example using geoquery as condition: + ```json { "description": "One subscription to rule them all", From c681efdb20d00925ced315b00179eb69c0547387 Mon Sep 17 00:00:00 2001 From: mapedraza <40356341+mapedraza@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:11:39 +0200 Subject: [PATCH 18/44] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fermín Galán Márquez --- doc/manuals/orion-api.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/manuals/orion-api.md b/doc/manuals/orion-api.md index d04f9e8e6e..2ef8dc67a5 100644 --- a/doc/manuals/orion-api.md +++ b/doc/manuals/orion-api.md @@ -3651,7 +3651,7 @@ A `condition` contains the following subfields: | Parameter | Optional | Type | Description | |--------------|----------|-------|-------------------------------------------------------------------------------------------------------------------------------| | `attrs` | ✓ | array | Array of attribute names that will trigger the notification. Empty list is not allowed. | -| `expression` | ✓ | object| An expression composed of `q`, `mq`, `georel`, `geometry` and `coords` (see [List Entities](#list-entities-get-v2entities) operation above about this field). `expression` and sub elements (i.e. `q`) must have content, i.e. `{}` or `""` is not allowed. `georel`, `geometry` and `coords` have to be used together (i.e. "all or nothing"). Check the example using geoquery as expression [above](#create-subscription-post-v2subscriptions).| +| `expression` | ✓ | object| An expression composed of `q`, `mq`, `georel`, `geometry` and `coords` (see [List Entities](#list-entities-get-v2entities) operation above about this field). `expression` and sub elements (i.e. `q`) must have content, i.e. `{}` or `""` is not allowed. `georel`, `geometry` and `coords` have to be used together (i.e. "all or nothing"). Check the example using geoquery as expression [below](#create-subscription-post-v2subscriptions).| | `alterationTypes` | ✓ | array | Specify under which alterations (entity creation, entity modification, etc.) the subscription is triggered (see section [Subscriptions based in alteration type](#subscriptions-based-in-alteration-type)) | | `notifyOnMetadataChange` | ✓ | boolean | If `true` then metadata is considered part of the value of the attribute in the context of notification, so if the value doesn't change but the metadata changes, then a notification is triggered. If `false` then the metadata is not considered part of the value of the attribute in the context of notification, so if the value doesn't change but the metadata changes, then a notification is not triggered. Default value is `true`. | @@ -3878,7 +3878,6 @@ Example: "attrs": [ "temperature" ], "expression": { "q": "temperature>40" - } } }, From 6d7475751b28c72a987aa8cebf31932cd6a5957c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 26 Oct 2023 10:02:54 +0200 Subject: [PATCH 19/44] FIX typo in roadmap.md --- doc/roadmap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/roadmap.md b/doc/roadmap.md index e6fddd6c9d..3b7167cbbe 100644 --- a/doc/roadmap.md +++ b/doc/roadmap.md @@ -33,7 +33,7 @@ The following list of features are planned to be addressed in the short term, and incorporated into the coming release(s) of the product: - MQTT Retain flag ([#4388](https://github.com/telefonicaid/fiware-orion/issues/4388)) -- MQTT notification retrial ([#4431](https://github.com/telefonicaid/fiware-orion/pull/4431)) +- MQTT notification retrial ([#4439](https://github.com/telefonicaid/fiware-orion/issues/4439)) - Allow multiple types in entity to support UNE 178503 requirements ([#3638](https://github.com/telefonicaid/fiware-orion/issues/3638)) - Pattern/filter batch updates ([#2389](https://github.com/telefonicaid/fiware-orion/issues/2389)) - Notification endpoint alias ([#3655](https://github.com/telefonicaid/fiware-orion/issues/3655)) From d0fb9339a3f3171f887fad5cf249093200e729b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 26 Oct 2023 10:22:05 +0200 Subject: [PATCH 20/44] Update roadmap.md --- doc/roadmap.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/roadmap.md b/doc/roadmap.md index 3b7167cbbe..96fc7a5121 100644 --- a/doc/roadmap.md +++ b/doc/roadmap.md @@ -53,8 +53,7 @@ after next planned release: supported by a Expressions Language - help wanted ([#4004](https://github.com/telefonicaid/fiware-orion/issues/4004)), ([#3815](https://github.com/telefonicaid/fiware-orion/issues/3815)) -- Service provisioning API (pools, etc.) -(based in [#3843](https://github.com/telefonicaid/fiware-orion/issues/3843)) +- Service provisioning API (pools, etc.) ([#4442](https://github.com/telefonicaid/fiware-orion/issues/4442)) - Advanced subscription management - Subscription debug mode (precise statistics consolidation, keep recent history of notifications sent, etc.) ([#4399](https://github.com/telefonicaid/fiware-orion/issues/4399)) - Custom ID subscription ([#4400](https://github.com/telefonicaid/fiware-orion/issues/4400)) From e56a7be2ba768229a7cbbe6e4e8a91f1feefea02 Mon Sep 17 00:00:00 2001 From: mapedraza <40356341+mapedraza@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:02:57 +0100 Subject: [PATCH 21/44] Apply suggestions --- doc/manuals/orion-api.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/manuals/orion-api.md b/doc/manuals/orion-api.md index 2ef8dc67a5..0f3406dc9c 100644 --- a/doc/manuals/orion-api.md +++ b/doc/manuals/orion-api.md @@ -3862,7 +3862,7 @@ _**Request payload**_ The payload is a JSON object containing a subscription that follows the JSON subscription representation format (described in ["Subscription payload datamodel](#subscription-payload-datamodel) section). -Example: +Example using attribute filter: ```json { @@ -3887,8 +3887,7 @@ Example: }, "attrs": ["temperature", "humidity"] }, - "expires": "2025-04-05T14:00:00.00Z", - "throttling": 5 + "expires": "2025-04-05T14:00:00.00Z" } ``` @@ -3909,7 +3908,7 @@ Example using geoquery as condition: "expression": { "georel": "near;maxDistance:15000", "geometry": "point", - "coords": "coords": "37.407804, -6.004552" + "coords": "37.407804,-6.004552" } } }, @@ -3919,8 +3918,7 @@ Example using geoquery as condition: }, "attrs": ["temperature", "humidity"] }, - "expires": "2025-04-05T14:00:00.00Z", - "throttling": 5 + "expires": "2025-04-05T14:00:00.00Z" } ``` From b3799cef3e3c3a78b73aa6971737bd60280b43f1 Mon Sep 17 00:00:00 2001 From: Kazuhito Suda Date: Fri, 3 Nov 2023 21:16:30 +0900 Subject: [PATCH 22/44] (JP) [Doc] Add geofencing subscription example (#4431) --- doc/manuals.jp/orion-api.md | 38 +++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/doc/manuals.jp/orion-api.md b/doc/manuals.jp/orion-api.md index 2653b3fd81..347963a9cc 100644 --- a/doc/manuals.jp/orion-api.md +++ b/doc/manuals.jp/orion-api.md @@ -3698,7 +3698,7 @@ _**レスポンス・ペイロード**_ | パラメータ | オプション | タイプ | 説明 | |-------------------|------------|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `attrs` | ✓ | array | 通知をトリガーする属性名の配列。空のリストは許可されていません | -| `expression` | ✓ | object | `q`, `mq`, `georel`, `geometry`, `coords` で構成される式 (このフィールドについては、上記の [エンティティをリスト](#list-entities-get-v2entities)操作を参照してください)。`expression` とサブ要素 (つまり `q`) にはコンテンツが必要です。つまり、`{}` または `""` は許可されません | +| `expression` | ✓ | object | `q`, `mq`, `georel`, `geometry`, `coords` で構成される式 (このフィールドについては、上記の [エンティティをリスト](#list-entities-get-v2entities)操作を参照してください)。`expression` とサブ要素 (つまり `q`) にはコンテンツが必要です。つまり、`{}` または `""` は許可されません。`georel`, `geometry`, および `coords` は一緒に使用する必要があります (つまり、"全てか無しか")。 geoquery を式として使用する例は下記(#create-subscription-post-v2subscriptions) を確認してください | | `alterationTypes` | ✓ | array | サブスクリプションがトリガーされる変更 (エンティティの作成、エンティティの変更など) を指定します ([変更タイプに基づくサブスクリプション](#subscriptions-based-in-alteration-type)のセクションを参照) | | `notifyOnMetadataChange` | ✓ | boolean | `true` の場合、メタデータは通知のコンテキストで属性の値の一部と見なされるため、値が変更されずにメタデータが変更された場合、通知がトリガーされます。`false` の場合、メタデータは通知のコンテキストで属性の値の一部と見なされないため、値が変更されずにメタデータが変更された場合、通知はトリガーされません。デフォルト値は `true` です | @@ -3927,7 +3927,7 @@ _**リクエスト・ペイロード**_ ペイロードは、JSON サブスクリプション表現形式 ([サブスクリプション・ペイロード・データモデル](#subscription-payload-datamodel) セクションで説明されています) に従うサブスクリプションを含む JSON オブジェクトです。 -例: +属性フィルタを使用した例: ```json { @@ -3952,8 +3952,38 @@ _**リクエスト・ペイロード**_ }, "attrs": ["temperature", "humidity"] }, - "expires": "2025-04-05T14:00:00.00Z", - "throttling": 5 + "expires": "2025-04-05T14:00:00.00Z" +} +``` + +条件としてジオクエリを使用する例: + +```json +{ + "description": "One subscription to rule them all", + "subject": { + "entities": [ + { + "idPattern": ".*", + "type": "Room" + } + ], + "condition": { + "attrs": [ "temperature" ], + "expression": { + "georel": "near;maxDistance:15000", + "geometry": "point", + "coords": "37.407804,-6.004552" + } + } + }, + "notification": { + "http": { + "url": "http://localhost:1234" + }, + "attrs": ["temperature", "humidity"] + }, + "expires": "2025-04-05T14:00:00.00Z" } ``` From 9639bc441a6b13fdf314c83c8f852b5ae3d69e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 8 Nov 2023 08:36:43 +0100 Subject: [PATCH 23/44] ADD CompoundValueNode equal() method --- src/lib/parse/CompoundValueNode.cpp | 68 ++++ src/lib/parse/CompoundValueNode.h | 3 + ...notify_upon_actual_change_in_geo_json.test | 226 +++++++++++ ...tify_upon_actual_change_in_json_value.test | 370 ++++++++++++++++++ 4 files changed, 667 insertions(+) create mode 100644 test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test create mode 100644 test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test diff --git a/src/lib/parse/CompoundValueNode.cpp b/src/lib/parse/CompoundValueNode.cpp index f26209f7a9..2d19d474bd 100644 --- a/src/lib/parse/CompoundValueNode.cpp +++ b/src/lib/parse/CompoundValueNode.cpp @@ -33,6 +33,7 @@ #include "common/JsonHelper.h" #include "common/macroSubstitute.h" #include "alarmMgr/alarmMgr.h" +#include "mongoDriver/safeMongo.h" #include "parse/forbiddenChars.h" #include "orionTypes/OrionValueType.h" @@ -522,6 +523,73 @@ std::string CompoundValueNode::check(const std::string& path) +/* **************************************************************************** +* +* CompoundValueNode::equal +* +*/ +bool CompoundValueNode::equal(const orion::BSONElement& be) +{ + // Note object cannot be declared inside switch block + std::vector ba; + + switch (valueType) + { + case orion::ValueTypeString: + return (be.type() == orion::String) && (stringValue == be.String()); + + case orion::ValueTypeNumber: + // FIXME PR: unurure if this is going to work with all the Number types (int32/int64/double) + return (be.type() == orion::NumberDouble && numberValue == be.Number()); + + case orion::ValueTypeBoolean: + return (be.type() == orion::Bool) && (boolValue == be.Bool()); + + case orion::ValueTypeNull: + return (be.type() == orion::jstNULL); + + case orion::ValueTypeVector: + // nodeP must be a vector + if (be.type() != orion::Array) + { + return false; + } + ba = be.Array(); + // nodeP must have the same number of elements + if (childV.size() != ba.size()) + { + return false; + } + for (unsigned int ix = 0; ix < childV.size(); ix++) + { + if (!(childV[ix]->equal(ba[ix]))) + { + return false; + } + } + return true; + + case orion::ValueTypeObject: + // nodeP must be a object + if (be.type() != orion::Object) + { + return false; + } + // TBD + return true; + + case orion::ValueTypeNotGiven: + LM_E(("Runtime Error (value type not given (%s))", name.c_str())); + return false; + + default: + LM_E(("Runtime Error (value type unknown (%s))", name.c_str())); + return false; + } +} + + + /* **************************************************************************** * * CompoundValueNode:toJson diff --git a/src/lib/parse/CompoundValueNode.h b/src/lib/parse/CompoundValueNode.h index 98f65b38a4..b46aa2c461 100644 --- a/src/lib/parse/CompoundValueNode.h +++ b/src/lib/parse/CompoundValueNode.h @@ -33,6 +33,8 @@ #include "orionTypes/OrionValueType.h" +#include "mongoDriver/BSONElement.h" + namespace orion { @@ -112,6 +114,7 @@ class CompoundValueNode CompoundValueNode* add(const orion::ValueType _type, const std::string& _name, double _value); CompoundValueNode* add(const orion::ValueType _type, const std::string& _name, bool _value); std::string check(const std::string& path); + bool equal(const orion::BSONElement& be); std::string finish(void); std::string toJson(std::map* replacementsP = NULL); diff --git a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test b/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test new file mode 100644 index 0000000000..9822816391 --- /dev/null +++ b/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test @@ -0,0 +1,226 @@ +# Copyright 2023 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-- +Notify upon actual change in geo:json value + +--SHELL-INIT-- +dbInit CB +brokerStart CB +accumulatorStart --pretty-print + +--SHELL-- + +# +# 01. Create subscription covering E-A +# 02. Create E-A entity with geo:json (notification) +# 03. Update E-A entity with same geo:json object (no notification) +# 04. Update E-A entity with different geo:json (notification) +# 05. Dump accumulator, see 2 notifications +# + +echo "01. Create subscription covering E-A" +echo "====================================" +payload='{ + "subject": { + "entities": [ + { + "id" : "E", + "type": "T" + } + ] + }, + "notification": { + "http": { + "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" + } + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + + +echo "02. Create E-A entity with geo:json (notification)" +echo "==================================================" +payload='{ + "id": "E", + "type": "T", + "A": { + "type": "geo:json", + "value": { + "type": "Point", + "coordinates": [10.2, 10.0] + } + } +}' +orionCurl --url /v2/entities --payload "$payload" +echo +echo + + +echo "03. Update E-A entity with same geo:json (no notification)" +echo "==========================================================" +payload='{ + "A": { + "type": "geo:json", + "value": { + "type": "Point", + "coordinates": [10.2, 10.0] + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "04. Update E-A entity with different geo:json (notification)" +echo "============================================================" +payload='{ + "A": { + "type": "geo:json", + "value": { + "type": "Point", + "coordinates": [11.2, -10.0] + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "05. Dump accumulator, see 3 notifications" +echo "=========================================" +accumulatorDump +echo +echo + + +--REGEXPECT-- +01. Create subscription covering E-A +==================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/subscriptions/REGEX([0-9a-f]{24}) +Content-Length: 0 + + + +02. Create E-A entity with geo:json (notification) +================================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/entities/E?type=T +Content-Length: 0 + + + +03. Update E-A entity with same geo:json (no notification) +========================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +04. Update E-A entity with different geo:json (notification) +============================================================ +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +05. Dump accumulator, see 2 notifications +========================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 163 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "geo:json", + "value": { + "coordinates": [ + 10.2, + 10 + ], + "type": "Point" + } + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 164 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "geo:json", + "value": { + "coordinates": [ + 11.2, + -10 + ], + "type": "Point" + } + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= + + +--TEARDOWN-- +brokerStop CB +dbDrop CB +accumulatorStop diff --git a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test b/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test new file mode 100644 index 0000000000..9d74d7bf56 --- /dev/null +++ b/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test @@ -0,0 +1,370 @@ +# Copyright 2023 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-- +Notify upon actual change in JSON value + +--SHELL-INIT-- +dbInit CB +brokerStart CB +accumulatorStart --pretty-print + +--SHELL-- + +# +# 01. Create subscription covering E-A +# 02. Create E-A entity with JSON object (notification) +# 03. Update E-A entity with same JSON object (no notification) +# 04. Update E-A entity with JSON array (notification) +# 05. Update E-A entity with same JSON array (no notification) +# 06. Update E-A entity with same string (notification) +# 07. Dump accumulator, see 3 notifications +# + +echo "01. Create subscription covering E-A" +echo "====================================" +payload='{ + "subject": { + "entities": [ + { + "id" : "E", + "type": "T" + } + ] + }, + "notification": { + "http": { + "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" + } + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + + +echo "02. Create E-A entity with JSON object (notification)" +echo "=====================================================" +payload='{ + "id": "E", + "type": "T", + "A": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } +}' +orionCurl --url /v2/entities --payload "$payload" +echo +echo + + +echo "03. Update E-A entity with same JSON object (no notification)" +echo "=============================================================" +payload='{ + "A": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "04. Update E-A entity with JSON array (notification)" +echo "====================================================" +payload='{ + "A": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "05. Update E-A entity with same JSON array (no notification)" +echo "============================================================" +payload='{ + "A": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "06. Update E-A entity with same string (notification)" +echo "=====================================================" +payload='{ + "A": { + "value": "foo", + "type": "Text" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "07. Dump accumulator, see 3 notifications" +echo "=========================================" +accumulatorDump +echo +echo + + +--REGEXPECT-- +01. Create subscription covering E-A +==================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/subscriptions/REGEX([0-9a-f]{24}) +Content-Length: 0 + + + +02. Create E-A entity with JSON object (notification) +===================================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/entities/E?type=T +Content-Length: 0 + + + +03. Update E-A entity with same JSON object (no notification) +============================================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +04. Update E-A entity with JSON array (notification) +==================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +05. Update E-A entity with same JSON array (no notification) +============================================================ +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +06. Update E-A entity with same string (notification) +===================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +07. Dump accumulator, see 3 notifications +========================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 271 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y2" + ] + }, + "text": "foo" + } + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 162 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 124 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Text", + "value": "foo" + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= + + +--TEARDOWN-- +brokerStop CB +dbDrop CB +accumulatorStop From 1520c7e2541f9e7e6c8db27f55b37111680955d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 8 Nov 2023 09:54:31 +0100 Subject: [PATCH 24/44] FIX correctly identify changes in JSON attribute values in subscription triggering logic --- src/lib/mongoBackend/MongoCommonUpdate.cpp | 71 +++---- src/lib/parse/CompoundValueNode.cpp | 18 +- ...notify_upon_actual_change_in_geo_json.test | 2 +- ...tify_upon_actual_change_in_json_value.test | 187 ++++++++++++++++-- 4 files changed, 229 insertions(+), 49 deletions(-) diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index e00218931b..544c94d3c1 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -529,48 +529,49 @@ static ChangeType mergeAttrInfo /* Was it an actual update? */ ChangeType changeType = NO_CHANGE; + /* We consider there is a change in the value if one or more of the following are true: + * + * 1) the value of the attribute changed (see attrValueChanges or CompoundValueNode::equal() for details) + * 2) the type of the attribute changed (in this case, !attr.hasField(ENT_ATTRS_TYPE) is needed, as attribute + * type is optional according to NGSI and the attribute may not have that field in the BSON) + * + * In addition, we consider there is change in the metadata if: + * + * 3) the metadata changed (this is done checking if the size of the original and final metadata vectors is + * different and, if they are of the same size, checking if the vectors are not equal) + */ + bool valueChanged; + bool typeChanged; + bool mdChanged; if (caP->compoundValueP == NULL) { - /* In the case of simple value, we consider there is a change in the value if one or more of the following are true: - * - * 1) the value of the attribute changed (see attrValueChanges for details) - * 2) the type of the attribute changed (in this case, !attr.hasField(ENT_ATTRS_TYPE) is needed, as attribute - * type is optional according to NGSI and the attribute may not have that field in the BSON) - * - * In addition, we consider there is change in the metadata if: - * - * 3) the metadata changed (this is done checking if the size of the original and final metadata vectors is - * different and, if they are of the same size, checking if the vectors are not equal) - */ - bool valueChanged = attrValueChanges(attr, caP, forcedUpdate, apiVersion) || - ((!caP->type.empty()) && (!attr.hasField(ENT_ATTRS_TYPE) || getStringFieldF(attr, ENT_ATTRS_TYPE) != caP->type) ); - bool mdChanged = (mdNew.nFields() != mdSize || !equalMetadata(md, mdNew)); - - if (valueChanged && !mdChanged) - { - changeType = CHANGE_ONLY_VALUE; - } - else if (!valueChanged && mdChanged) - { - changeType = CHANGE_ONLY_MD; - } - else if (valueChanged && mdChanged) - { - changeType = CHANGE_VALUE_AND_MD; - } - else // !valueChanged && !mdChanged - { - changeType = NO_CHANGE; - } + valueChanged = attrValueChanges(attr, caP, forcedUpdate, apiVersion); } else { - // FIXME #643 P6: in the case of compound value, it's more difficult to know if an attribute - // has really changed its value (many levels have to be traversed). Until we can develop the - // matching logic, we consider CHANGE_VALUE_AND_MD always. - // + valueChanged = !caP->compoundValueP->equal(getFieldF(attr, ENT_ATTRS_VALUE)); + } + typeChanged = ((!caP->type.empty()) && (!attr.hasField(ENT_ATTRS_TYPE) || getStringFieldF(attr, ENT_ATTRS_TYPE) != caP->type)); + mdChanged = (mdNew.nFields() != mdSize || !equalMetadata(md, mdNew)); + + valueChanged = valueChanged || typeChanged; + + if (valueChanged && !mdChanged) + { + changeType = CHANGE_ONLY_VALUE; + } + else if (!valueChanged && mdChanged) + { + changeType = CHANGE_ONLY_MD; + } + else if (valueChanged && mdChanged) + { changeType = CHANGE_VALUE_AND_MD; } + else // !valueChanged && !mdChanged + { + changeType = NO_CHANGE; + } /* 5. Add modification date (actual change only if actual update) */ if (changeType) diff --git a/src/lib/parse/CompoundValueNode.cpp b/src/lib/parse/CompoundValueNode.cpp index 2d19d474bd..b66f011951 100644 --- a/src/lib/parse/CompoundValueNode.cpp +++ b/src/lib/parse/CompoundValueNode.cpp @@ -532,6 +532,7 @@ bool CompoundValueNode::equal(const orion::BSONElement& be) { // Note object cannot be declared inside switch block std::vector ba; + orion::BSONObj bo; switch (valueType) { @@ -575,7 +576,22 @@ bool CompoundValueNode::equal(const orion::BSONElement& be) { return false; } - // TBD + bo = be.embeddedObject(); + if ((int) childV.size() != bo.nFields()) + { + return false; + } + for (unsigned int ix = 0; ix < childV.size(); ix++) + { + if (!bo.hasField(childV[ix]->name)) + { + return false; + } + if (!(childV[ix]->equal(getFieldF(bo, childV[ix]->name)))) + { + return false; + } + } return true; case orion::ValueTypeNotGiven: diff --git a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test b/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test index 9822816391..cd9a0c0506 100644 --- a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test +++ b/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test @@ -110,7 +110,7 @@ echo echo -echo "05. Dump accumulator, see 3 notifications" +echo "05. Dump accumulator, see 2 notifications" echo "=========================================" accumulatorDump echo diff --git a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test b/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test index 9d74d7bf56..b50fa070b2 100644 --- a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test +++ b/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test @@ -34,10 +34,12 @@ accumulatorStart --pretty-print # 01. Create subscription covering E-A # 02. Create E-A entity with JSON object (notification) # 03. Update E-A entity with same JSON object (no notification) -# 04. Update E-A entity with JSON array (notification) -# 05. Update E-A entity with same JSON array (no notification) -# 06. Update E-A entity with same string (notification) -# 07. Dump accumulator, see 3 notifications +# 04. Update E-A entity with different JSON object (notification) +# 05. Update E-A entity with JSON array (notification) +# 06. Update E-A entity with same JSON array (no notification) +# 07. Update E-A entity with different JSON array (notification) +# 08. Update E-A entity with same string (notification) +# 09. Dump accumulator, see 5 notifications # echo "01. Create subscription covering E-A" @@ -130,7 +132,40 @@ echo echo -echo "04. Update E-A entity with JSON array (notification)" +echo "04. Update E-A entity with different JSON object (notification)" +echo "===============================================================" +payload='{ + "A": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y_new" ] + } + }, + "type": "Json" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "05. Update E-A entity with JSON array (notification)" echo "====================================================" payload='{ "A": { @@ -150,7 +185,7 @@ echo echo -echo "05. Update E-A entity with same JSON array (no notification)" +echo "06. Update E-A entity with same JSON array (no notification)" echo "============================================================" payload='{ "A": { @@ -170,7 +205,27 @@ echo echo -echo "06. Update E-A entity with same string (notification)" +echo "07. Update E-A entity with different JSON array (notification)" +echo "==============================================================" +payload='{ + "A": { + "value": [ + "", + { + "x": [ "x1", "x_new" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "08. Update E-A entity with same string (notification)" echo "=====================================================" payload='{ "A": { @@ -183,7 +238,7 @@ echo echo -echo "07. Dump accumulator, see 3 notifications" +echo "09. Dump accumulator, see 5 notifications" echo "=========================================" accumulatorDump echo @@ -219,7 +274,15 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}) -04. Update E-A entity with JSON array (notification) +04. Update E-A entity with different JSON object (notification) +=============================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +05. Update E-A entity with JSON array (notification) ==================================================== HTTP/1.1 204 No Content Date: REGEX(.*) @@ -227,7 +290,7 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}) -05. Update E-A entity with same JSON array (no notification) +06. Update E-A entity with same JSON array (no notification) ============================================================ HTTP/1.1 204 No Content Date: REGEX(.*) @@ -235,7 +298,15 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}) -06. Update E-A entity with same string (notification) +07. Update E-A entity with different JSON array (notification) +============================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +08. Update E-A entity with same string (notification) ===================================================== HTTP/1.1 204 No Content Date: REGEX(.*) @@ -243,7 +314,7 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}) -07. Dump accumulator, see 3 notifications +09. Dump accumulator, see 5 notifications ========================================= POST http://127.0.0.1:REGEX(\d+)/notify Fiware-Servicepath: / @@ -301,6 +372,60 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 ======================================= POST http://127.0.0.1:REGEX(\d+)/notify Fiware-Servicepath: / +Content-Length: 274 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y_new" + ] + }, + "text": "foo" + } + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / Content-Length: 162 User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) Ngsiv2-Attrsformat: normalized @@ -339,6 +464,44 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 ======================================= POST http://127.0.0.1:REGEX(\d+)/notify Fiware-Servicepath: / +Content-Length: 165 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x_new" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / Content-Length: 124 User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) Ngsiv2-Attrsformat: normalized From 484babfac3e8da8afddea813e8948ed7e9aeb544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 8 Nov 2023 12:29:36 +0100 Subject: [PATCH 25/44] FIX correctly identify changes in JSON metadata values in subscription triggering logic --- src/lib/mongoBackend/MongoCommonUpdate.cpp | 69 +- src/lib/mongoDriver/BSONArray.cpp | 11 + src/lib/mongoDriver/BSONArray.h | 1 + src/lib/mongoDriver/BSONObj.cpp | 11 + src/lib/mongoDriver/BSONObj.h | 1 + .../change_evaluation_geojson.test} | 2 +- ..._evaluation_metadata_object_and_array.test | 600 ++++++++++++++++++ ...ge_evaluation_value_object_and_array.test} | 2 +- 8 files changed, 641 insertions(+), 56 deletions(-) rename test/functionalTest/cases/{4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test => 4211_right_json_change_evaluation_in_subs/change_evaluation_geojson.test} (99%) create mode 100644 test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array.test rename test/functionalTest/cases/{4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test => 4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array.test} (99%) diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index 544c94d3c1..bc5e0d036e 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -136,7 +136,7 @@ static bool hasMetadata(std::string name, std::string type, ContextAttribute* ca * * equalMetadataValues - */ -static bool equalMetadataValues(const orion::BSONObj& md1, const orion::BSONObj& md2) +static bool equalMetadataItems(const orion::BSONObj& md1, const orion::BSONObj& md2) { bool md1TypeExist = md1.hasField(ENT_ATTRS_MD_TYPE); bool md2TypeExist = md2.hasField(ENT_ATTRS_MD_TYPE); @@ -147,58 +147,23 @@ static bool equalMetadataValues(const orion::BSONObj& md1, const orion::BSONObj& return false; } - // If type exists in both metadata elments, check if they are the same + // If type exists in both metadata elements, check if they are the same if (md1TypeExist && md2TypeExist) { - if (getFieldF(md1, ENT_ATTRS_MD_TYPE).type() != getFieldF(md2, ENT_ATTRS_MD_TYPE).type()) + if ((getFieldF(md1, ENT_ATTRS_MD_TYPE).type() != orion::String)) { + LM_E(("Runtime Error (unallowed JSON type for metadata NGSI type: %d)", getFieldF(md1, ENT_ATTRS_MD_TYPE).type())); return false; } - switch (getFieldF(md1, ENT_ATTRS_MD_TYPE).type()) + if ((getFieldF(md2, ENT_ATTRS_MD_TYPE).type() != orion::String)) { - /* FIXME #643 P6: metadata array/object are now supported, but we haven't - implemented yet the logic to compare compounds between them - case Object: - ... - break; - - case Array: - ... - break; - */ - - case orion::NumberDouble: - if (getNumberFieldF(md1, ENT_ATTRS_MD_TYPE) != getNumberFieldF(md2, ENT_ATTRS_MD_TYPE)) - { - return false; - } - break; - - case orion::Bool: - if (getBoolFieldF(md1, ENT_ATTRS_MD_TYPE) != getBoolFieldF(md2, ENT_ATTRS_MD_TYPE)) - { - return false; - } - break; - - case orion::String: - if (getStringFieldF(md1, ENT_ATTRS_MD_TYPE) != getStringFieldF(md2, ENT_ATTRS_MD_TYPE)) - { - return false; - } - break; - - case orion::jstNULL: - if (!getFieldF(md2, ENT_ATTRS_MD_TYPE).isNull()) - { - return false; - } - break; + LM_E(("Runtime Error (unallowed JSON type for metadata NGSI type: %d)", getFieldF(md2, ENT_ATTRS_MD_TYPE).type())); + return false; + } - default: - LM_E(("Runtime Error (unknown JSON type for metadata NGSI type: %d)", getFieldF(md1, ENT_ATTRS_MD_TYPE).type())); + if (getStringFieldF(md1, ENT_ATTRS_MD_TYPE) != getStringFieldF(md2, ENT_ATTRS_MD_TYPE)) + { return false; - break; } } @@ -210,15 +175,11 @@ static bool equalMetadataValues(const orion::BSONObj& md1, const orion::BSONObj& switch (getFieldF(md1, ENT_ATTRS_MD_VALUE).type()) { - /* FIXME not yet case orion::Object: - ... - break; + return getObjectFieldF(md1, ENT_ATTRS_MD_VALUE).equal(getObjectFieldF(md2, ENT_ATTRS_MD_VALUE)); case orion::Array: - ... - break; - */ + return getArrayFieldF(md1, ENT_ATTRS_MD_VALUE).equal(getArrayFieldF(md2, ENT_ATTRS_MD_VALUE)); case orion::NumberDouble: return getNumberFieldF(md1, ENT_ATTRS_MD_VALUE) == getNumberFieldF(md2, ENT_ATTRS_MD_VALUE); @@ -266,7 +227,7 @@ static bool equalMetadata(const orion::BSONObj& md1, const orion::BSONObj& md2) orion::BSONObj md1Item = getObjectFieldF(md1, currentMd); orion::BSONObj md2Item = getObjectFieldF(md2, currentMd); - if (!equalMetadataValues(md1Item, md2Item)) + if (!equalMetadataItems(md1Item, md2Item)) { return false; } @@ -281,7 +242,7 @@ static bool equalMetadata(const orion::BSONObj& md1, const orion::BSONObj& md2) * * changedAttr - */ -static bool attrValueChanges(const orion::BSONObj& attr, ContextAttribute* caP, const bool& forcedUpdate, ApiVersion apiVersion) +static bool attrValueChanges(const orion::BSONObj& attr, ContextAttribute* caP, const bool& forcedUpdate) { /* Not finding the attribute field at MongoDB is considered as an implicit "" */ if (!attr.hasField(ENT_ATTRS_VALUE)) @@ -545,7 +506,7 @@ static ChangeType mergeAttrInfo bool mdChanged; if (caP->compoundValueP == NULL) { - valueChanged = attrValueChanges(attr, caP, forcedUpdate, apiVersion); + valueChanged = attrValueChanges(attr, caP, forcedUpdate); } else { diff --git a/src/lib/mongoDriver/BSONArray.cpp b/src/lib/mongoDriver/BSONArray.cpp index 7e69099455..afef83670e 100644 --- a/src/lib/mongoDriver/BSONArray.cpp +++ b/src/lib/mongoDriver/BSONArray.cpp @@ -87,6 +87,17 @@ std::string BSONArray::toString(void) const +/* **************************************************************************** +* +* BSONArray::equal - +*/ +bool BSONArray::equal(const BSONArray& ba) +{ + return (bson_compare(this->b, ba.b) == 0); +} + + + /* **************************************************************************** * * BSONArray::operator= - diff --git a/src/lib/mongoDriver/BSONArray.h b/src/lib/mongoDriver/BSONArray.h index d0e8b52c3f..098ac3520c 100644 --- a/src/lib/mongoDriver/BSONArray.h +++ b/src/lib/mongoDriver/BSONArray.h @@ -46,6 +46,7 @@ class BSONArray BSONArray(const BSONArray& _ba); int nFields(void) const; std::string toString(void) const; + bool equal(const BSONArray& ba); BSONArray& operator= (const BSONArray& rhs); // methods to be used only by mongoDriver/ code (with references to low-level driver code) diff --git a/src/lib/mongoDriver/BSONObj.cpp b/src/lib/mongoDriver/BSONObj.cpp index ad1ad1efb7..d7fcad2a49 100644 --- a/src/lib/mongoDriver/BSONObj.cpp +++ b/src/lib/mongoDriver/BSONObj.cpp @@ -192,6 +192,17 @@ void BSONObj::toElementsVector(std::vector* v) +/* **************************************************************************** +* +* BSONObj::equal - +*/ +bool BSONObj::equal(const BSONObj& bo) +{ + return (bson_compare(this->b, bo.b) == 0); +} + + + /* **************************************************************************** * * BSONObj::operator= - diff --git a/src/lib/mongoDriver/BSONObj.h b/src/lib/mongoDriver/BSONObj.h index d8b35f2c0b..473e974c01 100644 --- a/src/lib/mongoDriver/BSONObj.h +++ b/src/lib/mongoDriver/BSONObj.h @@ -59,6 +59,7 @@ class BSONObj bool isEmpty(void) const; void toStringMap(std::map* m); void toElementsVector(std::vector* v); + bool equal(const BSONObj& bo); BSONObj& operator= (const BSONObj& rhs); // methods to be used only by mongoDriver/ code (with references to low-level driver code) diff --git a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_geojson.test similarity index 99% rename from test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test rename to test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_geojson.test index cd9a0c0506..a540d7c043 100644 --- a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_geo_json.test +++ b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_geojson.test @@ -21,7 +21,7 @@ # VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh --NAME-- -Notify upon actual change in geo:json value +Right JSON change evaluation in subs (GeoJson case) --SHELL-INIT-- dbInit CB diff --git a/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array.test b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array.test new file mode 100644 index 0000000000..6fd56fd903 --- /dev/null +++ b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array.test @@ -0,0 +1,600 @@ +# Copyright 2023 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-- +Right JSON change evaluation in subs (objects and arrays in metadata case) + +--SHELL-INIT-- +dbInit CB +brokerStart CB +accumulatorStart --pretty-print + +--SHELL-- + +# +# 01. Create subscription covering E-A +# 02. Create E-A entity with JSON object in metadata (notification) +# 03. Update E-A entity with same JSON object in metadata (no notification) +# 04. Update E-A entity with different JSON object in metadata (notification) +# 05. Update E-A entity with JSON array in metadata (notification) +# 06. Update E-A entity with same JSON array in metadata (no notification) +# 07. Update E-A entity with different JSON array in metadata (notification) +# 08. Update E-A entity with same string in metadata (notification) +# 09. Dump accumulator, see 5 notifications +# + +echo "01. Create subscription covering E-A" +echo "====================================" +payload='{ + "subject": { + "entities": [ + { + "id" : "E", + "type": "T" + } + ] + }, + "notification": { + "http": { + "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" + } + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + + +echo "02. Create E-A entity with JSON object in metadata (notification)" +echo "=================================================================" +payload='{ + "id": "E", + "type": "T", + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } + } + } +}' +orionCurl --url /v2/entities --payload "$payload" +echo +echo + + +echo "03. Update E-A entity with same JSON object in metadata (no notification)" +echo "=========================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "04. Update E-A entity with different JSON object in metadata (notification)" +echo "===========================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y_new" ] + } + }, + "type": "Json" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "05. Update E-A entity with JSON array in metadata (notification)" +echo "================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "06. Update E-A entity with same JSON array in metadata (no notification)" +echo "========================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "07. Update E-A entity with different JSON array in metadata (notification)" +echo "==========================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": [ + "", + { + "x": [ "x1", "x_new" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "08. Update E-A entity with same string in metadata (notification)" +echo "=================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": "foo", + "type": "Text" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "09. Dump accumulator, see 5 notifications" +echo "=========================================" +accumulatorDump +echo +echo + + +--REGEXPECT-- +01. Create subscription covering E-A +==================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/subscriptions/REGEX([0-9a-f]{24}) +Content-Length: 0 + + + +02. Create E-A entity with JSON object in metadata (notification) +================================================================= +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/entities/E?type=T +Content-Length: 0 + + + +03. Update E-A entity with same JSON object in metadata (no notification) +========================================================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +04. Update E-A entity with different JSON object in metadata (notification) +=========================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +05. Update E-A entity with JSON array in metadata (notification) +================================================================ +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +06. Update E-A entity with same JSON array in metadata (no notification) +======================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +07. Update E-A entity with different JSON array in metadata (notification) +========================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +08. Update E-A entity with same string in metadata (notification) +================================================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +09. Dump accumulator, see 5 notifications +========================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 302 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y2" + ] + }, + "text": "foo" + } + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 305 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y_new" + ] + }, + "text": "foo" + } + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 193 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 196 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x_new" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 155 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Text", + "value": "foo" + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= + + +--TEARDOWN-- +brokerStop CB +dbDrop CB +accumulatorStop diff --git a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array.test similarity index 99% rename from test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test rename to test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array.test index b50fa070b2..cc664dd6cd 100644 --- a/test/functionalTest/cases/4211_notify_upon_actual_change_in_json_value/notify_upon_actual_change_in_json_value.test +++ b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array.test @@ -21,7 +21,7 @@ # VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh --NAME-- -Notify upon actual change in JSON value +Right JSON change evaluation in subs (objects and arrays in attribute value case) --SHELL-INIT-- dbInit CB From 51b921f7e626cc7f697757a9a064ac9c7ea5aacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 8 Nov 2023 13:00:40 +0100 Subject: [PATCH 26/44] FIX forcedUpdate with JSON changes --- src/lib/mongoBackend/MongoCommonUpdate.cpp | 2 +- ...ta_object_and_array_with_forcedUpdate.test | 705 ++++++++++++++++++ ...ue_object_and_array_with_forcedUpdate.test | 628 ++++++++++++++++ 3 files changed, 1334 insertions(+), 1 deletion(-) create mode 100644 test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_forcedUpdate.test create mode 100644 test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array_with_forcedUpdate.test diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index bc5e0d036e..faf2315238 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -510,7 +510,7 @@ static ChangeType mergeAttrInfo } else { - valueChanged = !caP->compoundValueP->equal(getFieldF(attr, ENT_ATTRS_VALUE)); + valueChanged = forcedUpdate || !caP->compoundValueP->equal(getFieldF(attr, ENT_ATTRS_VALUE)); } typeChanged = ((!caP->type.empty()) && (!attr.hasField(ENT_ATTRS_TYPE) || getStringFieldF(attr, ENT_ATTRS_TYPE) != caP->type)); mdChanged = (mdNew.nFields() != mdSize || !equalMetadata(md, mdNew)); diff --git a/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_forcedUpdate.test b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_forcedUpdate.test new file mode 100644 index 0000000000..a868b6576c --- /dev/null +++ b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_forcedUpdate.test @@ -0,0 +1,705 @@ +# Copyright 2023 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-- +Right JSON change evaluation in subs (objects and arrays in metadata case with forcedUpdate) + +--SHELL-INIT-- +dbInit CB +brokerStart CB +accumulatorStart --pretty-print + +--SHELL-- + +# +# Same as change_evaluation_metadata_object_and_array.test but using forcedUpdate un update operations +# +# +# 01. Create subscription covering E-A +# 02. Create E-A entity with JSON object in metadata (notification) +# 03. Update E-A entity with same JSON object in metadata (notification) +# 04. Update E-A entity with different JSON object in metadata (notification) +# 05. Update E-A entity with JSON array in metadata (notification) +# 06. Update E-A entity with same JSON array in metadata (notification) +# 07. Update E-A entity with different JSON array in metadata (notification) +# 08. Update E-A entity with same string in metadata (notification) +# 09. Dump accumulator, see 5 notifications +# + +echo "01. Create subscription covering E-A" +echo "====================================" +payload='{ + "subject": { + "entities": [ + { + "id" : "E", + "type": "T" + } + ] + }, + "notification": { + "http": { + "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" + } + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + + +echo "02. Create E-A entity with JSON object in metadata (notification)" +echo "=================================================================" +payload='{ + "id": "E", + "type": "T", + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } + } + } +}' +orionCurl --url /v2/entities --payload "$payload" +echo +echo + + +echo "03. Update E-A entity with same JSON object in metadata (notification)" +echo "======================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "04. Update E-A entity with different JSON object in metadata (notification)" +echo "===========================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y_new" ] + } + }, + "type": "Json" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "05. Update E-A entity with JSON array in metadata (notification)" +echo "================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "06. Update E-A entity with same JSON array in metadata (notification)" +echo "=====================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "07. Update E-A entity with different JSON array in metadata (notification)" +echo "==========================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": [ + "", + { + "x": [ "x1", "x_new" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "08. Update E-A entity with same string in metadata (notification)" +echo "=================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": "foo", + "type": "Text" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "09. Dump accumulator, see 7 notifications" +echo "=========================================" +accumulatorDump +echo +echo + + +--REGEXPECT-- +01. Create subscription covering E-A +==================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/subscriptions/REGEX([0-9a-f]{24}) +Content-Length: 0 + + + +02. Create E-A entity with JSON object in metadata (notification) +================================================================= +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/entities/E?type=T +Content-Length: 0 + + + +03. Update E-A entity with same JSON object in metadata (notification) +====================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +04. Update E-A entity with different JSON object in metadata (notification) +=========================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +05. Update E-A entity with JSON array in metadata (notification) +================================================================ +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +06. Update E-A entity with same JSON array in metadata (notification) +===================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +07. Update E-A entity with different JSON array in metadata (notification) +========================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +08. Update E-A entity with same string in metadata (notification) +================================================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +09. Dump accumulator, see 7 notifications +========================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 302 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y2" + ] + }, + "text": "foo" + } + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 302 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y2" + ] + }, + "text": "foo" + } + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 305 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y_new" + ] + }, + "text": "foo" + } + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 193 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 193 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 196 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x_new" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 155 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Text", + "value": "foo" + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= + + +--TEARDOWN-- +brokerStop CB +dbDrop CB +accumulatorStop diff --git a/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array_with_forcedUpdate.test b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array_with_forcedUpdate.test new file mode 100644 index 0000000000..150035d985 --- /dev/null +++ b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array_with_forcedUpdate.test @@ -0,0 +1,628 @@ +# Copyright 2023 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-- +Right JSON change evaluation in subs (objects and arrays in attribute value case with forcedUpdate) + +--SHELL-INIT-- +dbInit CB +brokerStart CB +accumulatorStart --pretty-print + +--SHELL-- + +# +# Same as change_evaluation_value_object_and_array.test but using forcedUpdate un update operations +# +# +# 01. Create subscription covering E-A +# 02. Create E-A entity with JSON object (notification) +# 03. Update E-A entity with same JSON object (notification) +# 04. Update E-A entity with different JSON object (notification) +# 05. Update E-A entity with JSON array (notification) +# 06. Update E-A entity with same JSON array (notification) +# 07. Update E-A entity with different JSON array (notification) +# 08. Update E-A entity with same string (notification) +# 09. Dump accumulator, see 7 notifications +# + +echo "01. Create subscription covering E-A" +echo "====================================" +payload='{ + "subject": { + "entities": [ + { + "id" : "E", + "type": "T" + } + ] + }, + "notification": { + "http": { + "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" + } + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + + +echo "02. Create E-A entity with JSON object (notification)" +echo "=====================================================" +payload='{ + "id": "E", + "type": "T", + "A": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } +}' +orionCurl --url /v2/entities --payload "$payload" +echo +echo + + +echo "03. Update E-A entity with same JSON object (notification)" +echo "==========================================================" +payload='{ + "A": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "04. Update E-A entity with different JSON object (notification)" +echo "===============================================================" +payload='{ + "A": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y_new" ] + } + }, + "type": "Json" + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "05. Update E-A entity with JSON array (notification)" +echo "====================================================" +payload='{ + "A": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "06. Update E-A entity with same JSON array (notification)" +echo "=========================================================" +payload='{ + "A": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "07. Update E-A entity with different JSON array (notification)" +echo "==============================================================" +payload='{ + "A": { + "value": [ + "", + { + "x": [ "x1", "x_new" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "08. Update E-A entity with same string (notification)" +echo "=====================================================" +payload='{ + "A": { + "value": "foo", + "type": "Text" + } +}' +orionCurl --url /v2/entities/E/attrs?options=forcedUpdate --payload "$payload" +echo +echo + + +echo "09. Dump accumulator, see 7 notifications" +echo "=========================================" +accumulatorDump +echo +echo + + +--REGEXPECT-- +01. Create subscription covering E-A +==================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/subscriptions/REGEX([0-9a-f]{24}) +Content-Length: 0 + + + +02. Create E-A entity with JSON object (notification) +===================================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/entities/E?type=T +Content-Length: 0 + + + +03. Update E-A entity with same JSON object (notification) +========================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +04. Update E-A entity with different JSON object (notification) +=============================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +05. Update E-A entity with JSON array (notification) +==================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +06. Update E-A entity with same JSON array (notification) +========================================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +07. Update E-A entity with different JSON array (notification) +============================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +08. Update E-A entity with same string (notification) +===================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +09. Dump accumulator, see 7 notifications +========================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 271 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y2" + ] + }, + "text": "foo" + } + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 271 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y2" + ] + }, + "text": "foo" + } + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 274 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y_new" + ] + }, + "text": "foo" + } + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 162 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 162 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 165 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x_new" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 124 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Text", + "value": "foo" + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= + + +--TEARDOWN-- +brokerStop CB +dbDrop CB +accumulatorStop From b4eb6b32bf7bf8480f5ec1a7cf90bf207054bdce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 8 Nov 2023 13:26:23 +0100 Subject: [PATCH 27/44] FIX simplify forcedUpdate processing --- src/lib/mongoBackend/MongoCommonUpdate.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index faf2315238..afdec2510f 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -242,7 +242,7 @@ static bool equalMetadata(const orion::BSONObj& md1, const orion::BSONObj& md2) * * changedAttr - */ -static bool attrValueChanges(const orion::BSONObj& attr, ContextAttribute* caP, const bool& forcedUpdate) +static bool attrValueChanges(const orion::BSONObj& attr, ContextAttribute* caP) { /* Not finding the attribute field at MongoDB is considered as an implicit "" */ if (!attr.hasField(ENT_ATTRS_VALUE)) @@ -265,13 +265,13 @@ static bool attrValueChanges(const orion::BSONObj& attr, ContextAttribute* caP, return true; case orion::NumberDouble: - return caP->valueType != orion::ValueTypeNumber || caP->numberValue != getNumberFieldF(attr, ENT_ATTRS_VALUE) || forcedUpdate; + return caP->valueType != orion::ValueTypeNumber || caP->numberValue != getNumberFieldF(attr, ENT_ATTRS_VALUE); case orion::Bool: - return caP->valueType != orion::ValueTypeBoolean || caP->boolValue != getBoolFieldF(attr, ENT_ATTRS_VALUE) || forcedUpdate; + return caP->valueType != orion::ValueTypeBoolean || caP->boolValue != getBoolFieldF(attr, ENT_ATTRS_VALUE); case orion::String: - return caP->valueType != orion::ValueTypeString || caP->stringValue != getStringFieldF(attr, ENT_ATTRS_VALUE) || forcedUpdate; + return caP->valueType != orion::ValueTypeString || caP->stringValue != getStringFieldF(attr, ENT_ATTRS_VALUE); case orion::jstNULL: return caP->valueType != orion::ValueTypeNull; @@ -492,8 +492,9 @@ static ChangeType mergeAttrInfo /* We consider there is a change in the value if one or more of the following are true: * - * 1) the value of the attribute changed (see attrValueChanges or CompoundValueNode::equal() for details) - * 2) the type of the attribute changed (in this case, !attr.hasField(ENT_ATTRS_TYPE) is needed, as attribute + * 1) forcedUpdate is enabled + * 2) the value of the attribute changed (see attrValueChanges or CompoundValueNode::equal() for details) + * 3) the type of the attribute changed (in this case, !attr.hasField(ENT_ATTRS_TYPE) is needed, as attribute * type is optional according to NGSI and the attribute may not have that field in the BSON) * * In addition, we consider there is change in the metadata if: @@ -506,7 +507,7 @@ static ChangeType mergeAttrInfo bool mdChanged; if (caP->compoundValueP == NULL) { - valueChanged = attrValueChanges(attr, caP, forcedUpdate); + valueChanged = forcedUpdate || attrValueChanges(attr, caP); } else { From b54284eabf8f1ca78841953e4aa1516bdaebf088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 8 Nov 2023 14:03:18 +0100 Subject: [PATCH 28/44] ADD entityUpdate test cases --- ...ta_object_and_array_with_entityUpdate.test | 649 ++++++++++++++++++ ...ue_object_and_array_with_entityUpdate.test | 577 ++++++++++++++++ 2 files changed, 1226 insertions(+) create mode 100644 test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_entityUpdate.test create mode 100644 test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array_with_entityUpdate.test diff --git a/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_entityUpdate.test b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_entityUpdate.test new file mode 100644 index 0000000000..54ee0e648b --- /dev/null +++ b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_entityUpdate.test @@ -0,0 +1,649 @@ +# Copyright 2023 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-- +Right JSON change evaluation in subs (objects and arrays in metadata case with entityUpdate) + +--SHELL-INIT-- +dbInit CB +brokerStart CB +accumulatorStart --pretty-print + +--SHELL-- + +# +# Same as change_evaluation_metadata_object_and_array.test but using entityUpdate in the subscription +# +# +# 01. Create subscription covering E-A +# 02. Create E-A entity with JSON object in metadata (no notification) +# 03. Update E-A entity with same JSON object in metadata (notification) +# 04. Update E-A entity with different JSON object in metadata (notification) +# 05. Update E-A entity with JSON array in metadata (notification) +# 06. Update E-A entity with same JSON array in metadata (notification) +# 07. Update E-A entity with different JSON array in metadata (notification) +# 08. Update E-A entity with same string in metadata (notification) +# 09. Dump accumulator, see 6 notifications +# + +echo "01. Create subscription covering E-A" +echo "====================================" +payload='{ + "subject": { + "entities": [ + { + "id" : "E", + "type": "T" + } + ], + "condition": { + "alterationTypes": [ "entityUpdate" ] + } + }, + "notification": { + "http": { + "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" + } + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + + +echo "02. Create E-A entity with JSON object in metadata (no notification)" +echo "====================================================================" +payload='{ + "id": "E", + "type": "T", + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } + } + } +}' +orionCurl --url /v2/entities --payload "$payload" +echo +echo + + +echo "03. Update E-A entity with same JSON object in metadata (notification)" +echo "======================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "04. Update E-A entity with different JSON object in metadata (notification)" +echo "===========================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y_new" ] + } + }, + "type": "Json" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "05. Update E-A entity with JSON array in metadata (notification)" +echo "================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "06. Update E-A entity with same JSON array in metadata (notification)" +echo "=====================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "07. Update E-A entity with different JSON array in metadata (notification)" +echo "==========================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": [ + "", + { + "x": [ "x1", "x_new" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "08. Update E-A entity with same string in metadata (notification)" +echo "=================================================================" +payload='{ + "A": { + "value": 1, + "type": "Number", + "metadata": { + "M": { + "value": "foo", + "type": "Text" + } + } + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "09. Dump accumulator, see 6 notifications" +echo "=========================================" +accumulatorDump +echo +echo + + +--REGEXPECT-- +01. Create subscription covering E-A +==================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/subscriptions/REGEX([0-9a-f]{24}) +Content-Length: 0 + + + +02. Create E-A entity with JSON object in metadata (no notification) +==================================================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/entities/E?type=T +Content-Length: 0 + + + +03. Update E-A entity with same JSON object in metadata (notification) +====================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +04. Update E-A entity with different JSON object in metadata (notification) +=========================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +05. Update E-A entity with JSON array in metadata (notification) +================================================================ +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +06. Update E-A entity with same JSON array in metadata (notification) +===================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +07. Update E-A entity with different JSON array in metadata (notification) +========================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +08. Update E-A entity with same string in metadata (notification) +================================================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +09. Dump accumulator, see 6 notifications +========================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 302 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y2" + ] + }, + "text": "foo" + } + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 305 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y_new" + ] + }, + "text": "foo" + } + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 193 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 193 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 196 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x_new" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 155 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": { + "M": { + "type": "Text", + "value": "foo" + } + }, + "type": "Number", + "value": 1 + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= + + +--TEARDOWN-- +brokerStop CB +dbDrop CB +accumulatorStop diff --git a/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array_with_entityUpdate.test b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array_with_entityUpdate.test new file mode 100644 index 0000000000..a0befc27d9 --- /dev/null +++ b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_value_object_and_array_with_entityUpdate.test @@ -0,0 +1,577 @@ +# Copyright 2023 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-- +Right JSON change evaluation in subs (objects and arrays in attribute value case with entityUpdate) + +--SHELL-INIT-- +dbInit CB +brokerStart CB +accumulatorStart --pretty-print + +--SHELL-- + +# +# Same as change_evaluation_value_object_and_array.test but using entityUpdate in the subscription +# +# +# 01. Create subscription covering E-A +# 02. Create E-A entity with JSON object (no notification) +# 03. Update E-A entity with same JSON object (notification) +# 04. Update E-A entity with different JSON object (notification) +# 05. Update E-A entity with JSON array (notification) +# 06. Update E-A entity with same JSON array (notification) +# 07. Update E-A entity with different JSON array (notification) +# 08. Update E-A entity with same string (notification) +# 09. Dump accumulator, see 6 notifications +# + +echo "01. Create subscription covering E-A" +echo "====================================" +payload='{ + "subject": { + "entities": [ + { + "id" : "E", + "type": "T" + } + ], + "condition": { + "alterationTypes": [ "entityUpdate" ] + } + }, + "notification": { + "http": { + "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" + } + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + + +echo "02. Create E-A entity with JSON object (no notification)" +echo "========================================================" +payload='{ + "id": "E", + "type": "T", + "A": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } +}' +orionCurl --url /v2/entities --payload "$payload" +echo +echo + + +echo "03. Update E-A entity with same JSON object (notification)" +echo "==========================================================" +payload='{ + "A": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y2" ] + } + }, + "type": "Json" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "04. Update E-A entity with different JSON object (notification)" +echo "===============================================================" +payload='{ + "A": { + "value": { + "text": "foo", + "number": 10, + "bool": true, + "null": null, + "array": [ + "22", + { + "x" : [ "x1", "x2" ], + "y" : 3 + }, + [ "z1", "z2" ] + ], + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ "y1", "y_new" ] + } + }, + "type": "Json" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "05. Update E-A entity with JSON array (notification)" +echo "====================================================" +payload='{ + "A": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "06. Update E-A entity with same JSON array (notification)" +echo "=========================================================" +payload='{ + "A": { + "value": [ + "", + { + "x": [ "x1", "x2" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "07. Update E-A entity with different JSON array (notification)" +echo "==============================================================" +payload='{ + "A": { + "value": [ + "", + { + "x": [ "x1", "x_new" ], + "y": "3" + }, + [ "z1", "z2" ] + ], + "type": "Array" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "08. Update E-A entity with same string (notification)" +echo "=====================================================" +payload='{ + "A": { + "value": "foo", + "type": "Text" + } +}' +orionCurl --url /v2/entities/E/attrs --payload "$payload" +echo +echo + + +echo "09. Dump accumulator, see 6 notifications" +echo "=========================================" +accumulatorDump +echo +echo + + +--REGEXPECT-- +01. Create subscription covering E-A +==================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/subscriptions/REGEX([0-9a-f]{24}) +Content-Length: 0 + + + +02. Create E-A entity with JSON object (no notification) +======================================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/entities/E?type=T +Content-Length: 0 + + + +03. Update E-A entity with same JSON object (notification) +========================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +04. Update E-A entity with different JSON object (notification) +=============================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +05. Update E-A entity with JSON array (notification) +==================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +06. Update E-A entity with same JSON array (notification) +========================================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +07. Update E-A entity with different JSON array (notification) +============================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +08. Update E-A entity with same string (notification) +===================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +09. Dump accumulator, see 6 notifications +========================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 271 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y2" + ] + }, + "text": "foo" + } + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 274 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Json", + "value": { + "array": [ + "22", + { + "x": [ + "x1", + "x2" + ], + "y": 3 + }, + [ + "z1", + "z2" + ] + ], + "bool": true, + "null": null, + "number": 10, + "object": { + "x": { + "x1": "a", + "x2": "b" + }, + "y": [ + "y1", + "y_new" + ] + }, + "text": "foo" + } + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 162 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 162 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x2" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 165 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Array", + "value": [ + "", + { + "x": [ + "x1", + "x_new" + ], + "y": "3" + }, + [ + "z1", + "z2" + ] + ] + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= +POST http://127.0.0.1:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 124 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: 127.0.0.1:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Text", + "value": "foo" + }, + "id": "E", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= + + +--TEARDOWN-- +brokerStop CB +dbDrop CB +accumulatorStop From f2818abb1ce3768db367fa9a5bdfb7de16e9116c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 8 Nov 2023 14:03:35 +0100 Subject: [PATCH 29/44] FIX typos --- src/lib/parse/CompoundValueNode.cpp | 5 +++-- ...aluation_metadata_object_and_array_with_forcedUpdate.test | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/parse/CompoundValueNode.cpp b/src/lib/parse/CompoundValueNode.cpp index b66f011951..454c239383 100644 --- a/src/lib/parse/CompoundValueNode.cpp +++ b/src/lib/parse/CompoundValueNode.cpp @@ -530,7 +530,7 @@ std::string CompoundValueNode::check(const std::string& path) */ bool CompoundValueNode::equal(const orion::BSONElement& be) { - // Note object cannot be declared inside switch block + // Note objects cannot be declared inside switch block std::vector ba; orion::BSONObj bo; @@ -540,7 +540,8 @@ bool CompoundValueNode::equal(const orion::BSONElement& be) return (be.type() == orion::String) && (stringValue == be.String()); case orion::ValueTypeNumber: - // FIXME PR: unurure if this is going to work with all the Number types (int32/int64/double) + // FIXME P2: according to regression tests, this seems to work with all number types (int32/int64/double) + // However, let's keep an eye on this in the case some day it fails... return (be.type() == orion::NumberDouble && numberValue == be.Number()); case orion::ValueTypeBoolean: diff --git a/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_forcedUpdate.test b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_forcedUpdate.test index a868b6576c..6a54735e5e 100644 --- a/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_forcedUpdate.test +++ b/test/functionalTest/cases/4211_right_json_change_evaluation_in_subs/change_evaluation_metadata_object_and_array_with_forcedUpdate.test @@ -42,7 +42,7 @@ accumulatorStart --pretty-print # 06. Update E-A entity with same JSON array in metadata (notification) # 07. Update E-A entity with different JSON array in metadata (notification) # 08. Update E-A entity with same string in metadata (notification) -# 09. Dump accumulator, see 5 notifications +# 09. Dump accumulator, see 7 notifications # echo "01. Create subscription covering E-A" From b5b623e6ac2102e4a5e6184f2fee1ab9efdccbfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 8 Nov 2023 14:03:44 +0100 Subject: [PATCH 30/44] ADD CNR entry --- CHANGES_NEXT_RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 7c55d0ee44..e241145fe2 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,5 +1,6 @@ - Add: servicePath field to builtin attributes (#2877) - Add: notification.mqtt.retain and notification.mqttCustom.retain flag for MQTT retain in notifications (#4388) +- Fix: correctly detect JSON attribute and metadata value changes in subscription triggering logic (#4211, #4434, #643) - Fix: DateTime and geo:json types were not supported in custom notifications using ngsi patching (#4435) - Fix: logDeprecate not working correctly (`geo:json` wrongly considered as deprecated) - Fix: improve error traces (#4387) From e9ab847f7580d73205106347e748530c9c55d663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 15 Nov 2023 11:05:31 +0100 Subject: [PATCH 31/44] ADD actionType delete with nulls --- .../batch_update_DELETE.test | 2 +- .../batch_update_DELETE_with_nulls.test | 206 ++++++++++++++++++ 2 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 test/functionalTest/cases/1715_batch_update/batch_update_DELETE_with_nulls.test diff --git a/test/functionalTest/cases/1715_batch_update/batch_update_DELETE.test b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE.test index ab5b5dcd56..8568b6fbfb 100644 --- a/test/functionalTest/cases/1715_batch_update/batch_update_DELETE.test +++ b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE.test @@ -21,7 +21,7 @@ # VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh --NAME-- -V2 batch update REPLACE +V2 batch update DELETE --SHELL-INIT-- dbInit CB diff --git a/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_with_nulls.test b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_with_nulls.test new file mode 100644 index 0000000000..aaca277e53 --- /dev/null +++ b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_with_nulls.test @@ -0,0 +1,206 @@ +# Copyright 2016 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-- +V2 batch update DELETE with nulls + +--SHELL-INIT-- +dbInit CB +brokerStart CB 0 + +--SHELL-- + +# +# 01. Create E1/T/A1-A2 and E2/T/A1-A2 using POST /v2/op/update with append +# 02. GET /v2/entities to see A1 and A2 in entities +# 03. Delete E1-A1=null and E2-A1=null using POST /v2/op/update with delete +# 04. GET /v2/entities to see A2 in entities +# + +echo "01. Create E1/T/A1-A2 and E2/T/A1-A2 using POST /v2/op/update with append" +echo "=========================================================================" +payload='{ + "actionType": "append", + "entities": [ + { + "id": "E1", + "type": "T", + "A1": { + "type": "Number", + "value": 11 + }, + "A2": { + "type": "Number", + "value": 12 + } + }, + { + "id": "E2", + "type": "T", + "A1": { + "type": "Number", + "value": 21 + }, + "A2": { + "type": "Number", + "value": 22 + } + } + ] +}' +orionCurl --url /v2/op/update --payload "$payload" +echo +echo + + +echo "02. GET /v2/entities to see A1 and A2 in entities" +echo "=================================================" +orionCurl --url /v2/entities +echo +echo + + +echo "03. Delete E1-A1=null and E2-A1=null using POST /v2/op/update with delete" +echo "=========================================================================" +payload='{ + "actionType": "delete", + "entities": [ + { + "id": "E1", + "type": "T", + "A1": { + "type": "Number", + "value": null + } + }, + { + "id": "E2", + "type": "T", + "A1": { + "type": "Number", + "value": null + } + } + ] +}' +orionCurl --url /v2/op/update --payload "$payload" +echo +echo + + +echo "04. GET /v2/entities to see A2 in entities" +echo "==========================================" +orionCurl --url /v2/entities +echo +echo + + +--REGEXPECT-- +01. Create E1/T/A1-A2 and E2/T/A1-A2 using POST /v2/op/update with append +========================================================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +02. GET /v2/entities to see A1 and A2 in entities +================================================= +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 239 + +[ + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 11 + }, + "A2": { + "metadata": {}, + "type": "Number", + "value": 12 + }, + "id": "E1", + "type": "T" + }, + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 21 + }, + "A2": { + "metadata": {}, + "type": "Number", + "value": 22 + }, + "id": "E2", + "type": "T" + } +] + + +03. Delete E1-A1=null and E2-A1=null using POST /v2/op/update with delete +========================================================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +04. GET /v2/entities to see A2 in entities +========================================== +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 143 + +[ + { + "A2": { + "metadata": {}, + "type": "Number", + "value": 12 + }, + "id": "E1", + "type": "T" + }, + { + "A2": { + "metadata": {}, + "type": "Number", + "value": 22 + }, + "id": "E2", + "type": "T" + } +] + + +--TEARDOWN-- +brokerStop CB +dbDrop CB From 331937eceace54f3162c55928366d4cbc6030405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 15 Nov 2023 11:07:28 +0100 Subject: [PATCH 32/44] FIX improve doc --- doc/manuals/orion-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manuals/orion-api.md b/doc/manuals/orion-api.md index 257f7787c6..d45e1305f6 100644 --- a/doc/manuals/orion-api.md +++ b/doc/manuals/orion-api.md @@ -4406,7 +4406,7 @@ regular non-batch operations can be done: * `appendStrict`: maps to `POST /v2/entities` (if the entity does not already exist) or `POST /v2/entities//attrs?options=append` (if the entity already exists). * `update`: maps to `PATCH /v2/entities//attrs`. -* `delete`: maps to `DELETE /v2/entities//attrs/` on every attribute included in the entity or +* `delete`: maps to `DELETE /v2/entities//attrs/` on every attribute included in the entity (in this case the actual value of the attribute is not relevant) or to `DELETE /v2/entities/` if no attribute were included in the entity. * `replace`: maps to `PUT /v2/entities//attrs`. From 982ec979cbfcb454cfbdb58c5a1b1f5a0f265f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 15 Nov 2023 11:17:32 +0100 Subject: [PATCH 33/44] ADD actionType delete test case when attribute doesn't exist --- ...batch_update_DELETE_non_existing_attr.test | 260 ++++++++++++++++++ .../batch_update_DELETE_with_nulls.test | 2 +- 2 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 test/functionalTest/cases/1715_batch_update/batch_update_DELETE_non_existing_attr.test diff --git a/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_non_existing_attr.test b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_non_existing_attr.test new file mode 100644 index 0000000000..76af634b17 --- /dev/null +++ b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_non_existing_attr.test @@ -0,0 +1,260 @@ +# Copyright 2023 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-- +V2 batch update DELETE in non existing attribute + +--SHELL-INIT-- +dbInit CB +brokerStart CB 0 + +--SHELL-- + +# +# 01. Create E1/T/A1-A2, E2/T/A1-A3 and E3/T/A1-A2 using POST /v2/op/update with append +# 02. GET /v2/entities to see E1/T/A1-A2, E2/T/A1-A3 and E3/T/A1-A2 +# 03. Delete E1-A2=null, E2-A2=null (not existing) and E3-A2=null using POST /v2/op/update with delete, get error +# 04. GET /v2/entities to see E1/T/A1, E2/T/A1-A3 and E3/T/A1 in entities +# + +echo "01. Create E1/T/A1-A2, E2/T/A1-A3 and E3/T/A1-A2 using POST /v2/op/update with append" +echo "=====================================================================================" +payload='{ + "actionType": "append", + "entities": [ + { + "id": "E1", + "type": "T", + "A1": { + "type": "Number", + "value": 11 + }, + "A2": { + "type": "Number", + "value": 12 + } + }, + { + "id": "E2", + "type": "T", + "A1": { + "type": "Number", + "value": 21 + }, + "A3": { + "type": "Number", + "value": 23 + } + }, + { + "id": "E3", + "type": "T", + "A1": { + "type": "Number", + "value": 31 + }, + "A2": { + "type": "Number", + "value": 32 + } + } + ] +}' +orionCurl --url /v2/op/update --payload "$payload" +echo +echo + + +echo "02. GET /v2/entities to see E1/T/A1-A2, E2/T/A1-A3 and E3/T/A1-A2" +echo "=================================================================" +orionCurl --url /v2/entities +echo +echo + + +echo "03. Delete E1-A2=null, E2-A2=null (not existing) and E3-A2=null using POST /v2/op/update with delete, get error" +echo "===============================================================================================================" +payload='{ + "actionType": "delete", + "entities": [ + { + "id": "E1", + "type": "T", + "A2": { + "type": "Number", + "value": null + } + }, + { + "id": "E2", + "type": "T", + "A2": { + "type": "Number", + "value": null + } + }, + { + "id": "E3", + "type": "T", + "A2": { + "type": "Number", + "value": null + } + } + ] +}' +orionCurl --url /v2/op/update --payload "$payload" +echo +echo + + +echo "04. GET /v2/entities to see E1/T/A1, E2/T/A1-A3 and E3/T/A1 in entities" +echo "=======================================================================" +orionCurl --url /v2/entities +echo +echo + + +--REGEXPECT-- +01. Create E1/T/A1-A2, E2/T/A1-A3 and E3/T/A1-A2 using POST /v2/op/update with append +===================================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +02. GET /v2/entities to see E1/T/A1-A2, E2/T/A1-A3 and E3/T/A1-A2 +================================================================= +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 358 + +[ + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 11 + }, + "A2": { + "metadata": {}, + "type": "Number", + "value": 12 + }, + "id": "E1", + "type": "T" + }, + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 21 + }, + "A3": { + "metadata": {}, + "type": "Number", + "value": 23 + }, + "id": "E2", + "type": "T" + }, + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 31 + }, + "A2": { + "metadata": {}, + "type": "Number", + "value": 32 + }, + "id": "E3", + "type": "T" + } +] + + +03. Delete E1-A2=null, E2-A2=null (not existing) and E3-A2=null using POST /v2/op/update with delete, get error +=============================================================================================================== +HTTP/1.1 404 Not Found +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 79 + +{ + "description": "The entity does not have such an attribute", + "error": "NotFound" +} + + +04. GET /v2/entities to see E1/T/A1, E2/T/A1-A3 and E3/T/A1 in entities +======================================================================= +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 262 + +[ + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 11 + }, + "id": "E1", + "type": "T" + }, + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 21 + }, + "A3": { + "metadata": {}, + "type": "Number", + "value": 23 + }, + "id": "E2", + "type": "T" + }, + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 31 + }, + "id": "E3", + "type": "T" + } +] + + +--TEARDOWN-- +brokerStop CB +dbDrop CB diff --git a/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_with_nulls.test b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_with_nulls.test index aaca277e53..7aeff02697 100644 --- a/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_with_nulls.test +++ b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_with_nulls.test @@ -1,4 +1,4 @@ -# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U +# Copyright 2023 Telefonica Investigacion y Desarrollo, S.A.U # # This file is part of Orion Context Broker. # From d4e6461f952084cf19c7b2f3d612e24fe736432d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 15 Nov 2023 11:26:48 +0100 Subject: [PATCH 34/44] FIX additional ftest case --- ...date_DELETE_non_existing_and_existing.test | 290 ++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 test/functionalTest/cases/1715_batch_update/batch_update_DELETE_non_existing_and_existing.test diff --git a/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_non_existing_and_existing.test b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_non_existing_and_existing.test new file mode 100644 index 0000000000..8cd808c80b --- /dev/null +++ b/test/functionalTest/cases/1715_batch_update/batch_update_DELETE_non_existing_and_existing.test @@ -0,0 +1,290 @@ +# Copyright 2023 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-- +V2 batch update DELETE in non existing and existing attribute + +--SHELL-INIT-- +dbInit CB +brokerStart CB 0 + +--SHELL-- + +# +# 01. Create E1/T/A1-A2-A3, E2/T/A1-A3 and E3/T/A1-A2-A3 using POST /v2/op/update with append +# 02. GET /v2/entities to see E1/T/A1-A2-A3, E2/T/A1-A3 and E3/T/A1-A2-A3 +# 03. Delete E1-A1/A2=null, E2-A1/A2=null (A2 not existing) and E3-A1/A2=null using POST /v2/op/update with delete, get error +# 04. GET /v2/entities to see E1/T/A3, E2/T/A1-A3 and E3/T/A3 in entities +# + +echo "01. Create E1/T/A1-A2-A3, E2/T/A1-A3 and E3/T/A1-A2-A3 using POST /v2/op/update with append" +echo "===========================================================================================" +payload='{ + "actionType": "append", + "entities": [ + { + "id": "E1", + "type": "T", + "A1": { + "type": "Number", + "value": 11 + }, + "A2": { + "type": "Number", + "value": 12 + }, + "A3": { + "type": "Number", + "value": 13 + } + }, + { + "id": "E2", + "type": "T", + "A1": { + "type": "Number", + "value": 21 + }, + "A3": { + "type": "Number", + "value": 23 + } + }, + { + "id": "E3", + "type": "T", + "A1": { + "type": "Number", + "value": 31 + }, + "A2": { + "type": "Number", + "value": 32 + }, + "A3": { + "type": "Number", + "value": 33 + } + } + ] +}' +orionCurl --url /v2/op/update --payload "$payload" +echo +echo + + +echo "02. GET /v2/entities to see E1/T/A1-A2-A3, E2/T/A1-A3 and E3/T/A1-A2-A3" +echo "=======================================================================" +orionCurl --url /v2/entities +echo +echo + + +echo "03. Delete E1-A1/A2=null, E2-A1/A2=null (A2 not existing) and E3-A1/A2=null using POST /v2/op/update with delete, get error" +echo "===========================================================================================================================" +payload='{ + "actionType": "delete", + "entities": [ + { + "id": "E1", + "type": "T", + "A1": { + "type": "Number", + "value": null + }, + "A2": { + "type": "Number", + "value": null + } + }, + { + "id": "E2", + "type": "T", + "A1": { + "type": "Number", + "value": null + }, + "A2": { + "type": "Number", + "value": null + } + }, + { + "id": "E3", + "type": "T", + "A1": { + "type": "Number", + "value": null + }, + "A2": { + "type": "Number", + "value": null + } + } + ] +}' +orionCurl --url /v2/op/update --payload "$payload" +echo +echo + + +echo "04. GET /v2/entities to see E1/T/A3, E2/T/A1-A3 and E3/T/A3 in entities" +echo "=======================================================================" +orionCurl --url /v2/entities +echo +echo + + +--REGEXPECT-- +01. Create E1/T/A1-A2-A3, E2/T/A1-A3 and E3/T/A1-A2-A3 using POST /v2/op/update with append +=========================================================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +02. GET /v2/entities to see E1/T/A1-A2-A3, E2/T/A1-A3 and E3/T/A1-A2-A3 +======================================================================= +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 454 + +[ + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 11 + }, + "A2": { + "metadata": {}, + "type": "Number", + "value": 12 + }, + "A3": { + "metadata": {}, + "type": "Number", + "value": 13 + }, + "id": "E1", + "type": "T" + }, + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 21 + }, + "A3": { + "metadata": {}, + "type": "Number", + "value": 23 + }, + "id": "E2", + "type": "T" + }, + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 31 + }, + "A2": { + "metadata": {}, + "type": "Number", + "value": 32 + }, + "A3": { + "metadata": {}, + "type": "Number", + "value": 33 + }, + "id": "E3", + "type": "T" + } +] + + +03. Delete E1-A1/A2=null, E2-A1/A2=null (A2 not existing) and E3-A1/A2=null using POST /v2/op/update with delete, get error +=========================================================================================================================== +HTTP/1.1 404 Not Found +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 79 + +{ + "description": "The entity does not have such an attribute", + "error": "NotFound" +} + + +04. GET /v2/entities to see E1/T/A3, E2/T/A1-A3 and E3/T/A3 in entities +======================================================================= +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 262 + +[ + { + "A3": { + "metadata": {}, + "type": "Number", + "value": 13 + }, + "id": "E1", + "type": "T" + }, + { + "A1": { + "metadata": {}, + "type": "Number", + "value": 21 + }, + "A3": { + "metadata": {}, + "type": "Number", + "value": 23 + }, + "id": "E2", + "type": "T" + }, + { + "A3": { + "metadata": {}, + "type": "Number", + "value": 33 + }, + "id": "E3", + "type": "T" + } +] + + +--TEARDOWN-- +brokerStop CB +dbDrop CB From a7a86bd09a2ae597bf6ff5009a30d592a4ac1e49 Mon Sep 17 00:00:00 2001 From: Kazuhito Suda Date: Thu, 16 Nov 2023 12:51:13 +0900 Subject: [PATCH 35/44] (JP) ADD documentation about actionType delete (#4445) --- doc/manuals.jp/orion-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manuals.jp/orion-api.md b/doc/manuals.jp/orion-api.md index 347963a9cc..bc4a4f0c7d 100644 --- a/doc/manuals.jp/orion-api.md +++ b/doc/manuals.jp/orion-api.md @@ -4511,7 +4511,7 @@ _**リクエスト・ペイロード**_ - `appendStrict`: `POST /v2/entities` (エンティティがまだ存在しない場合) または `POST /v2/entities//attrs?options=append` (エンティティが既に存在する場合) にマップします - `update`: `PATCH /v2/entities//attrs` にマップされます -- `delete`: エンティティに含まれているすべての属性に対して、`DELETE /v2/entities//attrs/` +- `delete`: エンティティに含まれているすべての属性に対して (この場合、属性の実際の値は関係ありません)、`DELETE /v2/entities//attrs/` にマッピングし、エンティティに属性が含まれていない場合は、`DELETE /v2/entities/` にマッピングします - `replace`: `PUT /v2/entities//attrs` にマッピングします From 81fe405b69b0d4c31b6eaaa3e08150029b47bbb6 Mon Sep 17 00:00:00 2001 From: Pradyumn Agrawal Date: Tue, 12 Dec 2023 14:46:48 +0530 Subject: [PATCH 36/44] Cookbook Modified --- doc/manuals/devel/cookbook.md | 53 +---------------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/doc/manuals/devel/cookbook.md b/doc/manuals/devel/cookbook.md index 5d75a4ddff..7db8caa76a 100644 --- a/doc/manuals/devel/cookbook.md +++ b/doc/manuals/devel/cookbook.md @@ -118,62 +118,11 @@ typedef struct RestService { RequestType request; // The type of the request int components; // Number of components in the URL path - std::string compV[10]; // Vector of URL path components. E.g. { "v2", "entities" } - std::string payloadWord; // No longer used, should be removed ... ? + std::string compV[10]; // Vector of URL path components. E.g. { "v2", "entities" } RestTreat treat; // service function pointer } RestService; ``` -So, to add a REST service eg. `PUT /v2/entities/{EntitId}/attrs/{AttributeName}/metadata/{MetadataName}`, the new item if the RestService vector `putServiceV` would look like this: - -``` -{ Metadata, 7, { "v2", "entities", "*", "attrs", "*", "metadata", "*" }, "", putMetadata } -``` - -NOTE: - -* Item 1: `Metadata` would have to be added as an enum constant in the `enum RequestType` in `src/lib/ngsi/Request.h` -* Item 3: `"*"`. An asterisc in the component vector `RestService::compV` matches ANY string, and whenever a path including entity id, attribute name, etc is defined, `"*"` must be used. -* Item 5: `putMetadata()` is the service routine for `PUT /v2/entities/*/attrs/*/metadata/*` and the function must be implemented. The directory of the library for NGSIv2 service routines is `src/lib/serviceRoutinesV2` (see [library description](sourceCode.md#srclibserviceroutinesv2)). - -Note also that in `orionRestServices.cpp`, these `RestService` vector lines are really long, and our style guide is against too long lines. However, making the lines shorter by using definitions just make the code more difficult to understand and we don't want that. - -> Side-note: The [style guide](contribution_guidelines.md#s9-line-length) says a source code line **shouldn't** be longer than 120 chars. - -The service routine `putMetadata()` should reside in `src/lib/serviceRoutinesV2/putMetadata.h/cpp` and its signature must be as follows: -``` -std::string putMetadata -( - ConnectionInfo* ciP, - int components, - std::vector& compV, - ParseData* parseDataP -) -``` - -The `entity id`, `attribute name`, and `metadata name` (all part of the URL path), must be "extracted" from the component vector `compV`: - -``` - std::string entityId = compV[2]; - std::string attributeName = compV[4]; - std::string metadataName = compV[6]; -``` - -All service routines that modify/create entities/attributes/metadata rely on the NGSIv1 service routine `postUpdateContext()`, and `putMetadata()` is no exception. So, what needs to be done in `putMetadata()` is to build a `UpdateContextRequest` object using the parameters of `putMetadata()` and call `postUpdateContext()`. Something like this: - -``` - parseDataP->upcr.res.fill(entityId, attributeName, metadataName, ActionTypeAppend); - postUpdateContext(ciP, components, compV, parseDataP, NGSIV2_FLAVOUR_ONAPPEND); -``` - -`UpdateContextRequest` has a bunch of `fill()` methods (seven `fill()` methods as of March 2017) and if there is no fill-method suited for your demands in `putMetadata()`, then another fill-method must be implemented for `UpdateContextRequest`. - -It is easy enough, just copy from an older, similar, fill-method. - -Now just add `putMetadata.cpp` to the CMake file `src/lib/serviceRoutinesV2/CMakeLists.txt` and compile the broker. To test that `putMetadata()` works correctly, a new functional test case should be implemented. [The following recipe](#adding-a-functional-test-case) explains how to do that. - -To capture "POST/PATCH/XXX /v2/entities/*/attrs/*/metadata/*" and respond with a `405 Method Not Allowed`, please have a look at [the recipe about bad method](#catching-a-405-method-not-allowed). - [Top](#top) ## Adding a Functional Test Case From 3c333aff13b290da954df656ba7982fc5ed460cc Mon Sep 17 00:00:00 2001 From: Pradyumn Agrawal Date: Thu, 14 Dec 2023 11:19:38 +0530 Subject: [PATCH 37/44] Cookbook: The section Adding a REST service is updated --- doc/manuals/devel/cookbook.md | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/doc/manuals/devel/cookbook.md b/doc/manuals/devel/cookbook.md index 7db8caa76a..3f5e8e7198 100644 --- a/doc/manuals/devel/cookbook.md +++ b/doc/manuals/devel/cookbook.md @@ -123,6 +123,57 @@ typedef struct RestService } RestService; ``` + +So, to add a REST service eg. `PUT /v2/entities/{EntitId}/attrs/{AttributeName}/metadata/{MetadataName}`, the new item if the RestService vector `putServiceV` would look like this: + +``` +{ Metadata, 7, { "v2", "entities", "*", "attrs", "*", "metadata", "*" }, "", putMetadata } +``` + +NOTE: + +* Item 1: `Metadata` would have to be added as an enum constant in the `enum RequestType` in `src/lib/ngsi/Request.h` +* Item 3: `"*"`. An asterisc in the component vector `RestService::compV` matches ANY string, and whenever a path including entity id, attribute name, etc is defined, `"*"` must be used. +* Item 5: `putMetadata()` is the service routine for `PUT /v2/entities/*/attrs/*/metadata/*` and the function must be implemented. The directory of the library for NGSIv2 service routines is `src/lib/serviceRoutinesV2` (see [library description](sourceCode.md#srclibserviceroutinesv2)). + +Note also that in `orionRestServices.cpp`, these `RestService` vector lines are really long, and our style guide is against too long lines. However, making the lines shorter by using definitions just make the code more difficult to understand and we don't want that. + +> Side-note: The [style guide](contribution_guidelines.md#s9-line-length) says a source code line **shouldn't** be longer than 120 chars. + +The service routine `putMetadata()` should reside in `src/lib/serviceRoutinesV2/putMetadata.h/cpp` and its signature must be as follows: +``` +std::string putMetadata +( + ConnectionInfo* ciP, + int components, + std::vector& compV, + ParseData* parseDataP +) +``` + +The `entity id`, `attribute name`, and `metadata name` (all part of the URL path), must be "extracted" from the component vector `compV`: + +``` + std::string entityId = compV[2]; + std::string attributeName = compV[4]; + std::string metadataName = compV[6]; +``` + +All service routines that modify/create entities/attributes/metadata rely on the NGSIv1 service routine `postUpdateContext()`, and `putMetadata()` is no exception. So, what needs to be done in `putMetadata()` is to build a `UpdateContextRequest` object using the parameters of `putMetadata()` and call `postUpdateContext()`. Something like this: + +``` + parseDataP->upcr.res.fill(entityId, attributeName, metadataName, ActionTypeAppend); + postUpdateContext(ciP, components, compV, parseDataP, NGSIV2_FLAVOUR_ONAPPEND); +``` + +`UpdateContextRequest` has a bunch of `fill()` methods (seven `fill()` methods as of March 2017) and if there is no fill-method suited for your demands in `putMetadata()`, then another fill-method must be implemented for `UpdateContextRequest`. + +It is easy enough, just copy from an older, similar, fill-method. + +Now just add `putMetadata.cpp` to the CMake file `src/lib/serviceRoutinesV2/CMakeLists.txt` and compile the broker. To test that `putMetadata()` works correctly, a new functional test case should be implemented. [The following recipe](#adding-a-functional-test-case) explains how to do that. + +To capture "POST/PATCH/XXX /v2/entities/*/attrs/*/metadata/*" and respond with a `405 Method Not Allowed`, please have a look at [the recipe about bad method](#catching-a-405-method-not-allowed). + [Top](#top) ## Adding a Functional Test Case From 970c96c5cd8fa9eefbae04024aa44205de5d94fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 14 Dec 2023 08:36:32 +0100 Subject: [PATCH 38/44] Update doc/manuals/devel/cookbook.md --- doc/manuals/devel/cookbook.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/manuals/devel/cookbook.md b/doc/manuals/devel/cookbook.md index 3f5e8e7198..6af4ee7b8f 100644 --- a/doc/manuals/devel/cookbook.md +++ b/doc/manuals/devel/cookbook.md @@ -123,7 +123,6 @@ typedef struct RestService } RestService; ``` - So, to add a REST service eg. `PUT /v2/entities/{EntitId}/attrs/{AttributeName}/metadata/{MetadataName}`, the new item if the RestService vector `putServiceV` would look like this: ``` From 9482f41b005a5f242301ff1f28252093b389fd52 Mon Sep 17 00:00:00 2001 From: Kazuhito Suda Date: Thu, 14 Dec 2023 19:32:43 +0900 Subject: [PATCH 39/44] (JP) Cookbook: The section "Adding a REST service" is updated --- doc/manuals.jp/devel/cookbook.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/manuals.jp/devel/cookbook.md b/doc/manuals.jp/devel/cookbook.md index 5da690df72..f25aa69f26 100644 --- a/doc/manuals.jp/devel/cookbook.md +++ b/doc/manuals.jp/devel/cookbook.md @@ -122,8 +122,7 @@ typedef struct RestService { RequestType request; // The type of the request int components; // Number of components in the URL path - std::string compV[10]; // Vector of URL path components. E.g. { "v2", "entities" } - std::string payloadWord; // No longer used, should be removed ... ? + std::string compV[10]; // Vector of URL path components. E.g. { "v2", "entities" } RestTreat treat; // service function pointer } RestService; ``` From 16fa33b1f4590d26603965bd8d0fac804a0ce112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 19 Dec 2023 09:39:04 +0100 Subject: [PATCH 40/44] FIX mongo -> mongosh --- scripts/dbList.sh | 4 +- scripts/dbReset.sh | 4 +- scripts/managedb/do_in_all_orion_dbs.sh | 2 +- .../service_ignore_without_multiservice.test | 8 +- ...iption_before_and_after_cache_refresh.test | 18 +- ...fter_cache_refresh_status_in_db_older.test | 18 +- .../refresh_cache_wins_notif_disabled.test | 6 +- ...if_disabled_with_update_in_the_middle.test | 8 +- .../refresh_cache_wins_notif_fail.test | 6 +- ..._notif_fail_with_update_in_the_middle.test | 8 +- .../refresh_cache_wins_notif_success.test | 6 +- ...tif_success_with_update_in_the_middle.test | 8 +- .../refresh_db_wins_notif_disabled.test | 6 +- ...if_disabled_with_update_in_the_middle.test | 8 +- .../refresh_db_wins_notif_fail.test | 6 +- ..._notif_fail_with_update_in_the_middle.test | 8 +- .../refresh_db_wins_notif_success.test | 6 +- ...tif_success_with_update_in_the_middle.test | 8 +- .../metadata_with_dots_v2.test | 27 +- ...alues_option_with_empty_type_entities.test | 4 +- ...lues_option_with_null_and_empty_types.test | 4 +- .../put_replacing_dot_in_attrnames.test | 9 +- .../bad_input_on_notification_error.test | 4 +- ...tification_error_with_relogged_alarms.test | 4 +- .../inconsistent_mdnames_after_update.test | 8 +- .../v1_append_not_updates_geo_point.test | 8 +- .../fwd_update_ok_but_not_found_response.test | 10 +- .../create_location_attr_V2.test | 4 +- .../blanked_out_attr.test | 4 +- .../query_for_arrays.test | 16 +- ...geobox_create_does_not_break_location.test | 114 ++++---- ...geobox_update_does_not_break_location.test | 248 +++++++++--------- ...eojson_create_does_not_break_location.test | 76 +++--- ...eojson_update_does_not_break_location.test | 172 ++++++------ ...eoline_create_does_not_break_location.test | 88 ++++--- ...eoline_update_does_not_break_location.test | 196 +++++++------- ...opoint_create_does_not_break_location.test | 72 ++--- ...opoint_update_does_not_break_location.test | 164 ++++++------ ...olygon_create_does_not_break_location.test | 110 ++++---- ...olygon_update_does_not_break_location.test | 240 ++++++++--------- .../incorrect_location_processing.test | 6 +- .../mqtt_custom_notifications_auth.test | 12 +- .../mqtt_notifications_auth.test | 12 +- ...inactive_not_working_with_cache_in_ha.test | 2 +- test/functionalTest/harnessFunctions.sh | 52 +--- .../cache_refresh/drop_database_mongo.sh | 4 +- test/loadTest/perf/csub_clean.sh | 1 + test/valgrind/valgrindTestSuite.sh | 2 +- 48 files changed, 916 insertions(+), 895 deletions(-) diff --git a/scripts/dbList.sh b/scripts/dbList.sh index 7156d90279..de3931276c 100755 --- a/scripts/dbList.sh +++ b/scripts/dbList.sh @@ -24,6 +24,4 @@ then exit 1 fi -mongo --quiet << EOF - show dbs -EOF +mongosh --eval 'show dbs' --quiet diff --git a/scripts/dbReset.sh b/scripts/dbReset.sh index 05ca42318e..1e3f15cf4f 100755 --- a/scripts/dbReset.sh +++ b/scripts/dbReset.sh @@ -32,11 +32,11 @@ then db=testharness fi - echo 'db.dropDatabase()' | mongo $db --quiet + mongosh $db --eval 'db.dropDatabase()' --quiet else while [ "$#" != 0 ] do - echo 'db.dropDatabase()' | mongo $1 --quiet + mongosh $1 --eval 'db.dropDatabase()' --quiet shift done fi diff --git a/scripts/managedb/do_in_all_orion_dbs.sh b/scripts/managedb/do_in_all_orion_dbs.sh index 0d084b47b9..79f4bbd274 100755 --- a/scripts/managedb/do_in_all_orion_dbs.sh +++ b/scripts/managedb/do_in_all_orion_dbs.sh @@ -22,7 +22,7 @@ MONGO_URI="mongodb://127.0.0.1:27017" #MONGO_URI="mongodb://mongodb1:27017,mongodb2:27017,mongodb3:27017/?replicaSet=cb_rs0" -for db in $(echo 'show dbs' | mongo $MONGO_URI | grep '^orion' | awk -F ' ' '{print $1}') +for db in $(mongosh $MONGO_URI --eval 'show dbs' --quiet | grep '^orion' | awk -F ' ' '{print $1}') do echo "Processing $db db" # Edit next line to set the script you want diff --git a/test/functionalTest/cases/0725_multiservice_ignore/service_ignore_without_multiservice.test b/test/functionalTest/cases/0725_multiservice_ignore/service_ignore_without_multiservice.test index 20b21596de..685b3bb91a 100644 --- a/test/functionalTest/cases/0725_multiservice_ignore/service_ignore_without_multiservice.test +++ b/test/functionalTest/cases/0725_multiservice_ignore/service_ignore_without_multiservice.test @@ -59,14 +59,14 @@ echo echo "2. Check that the number of orion databases is just 1" echo "=====================================================" # In this case mongoCmd helper is not used, due to we don't have -# a particular database for mongo command and the output could be +# a particular database for mongosh command and the output could be # multiline in a general case -echo "show dbs" | mongo | grep ${CB_DB_NAME} | wc -l -echo "show dbs" | mongo | grep ${CB_DB_NAME}-foo | wc -l +mongosh --eval 'show dbs' | grep ${CB_DB_NAME} | wc -l +mongosh --eval 'show dbs' | grep ${CB_DB_NAME}-foo | wc -l # Next line was added in PR https://github.com/telefonicaid/fiware-orion/pull/1184/files#r37738638 # in order to help us to detect where the ftest-ftest-ftest-... problem is. It could happen that # after fixing #1186 this is no longer needed, but let's keep it for a while as a "quarentine" measure... -echo "show dbs" | mongo | grep ${CB_DB_NAME} | awk '{ print $1 }' +mongosh --eval 'show dbs' | grep ${CB_DB_NAME} | awk '{ print $1 }' --REGEXPECT-- 1. Create an entity using foo as tenant diff --git a/test/functionalTest/cases/1048_subscription_cache/get_subscription_before_and_after_cache_refresh.test b/test/functionalTest/cases/1048_subscription_cache/get_subscription_before_and_after_cache_refresh.test index 0f616583fe..4ed5c6ef33 100644 --- a/test/functionalTest/cases/1048_subscription_cache/get_subscription_before_and_after_cache_refresh.test +++ b/test/functionalTest/cases/1048_subscription_cache/get_subscription_before_and_after_cache_refresh.test @@ -26,7 +26,7 @@ Get subscription before and after cache refresh --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:1028/accumulate", @@ -134,15 +134,15 @@ echo echo "02. Set dynamic fields in DB to set B" echo "=====================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.update({_id: ObjectId("61960a51596aa2623032357d")}, { +mongoCmd ${CB_DB_NAME} 'db.csubs.updateOne({_id: ObjectId("61960a51596aa2623032357d")}, { $set: { - lastNotification: NumberLong(1577876400), - lastSuccess: NumberLong(1577876400), - lastFailure: NumberLong(1577872800), - lastSuccessCode: NumberLong(204), + lastNotification: NumberLong("1577876400"), + lastSuccess: NumberLong("1577876400"), + lastFailure: NumberLong("1577872800"), + lastSuccessCode: NumberLong("204"), lastFailureReason: "Timeout", - count: NumberLong(25), - failsCounter: NumberLong(8), + count: NumberLong("25"), + failsCounter: NumberLong("8"), status: "inactive", statusLastChange: 1578733200 } @@ -217,7 +217,7 @@ Content-Length: 551 02. Set dynamic fields in DB to set B ===================================== -WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) +{"acknowledged":true,"insertedId":null,"matchedCount":1,"modifiedCount":1,"upsertedCount":0} 03. GET /v2/subscriptions and see dynamic fields set B although cache has not been synched yet diff --git a/test/functionalTest/cases/1048_subscription_cache/get_subscription_before_and_after_cache_refresh_status_in_db_older.test b/test/functionalTest/cases/1048_subscription_cache/get_subscription_before_and_after_cache_refresh_status_in_db_older.test index f377701aee..157a789900 100644 --- a/test/functionalTest/cases/1048_subscription_cache/get_subscription_before_and_after_cache_refresh_status_in_db_older.test +++ b/test/functionalTest/cases/1048_subscription_cache/get_subscription_before_and_after_cache_refresh_status_in_db_older.test @@ -26,7 +26,7 @@ Get subscription before and after cache refresh with status older in DB during r --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:1028/accumulate", @@ -99,15 +99,15 @@ echo echo "02. Set dynamic fields in DB to set B" echo "=====================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.update({_id: ObjectId("61960a51596aa2623032357d")}, { +mongoCmd ${CB_DB_NAME} 'db.csubs.updateOne({_id: ObjectId("61960a51596aa2623032357d")}, { $set: { - lastNotification: NumberLong(1577876400), - lastSuccess: NumberLong(1577876400), - lastFailure: NumberLong(1577872800), - lastSuccessCode: NumberLong(204), + lastNotification: NumberLong("1577876400"), + lastSuccess: NumberLong("1577876400"), + lastFailure: NumberLong("1577872800"), + lastSuccessCode: NumberLong("204"), lastFailureReason: "Timeout", - count: NumberLong(25), - failsCounter: NumberLong(8), + count: NumberLong("25"), + failsCounter: NumberLong("8"), status: "inactive", statusLastChange: 1577869200 } @@ -182,7 +182,7 @@ Content-Length: 551 02. Set dynamic fields in DB to set B ===================================== -WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) +{"acknowledged":true,"insertedId":null,"matchedCount":1,"modifiedCount":1,"upsertedCount":0} 03. GET /v2/subscriptions and see dynamic fields set B although cache has not been synched yet diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_disabled.test b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_disabled.test index b9f43ee4f1..1202288ba8 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_disabled.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_disabled.test @@ -26,7 +26,7 @@ Cache refresh keeps newer information from cache in disabled notification scenar --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -131,7 +131,7 @@ echo echo "05. Get doc in DB before cache refresh and see status active changed in the past and without count and without failsCounter" echo "===========================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -146,7 +146,7 @@ echo echo "07. Get doc in DB after cache refresh and see status inactive changed in the present and count 2, failsCounter 2" echo "================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_disabled_with_update_in_the_middle.test b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_disabled_with_update_in_the_middle.test index 7b037d9373..384ede8153 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_disabled_with_update_in_the_middle.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_disabled_with_update_in_the_middle.test @@ -26,7 +26,7 @@ Cache refresh keeps newer information from cache in disabled notification scenar --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -133,7 +133,7 @@ echo echo "05. Get doc in DB before cache refresh and see status active changed in the past and without count and without failsCounter" echo "===========================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -150,7 +150,7 @@ echo echo "07. Get doc in DB before cache refresh and see status active changed in the past and without count and without failsCounter + description" echo "=========================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -165,7 +165,7 @@ echo echo "09. Get doc in DB after cache refresh and see status inactive changed in the present and count 2, failsCounter 2 + description" echo "==============================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_fail.test b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_fail.test index f0a00408b0..7272205b19 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_fail.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_fail.test @@ -26,7 +26,7 @@ Cache refresh keeps newer information from cache in failed notification scenario --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -124,7 +124,7 @@ echo echo "04. Get doc in DB before cache refresh and see lastNotification/Failure in a the past and reason 'some reason' but no count and no failsCounter" echo "===============================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -139,7 +139,7 @@ echo echo "06. Get doc in DB after cache refresh and see lastNotification/Failure in the present and reason 'could not connect' and count 1 and failsCounter 1" echo "===================================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_fail_with_update_in_the_middle.test b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_fail_with_update_in_the_middle.test index d13bc3f79d..f602ba30b6 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_fail_with_update_in_the_middle.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_fail_with_update_in_the_middle.test @@ -26,7 +26,7 @@ Cache refresh keeps newer information from cache in failed notification scenario --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -126,7 +126,7 @@ echo echo "04. Get doc in DB before cache refresh and see lastNotification/Failure in a the past and reason 'some reason' but no count and no failsCounter" echo "===============================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -143,7 +143,7 @@ echo echo "06. Get doc in DB before cache refresh and see lastNotification/Failure in a the past and reason 'some reason' but no count and no failsCounter + description" echo "=============================================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -158,7 +158,7 @@ echo echo "08. Get doc in DB after cache refresh and see lastNotification/Failure in the present and reason 'could not connect' and count 1 and failsCounter 1 + description" echo "=================================================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_success.test b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_success.test index e552f2aa5d..b39bae8cba 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_success.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_success.test @@ -26,7 +26,7 @@ Cache refresh keeps newer information from cache in successfull notification sce --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -126,7 +126,7 @@ echo echo "04. Get doc in DB before cache refresh and see lastNotification/Success in the past and status code 211 but no count" echo "====================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -141,7 +141,7 @@ echo echo "06. Get doc in DB after cache refresh and see lastNotification/Success in the present and status code 200 and count 1" echo "=====================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_success_with_update_in_the_middle.test b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_success_with_update_in_the_middle.test index c4353bc50a..850b9d6765 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_success_with_update_in_the_middle.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_cache_wins_notif_success_with_update_in_the_middle.test @@ -26,7 +26,7 @@ Cache refresh keeps newer information from cache in successfull notification sce --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -128,7 +128,7 @@ echo echo "04. Get doc in DB before cache refresh and see lastNotification/Success in the past and status code 211 but no count" echo "====================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -145,7 +145,7 @@ echo echo "06. Get doc in DB before cache refresh and see lastNotification/Success in the past and status code 211 but no count + description" echo "==================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -160,7 +160,7 @@ echo echo "08. Get doc in DB after cache refresh and see lastNotification/Success in the present and status code 200 and count 1 + description" echo "===================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_disabled.test b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_disabled.test index b4986ff145..d3ceaa5982 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_disabled.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_disabled.test @@ -26,7 +26,7 @@ Cache refresh takes newer information from DB in disabled notification scenario --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -128,7 +128,7 @@ echo echo "05. Get doc in DB before cache refresh and see status active changed in a far future and without count and without failsCounter" echo "===============================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -143,7 +143,7 @@ echo echo "07. Get doc in DB after cache refresh and see status active changed in a far future and count 2, failsCounter 2" echo "===============================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_disabled_with_update_in_the_middle.test b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_disabled_with_update_in_the_middle.test index 86c2f0cdc9..d93748cb57 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_disabled_with_update_in_the_middle.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_disabled_with_update_in_the_middle.test @@ -26,7 +26,7 @@ Cache refresh takes newer information from DB in disabled notification scenario --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -130,7 +130,7 @@ echo echo "05. Get doc in DB before cache refresh and see status active changed in a far future and without count and without failsCounter" echo "===============================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -147,7 +147,7 @@ echo echo "07. Get doc in DB before cache refresh and see status active changed in a far future and without count and without failsCounter + description" echo "=============================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -162,7 +162,7 @@ echo echo "09. Get doc in DB after cache refresh and see status active changed in a far future and count 2, failsCounter 2 + description" echo "=============================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_fail.test b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_fail.test index 4dfe82b91c..032e2ed5d4 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_fail.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_fail.test @@ -26,7 +26,7 @@ Cache refresh takes newer information from DB in failed notification scenario --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -121,7 +121,7 @@ echo echo "04. Get doc in DB before cache refresh and see lastNotification/Failure in a far future and reason 'some reason' but no count and no failsCounter" echo "=================================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -136,7 +136,7 @@ echo echo "06. Get doc in DB after cache refresh and see lastNotification/Failure in a far future and reason 'some reason' and count 1 and failsCounter 1" echo "==============================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_fail_with_update_in_the_middle.test b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_fail_with_update_in_the_middle.test index 9792d862f6..1a7e1a5093 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_fail_with_update_in_the_middle.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_fail_with_update_in_the_middle.test @@ -26,7 +26,7 @@ Cache refresh takes newer information from DB in failed notification scenario wi --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -123,7 +123,7 @@ echo echo "04. Get doc in DB before cache refresh and see lastNotification/Failure in a far future and reason 'some reason' but no count and no failsCounter" echo "=================================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -140,7 +140,7 @@ echo echo "06. Get doc in DB before cache refresh and see lastNotification/Failure in a far future and reason 'some reason' but no count and no failsCounter + description" echo "===============================================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -155,7 +155,7 @@ echo echo "08. Get doc in DB after cache refresh and see lastNotification/Failure in a far future and reason 'some reason' and count 1 and failsCounter 1 + description" echo "============================================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_success.test b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_success.test index 64d3648b08..51dff14bbc 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_success.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_success.test @@ -26,7 +26,7 @@ Cache refresh takes newer information from DB in successfull notification scenar --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -123,7 +123,7 @@ echo echo "04. Get doc in DB before cache refresh and see lastNotification/Success in a far future and status code 211 but no count" echo "========================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -138,7 +138,7 @@ echo echo "06. Get doc in DB after cache refresh and see lastNotification/Success in a far future and status code 211 and count 1" echo "======================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_success_with_update_in_the_middle.test b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_success_with_update_in_the_middle.test index eb2d3961d5..c20ce9479a 100644 --- a/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_success_with_update_in_the_middle.test +++ b/test/functionalTest/cases/1048_subscription_cache/refresh_db_wins_notif_success_with_update_in_the_middle.test @@ -26,7 +26,7 @@ Cache refresh takes newer information from DB in successfull notification scenar --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("61960a51596aa2623032357d"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:9997/notify", @@ -125,7 +125,7 @@ echo echo "04. Get doc in DB before cache refresh and see lastNotification/Success in a far future and status code 211 but no count" echo "========================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -142,7 +142,7 @@ echo echo "06. Get doc in DB before cache refresh and see lastNotification/Success in a far future and status code 211 but no count + description" echo "======================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -157,7 +157,7 @@ echo echo "08. Get doc in DB after cache refresh and see lastNotification/Success in a far future and status code 211 and count 1 + description" echo "====================================================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.find({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | sed 's/NumberLong(\([[:digit:]]\+\))/\1/g' | sed 's/NumberLong("\([[:digit:]]\+\)")/\1/g' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.csubs.findOne({ _id: ObjectId("61960a51596aa2623032357d")}, {_id:0, expiration: 0})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/1112_metadata_as_keymap/metadata_with_dots_v2.test b/test/functionalTest/cases/1112_metadata_as_keymap/metadata_with_dots_v2.test index a2c3e5a2d1..ddb7f001a0 100644 --- a/test/functionalTest/cases/1112_metadata_as_keymap/metadata_with_dots_v2.test +++ b/test/functionalTest/cases/1112_metadata_as_keymap/metadata_with_dots_v2.test @@ -68,7 +68,7 @@ echo echo "03. Check the '=' in DB" echo "=======================" -mongoCmd ${CB_DB_NAME} 'db.entities.find({ "_id" : { "id" : "E", "type": "T", "servicePath" : "/" } }, {_id:0, attrs: 1})' +mongoCmd ${CB_DB_NAME} 'db.entities.findOne({ "_id" : { "id" : "E", "type": "T", "servicePath" : "/" } }, {_id:0, attrs: 1})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -114,7 +114,30 @@ Content-Length: 139 03. Check the '=' in DB ======================= -{ "attrs" : { "A" : { "value" : "foo", "type" : "T", "creDate" : REGEX(.*), "md" : { "m=x" : { "type" : "string", "value" : "black" }, "m=y" : { "type" : "double", "value" : 5 } }, "mdNames" : [ "m.x", "m.y" ] } } } +{ + "attrs": { + "A": { + "creDate": REGEX(.*), + "md": { + "m=x": { + "type": "string", + "value": "black" + }, + "m=y": { + "type": "double", + "value": 5 + } + }, + "mdNames": [ + "m.x", + "m.y" + ], + "modDate": REGEX(.*), + "type": "T", + "value": "foo" + } + } +} --TEARDOWN-- diff --git a/test/functionalTest/cases/1170_get_types_values_option/get_types_values_option_with_empty_type_entities.test b/test/functionalTest/cases/1170_get_types_values_option/get_types_values_option_with_empty_type_entities.test index 4cd0acf465..dfd643fc66 100644 --- a/test/functionalTest/cases/1170_get_types_values_option/get_types_values_option_with_empty_type_entities.test +++ b/test/functionalTest/cases/1170_get_types_values_option/get_types_values_option_with_empty_type_entities.test @@ -72,7 +72,7 @@ echo "=====================================" # It seems that the ability to generate _id.type = "" was lost in some old Orion version # (although some DB generated with old versions could persist nowadays). Thus, we need to # createthis entity with a hack at MongoDB level -mongoCmd ${CB_DB_NAME} 'db.entities.insert({ +mongoCmd ${CB_DB_NAME} 'db.entities.insertOne({ "_id": { "id": "E2", "type": "", @@ -171,7 +171,7 @@ Content-Length: 6 04. Create E2/""/A1+A3 (using NGSIv1) ===================================== -WriteResult({ "nInserted" : 1 }) +{"acknowledged":true,"insertedId":{"id":"E2","type":"","servicePath":"/"}} 05. Create E3/T3/A2+A4 diff --git a/test/functionalTest/cases/1170_get_types_values_option/get_types_values_option_with_null_and_empty_types.test b/test/functionalTest/cases/1170_get_types_values_option/get_types_values_option_with_null_and_empty_types.test index fcee2f5939..8f9dd731a4 100644 --- a/test/functionalTest/cases/1170_get_types_values_option/get_types_values_option_with_null_and_empty_types.test +++ b/test/functionalTest/cases/1170_get_types_values_option/get_types_values_option_with_null_and_empty_types.test @@ -52,7 +52,7 @@ echo "======================" # It seems that the ability to generate _id.type = "" was lost in some old Orion version # (although some DB generated with old versions could persist nowadays). Thus, we need to # createthis entity with a hack at MongoDB level -mongoCmd ${CB_DB_NAME} 'db.entities.insert({ +mongoCmd ${CB_DB_NAME} 'db.entities.insertOne({ "_id": { "id": "E1", "type": "", @@ -163,7 +163,7 @@ Content-Length: 2 02. Create E1/""/A1+A2 ====================== -WriteResult({ "nInserted" : 1 }) +{"acknowledged":true,"insertedId":{"id":"E1","type":"","servicePath":"/"}} 03. GET /v2/types?options=values and get a non-empty list diff --git a/test/functionalTest/cases/1323_put_replacing_dot_in_attrnames/put_replacing_dot_in_attrnames.test b/test/functionalTest/cases/1323_put_replacing_dot_in_attrnames/put_replacing_dot_in_attrnames.test index 298850f82d..d34a341357 100644 --- a/test/functionalTest/cases/1323_put_replacing_dot_in_attrnames/put_replacing_dot_in_attrnames.test +++ b/test/functionalTest/cases/1323_put_replacing_dot_in_attrnames/put_replacing_dot_in_attrnames.test @@ -117,7 +117,7 @@ echo echo "07. Check attributes in DB" echo "==========================" -mongoCmd ${CB_DB_NAME} 'db.entities.find({ "_id" : { "id" : "E1", "type": "Thing", "servicePath" : "/" } }, {_id:0, attrNames: 1})' +mongoCmd ${CB_DB_NAME} 'db.entities.findOne({ "_id" : { "id" : "E1", "type": "Thing", "servicePath" : "/" } }, {_id:0, attrNames: 1})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -279,7 +279,12 @@ Content-Length: 10 07. Check attributes in DB ========================== -{ "attrNames" : [ "A2..y", "A3.Z" ] } +{ + "attrNames": [ + "A2..y", + "A3.Z" + ] +} --TEARDOWN-- diff --git a/test/functionalTest/cases/1661_bad_input_on_notification_error/bad_input_on_notification_error.test b/test/functionalTest/cases/1661_bad_input_on_notification_error/bad_input_on_notification_error.test index 91c152b1fe..c726bb7a88 100644 --- a/test/functionalTest/cases/1661_bad_input_on_notification_error/bad_input_on_notification_error.test +++ b/test/functionalTest/cases/1661_bad_input_on_notification_error/bad_input_on_notification_error.test @@ -168,7 +168,7 @@ echo echo "07. Corrupt reference in subscription (using mongo)" echo "===================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.update({_id: ObjectId("'$SUB_ID'")}, { $set: { "reference": "badReferenceForSubscription" }})' +mongoCmd ${CB_DB_NAME} 'db.csubs.updateOne({_id: ObjectId("'$SUB_ID'")}, { $set: { "reference": "badReferenceForSubscription" }})' echo echo @@ -265,7 +265,7 @@ Releasing alarm BadInput REGEX((0.0.0.0|127.0.0.1)) 07. Corrupt reference in subscription (using mongo) =================================================== -WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) +{"acknowledged":true,"insertedId":null,"matchedCount":1,"modifiedCount":1,"upsertedCount":0} 08. Wait six seconds to assure the subscription cache has been modified diff --git a/test/functionalTest/cases/1661_bad_input_on_notification_error/bad_input_on_notification_error_with_relogged_alarms.test b/test/functionalTest/cases/1661_bad_input_on_notification_error/bad_input_on_notification_error_with_relogged_alarms.test index 773ddecae9..c99478e16b 100644 --- a/test/functionalTest/cases/1661_bad_input_on_notification_error/bad_input_on_notification_error_with_relogged_alarms.test +++ b/test/functionalTest/cases/1661_bad_input_on_notification_error/bad_input_on_notification_error_with_relogged_alarms.test @@ -168,7 +168,7 @@ echo echo "07. Corrupt reference in subscription (using mongo)" echo "===================================================" -mongoCmd ${CB_DB_NAME} 'db.csubs.update({_id: ObjectId("'$SUB_ID'")}, { $set: { "reference": "badReferenceForSubscription" }})' +mongoCmd ${CB_DB_NAME} 'db.csubs.updateOne({_id: ObjectId("'$SUB_ID'")}, { $set: { "reference": "badReferenceForSubscription" }})' echo echo @@ -269,7 +269,7 @@ Releasing alarm BadInput REGEX((0.0.0.0|127.0.0.1)) 07. Corrupt reference in subscription (using mongo) =================================================== -WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) +{"acknowledged":true,"insertedId":null,"matchedCount":1,"modifiedCount":1,"upsertedCount":0} 08. Wait six seconds to assure the subscription cache has been modified diff --git a/test/functionalTest/cases/2394_inconsistent_mdnames_after_update/inconsistent_mdnames_after_update.test b/test/functionalTest/cases/2394_inconsistent_mdnames_after_update/inconsistent_mdnames_after_update.test index e88e74907b..ba822b78d1 100644 --- a/test/functionalTest/cases/2394_inconsistent_mdnames_after_update/inconsistent_mdnames_after_update.test +++ b/test/functionalTest/cases/2394_inconsistent_mdnames_after_update/inconsistent_mdnames_after_update.test @@ -61,7 +61,7 @@ echo echo "02. Get from Database, only 2 metadata" echo "======================================" -mongoCmd ${CB_DB_NAME} "db.entities.find({}, {_id:0, \"attrs.temperature.mdNames\":1})" +mongoCmd ${CB_DB_NAME} "db.entities.find({}, {_id:0, \"attrs.temperature.mdNames\":1}).toArray()" echo echo @@ -88,7 +88,7 @@ echo echo "04. Get from Database, only 2 metadata" echo "======================================" -mongoCmd ${CB_DB_NAME} "db.entities.find({}, {_id:0, \"attrs.temperature.mdNames\":1})" +mongoCmd ${CB_DB_NAME} "db.entities.find({}, {_id:0, \"attrs.temperature.mdNames\":1}).toArray()" echo echo @@ -106,7 +106,7 @@ Content-Length: 0 02. Get from Database, only 2 metadata ====================================== -{ "attrs" : { "temperature" : { "mdNames" : [ "34.4E-34_1", "34.4E-34_0" ] } } } +[{"attrs":{"temperature":{"mdNames":["34.4E-34_1","34.4E-34_0"]}}}] 03. Update E-temperature, including metatata @@ -119,7 +119,7 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}) 04. Get from Database, only 2 metadata ====================================== -{ "attrs" : { "temperature" : { "mdNames" : [ "34.4E-34_1", "34.4E-34_0" ] } } } +[{"attrs":{"temperature":{"mdNames":["34.4E-34_1","34.4E-34_0"]}}}] --TEARDOWN-- diff --git a/test/functionalTest/cases/2770_v1_append_not_updates_geo_point/v1_append_not_updates_geo_point.test b/test/functionalTest/cases/2770_v1_append_not_updates_geo_point/v1_append_not_updates_geo_point.test index 6b6aee38df..cf183f4d39 100644 --- a/test/functionalTest/cases/2770_v1_append_not_updates_geo_point/v1_append_not_updates_geo_point.test +++ b/test/functionalTest/cases/2770_v1_append_not_updates_geo_point/v1_append_not_updates_geo_point.test @@ -54,7 +54,7 @@ echo echo "02. Check location field at DB is -4.33, 36.12" echo "==============================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find({"_id.id": "line1"}, {_id: 0, location: 1})' +mongoCmd ${CB_DB_NAME} 'db.entities.find({"_id.id": "line1"}, {_id: 0, location: 1}).toArray()' echo echo @@ -84,7 +84,7 @@ echo echo "04. Check location field at DB is -11.22, 22.33" echo "===============================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find({"_id.id": "line1"}, {_id: 0, location: 1})' +mongoCmd ${CB_DB_NAME} 'db.entities.find({"_id.id": "line1"}, {_id: 0, location: 1}).toArray()' echo echo @@ -102,7 +102,7 @@ Content-Length: 0 02. Check location field at DB is -4.33, 36.12 ============================================== -{ "location" : { "attrName" : "loc", "coords" : { "type" : "Point", "coordinates" : [ -4.33, 36.12 ] } } } +[{"location":{"attrName":"loc","coords":{"type":"Point","coordinates":[-4.33,36.12]}}}] 03. Update entity using v1 updateContext APPEND @@ -139,7 +139,7 @@ Content-Length: 197 04. Check location field at DB is -11.22, 22.33 =============================================== -{ "location" : { "attrName" : "loc", "coords" : { "type" : "Point", "coordinates" : [ -11.22, 22.33 ] } } } +[{"location":{"attrName":"loc","coords":{"type":"Point","coordinates":[-11.22,22.33]}}}] --TEARDOWN-- diff --git a/test/functionalTest/cases/2871_fwd_update_ok_but_not_found_response/fwd_update_ok_but_not_found_response.test b/test/functionalTest/cases/2871_fwd_update_ok_but_not_found_response/fwd_update_ok_but_not_found_response.test index 7a7b1c567e..a5595702d1 100644 --- a/test/functionalTest/cases/2871_fwd_update_ok_but_not_found_response/fwd_update_ok_but_not_found_response.test +++ b/test/functionalTest/cases/2871_fwd_update_ok_but_not_found_response/fwd_update_ok_but_not_found_response.test @@ -49,7 +49,7 @@ echo "01. Create registration directly in DB" echo "======================================" doc='{ "_id":ObjectId("5b1ff2ee49597334c9b5efc7"), - "expiration":NumberLong(1845053934), + "expiration":NumberLong("1845053934"), "servicePath":"/ss1", "format":"JSON", "contextRegistration":[ @@ -70,7 +70,7 @@ doc='{ } ] }' -mongoCmd ${CB_DB_NAME} "db.registrations.insert($doc)" +mongoCmd ${CB_DB_NAME} "db.registrations.insertOne($doc)" echo echo @@ -131,7 +131,7 @@ doc='{ "modDate": 1528820541, "lastCorrelator": "c8bcef8a-6e5c-11e8-a06c-0242ac11000b" }' -mongoCmd ${CB_DB_NAME} "db.entities.insert($doc)" +mongoCmd ${CB_DB_NAME} "db.entities.insertOne($doc)" echo echo @@ -222,12 +222,12 @@ echo --REGEXPECT-- 01. Create registration directly in DB ====================================== -WriteResult({ "nInserted" : 1 }) +{"acknowledged":true,"insertedId":{"$oid":"5b1ff2ee49597334c9b5efc7"}} 02. Create entity directly in DB ================================ -WriteResult({ "nInserted" : 1 }) +{"acknowledged":true,"insertedId":{"id":"entity1","type":"device","servicePath":"/ss1"}} 03. Update turn attribute using PATCH on entity diff --git a/test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V2.test b/test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V2.test index 496b530cec..be79908420 100644 --- a/test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V2.test +++ b/test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V2.test @@ -80,14 +80,14 @@ echo echo "03. Check E1 entity in DB has location metadata but no location GeoJSON field" echo "=============================================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find({ "_id" : { "id" : "E1", "type": "T", "servicePath" : "/" } }, {_id:0, attrs: 1, location: 1})' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.findOne({ "_id" : { "id" : "E1", "type": "T", "servicePath" : "/" } }, {_id:0, attrs: 1, location: 1})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo echo "04. Check E2 entity in DB has no location metadata but location GeoJSON field" echo "=============================================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find({ "_id" : { "id" : "E2", "type": "T", "servicePath" : "/" } }, {_id:0, attrs: 1, location: 1})' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.findOne({ "_id" : { "id" : "E2", "type": "T", "servicePath" : "/" } }, {_id:0, attrs: 1, location: 1})' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/3162_context_providers_legacy_non_primitive/blanked_out_attr.test b/test/functionalTest/cases/3162_context_providers_legacy_non_primitive/blanked_out_attr.test index 377cf618be..40c7feed77 100644 --- a/test/functionalTest/cases/3162_context_providers_legacy_non_primitive/blanked_out_attr.test +++ b/test/functionalTest/cases/3162_context_providers_legacy_non_primitive/blanked_out_attr.test @@ -86,7 +86,7 @@ echo echo "03. Get entity from mongodb" echo "===========================" -m=$(mongoCmd ${CB_DB_NAME} 'db.entities.find({ "_id" : { "id" : "urn:ngsi-ld:Store:004", "type": "Store", "servicePath" : "/" }})') +m=$(mongoCmd ${CB_DB_NAME} 'db.entities.findOne({ "_id" : { "id" : "urn:ngsi-ld:Store:004", "type": "Store", "servicePath" : "/" }})') echo $m | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -128,7 +128,7 @@ echo echo "06. Get entity from mongodb" echo "===========================" -m=$(mongoCmd ${CB_DB_NAME} 'db.entities.find({ "_id" : { "id" : "urn:ngsi-ld:Store:004", "type": "Store", "servicePath" : "/" }})') +m=$(mongoCmd ${CB_DB_NAME} 'db.entities.findOne({ "_id" : { "id" : "urn:ngsi-ld:Store:004", "type": "Store", "servicePath" : "/" }})') echo $m | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo diff --git a/test/functionalTest/cases/3162_context_providers_legacy_non_primitive/query_for_arrays.test b/test/functionalTest/cases/3162_context_providers_legacy_non_primitive/query_for_arrays.test index 67bffeca00..f6db6dcf1a 100644 --- a/test/functionalTest/cases/3162_context_providers_legacy_non_primitive/query_for_arrays.test +++ b/test/functionalTest/cases/3162_context_providers_legacy_non_primitive/query_for_arrays.test @@ -51,7 +51,7 @@ payload='{ "entities": [ { "id": "E1", - "type": "E" + "type": "T" } ], "attrs": [ @@ -75,7 +75,7 @@ echo "==================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", "id": "E1", "attributes": [ @@ -99,7 +99,7 @@ echo "======================" payload='{ "entities": [ { - "type": "E", + "type": "T", "isPattern": "false", "id": "E1" } @@ -125,7 +125,7 @@ echo "==========================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", "id": "E1", "attributes": [ @@ -190,7 +190,7 @@ Content-Length: 187 ], "id": "E1", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -225,7 +225,7 @@ Content-Length: 203 ], "id": "E1", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -271,7 +271,7 @@ Content-Length: 187 ], "id": "E1", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -319,7 +319,7 @@ Content-Length: 148 ] }, "id": "E1", - "type": "E" + "type": "T" } diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geobox_create_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geobox_create_does_not_break_location.test index cf68b94d8c..dcd6943251 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geobox_create_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geobox_create_does_not_break_location.test @@ -40,7 +40,7 @@ echo "===================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", "id": "E1", "attributes": [ @@ -61,7 +61,7 @@ echo echo "02. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -89,7 +89,7 @@ Content-Length: 195 ], "id": "E1", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -102,61 +102,63 @@ Content-Length: 195 02. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:box", - "value": [ - "7.7, 8.8", - "9.9, -10.10" - ] - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - [ - [ - -10.1, - 7.7 - ], - [ - -10.1, - 9.9 - ], - [ - 8.8, - 9.9 - ], - [ - 8.8, - 7.7 - ], +[ + { + "_id": { + "id": "E1", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "position" + ], + "attrs": { + "position": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:box", + "value": [ + "7.7, 8.8", + "9.9, -10.10" + ] + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "position", + "coords": { + "coordinates": [ [ - -10.1, - 7.7 + [ + -10.1, + 7.7 + ], + [ + -10.1, + 9.9 + ], + [ + 8.8, + 9.9 + ], + [ + 8.8, + 7.7 + ], + [ + -10.1, + 7.7 + ] ] - ] - ], - "type": "Polygon" - } - }, - "modDate": REGEX(\d+\.\d+) -} + ], + "type": "Polygon" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geobox_update_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geobox_update_does_not_break_location.test index 8ffdc90cac..2d0ba1d089 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geobox_update_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geobox_update_does_not_break_location.test @@ -57,12 +57,12 @@ echo "===================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:box", "value": ["-3.3, 4.4", "5.5, -6.6"] } @@ -78,7 +78,7 @@ echo echo "03. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -88,12 +88,12 @@ echo "===================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:box", "value": ["7.7, 8.8", "9.9, -10.10"] } @@ -109,7 +109,7 @@ echo echo "05. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -132,7 +132,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 195 +Content-Length: 194 { "contextResponses": [ @@ -140,14 +140,14 @@ Content-Length: 195 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:box", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -160,61 +160,63 @@ Content-Length: 195 03. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:box", - "value": [ - "-3.3, 4.4", - "5.5, -6.6" - ] - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - [ - [ - -6.6, - -3.3 - ], - [ - -6.6, - 5.5 - ], - [ - 4.4, - 5.5 - ], - [ - 4.4, - -3.3 - ], +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:box", + "value": [ + "-3.3, 4.4", + "5.5, -6.6" + ] + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { + "coordinates": [ [ - -6.6, - -3.3 + [ + -6.6, + -3.3 + ], + [ + -6.6, + 5.5 + ], + [ + 4.4, + 5.5 + ], + [ + 4.4, + -3.3 + ], + [ + -6.6, + -3.3 + ] ] - ] - ], - "type": "Polygon" - } - }, - "modDate": REGEX(\d+\.\d+) -} + ], + "type": "Polygon" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] 04. Update entity with geo:box with NGSIv1 (UPDATE) @@ -223,7 +225,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 195 +Content-Length: 194 { "contextResponses": [ @@ -231,14 +233,14 @@ Content-Length: 195 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:box", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -251,61 +253,63 @@ Content-Length: 195 05. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:box", - "value": [ - "7.7, 8.8", - "9.9, -10.10" - ] - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - [ - [ - -10.1, - 7.7 - ], - [ - -10.1, - 9.9 - ], - [ - 8.8, - 9.9 - ], - [ - 8.8, - 7.7 - ], +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:box", + "value": [ + "7.7, 8.8", + "9.9, -10.10" + ] + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { + "coordinates": [ [ - -10.1, - 7.7 + [ + -10.1, + 7.7 + ], + [ + -10.1, + 9.9 + ], + [ + 8.8, + 9.9 + ], + [ + 8.8, + 7.7 + ], + [ + -10.1, + 7.7 + ] ] - ] - ], - "type": "Polygon" - } - }, - "modDate": REGEX(\d+\.\d+) -} + ], + "type": "Polygon" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geojson_create_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geojson_create_does_not_break_location.test index 17ea8ae9f8..143371555b 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geojson_create_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geojson_create_does_not_break_location.test @@ -40,7 +40,7 @@ echo "====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", "id": "E1", "attributes": [ @@ -64,7 +64,7 @@ echo echo "02. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -92,7 +92,7 @@ Content-Length: 196 ], "id": "E1", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -105,44 +105,46 @@ Content-Length: 196 02. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:json", - "value": { +[ + { + "_id": { + "id": "E1", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "position" + ], + "attrs": { + "position": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:json", + "value": { + "coordinates": [ + "5.5", + "-6.6" + ], + "type": "Point" + } + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "position", + "coords": { "coordinates": [ - "5.5", - "-6.6" + 5.5, + -6.6 ], "type": "Point" } - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - 5.5, - -6.6 - ], - "type": "Point" - } - }, - "modDate": REGEX(\d+\.\d+) -} + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geojson_update_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geojson_update_does_not_break_location.test index 064a19243c..a441e56954 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geojson_update_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geojson_update_does_not_break_location.test @@ -57,12 +57,12 @@ echo "====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:json", "value": { "type": "Point", @@ -81,7 +81,7 @@ echo echo "03. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -91,12 +91,12 @@ echo "====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:json", "value": { "type": "Point", @@ -115,7 +115,7 @@ echo echo "05. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -138,7 +138,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 196 +Content-Length: 195 { "contextResponses": [ @@ -146,14 +146,14 @@ Content-Length: 196 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:json", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -166,44 +166,46 @@ Content-Length: 196 03. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:json", - "value": { +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:json", + "value": { + "coordinates": [ + "-3.3", + "4.4" + ], + "type": "Point" + } + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { "coordinates": [ - "-3.3", - "4.4" + -3.3, + 4.4 ], "type": "Point" } - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - -3.3, - 4.4 - ], - "type": "Point" - } - }, - "modDate": REGEX(\d+\.\d+) -} + }, + "modDate": REGEX(\d+\.\d+) + } +] 04. Update entity with geo:json with NGSIv1 (UPDATE) @@ -212,7 +214,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 196 +Content-Length: 195 { "contextResponses": [ @@ -220,14 +222,14 @@ Content-Length: 196 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:json", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -240,44 +242,46 @@ Content-Length: 196 05. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:json", - "value": { +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:json", + "value": { + "coordinates": [ + "5.5", + "-6.6" + ], + "type": "Point" + } + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { "coordinates": [ - "5.5", - "-6.6" + 5.5, + -6.6 ], "type": "Point" } - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - 5.5, - -6.6 - ], - "type": "Point" - } - }, - "modDate": REGEX(\d+\.\d+) -} + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geoline_create_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geoline_create_does_not_break_location.test index 3871ac0398..c210466a92 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geoline_create_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geoline_create_does_not_break_location.test @@ -40,7 +40,7 @@ echo "====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", "id": "E1", "attributes": [ @@ -61,7 +61,7 @@ echo echo "02. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -89,7 +89,7 @@ Content-Length: 196 ], "id": "E1", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -102,47 +102,49 @@ Content-Length: 196 02. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:line", - "value": [ - "7.7, 8.8", - "9.9, -10.10" - ] - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - [ - 8.8, - 7.7 - ], - [ - -10.1, - 9.9 +[ + { + "_id": { + "id": "E1", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "position" + ], + "attrs": { + "position": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:line", + "value": [ + "7.7, 8.8", + "9.9, -10.10" ] - ], - "type": "LineString" - } - }, - "modDate": REGEX(\d+\.\d+) -} + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "position", + "coords": { + "coordinates": [ + [ + 8.8, + 7.7 + ], + [ + -10.1, + 9.9 + ] + ], + "type": "LineString" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geoline_update_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geoline_update_does_not_break_location.test index 60f3a45428..c3c8e42075 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geoline_update_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geoline_update_does_not_break_location.test @@ -57,12 +57,12 @@ echo "====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:line", "value": ["-3.3, 4.4", "5.5, -6.6"] } @@ -78,7 +78,7 @@ echo echo "03. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -88,12 +88,12 @@ echo "====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:line", "value": ["7.7, 8.8", "9.9, -10.10"] } @@ -109,7 +109,7 @@ echo echo "05. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -132,7 +132,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 196 +Content-Length: 195 { "contextResponses": [ @@ -140,14 +140,14 @@ Content-Length: 196 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:line", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -160,47 +160,49 @@ Content-Length: 196 03. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:line", - "value": [ - "-3.3, 4.4", - "5.5, -6.6" - ] - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - [ - 4.4, - -3.3 - ], - [ - -6.6, - 5.5 +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:line", + "value": [ + "-3.3, 4.4", + "5.5, -6.6" ] - ], - "type": "LineString" - } - }, - "modDate": REGEX(\d+\.\d+) -} + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { + "coordinates": [ + [ + 4.4, + -3.3 + ], + [ + -6.6, + 5.5 + ] + ], + "type": "LineString" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] 04. Update entity with geo:line with NGSIv1 (UPDATE) @@ -209,7 +211,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 196 +Content-Length: 195 { "contextResponses": [ @@ -217,14 +219,14 @@ Content-Length: 196 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:line", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -237,47 +239,49 @@ Content-Length: 196 05. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:line", - "value": [ - "7.7, 8.8", - "9.9, -10.10" - ] - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - [ - 8.8, - 7.7 - ], - [ - -10.1, - 9.9 +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:line", + "value": [ + "7.7, 8.8", + "9.9, -10.10" ] - ], - "type": "LineString" - } - }, - "modDate": REGEX(\d+\.\d+) -} + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { + "coordinates": [ + [ + 8.8, + 7.7 + ], + [ + -10.1, + 9.9 + ] + ], + "type": "LineString" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopoint_create_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopoint_create_does_not_break_location.test index 3d6563b108..de3fa48d9e 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopoint_create_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopoint_create_does_not_break_location.test @@ -40,7 +40,7 @@ echo "=====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", "id": "E1", "attributes": [ @@ -61,7 +61,7 @@ echo echo "02. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -89,7 +89,7 @@ Content-Length: 197 ], "id": "E1", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -102,38 +102,40 @@ Content-Length: 197 02. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:point", - "value": "5.5, -6.6" - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - -6.6, - 5.5 - ], - "type": "Point" - } - }, - "modDate": REGEX(\d+\.\d+) -} +[ + { + "_id": { + "id": "E1", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "position" + ], + "attrs": { + "position": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:point", + "value": "5.5, -6.6" + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "position", + "coords": { + "coordinates": [ + -6.6, + 5.5 + ], + "type": "Point" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopoint_update_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopoint_update_does_not_break_location.test index 141019e70f..6fabd5604c 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopoint_update_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopoint_update_does_not_break_location.test @@ -57,12 +57,12 @@ echo "=====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:point", "value": "-3.3, 4.4" } @@ -78,7 +78,7 @@ echo echo "03. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -88,12 +88,12 @@ echo "=====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:point", "value": "5.5, -6.6" } @@ -109,7 +109,7 @@ echo echo "05. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -132,7 +132,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 197 +Content-Length: 196 { "contextResponses": [ @@ -140,14 +140,14 @@ Content-Length: 197 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:point", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -160,38 +160,40 @@ Content-Length: 197 03. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:point", - "value": "-3.3, 4.4" - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - 4.4, - -3.3 - ], - "type": "Point" - } - }, - "modDate": REGEX(\d+\.\d+) -} +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:point", + "value": "-3.3, 4.4" + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { + "coordinates": [ + 4.4, + -3.3 + ], + "type": "Point" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] 04. Update entity with geo:point with NGSIv1 (UPDATE) @@ -200,7 +202,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 197 +Content-Length: 196 { "contextResponses": [ @@ -208,14 +210,14 @@ Content-Length: 197 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:point", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -228,38 +230,40 @@ Content-Length: 197 05. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:point", - "value": "5.5, -6.6" - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - -6.6, - 5.5 - ], - "type": "Point" - } - }, - "modDate": REGEX(\d+\.\d+) -} +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:point", + "value": "5.5, -6.6" + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { + "coordinates": [ + -6.6, + 5.5 + ], + "type": "Point" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopolygon_create_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopolygon_create_does_not_break_location.test index 9de8bd322b..56e69a6734 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopolygon_create_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopolygon_create_does_not_break_location.test @@ -40,7 +40,7 @@ echo "=======================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", "id": "E1", "attributes": [ @@ -61,7 +61,7 @@ echo echo "02. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -89,7 +89,7 @@ Content-Length: 199 ], "id": "E1", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -102,59 +102,61 @@ Content-Length: 199 02. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:polygon", - "value": [ - "7.7, 8.8", - "9.9, -10.10", - "3.3, 2.2", - "7.7, 8.8" - ] - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - [ - [ - 8.8, - 7.7 - ], - [ - -10.1, - 9.9 - ], - [ - 2.2, - 3.3 - ], +[ + { + "_id": { + "id": "E1", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "position" + ], + "attrs": { + "position": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:polygon", + "value": [ + "7.7, 8.8", + "9.9, -10.10", + "3.3, 2.2", + "7.7, 8.8" + ] + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "position", + "coords": { + "coordinates": [ [ - 8.8, - 7.7 + [ + 8.8, + 7.7 + ], + [ + -10.1, + 9.9 + ], + [ + 2.2, + 3.3 + ], + [ + 8.8, + 7.7 + ] ] - ] - ], - "type": "Polygon" - } - }, - "modDate": REGEX(\d+\.\d+) -} + ], + "type": "Polygon" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopolygon_update_does_not_break_location.test b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopolygon_update_does_not_break_location.test index 5e25fef048..0810506047 100644 --- a/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopolygon_update_does_not_break_location.test +++ b/test/functionalTest/cases/3442_ngsiv1_interop_location_fix/ngsiv1_geopolygon_update_does_not_break_location.test @@ -57,12 +57,12 @@ echo "=======================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:polygon", "value": ["-3.3, 4.4", "5.5, -6.6", "1.1, 2.2", "-3.3, 4.4"] } @@ -78,7 +78,7 @@ echo echo "03. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -88,12 +88,12 @@ echo "====================================================" payload='{ "contextElements": [ { - "type": "E", + "type": "T", "isPattern": "false", - "id": "E1", + "id": "E", "attributes": [ { - "name": "position", + "name": "location", "type": "geo:polygon", "value": ["7.7, 8.8", "9.9, -10.10", "3.3, 2.2", "7.7, 8.8"] } @@ -109,7 +109,7 @@ echo echo "05. Check location field is not broken in database" echo "==================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find()' | python ${SCRIPT_HOME}/jsonBeautifier.py +mongoCmd ${CB_DB_NAME} 'db.entities.find().toArray()' | python ${SCRIPT_HOME}/jsonBeautifier.py echo echo @@ -132,7 +132,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 199 +Content-Length: 198 { "contextResponses": [ @@ -140,14 +140,14 @@ Content-Length: 199 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:polygon", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -160,59 +160,61 @@ Content-Length: 199 03. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:polygon", - "value": [ - "-3.3, 4.4", - "5.5, -6.6", - "1.1, 2.2", - "-3.3, 4.4" - ] - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - [ - [ - 4.4, - -3.3 - ], - [ - -6.6, - 5.5 - ], - [ - 2.2, - 1.1 - ], +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:polygon", + "value": [ + "-3.3, 4.4", + "5.5, -6.6", + "1.1, 2.2", + "-3.3, 4.4" + ] + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { + "coordinates": [ [ - 4.4, - -3.3 + [ + 4.4, + -3.3 + ], + [ + -6.6, + 5.5 + ], + [ + 2.2, + 1.1 + ], + [ + 4.4, + -3.3 + ] ] - ] - ], - "type": "Polygon" - } - }, - "modDate": REGEX(\d+\.\d+) -} + ], + "type": "Polygon" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] 04. Update entity with geo:polygon with NGSIv1 (UPDATE) @@ -221,7 +223,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 199 +Content-Length: 198 { "contextResponses": [ @@ -229,14 +231,14 @@ Content-Length: 199 "contextElement": { "attributes": [ { - "name": "position", + "name": "location", "type": "geo:polygon", "value": "" } ], - "id": "E1", + "id": "E", "isPattern": "false", - "type": "E" + "type": "T" }, "statusCode": { "code": "200", @@ -249,59 +251,61 @@ Content-Length: 199 05. Check location field is not broken in database ================================================== -{ - "_id": { - "id": "E1", - "servicePath": "/", - "type": "E" - }, - "attrNames": [ - "position" - ], - "attrs": { - "position": { - "creDate": REGEX(\d+\.\d+), - "mdNames": [], - "modDate": REGEX(\d+\.\d+), - "type": "geo:polygon", - "value": [ - "7.7, 8.8", - "9.9, -10.10", - "3.3, 2.2", - "7.7, 8.8" - ] - } - }, - "creDate": REGEX(\d+\.\d+), - "lastCorrelator": "REGEX(.*)", - "location": { - "attrName": "position", - "coords": { - "coordinates": [ - [ - [ - 8.8, - 7.7 - ], - [ - -10.1, - 9.9 - ], - [ - 2.2, - 3.3 - ], +[ + { + "_id": { + "id": "E", + "servicePath": "/", + "type": "T" + }, + "attrNames": [ + "location" + ], + "attrs": { + "location": { + "creDate": REGEX(\d+\.\d+), + "mdNames": [], + "modDate": REGEX(\d+\.\d+), + "type": "geo:polygon", + "value": [ + "7.7, 8.8", + "9.9, -10.10", + "3.3, 2.2", + "7.7, 8.8" + ] + } + }, + "creDate": REGEX(\d+\.\d+), + "lastCorrelator": "REGEX(.*)", + "location": { + "attrName": "location", + "coords": { + "coordinates": [ [ - 8.8, - 7.7 + [ + 8.8, + 7.7 + ], + [ + -10.1, + 9.9 + ], + [ + 2.2, + 3.3 + ], + [ + 8.8, + 7.7 + ] ] - ] - ], - "type": "Polygon" - } - }, - "modDate": REGEX(\d+\.\d+) -} + ], + "type": "Polygon" + } + }, + "modDate": REGEX(\d+\.\d+) + } +] --TEARDOWN-- diff --git a/test/functionalTest/cases/3706_incorrect_location_processing/incorrect_location_processing.test b/test/functionalTest/cases/3706_incorrect_location_processing/incorrect_location_processing.test index 64e62982bd..ec5a7c49d2 100644 --- a/test/functionalTest/cases/3706_incorrect_location_processing/incorrect_location_processing.test +++ b/test/functionalTest/cases/3706_incorrect_location_processing/incorrect_location_processing.test @@ -239,9 +239,7 @@ doc='{ "modDate": 1603273111.6493506, "lastCorrelator": "2e7b6c36-1381-11eb-a1f0-0242ac110013" }' -# FIXME P3: not sure why mongCmd() doesn't work this time... maybe $doc is too long? -#mongoCmd ${CB_DB_NAME} "db.entities.insert($doc)" -echo "db.entities.insert($doc)" | mongo mongodb://localhost:27017/${CB_DB_NAME} | tail -n 2 | head -n 1 +mongoCmd ${CB_DB_NAME} "db.entities.insertOne($doc)" echo echo @@ -264,7 +262,7 @@ echo --REGEXPECT-- 01. Create entity directly in DB ================================ -WriteResult({ "nInserted" : 1 }) +{"acknowledged":true,"insertedId":{"id":"ES0021000001111111AA","type":"SupplyPoint","servicePath":"/energia"}} 02. Update the entity as described in #3706 and check we don't get 413 error diff --git a/test/functionalTest/cases/3914_mqtt_notifications_auth/mqtt_custom_notifications_auth.test b/test/functionalTest/cases/3914_mqtt_notifications_auth/mqtt_custom_notifications_auth.test index 95d03e9ebd..59a65b45f0 100644 --- a/test/functionalTest/cases/3914_mqtt_notifications_auth/mqtt_custom_notifications_auth.test +++ b/test/functionalTest/cases/3914_mqtt_notifications_auth/mqtt_custom_notifications_auth.test @@ -353,8 +353,8 @@ Content-Length: 366 06. Get sub password pass1 from DB ================================== -user1 -pass1 +"user1" +"pass1" 07. PATCH sub changing password to user10 and pass10 @@ -407,8 +407,8 @@ Content-Length: 367 09. Get sub password pass10 from DB =================================== -user10 -pass10 +"user10" +"pass10" 10. PATCH sub removing auth parameters @@ -513,8 +513,8 @@ Content-Length: 366 15. Get sub password pass1 from DB ================================== -user1 -pass1 +"user1" +"pass1" --TEARDOWN-- diff --git a/test/functionalTest/cases/3914_mqtt_notifications_auth/mqtt_notifications_auth.test b/test/functionalTest/cases/3914_mqtt_notifications_auth/mqtt_notifications_auth.test index 2b149a5221..f165102fb6 100644 --- a/test/functionalTest/cases/3914_mqtt_notifications_auth/mqtt_notifications_auth.test +++ b/test/functionalTest/cases/3914_mqtt_notifications_auth/mqtt_notifications_auth.test @@ -353,8 +353,8 @@ Content-Length: 360 06. Get sub password pass1 from DB ================================== -user1 -pass1 +"user1" +"pass1" 07. PATCH sub changing password to user10 and pass10 @@ -407,8 +407,8 @@ Content-Length: 361 09. Get sub password pass10 from DB =================================== -user10 -pass10 +"user10" +"pass10" 10. PATCH sub removing auth parameters @@ -513,8 +513,8 @@ Content-Length: 360 15. Get sub password pass1 from DB ================================== -user1 -pass1 +"user1" +"pass1" --TEARDOWN-- diff --git a/test/functionalTest/cases/4069_status_inactive_not_working_with_cache_in_ha/status_inactive_not_working_with_cache_in_ha.test b/test/functionalTest/cases/4069_status_inactive_not_working_with_cache_in_ha/status_inactive_not_working_with_cache_in_ha.test index 7940e619b1..971e0151e9 100644 --- a/test/functionalTest/cases/4069_status_inactive_not_working_with_cache_in_ha/status_inactive_not_working_with_cache_in_ha.test +++ b/test/functionalTest/cases/4069_status_inactive_not_working_with_cache_in_ha/status_inactive_not_working_with_cache_in_ha.test @@ -26,7 +26,7 @@ Status inactive was not working in HA scenario when cache is used --SHELL-INIT-- dbInit CB -mongoCmd ${CB_DB_NAME} 'db.csubs.insert({ +mongoCmd ${CB_DB_NAME} 'db.csubs.insertOne({ "_id" : ObjectId("620e0d04219c8378695c822b"), "expiration" : NumberLong("9223372036854775807"), "reference" : "http://localhost:1234", diff --git a/test/functionalTest/harnessFunctions.sh b/test/functionalTest/harnessFunctions.sh index 08df1697f3..f9035f2d9f 100644 --- a/test/functionalTest/harnessFunctions.sh +++ b/test/functionalTest/harnessFunctions.sh @@ -145,7 +145,7 @@ function dbInit() fi dMsg "database to drop: <$db>" - echo 'db.dropDatabase()' | mongo mongodb://$host:$port/$db --quiet + mongosh mongodb://$host:$port/$db --eval 'db.dropDatabase()' --quiet } @@ -186,9 +186,9 @@ function dbList if [ "$name" != "" ] then - echo show dbs | mongo mongodb://$host:$port --quiet | grep "$name" | awk '{ print $1 }' + mongosh mongodb://$host:$port --eval 'show dbs' --quiet | grep "$name" | awk '{ print $1 }' else - echo show dbs | mongo mongodb://$host:$port --quiet | awk '{ print $1 }' + mongosh mongodb://$host:$port --eval 'show dbs' --quiet | awk '{ print $1 }' fi } @@ -212,7 +212,7 @@ function dbResetAll() port="27017" fi - all=$(echo show dbs | mongo mongodb://$host:$port --quiet | grep ftest | awk '{ print $1 }') + all=$(mongosh mongodb://$host:$port --eval 'show dbs' --quiet | grep ftest | awk '{ print $1 }') for db in $all do dbDrop $db @@ -1040,17 +1040,7 @@ function valgrindSleep() # ------------------------------------------------------------------------------ # -# mongoCmd - -# -# This functions is needed due to some problems with jenkins that seems to avoid -# the usage of 'mongo --quiet ...' directly. Thus, we need to use mongo without -# --quiet, but we need to get rid of some preamble lines about mongo version and -# connection information and a final 'bye' line -# -# NOTE: this will no longer work with new mongosh shell. Note that legacy shell -# (the 'mongo' command) has been deprecated in MongoDB 5.0 and removed in MongoDB 6.0. -# This function (and many .test using mongoCmd) would need fixing after stepping to -# MongoDB 6.0 +# mongoCmd - # function mongoCmd() { @@ -1066,35 +1056,12 @@ function mongoCmd() port="27017" fi - db=$1 - cmd=$2 - echo $cmd | mongo mongodb://$host:$port/$db | tail -n 2 | head -n 1 -} - - - -# ------------------------------------------------------------------------------ -# -# mongoCmdLong - like mongoCmd but showing all the output, not just the last line. -# Meant to be used in conjunction with 'grep' -# -function mongoCmdLong() -{ - host="${CB_DATABASE_HOST}" - if [ "$host" == "" ] - then - host="localhost" - fi - - port="${CB_DATABASE_PORT}" - if [ "$port" == "" ] - then - port="27017" - fi + # Why to use EJSON.stringfiy() instead of JSON.stringfly()? + # See https://stackoverflow.com/q/77678898/1485926 db=$1 - cmd=$2 - echo $cmd | mongo mongodb://$host:$port/$db + cmd="EJSON.stringify($2)" + mongosh mongodb://$host:$port/$db --eval "$cmd" --quiet } @@ -1426,7 +1393,6 @@ export -f accumulator3Reset export -f orionCurl export -f dbInsertEntity export -f mongoCmd -export -f mongoCmdLong export -f vMsg export -f dMsg export -f valgrindSleep diff --git a/test/loadTest/cache_refresh/drop_database_mongo.sh b/test/loadTest/cache_refresh/drop_database_mongo.sh index 1857640035..1a4d50fad2 100644 --- a/test/loadTest/cache_refresh/drop_database_mongo.sh +++ b/test/loadTest/cache_refresh/drop_database_mongo.sh @@ -19,7 +19,7 @@ # # For those usages not covered by this license please contact with # iot_support at tid dot es -# author: 'Ivn Arias Len (ivan dot ariasleon at telefonica dot com)' +# author: 'Iván Arias León (ivan dot ariasleon at telefonica dot com)' if [ "$1" == "" ] then @@ -41,7 +41,7 @@ fi - +# FIXME: use mongosh instead of mongo dbs=(`(echo 'show databases' | mongo --host $host) | grep $prefix`) for db in ${dbs[@]}; do diff --git a/test/loadTest/perf/csub_clean.sh b/test/loadTest/perf/csub_clean.sh index 7d46460fe1..5701af6a86 100755 --- a/test/loadTest/perf/csub_clean.sh +++ b/test/loadTest/perf/csub_clean.sh @@ -19,4 +19,5 @@ # For those usages not covered by this license please contact with # iot_support at tid dot es +# FIXME: use mongosh instead of mongo echo 'db.csubs.drop()' | mongo --quiet orion diff --git a/test/valgrind/valgrindTestSuite.sh b/test/valgrind/valgrindTestSuite.sh index ee817af3cc..ce1501235c 100755 --- a/test/valgrind/valgrindTestSuite.sh +++ b/test/valgrind/valgrindTestSuite.sh @@ -103,7 +103,7 @@ function vMsg() # ----------------------------------------------------------------------------- # -# If any mongo database ftest-ftest exists, strange memory leaks appear ... +# If any MongoDB database ftest-ftest exists, strange memory leaks appear ... # So, before starting, it's important to remove all ftest DBs # function dbReset() From 7ca8cc0e42d634da3242cf95e92f1c08d1bd3185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 19 Dec 2023 09:54:29 +0100 Subject: [PATCH 41/44] FIX change MongoDB references from 4.4 to 6.0 --- .github/workflows/functional.yml | 2 +- CHANGES_NEXT_RELEASE | 1 + ci/deb/build-dep.sh | 10 +++------- doc/manuals/admin/build_source.md | 8 +------- doc/manuals/admin/install.md | 2 +- doc/manuals/admin/perf_tuning.md | 2 +- docker/README.md | 6 +++--- docker/docker-compose.yml | 2 +- docker/docker_swarm.md | 2 +- docker/raspberry_pi.md | 2 +- 10 files changed, 14 insertions(+), 23 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 71f83bc156..7b6b61eeea 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -1,4 +1,4 @@ -name: Functional Tests +name: Functional Tests on: push: diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index c3b7ccea03..d8e231d639 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -6,4 +6,5 @@ - Fix: improve logs in MongoDB query logic - Upgrade Debian version from 11.6 to 12.1 in Dockerfile - Hardening: upgrade libmongoc dependency from 1.23.1 to 1.24.3 +- Reference MongoDB version changed from 4.4 to 6.0 - Reference distribution changed from Debian 11 to Debian 12 diff --git a/ci/deb/build-dep.sh b/ci/deb/build-dep.sh index 5ee98b8e5e..7774038150 100755 --- a/ci/deb/build-dep.sh +++ b/ci/deb/build-dep.sh @@ -49,15 +49,11 @@ apt-get -y install \ libsasl2-dev \ libgcrypt-dev -## FIXME: check note in build_source.md about the libssl1 installation hack. It will be no longer needed from MongoDB 6.0 on echo "INSTALL: MongoDB shell" \ -&& curl -L http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb --output libssl1.1_1.1.1f-1ubuntu2_amd64.deb \ -&& dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb \ -&& rm libssl1.1_1.1.1f-1ubuntu2_amd64.deb \ -&& curl -L https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - \ -&& echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list \ +&& curl -L https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add - \ +&& echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/6.0 main" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list \ && apt-get -y update \ -&& apt-get -y install mongodb-org-shell +&& apt-get -y install mongodb-mongosh echo "INSTALL: python special dependencies" \ && cd /opt \ diff --git a/doc/manuals/admin/build_source.md b/doc/manuals/admin/build_source.md index 38bbca42cc..4f6b7caeaa 100644 --- a/doc/manuals/admin/build_source.md +++ b/doc/manuals/admin/build_source.md @@ -107,13 +107,7 @@ The Orion Context Broker comes with a suite of unit, valgrind and end-to-end tes In the case of the aarch64 architecture, install libxslt using apt-get, and run `./configure` with `--build=arm-linux` option. -* Install MongoDB (tests rely on mongod running in localhost). Check [the official MongoDB documentation](hhttps://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-debian/) for details. Recommended version is 4.4 (it may work with previous versions, but we don't recommend it). - * Note that mongo legacy shell (the `mongo` command) has been deprecated in MongoDB 5 and removed in MongoDB 6 in favour of the new shell (`mongosh` command). Some functional tests (ftest) will fail due to this if you use MongoDB 6 or beyond, as they are suited to use `mongo` and not `mongosh`. - * Debian 12 has stepped to libssl3 but some MongoDB versions may require libssl1. In the case you get a `Depends: libssl1.1 (>= 1.1.1) but it is not installable` error, you can test the following (reference [here](https://askubuntu.com/a/1421959)) - - wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb - sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb - rm libssl1.1_1.1.1f-1ubuntu2_amd64.deb # optional, for cleanness +* Install MongoDB (tests rely on mongod running in localhost). Check [the official MongoDB documentation](hhttps://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-debian/) for details. Recommended version is 6.0 (it may work with previous versions, but we don't recommend it). * Run unit test diff --git a/doc/manuals/admin/install.md b/doc/manuals/admin/install.md index 80fdf6b09f..13da6cc513 100644 --- a/doc/manuals/admin/install.md +++ b/doc/manuals/admin/install.md @@ -26,7 +26,7 @@ In the case you are installing Orion building from sources you need: * Operating system: Debian. The reference operating system is Debian 12.1 but it should work also in any later Debian 12 version. * Database: MongoDB is required to run either in the same host where Orion Context Broker is to be installed or in a different host accessible through the network. The recommended MongoDB version - is 4.4 (Orion may work with older versions but we don't recommend it at all!). + is 6.0 (Orion may work with older versions but we don't recommend it at all!). For system resources (CPUs, RAM, etc.) see [these recommendations](diagnosis.md#resource-availability). diff --git a/doc/manuals/admin/perf_tuning.md b/doc/manuals/admin/perf_tuning.md index e3f6ab0c94..a06795f0c2 100644 --- a/doc/manuals/admin/perf_tuning.md +++ b/doc/manuals/admin/perf_tuning.md @@ -20,7 +20,7 @@ ## MongoDB configuration -From a performance point of view, it is recommended to use MongoDB 4.4 with WireTiger, especially +From a performance point of view, it is recommended to use MongoDB 6.0 with WireTiger, especially in update-intensive scenarios. In addition, take into account the following information from the official MongoDB documentation, as it may have diff --git a/docker/README.md b/docker/README.md index 07d9452258..e8cc578dce 100644 --- a/docker/README.md +++ b/docker/README.md @@ -38,7 +38,7 @@ Follow these steps: command: -dbhost mongo mongo: - image: mongo:4.4 + image: mongo:6.0 command: --nojournal 3. Using the command-line and within the directory you created type: `sudo docker-compose up`. @@ -77,7 +77,7 @@ Check that everything works with ### 2B. MongoDB runs on another docker container In case you want to run MongoDB on another container you can launch it like this - sudo docker run --name mongodb -d mongo:4.4 + sudo docker run --name mongodb -d mongo:6.0 And then run Orion with this command @@ -111,7 +111,7 @@ Steps: 4. Run Orion... * Using an automated scenario with docker-compose and building your new image: `sudo docker-compose up`. You may also modify the provided `docker-compose.yml` file if you need so. * Manually, running MongoDB on another container: - 1. `sudo docker run --name mongodb -d mongo:4.4` + 1. `sudo docker run --name mongodb -d mongo:6.0` 2. `sudo docker build -t orion .` 3. `sudo docker run -d --name orion1 --link mongodb:mongodb -p 1026:1026 orion -dbhost mongodb`. * Manually, specifying where to find your MongoDB host: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index cec2de0556..4587af3990 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -10,6 +10,6 @@ services: command: -dbhost mongo mongo: - image: mongo:4.4 + image: mongo:6.0 command: --nojournal diff --git a/docker/docker_swarm.md b/docker/docker_swarm.md index 867a7ee6da..ef30a5b5a4 100644 --- a/docker/docker_swarm.md +++ b/docker/docker_swarm.md @@ -86,7 +86,7 @@ Details on how to deploy a MongoDB ReplicaSet in Docker Swarm are available services: mongo: - image: mongo:4.4 + image: mongo:6.0 entrypoint: [ "/usr/bin/mongod", "--replSet", "rs", "--journal", "--smallfiles", "--bind_ip", "0.0.0.0"] volumes: - mongodata:/data/db diff --git a/docker/raspberry_pi.md b/docker/raspberry_pi.md index 500e5f9894..bbc3615ac6 100644 --- a/docker/raspberry_pi.md +++ b/docker/raspberry_pi.md @@ -49,7 +49,7 @@ services: command: -dbhost mongo mongo: - image: mongo:4.4 + image: mongo:6.0 command: --nojournal ``` From a649bd01da9e48d2ac6b1ef2a3157049f655ae17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 19 Dec 2023 11:33:10 +0100 Subject: [PATCH 42/44] FIX mongo -> mongosh --- test/functionalTest/harnessFunctions.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functionalTest/harnessFunctions.sh b/test/functionalTest/harnessFunctions.sh index f9035f2d9f..2bb06c134f 100644 --- a/test/functionalTest/harnessFunctions.sh +++ b/test/functionalTest/harnessFunctions.sh @@ -1125,7 +1125,8 @@ function dbInsertEntity() port="27017" fi - echo "$jsCode ; $ent ; $doc ; $cmd" | mongo mongodb://$host:$port/$db + #echo "$jsCode ; $ent ; $doc ; $cmd" | mongo mongodb://$host:$port/$db + mongosh mongodb://$host:$port/$db --eval "$jsCode ; $ent ; $doc ; $cmd" --quiet } From a18f72e0d36b74b7eea6a4e3278e5a7ad5fde0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 19 Dec 2023 11:49:34 +0100 Subject: [PATCH 43/44] FIX cleanup comment --- test/functionalTest/harnessFunctions.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/functionalTest/harnessFunctions.sh b/test/functionalTest/harnessFunctions.sh index 2bb06c134f..d1de8a684d 100644 --- a/test/functionalTest/harnessFunctions.sh +++ b/test/functionalTest/harnessFunctions.sh @@ -1125,7 +1125,6 @@ function dbInsertEntity() port="27017" fi - #echo "$jsCode ; $ent ; $doc ; $cmd" | mongo mongodb://$host:$port/$db mongosh mongodb://$host:$port/$db --eval "$jsCode ; $ent ; $doc ; $cmd" --quiet } From 09ecb315e4ef0c6939397fc6687df25cebc69c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 19 Dec 2023 13:07:16 +0100 Subject: [PATCH 44/44] FIX mongo -> mongosh --- .../service_ignore_without_multiservice.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functionalTest/cases/0725_multiservice_ignore/service_ignore_without_multiservice.test b/test/functionalTest/cases/0725_multiservice_ignore/service_ignore_without_multiservice.test index 685b3bb91a..100bea14eb 100644 --- a/test/functionalTest/cases/0725_multiservice_ignore/service_ignore_without_multiservice.test +++ b/test/functionalTest/cases/0725_multiservice_ignore/service_ignore_without_multiservice.test @@ -27,7 +27,7 @@ Ignoring service header when not running in multiservice mode dbInit CB dbInit ${CB_DB_NAME}-foo dbResetAll -echo "show dbs" | mongo | grep ${CB_DB_NAME} | awk '{ print $1 }' +mongosh --eval 'show dbs' | grep ${CB_DB_NAME} | awk '{ print $1 }' brokerStart CB 0-255 IPV4