From f856ede45eb95cc490442751c25bdf89512907e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Fri, 28 Jan 2022 15:43:39 +0100 Subject: [PATCH 01/11] ADD check_legacy_location_metadata.py script --- .../check_legacy_location_metadata.py | 219 ++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 scripts/managedb/upgrade-3.5.0/check_legacy_location_metadata.py diff --git a/scripts/managedb/upgrade-3.5.0/check_legacy_location_metadata.py b/scripts/managedb/upgrade-3.5.0/check_legacy_location_metadata.py new file mode 100644 index 0000000000..4c66409db3 --- /dev/null +++ b/scripts/managedb/upgrade-3.5.0/check_legacy_location_metadata.py @@ -0,0 +1,219 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright 2022 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 + +# Hint: use 'PYTHONIOENCODING=utf8 python check_legacy_location_metadata.py' +# if you are going to redirect the output of this script to a file + + +__author__ = 'fermin' + +from pymongo import MongoClient +import sys + + +def flatten(_id): + """ + The way in which Python manage dictionaries doesn't make easy to be sure + of field ordering, which is important for MongoDB in the case of using an + embedded document for _id. This function helps. + + :param _id: JSON document containing id, type and servicePath + :return: a "flatten" version of the _id + """ + + r = {'_id.id': _id['id']} + + if 'type' in _id: + r['_id.type'] = _id['type'] + else: + r['_id.type'] = {'$exists': False} + + if 'servicePath' in _id: + r['_id.servicePath'] = _id['servicePath'] + else: + r['_id.servicePath'] = {'$exists': False} + + return r + + +def entity_id(doc): + """ + Extracts entity identification keys and returns an object with them + + :param doc: entity document, as taken from DB + :return: {id, type, servicePath} object + """ + id = doc['_id']['id'] + type = doc['_id']['type'] + sp = doc['_id']['servicePath'] + + return {'id': id, 'type': type, 'servicePath': sp} + + +########################## +# Main program starts here + +autofix = False + +if len(sys.argv) != 2: + print "invalid number of arguments, please check https://fiware-orion.readthedocs.io/en/master/admin/upgrading_crossing_3-5-0/index.html" + sys.exit() + +DB = sys.argv[1] + +# Warn user +if autofix: + print "WARNING!!!! This script modifies your '%s' database. It is STRONGLY RECOMMENDED that you" % DB + print "do a backup of your database before using it as described in https://fiware-orion.readthedocs.io/en/master/admin/database_admin/index.html#backup. Use this script at your own risk." + print "If you are sure you want to continue type 'yes' and press Enter" + + confirm = raw_input() + + if confirm != 'yes': + sys.exit() + +uri = 'mongodb://localhost:27017' +client = MongoClient(uri) +db = client[DB] + +need_fix = False +corrupted = False +verbose = True + +# Counters +processed = 0 +counter_location_ngsiv2 = 0 +counter_location_md_wgs84 = 0 +counter_location_md_not_wgs84 = 0 +counter_location_more_than_one = 0 +counter_untouched = 0 +counter_changed = 0 + +corrupted_entities = [] +affected_entities = [] + +total = db['entities'].count() + +print "- processing entities collection (%d entities) looking for attributes with ID metadata, this may take a while... " % total + +# The sort() is a way of ensuring that a modified document doesn't enter again at the end of the cursor (we have +# observed that this may happen with large collections, e.g ~50,000 entities). In addition, we have to use +# batch_size so the cursor doesn't expire at server (see http://stackoverflow.com/questions/10298354/mongodb-cursor-id-not-valid-error). +# The used batch_size value is a heuristic +for entity in db['entities'].find().sort([('_id.id', 1), ('_id.type', -1), ('_id.servicePath', 1)]).batch_size(100): + + processed += 1 + + sys.stdout.write('- processing entity: %d/%d \r' % (processed, total)) + sys.stdout.flush() + + # It may happen that entity doesn't have any attribute. We early detect that situation and skip in that case + if len(entity['attrs'].keys()) == 0: + # print '- %d: entity without attributes %s. Skipping' % (processed, json.dumps(entity['_id'])) + continue # entities loop + + wgs84_attr = None + for attr in entity['attrs']: + if 'md' in entity['attrs'][attr] and 'location' in entity['attrs'][attr]['md']: + if entity['attrs'][attr]['md']['location']['value'] == 'WGS84' \ + or entity['attrs'][attr]['md']['location']['value'] == 'WSG84': + if wgs84_attr is not None: + # more than one location metadata is not allowed due to the checks done by CB + # in processLocationAtEntityCreation() function. However, we check in + # any case as CB could be buggy. Note in this case we don't append to + # affected_entities as that was done first time the location metadata was detected + counter_location_more_than_one += 1 + corrupted = True + corrupted_entities.append(entity_id(entity)) + continue # entities loop + else: + # Note that location metadata doesn't have any semantic in NGSIv2, so we can + # have an entity created with NGSIv2 with location metadata but not location geo-index. + # We need to detect that situation + if "location" in entity: + counter_location_md_wgs84 += 1 + affected_entities.append(entity_id(entity)) + wgs84_attr = attr + else: + counter_location_ngsiv2 += 1 + else: + # location metadata with a value different to WGS84 is not possible taking into + # account the checks done by CB in processLocationAtEntityCreation() function + # However, we check in any case as CB could be buggy + counter_location_md_not_wgs84 += 1 + corrupted = True + corrupted_entities.append(entity_id(entity)) + continue # entities loop + + if wgs84_attr is not None: + if autofix: + # Autofix consist on: + # 1) Remove location metadata (key in 'md' and item in 'mdNames') + # 2) Change attribute type by "geo:point" + + attr = entity['attrs'][wgs84_attr] + attr['mdNames'] = list(filter(lambda x: x != 'location', attr['mdNames'])) + + attr['md'].pop('location', None) + if len(attr['md'].keys()) == 0: + attr.pop('md', None) + + attr['type'] = 'geo:point' + + # it would be easier db['entities'].save(entity) but it seems it has problems when + # _id value is an object and may lead to duplicating entities instead of updating + # note we removed _id from update doc, to avoid possible problems reported by + # pymongo such as "the (immutable) field '_id' was found to have been altered" + query = flatten(entity['_id']) + entity.pop('_id', None) + db['entities'].update(query, entity) + counter_changed += 1 + else: + # Fix should be done by the user + counter_untouched += 1 + need_fix = True + else: + counter_untouched += 1 + +print '- processing entity: %d/%d' % (processed, total) +print '- documents analyzed: %d' % processed +print ' * entities w/ location md w/ WGS84/WSG84 value: %d' % counter_location_md_wgs84 +print ' * entities w/ location md w/o WGS84/WSG84 value (DB corruption!): %d' % counter_location_md_not_wgs84 +print ' * entities w/ more than one location md (DB corruption!): %d' % counter_location_more_than_one +print ' * entities w/ meaningless location md (created by NGSIv2) %d' % counter_location_ngsiv2 +print '- documents processed: %d' % processed +print ' * untouched: %d' % counter_untouched +print ' * changed: %d' % counter_changed + +if verbose: + if len(affected_entities) > 0: + print '- Affected entities:' + for entity in affected_entities: + print ' * ' + str(entity) + if len(corrupted_entities) > 0: + print '- Corrupted entities:' + for entity in corrupted_entities: + print ' * ' + str(entity) + +if need_fix or corrupted: + print "------------------------------------------------------" + print "WARNING: some problem was found during the process. Please check the documentation at https://fiware-orion.readthedocs.io/en/master/admin/upgrading_crossing_3-5-0/index.html" From f015be30281fcd598acc2ed054ad87d84dfbb2d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 2 Feb 2022 13:29:05 +0100 Subject: [PATCH 02/11] REMOVE NGSIv1 location metadata functionality --- CHANGES_NEXT_RELEASE | 1 + src/lib/common/globals.h | 3 - src/lib/mongoBackend/MongoCommonUpdate.cpp | 2 +- src/lib/mongoBackend/location.cpp | 40 +- src/lib/ngsi/ContextAttribute.cpp | 19 +- src/lib/ngsi/ContextAttribute.h | 2 +- src/lib/ngsi/ContextElementResponse.cpp | 30 +- src/lib/ngsi/Metadata.h | 1 - .../geoquery_circle_deprecated.test | 505 ------------ .../legacy_geolocalization_area_json.test | 219 ------ .../legacy_geoquery_bad_coords.test | 253 ------ .../legacy_geoquery_circle_json.test | 502 ------------ .../legacy_geoquery_polygon_json.test | 728 ------------------ ...cy_location_no_actual_location_change.test | 163 ---- .../legacy_wgs84.test | 503 ------------ .../wrong_inclusion_location_metadata_V1.test | 347 --------- ..._location_metadata_V1_V2_and_geoquery.test | 326 -------- .../create_location_attr_V1.test | 215 ------ .../create_location_attr_V2.test | 166 ---- .../get_location_attr_with_V1_creation.test | 176 ----- .../get_location_attr_with_V2_creation.test | 129 ---- .../get_location_attr_with_db_creation.test | 152 ---- 22 files changed, 15 insertions(+), 4467 deletions(-) delete mode 100644 test/functionalTest/cases/0000_deprecated_checkings/geoquery_circle_deprecated.test delete mode 100644 test/functionalTest/cases/0000_deprecated_checkings/legacy_geolocalization_area_json.test delete mode 100644 test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_bad_coords.test delete mode 100644 test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_circle_json.test delete mode 100644 test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_polygon_json.test delete mode 100644 test/functionalTest/cases/0000_deprecated_checkings/legacy_location_no_actual_location_change.test delete mode 100644 test/functionalTest/cases/0000_deprecated_checkings/legacy_wgs84.test delete mode 100644 test/functionalTest/cases/3045_wrong_inclusion_location_metadata_notification/wrong_inclusion_location_metadata_V1.test delete mode 100644 test/functionalTest/cases/3122_location_metadata_issues/create_and_get_location_metadata_V1_V2_and_geoquery.test delete mode 100644 test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V1.test delete mode 100644 test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V2.test delete mode 100644 test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_V1_creation.test delete mode 100644 test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_V2_creation.test delete mode 100644 test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_db_creation.test diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 70f6c9d210..51df6bbc55 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1,2 @@ - Add: ignoreType metadata so Orion ignores attribute type semantic (supported by geo-types at the present moment) (#4032) +- Remove: deprecated NGSIv1 location metadata to specify entity geo-location diff --git a/src/lib/common/globals.h b/src/lib/common/globals.h index 4caa07d716..8abc7b6751 100644 --- a/src/lib/common/globals.h +++ b/src/lib/common/globals.h @@ -44,9 +44,6 @@ #define EARTH_RADIUS_METERS 6371000 -#define LOCATION_WGS84 "WGS84" -#define LOCATION_WGS84_LEGACY "WSG84" // We fixed the right string at 0.17.0, but the old one needs to be mantained - /* **************************************************************************** diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index 76bc31f6ce..3de9e1384c 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -2448,7 +2448,7 @@ static bool deleteContextAttributeItem *entityModified = true; /* Check aspects related with location */ - if (!targetAttr->getLocation(apiVersion).empty()) + if (targetAttr->getLocation(apiVersion)) { std::string details = std::string("action: DELETE") + " - entity: [" + entityDetail + "]" + diff --git a/src/lib/mongoBackend/location.cpp b/src/lib/mongoBackend/location.cpp index b874e33050..d1014f6390 100644 --- a/src/lib/mongoBackend/location.cpp +++ b/src/lib/mongoBackend/location.cpp @@ -340,9 +340,7 @@ bool processLocationAtEntityCreation { const ContextAttribute* caP = caV[ix]; - std::string location = caP->getLocation(apiVersion); - - if (location.empty()) + if (!caP->getLocation(apiVersion)) { continue; } @@ -354,13 +352,6 @@ bool processLocationAtEntityCreation return false; } - if ((location != LOCATION_WGS84) && (location != LOCATION_WGS84_LEGACY)) - { - *errDetail = "only WGS84 are supported, found: " + location; - oe->fill(SccBadRequest, *errDetail, ERROR_BAD_REQUEST); - return false; - } - if (!getGeoJson(caP, geoJson, errDetail, apiVersion)) { oe->fill(SccBadRequest, *errDetail, ERROR_BAD_REQUEST); @@ -390,22 +381,12 @@ bool processLocationAtUpdateAttribute ) { std::string subErr; - std::string locationString = targetAttr->getLocation(apiVersion); - - /* Check that location (if any) is using the correct coordinates string (it only - * makes sense for NGSIv1, this is legacy code that will be eventually removed) */ - if ((!locationString.empty()) && (locationString != LOCATION_WGS84) && (locationString != LOCATION_WGS84_LEGACY)) - { - *errDetail = "only WGS84 is supported for location, found: [" + targetAttr->getLocation() + "]"; - oe->fill(SccBadRequest, *errDetail, ERROR_BAD_REQUEST); - return false; - } // // Case 1: // update *to* location. There are 3 sub-cases // - if (!locationString.empty()) + if (targetAttr->getLocation(apiVersion)) { // // Case 1a: @@ -515,19 +496,10 @@ bool processLocationAtAppendAttribute ) { std::string subErr; - std::string locationString = targetAttr->getLocation(apiVersion); - - /* Check that location (if any) is using the correct coordinates string (it only - * makes sense for NGSIv1, this is legacy code that will be eventually removed) */ - if ((!locationString.empty()) && (locationString != LOCATION_WGS84) && (locationString != LOCATION_WGS84_LEGACY)) - { - *errDetail = "only WGS84 is supported for location, found: [" + targetAttr->getLocation() + "]"; - oe->fill(SccBadRequest, *errDetail, ERROR_BAD_REQUEST); - return false; - } + bool isALocation = targetAttr->getLocation(apiVersion); /* Case 1: append of new location attribute */ - if (actualAppend && (!locationString.empty())) + if (actualAppend && isALocation) { /* Case 1a: there is a previous location attribute -> error */ if (!currentLocAttrName->empty()) @@ -552,7 +524,7 @@ bool processLocationAtAppendAttribute } } /* Case 2: append-as-update changing attribute type from no-location -> location */ - else if (!actualAppend && (!locationString.empty())) + else if (!actualAppend && isALocation) { /* Case 2a: there is a previous (not empty and with different name) location attribute -> error */ if ((!currentLocAttrName->empty()) && (*currentLocAttrName != targetAttr->name)) @@ -588,7 +560,7 @@ bool processLocationAtAppendAttribute } /* Check 3: in the case of append-as-update, type changes from location -> no-location for the current location * attribute, then remove location attribute */ - else if (!actualAppend && (locationString.empty()) && (*currentLocAttrName == targetAttr->name)) + else if (!actualAppend && !isALocation && (*currentLocAttrName == targetAttr->name)) { *currentLocAttrName = ""; } diff --git a/src/lib/ngsi/ContextAttribute.cpp b/src/lib/ngsi/ContextAttribute.cpp index 93aec55ef5..73a7110b95 100644 --- a/src/lib/ngsi/ContextAttribute.cpp +++ b/src/lib/ngsi/ContextAttribute.cpp @@ -550,25 +550,16 @@ ContextAttribute::ContextAttribute * * ContextAttribute::getLocation() - */ -std::string ContextAttribute::getLocation(ApiVersion apiVersion) const +bool ContextAttribute::getLocation(ApiVersion apiVersion) const { if (apiVersion == V1) { - // Deprecated way, but still supported - for (unsigned int ix = 0; ix < metadataVector.size(); ++ix) - { - if (metadataVector[ix]->name == NGSI_MD_LOCATION) - { - return metadataVector[ix]->stringValue; - } - } - // Current way of declaring location in NGSIv1, aligned with NGSIv2 (originally only only geo:point was supported // but doing so have problems so we need to support all them at the end, // see https://github.com/telefonicaid/fiware-orion/issues/3442 for details) if ((type == GEO_POINT) || (type == GEO_LINE) || (type == GEO_BOX) || (type == GEO_POLYGON) || (type == GEO_JSON)) { - return LOCATION_WGS84; + return true; } } else // v2 @@ -583,15 +574,15 @@ std::string ContextAttribute::getLocation(ApiVersion apiVersion) const { if ((metadataVector[ix]->valueType == orion::ValueTypeBoolean) && (metadataVector[ix]->boolValue == true)) { - return ""; + return false; } } } - return LOCATION_WGS84; + return true; } } - return ""; + return false; } diff --git a/src/lib/ngsi/ContextAttribute.h b/src/lib/ngsi/ContextAttribute.h index 4995a8b7b8..d490859419 100644 --- a/src/lib/ngsi/ContextAttribute.h +++ b/src/lib/ngsi/ContextAttribute.h @@ -92,7 +92,7 @@ typedef struct ContextAttribute ContextAttribute(const std::string& _name, const std::string& _type, orion::CompoundValueNode* _compoundValueP); /* Grabbers for metadata to which CB gives a special semantic */ - std::string getLocation(ApiVersion apiVersion = V1) const; + bool getLocation(ApiVersion apiVersion = V1) const; std::string toJsonV1(bool asJsonObject, RequestType request, diff --git a/src/lib/ngsi/ContextElementResponse.cpp b/src/lib/ngsi/ContextElementResponse.cpp index 1a140f5981..68c80aea06 100644 --- a/src/lib/ngsi/ContextElementResponse.cpp +++ b/src/lib/ngsi/ContextElementResponse.cpp @@ -136,7 +136,6 @@ ContextElementResponse::ContextElementResponse orion::BSONObj attr = getObjectFieldF(attrs, attrName); ContextAttribute* caP = NULL; ContextAttribute ca; - bool noLocationMetadata = true; // Name and type ca.name = dbDecode(attrName); @@ -215,7 +214,7 @@ ContextElementResponse::ContextElementResponse /* Setting custom metadata (if any) */ if (attr.hasField(ENT_ATTRS_MD)) { - orion::BSONObj mds = getObjectFieldF(attr, ENT_ATTRS_MD); + orion::BSONObj mds = getObjectFieldF(attr, ENT_ATTRS_MD); std::set mdsSet; mds.getFieldNames(&mdsSet); @@ -223,33 +222,6 @@ ContextElementResponse::ContextElementResponse { std::string currentMd = *i; Metadata* md = new Metadata(dbDecode(currentMd), getObjectFieldF(mds, currentMd)); - - /* The flag below indicates that a location metadata with WGS84 was found during iteration. - * It needs to the NGSIV1 check below, in order to add it if the flag is false - * In addition, adjust old wrong WSG84 metadata value with WGS84 */ - if (md->name == NGSI_MD_LOCATION) - { - noLocationMetadata = false; - - if (md->valueType == orion::ValueTypeString && md->stringValue == LOCATION_WGS84_LEGACY) - { - md->stringValue = LOCATION_WGS84; - } - } - - caP->metadataVector.push_back(md); - } - } - - if (apiVersion == V1) - { - /* Setting location metadata (if location attr found - * and the location metadata was not present or was present but with old wrong WSG84 value) */ - if ((locAttr == ca.name) && (ca.type != GEO_POINT) && noLocationMetadata) - { - /* Note that if attribute type is geo:point then the user is using the "new way" - * of locating entities in NGSIv1, thus location metadata is not rendered */ - Metadata* md = new Metadata(NGSI_MD_LOCATION, "string", LOCATION_WGS84); caP->metadataVector.push_back(md); } } diff --git a/src/lib/ngsi/Metadata.h b/src/lib/ngsi/Metadata.h index 1033020c08..d42a8de7f0 100644 --- a/src/lib/ngsi/Metadata.h +++ b/src/lib/ngsi/Metadata.h @@ -44,7 +44,6 @@ * * Metadata interpreted by Orion Context Broker, i.e. not custom metadata */ -#define NGSI_MD_LOCATION "location" // Deprecated (NGSIv1) #define NGSI_MD_IGNORE_TYPE "ignoreType" #define NGSI_MD_PREVIOUSVALUE "previousValue" // Special metadata #define NGSI_MD_ACTIONTYPE "actionType" // Special metadata diff --git a/test/functionalTest/cases/0000_deprecated_checkings/geoquery_circle_deprecated.test b/test/functionalTest/cases/0000_deprecated_checkings/geoquery_circle_deprecated.test deleted file mode 100644 index f69a093708..0000000000 --- a/test/functionalTest/cases/0000_deprecated_checkings/geoquery_circle_deprecated.test +++ /dev/null @@ -1,505 +0,0 @@ -# Copyright 2014 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-- -Geo query circle - deprecated - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- -# The tests in this file use FIWARE_Location (instead of FIWARE::Location), which was deprecated -# in Orion 0.16.0 - -echo "1. Create entity corresponding to Madrid" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Madrid", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -echo -sleep 1.1 - -echo "2. Create entity corresponding to Alcobendas" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Alcobendas", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.533333, -3.633333", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -echo -sleep 1.1 - - -echo "3. Create entity corresponding to Leganes" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Leganes", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.316667, -3.75", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" - - -echo "4: ++++++++++ Madrid in 13.5 kms ++++++++++" -# Query inside 13.5 kms radius from Madrid center -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "City", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE_Location", - "value" : { - "circle": { - "centerLatitude": "40.418889", - "centerLongitude": "-3.691944", - "radius": "13500" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" - -echo "5: +++++++++++ Madrid in 15 kms +++++++++" -# Query inside 15 kms radius from Madrid center -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "City", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE_Location", - "value" : { - "circle": { - "centerLatitude": "40.418889", - "centerLongitude": "-3.691944", - "radius": "15000" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" - -echo "6: ++++++++++++ Madrid out 13.5 kms ++++++++" -# Query in 13.5 kms radius outside Madrid center -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "City", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE_Location", - "value" : { - "circle": { - "centerLatitude": "40.418889", - "centerLongitude": "-3.691944", - "radius": "13500", - "inverted": "true" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" - ---REGEXPECT-- -1. Create entity corresponding to Madrid -HTTP/1.1 200 OK -Content-Length: 267 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - -2. Create entity corresponding to Alcobendas -HTTP/1.1 200 OK -Content-Length: 271 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Alcobendas", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - -3. Create entity corresponding to Leganes -HTTP/1.1 200 OK -Content-Length: 268 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Leganes", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -4: ++++++++++ Madrid in 13.5 kms ++++++++++ -HTTP/1.1 200 OK -Content-Length: 549 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.316667, -3.75" - } - ], - "id": "Leganes", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -5: +++++++++++ Madrid in 15 kms +++++++++ -HTTP/1.1 200 OK -Content-Length: 818 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.533333, -3.633333" - } - ], - "id": "Alcobendas", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.316667, -3.75" - } - ], - "id": "Leganes", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -6: ++++++++++++ Madrid out 13.5 kms ++++++++ -HTTP/1.1 200 OK -Content-Length: 291 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.533333, -3.633333" - } - ], - "id": "Alcobendas", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/0000_deprecated_checkings/legacy_geolocalization_area_json.test b/test/functionalTest/cases/0000_deprecated_checkings/legacy_geolocalization_area_json.test deleted file mode 100644 index 97da9251a2..0000000000 --- a/test/functionalTest/cases/0000_deprecated_checkings/legacy_geolocalization_area_json.test +++ /dev/null @@ -1,219 +0,0 @@ -# Copyright 2014 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-- -Geo-localization JSON test (based on deprecated location metadata) - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- -echo "0: ++++++++++++++++++++" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "Room", - "isPattern": "false", - "id": "OfficeRoom", - "attributes": [ - { - "name": "location", - "type": "centigrade", - "value": "-3.5, 45.20", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" - -echo "1: ++++++++++++++++++++" -url="/v1/subscribeContext" -payload='{ - "entities": [ - { - "type": "Room", - "isPattern": "false", - "id": "OfficeRoom" - } - ], - "attributes": [ - "temperature", - "lightstatus" - ], - "reference": "http://127.0.0.1:'${LISTENER_PORT}'/notify", - "duration": "PT1H", - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "circle": { - "centerLatitude": "40", - "centerLongitude": "20", - "radius": "5" - } - } - } - ] - }, - "notifyConditions": [ - { - "type": "ONCHANGE", - "condValues": [ - "temperature", - "lightstatus" - ] - } - ] -}' -orionCurl --url "$url" --payload "$payload" - -echo "2: ++++++++++++++++++++" -url="/v1/subscribeContext" -payload='{ - "entities": [ - { - "type": "Room", - "isPattern": "false", - "id": "OfficeRoom" - } - ], - "attributes": [ - "temperature", - "lightstatus" - ], - "reference": "http://127.0.0.1:'${LISTENER_PORT}'/notify", - "duration": "PT1H", - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "polygon": { - "vertices": [ - { - "latitude": "40", - "longitude": "20" - }, - { - "latitude": "45", - "longitude": "45" - }, - { - "latitude": "35", - "longitude": "10" - } - ] - } - } - } - ] - }, - "notifyConditions": [ - { - "type": "ONCHANGE", - "condValues": [ - "temperature", - "lightstatus" - ] - } - ] -}' -orionCurl --url "$url" --payload "$payload" - ---REGEXPECT-- -0: ++++++++++++++++++++ -HTTP/1.1 200 OK -Content-Length: 275 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "centigrade", - "value": "" - } - ], - "id": "OfficeRoom", - "isPattern": "false", - "type": "Room" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -1: ++++++++++++++++++++ -HTTP/1.1 200 OK -Content-Length: 85 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "subscribeResponse": { - "duration": "PT1H", - "subscriptionId": "REGEX([0-9a-f]{24})" - } -} -2: ++++++++++++++++++++ -HTTP/1.1 200 OK -Content-Length: 85 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "subscribeResponse": { - "duration": "PT1H", - "subscriptionId": "REGEX([0-9a-f]{24})" - } -} ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_bad_coords.test b/test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_bad_coords.test deleted file mode 100644 index b0733cfdb6..0000000000 --- a/test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_bad_coords.test +++ /dev/null @@ -1,253 +0,0 @@ -# Copyright 2014 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-- -Geo query with invalid coordinates (based on deprecated location metadata) - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -echo "1: +++++++++ Update/Append +++++++++++" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Long200Lat100", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "200, 100", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -echo -echo - -echo "2: ++++++++++ OK Query ++++++++++" -# query according to issue #461 -url=/v1/queryContext -payload='{ - "entities": [ - { - "type": "Point", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "polygon": { - "vertices": [ - { "latitude" : 2.811371193331, "longitude" : 130.078061 }, - { "latitude" : 13.031027211328, "longitude" : 130.078061 }, - { "latitude" : 13.031027211328, "longitude" : 140.24472766667 }, - { "latitude" : 2.811371193331, "longitude" : 140.24472766667 } - ] - } - } - } - ] - } -}' - -orionCurl --url "$url" --payload "${payload}" -echo -echo - -echo "3: ++++++++++ Query with invalid latitude ++++++++++" -url=/v1/queryContext -payload='{ - "entities": [ - { - "type": "Point", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "polygon": { - "vertices": [ - { "latitude" : 92.811371193331, "longitude" : 130.078061 }, - { "latitude" : 13.031027211328, "longitude" : 130.078061 }, - { "latitude" : 13.031027211328, "longitude" : 140.24472766667 }, - { "latitude" : 2.811371193331, "longitude" : 140.24472766667 } - ] - } - } - } - ] - } -}' - -orionCurl --url "$url" --payload "${payload}" -echo -echo - - -echo "4: ++++++++++ Query with invalid longitude ++++++++++" -url=/v1/queryContext -payload='{ - "entities": [ - { - "type": "Point", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "polygon": { - "vertices": [ - { "latitude" : 12.811371193331, "longitude" : 130.078061 }, - { "latitude" : 13.031027211328, "longitude" : 130.078061 }, - { "latitude" : 13.031027211328, "longitude" : 240.24472766667 }, - { "latitude" : 2.811371193331, "longitude" : 140.24472766667 } - ] - } - } - } - ] - } -}' - -orionCurl --url "$url" --payload "${payload}" -echo -echo - - ---REGEXPECT-- -1: +++++++++ Update/Append +++++++++++ -HTTP/1.1 200 OK -Content-Length: 387 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Long200Lat100", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "472", - "details": "geo coordinates format error [see Orion user manual]: 200, 100", - "reasonPhrase": "request parameter is invalid/not allowed" - } - } - ] -} - - -2: ++++++++++ OK Query ++++++++++ -HTTP/1.1 200 OK -Content-Length: 70 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "errorCode": { - "code": "404", - "reasonPhrase": "No context element found" - } -} - - -3: ++++++++++ Query with invalid latitude ++++++++++ -HTTP/1.1 200 OK -Content-Length: 96 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "errorCode": { - "code": "400", - "details": "invalid value for latitude", - "reasonPhrase": "Bad Request" - } -} - - -4: ++++++++++ Query with invalid longitude ++++++++++ -HTTP/1.1 200 OK -Content-Length: 97 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "errorCode": { - "code": "400", - "details": "invalid value for longitude", - "reasonPhrase": "Bad Request" - } -} - - ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_circle_json.test b/test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_circle_json.test deleted file mode 100644 index 2c24c9dbe7..0000000000 --- a/test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_circle_json.test +++ /dev/null @@ -1,502 +0,0 @@ -# Copyright 2014 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-- -Geo query (circle) JSON test (based on deprecated location metadata) - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- -echo "1. Create entity corresponding to Madrid" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Madrid", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -echo -sleep 1.1 - -echo "2. Create entity corresponding to Alcobendas" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Alcobendas", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.533333, -3.633333", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -echo -sleep 1.1 - - -echo "3. Create entity corresponding to Leganes" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Leganes", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.316667, -3.75", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" - - -echo "4: ++++++++++ Madrid in 13.5 kms ++++++++++" -# Query inside 13.5 kms radius from Madrid center -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "City", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "circle": { - "centerLatitude": "40.418889", - "centerLongitude": "-3.691944", - "radius": "13500" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" - -echo "5: +++++++++++ Madrid in 15 kms +++++++++" -# Query inside 15 kms radius from Madrid center -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "City", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "circle": { - "centerLatitude": "40.418889", - "centerLongitude": "-3.691944", - "radius": "15000" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" - -echo "6: ++++++++++++ Madrid out 13.5 kms ++++++++" -# Query in 13.5 kms radius outside Madrid center -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "City", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "circle": { - "centerLatitude": "40.418889", - "centerLongitude": "-3.691944", - "radius": "13500", - "inverted": "true" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" - ---REGEXPECT-- -1. Create entity corresponding to Madrid -HTTP/1.1 200 OK -Content-Length: 267 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - -2. Create entity corresponding to Alcobendas -HTTP/1.1 200 OK -Content-Length: 271 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Alcobendas", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - -3. Create entity corresponding to Leganes -HTTP/1.1 200 OK -Content-Length: 268 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Leganes", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -4: ++++++++++ Madrid in 13.5 kms ++++++++++ -HTTP/1.1 200 OK -Content-Length: 549 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.316667, -3.75" - } - ], - "id": "Leganes", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -5: +++++++++++ Madrid in 15 kms +++++++++ -HTTP/1.1 200 OK -Content-Length: 818 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.533333, -3.633333" - } - ], - "id": "Alcobendas", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.316667, -3.75" - } - ], - "id": "Leganes", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -6: ++++++++++++ Madrid out 13.5 kms ++++++++ -HTTP/1.1 200 OK -Content-Length: 291 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.533333, -3.633333" - } - ], - "id": "Alcobendas", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_polygon_json.test b/test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_polygon_json.test deleted file mode 100644 index cd4c82d4a9..0000000000 --- a/test/functionalTest/cases/0000_deprecated_checkings/legacy_geoquery_polygon_json.test +++ /dev/null @@ -1,728 +0,0 @@ -# Copyright 2014 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-- -Geo query test (polygon) (based on deprecated location metadata) - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- -echo "1: +++++++++ Point A +++++++++++" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "Point", - "isPattern": "false", - "id": "A", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "3, 2", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -sleep 1.1 -echo -echo - - -echo "2: +++++++++ Point B +++++++++++" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "Point", - "isPattern": "false", - "id": "B", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "5, 5", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -sleep 1.1 -echo -echo - - -echo "3: +++++++++ Point C +++++++++++" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "Point", - "isPattern": "false", - "id": "C", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "7, 4", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -sleep 1.1 -echo -echo - - -echo "4: ++++++++++ Rectangle in: A, B ++++++++++" -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "Point", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "polygon": { - "vertices": [ - { - "latitude": "0", - "longitude": "0" - }, - { - "latitude": "0", - "longitude": "6" - }, - { - "latitude": "6", - "longitude": "6" - }, - { - "latitude": "6", - "longitude": "0" - } - ] - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" -echo -echo - - -echo "5: ++++++++++ Rectangle in: B, C ++++++++++" -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "Point", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "polygon": { - "vertices": [ - { - "latitude": "3", - "longitude": "3" - }, - { - "latitude": "3", - "longitude": "8" - }, - { - "latitude": "11", - "longitude": "8" - }, - { - "latitude": "11", - "longitude": "3" - } - ] - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" -echo -echo - - -echo "6: ++++++++++ Triangle in: A ++++++++++" -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "Point", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "polygon": { - "vertices": [ - { - "latitude": "0", - "longitude": "0" - }, - { - "latitude": "0", - "longitude": "6" - }, - { - "latitude": "6", - "longitude": "0" - } - ] - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" -echo -echo - - -echo "7: ++++++++++ Rectangle out: A ++++++++++" -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "Point", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "polygon": { - "vertices": [ - { - "latitude": "3", - "longitude": "3" - }, - { - "latitude": "3", - "longitude": "8" - }, - { - "latitude": "11", - "longitude": "8" - }, - { - "latitude": "11", - "longitude": "3" - } - ], - "inverted": "true" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" -echo -echo - - -echo "8: ++++++++++ Triangle out: B, C ++++++++++" -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "Point", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "polygon": { - "vertices": [ - { - "latitude": "0", - "longitude": "0" - }, - { - "latitude": "0", - "longitude": "6" - }, - { - "latitude": "6", - "longitude": "0" - } - ], - "inverted": "true" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" -echo -echo - - ---REGEXPECT-- -1: +++++++++ Point A +++++++++++ -HTTP/1.1 200 OK -Content-Length: 263 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "A", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -2: +++++++++ Point B +++++++++++ -HTTP/1.1 200 OK -Content-Length: 263 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "B", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -3: +++++++++ Point C +++++++++++ -HTTP/1.1 200 OK -Content-Length: 263 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "C", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -4: ++++++++++ Rectangle in: A, B ++++++++++ -HTTP/1.1 200 OK -Content-Length: 512 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "3, 2" - } - ], - "id": "A", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "5, 5" - } - ], - "id": "B", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -5: ++++++++++ Rectangle in: B, C ++++++++++ -HTTP/1.1 200 OK -Content-Length: 512 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "5, 5" - } - ], - "id": "B", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "7, 4" - } - ], - "id": "C", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -6: ++++++++++ Triangle in: A ++++++++++ -HTTP/1.1 200 OK -Content-Length: 267 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "3, 2" - } - ], - "id": "A", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -7: ++++++++++ Rectangle out: A ++++++++++ -HTTP/1.1 200 OK -Content-Length: 267 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "3, 2" - } - ], - "id": "A", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -8: ++++++++++ Triangle out: B, C ++++++++++ -HTTP/1.1 200 OK -Content-Length: 512 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "5, 5" - } - ], - "id": "B", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "7, 4" - } - ], - "id": "C", - "isPattern": "false", - "type": "Point" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/0000_deprecated_checkings/legacy_location_no_actual_location_change.test b/test/functionalTest/cases/0000_deprecated_checkings/legacy_location_no_actual_location_change.test deleted file mode 100644 index 857588bd7a..0000000000 --- a/test/functionalTest/cases/0000_deprecated_checkings/legacy_location_no_actual_location_change.test +++ /dev/null @@ -1,163 +0,0 @@ -# Copyright 2014 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-- -Location - no actual location change (based on deprecated location metadata) - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- -echo "0: ++++++++++++++++++++" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "Room", - "isPattern": "false", - "id": "OfficeRoom", - "attributes": [ - { - "name": "location", - "type": "centigrade", - "value": "-3.5, 45.20", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" - -echo "1: ++++++++++++++++++++" - -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "Room", - "isPattern": "false", - "id": "OfficeRoom", - "attributes": [ - { - "name": "location", - "type": "centigrade", - "value": "-3.6, 48.20", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" - ---REGEXPECT-- -0: ++++++++++++++++++++ -HTTP/1.1 200 OK -Content-Length: 275 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "centigrade", - "value": "" - } - ], - "id": "OfficeRoom", - "isPattern": "false", - "type": "Room" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -1: ++++++++++++++++++++ -HTTP/1.1 200 OK -Content-Length: 275 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "centigrade", - "value": "" - } - ], - "id": "OfficeRoom", - "isPattern": "false", - "type": "Room" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/0000_deprecated_checkings/legacy_wgs84.test b/test/functionalTest/cases/0000_deprecated_checkings/legacy_wgs84.test deleted file mode 100644 index 4d2268ab34..0000000000 --- a/test/functionalTest/cases/0000_deprecated_checkings/legacy_wgs84.test +++ /dev/null @@ -1,503 +0,0 @@ -# Copyright 2014 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-- -Geo query circle (old wrong WSG84 token) - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -echo "1. Create entity corresponding to Madrid" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Madrid", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WSG84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -echo -sleep 1.1 - -echo "2. Create entity corresponding to Alcobendas" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Alcobendas", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.533333, -3.633333", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WSG84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" -echo -sleep 1.1 - - -echo "3. Create entity corresponding to Leganes" -url="/v1/updateContext" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Leganes", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.316667, -3.75", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WSG84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url "$url" --payload "$payload" - - -echo "4: ++++++++++ Madrid in 13.5 kms ++++++++++" -# Query inside 13.5 kms radius from Madrid center -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "City", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "circle": { - "centerLatitude": "40.418889", - "centerLongitude": "-3.691944", - "radius": "13500" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" - -echo "5: +++++++++++ Madrid in 15 kms +++++++++" -# Query inside 15 kms radius from Madrid center -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "City", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "circle": { - "centerLatitude": "40.418889", - "centerLongitude": "-3.691944", - "radius": "15000" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" - -echo "6: ++++++++++++ Madrid out 13.5 kms ++++++++" -# Query in 13.5 kms radius outside Madrid center -url="/v1/queryContext" -payload='{ - "entities": [ - { - "type": "City", - "isPattern": "true", - "id": ".*" - } - ], - "restriction": { - "scopes": [ - { - "type" : "FIWARE::Location", - "value" : { - "circle": { - "centerLatitude": "40.418889", - "centerLongitude": "-3.691944", - "radius": "13500", - "inverted": "true" - } - } - } - ] - } -}' -orionCurl --url "$url" --payload "$payload" - ---REGEXPECT-- -1. Create entity corresponding to Madrid -HTTP/1.1 200 OK -Content-Length: 267 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WSG84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - -2. Create entity corresponding to Alcobendas -HTTP/1.1 200 OK -Content-Length: 271 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WSG84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Alcobendas", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - -3. Create entity corresponding to Leganes -HTTP/1.1 200 OK -Content-Length: 268 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WSG84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Leganes", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -4: ++++++++++ Madrid in 13.5 kms ++++++++++ -HTTP/1.1 200 OK -Content-Length: 549 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.316667, -3.75" - } - ], - "id": "Leganes", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -5: +++++++++++ Madrid in 15 kms +++++++++ -HTTP/1.1 200 OK -Content-Length: 818 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.533333, -3.633333" - } - ], - "id": "Alcobendas", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.316667, -3.75" - } - ], - "id": "Leganes", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -6: ++++++++++++ Madrid out 13.5 kms ++++++++ -HTTP/1.1 200 OK -Content-Length: 291 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "location", - "type": "coords", - "value": "40.533333, -3.633333" - } - ], - "id": "Alcobendas", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/3045_wrong_inclusion_location_metadata_notification/wrong_inclusion_location_metadata_V1.test b/test/functionalTest/cases/3045_wrong_inclusion_location_metadata_notification/wrong_inclusion_location_metadata_V1.test deleted file mode 100644 index aa95e78fda..0000000000 --- a/test/functionalTest/cases/3045_wrong_inclusion_location_metadata_notification/wrong_inclusion_location_metadata_V1.test +++ /dev/null @@ -1,347 +0,0 @@ -# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Check "location" metadata is included in NGSIv1 notifications -triggered by NGSIV1 subscription creation, update or attribute update - ---SHELL-INIT-- -dbInit CB -brokerStart CB -accumulatorStart --pretty-print - ---SHELL-- - -# -# 01. Create NGSIv1 subscription for E -# 02. Create E with type T -# 03. Trigger notification by updating value of "name" attribute (in NGSIv1) -# 04. See NGSIv1 notifications and make sure "location" metadata is included -# -# FIXME P2: it seems that in the first notification metadata is no included. This -# makes me think that some difference between create entity and update entity logic -# is causing not including it in the first case. However, given that NGSIv1 is -# deprecated, we are not going to invest effort in fixing this problem. -# - - -echo "01. Create NGSIv1 subscription for E" -echo "====================================" -payload='{ - "entities": [ - { - "type": "T", - "isPattern": "false", - "id": "E" - } - ], - "attributes": [], - "reference": "http://localhost:'$LISTENER_PORT'/notify", - "notifyConditions": [ - { - "type": "ONCHANGE", - "condValues": [] - } - ] -}' -orionCurl --url /v1/subscribeContext --payload "$payload" -echo -echo - -SUB_ID=$(echo "$_response" | grep subscriptionId | awk -F\" '{ print $4 }') - - -echo "02. Create E with type: T" -echo "=========================" -payload='{ - "id": "E", - "type": "T", - "name":{ - "value": "SD3", - "type": "Text" - }, - "perimeter": { - "type":"geo:json", - "value":{ - "type": "Polygon", - "coordinates": [ - [ - [-13.806454999999991,33.46727800000001,0], - [-13.806707999999981,33.46723400000001,0], - [-13.806863999999999,33.46720599999997,0], - [-13.807017000000008,33.46719100000001,0], - [-13.806454999999991,33.46727800000001,0] - ] - ] - } - } -}' -orionCurl --url /v2/entities --payload "$payload" -echo -echo - - -echo "03. Trigger notification by updating value of name attribute (in NGSIv1)" -echo "========================================================================" -payload='{ - "contextElements": [ - { - "type": "T", - "isPattern": "false", - "id": "E", - "attributes": [ - { - "name": "name", - "type": "string", - "value": "2" - } - ] - } - ], - "updateAction": "UPDATE" -}' -orionCurl --url /v1/updateContext --payload "$payload" -echo -echo - - -echo "04. See NGSIv1 notifications and make sure location metadata is included" -echo "========================================================================" -accumulatorDump -echo -echo - - ---REGEXPECT-- -01. Create NGSIv1 subscription for E -==================================== -HTTP/1.1 200 OK -Content-Length: 86 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "subscribeResponse": { - "duration": "PT24H", - "subscriptionId": "REGEX([0-9a-f]{24})" - } -} - - -02. Create E with type: T -========================= -HTTP/1.1 201 Created -Content-Length: 0 -Location: /v2/entities/E?type=T -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - - - -03. Trigger notification by updating value of name attribute (in NGSIv1) -======================================================================== -HTTP/1.1 200 OK -Content-Length: 189 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "name": "name", - "type": "string", - "value": "" - } - ], - "id": "E", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -04. See NGSIv1 notifications and make sure location metadata is included -======================================================================== -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 468 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "name": "name", - "type": "Text", - "value": "SD3" - }, - { - "name": "perimeter", - "type": "geo:json", - "value": { - "coordinates": [ - [ - [ - -13.806455, - 33.467278, - 0 - ], - [ - -13.806708, - 33.467234, - 0 - ], - [ - -13.806864, - 33.467206, - 0 - ], - [ - -13.807017, - 33.467191, - 0 - ], - [ - -13.806455, - 33.467278, - 0 - ] - ] - ], - "type": "Polygon" - } - } - ], - "id": "E", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 534 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "name": "name", - "type": "string", - "value": "2" - }, - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "perimeter", - "type": "geo:json", - "value": { - "coordinates": [ - [ - [ - -13.806455, - 33.467278, - 0 - ], - [ - -13.806708, - 33.467234, - 0 - ], - [ - -13.806864, - 33.467206, - 0 - ], - [ - -13.807017, - 33.467191, - 0 - ], - [ - -13.806455, - 33.467278, - 0 - ] - ] - ], - "type": "Polygon" - } - } - ], - "id": "E", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - ---TEARDOWN-- -brokerStop CB -dbDrop CB -accumulatorStop diff --git a/test/functionalTest/cases/3122_location_metadata_issues/create_and_get_location_metadata_V1_V2_and_geoquery.test b/test/functionalTest/cases/3122_location_metadata_issues/create_and_get_location_metadata_V1_V2_and_geoquery.test deleted file mode 100644 index 6449c0539b..0000000000 --- a/test/functionalTest/cases/3122_location_metadata_issues/create_and_get_location_metadata_V1_V2_and_geoquery.test +++ /dev/null @@ -1,326 +0,0 @@ -# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Create 2 entities, both with an attribute containing a location metadata. -One with NGSIv1 POST (old way of defining location attribute), the other one with NGSIv2 POST. -See that getting entities both in NGSIV1 and NGSIV2, the attribute metadatas are correctly rendered. -In addition, see that Geoqueries returns only the entity (E2) created with the NGSIv1 way of defining location attribute -and then contained in the polygon and bounding box of the geo query. - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -# -# 01. Create E1 with NGSIV2 -# 02. Create E2 with NGSIV1 -# 03. Get E1 and E2 with NGSIV2 -# 04. Get E1 and E2 with NGSIV1 -# 05. Make a Geo query with a polygon and check that only E2 is returned -# 06. Make a Geo query with a bounding box and check that only E2 is returned - -echo "01. Create E1 with NGSIV2" -echo "=========================" -payload=' -{ - "id": "E1", - "type": "T", - "A": { - "value": "40, -3", - "type": "whatever", - "metadata": { - "location": { - "type": "string", - "value": "WGS84" - } - } - } -} -' -orionCurl --url '/v2/entities' --payload "$payload" -echo -echo - - -echo "02. Create E2 with NGSIV1" -echo "=========================" -payload=' -{ - "attributes": [ - { - "name": "A", - "type": "whatever", - "value": "39,-2", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] -} -' -orionCurl --url '/v1/contextEntities/type/T/id/E2' --payload "$payload" -echo -echo - - -echo "03. Get E1 and E2 with NGSIV2" -echo "=============================" -orionCurl --url /v2/entities -echo -echo - - -echo "04. Get E1 and E2 with NGSIV1" -echo "=============================" -orionCurl --url /v1/contextEntities -echo -echo - - -echo "05. Make a Geo query with a polygon and check that only E2 is returned" -echo "======================================================================" -orionCurl --url '/v2/entities?georel=coveredBy&coords=0,0;50,0;50,-50;0,-50;0,0&geometry=polygon' -echo -echo - - -echo "06. Make a Geo query with a bounding box and check that only E2 is returned" -echo "===========================================================================" -orionCurl --url '/v2/entities?georel=coveredBy&coords=0,0;50,-50&geometry=box' -echo -echo - - ---REGEXPECT-- -01. Create E1 with NGSIV2 -========================= -HTTP/1.1 201 Created -Content-Length: 0 -Location: /v2/entities/E1?type=T -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - - - -02. Create E2 with NGSIV1 -========================= -HTTP/1.1 200 OK -Content-Length: 236 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "A", - "type": "whatever", - "value": "" - } - ], - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "id": "E2", - "isPattern": "false", - "type": "T" -} - - -03. Get E1 and E2 with NGSIV2 -============================= -HTTP/1.1 200 OK -Content-Length: 244 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -[ - { - "A": { - "metadata": { - "location": { - "type": "string", - "value": "WGS84" - } - }, - "type": "whatever", - "value": "40, -3" - }, - "id": "E1", - "type": "T" - }, - { - "A": { - "metadata": { - "location": { - "type": "string", - "value": "WGS84" - } - }, - "type": "whatever", - "value": "39,-2" - }, - "id": "E2", - "type": "T" - } -] - - -04. Get E1 and E2 with NGSIV1 -============================= -HTTP/1.1 200 OK -Content-Length: 499 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "A", - "type": "whatever", - "value": "40, -3" - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }, - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "A", - "type": "whatever", - "value": "39,-2" - } - ], - "id": "E2", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -05. Make a Geo query with a polygon and check that only E2 is returned -====================================================================== -HTTP/1.1 200 OK -Content-Length: 122 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -[ - { - "A": { - "metadata": { - "location": { - "type": "string", - "value": "WGS84" - } - }, - "type": "whatever", - "value": "39,-2" - }, - "id": "E2", - "type": "T" - } -] - - -06. Make a Geo query with a bounding box and check that only E2 is returned -=========================================================================== -HTTP/1.1 200 OK -Content-Length: 122 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -[ - { - "A": { - "metadata": { - "location": { - "type": "string", - "value": "WGS84" - } - }, - "type": "whatever", - "value": "39,-2" - }, - "id": "E2", - "type": "T" - } -] - - ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V1.test b/test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V1.test deleted file mode 100644 index 73cd8842ed..0000000000 --- a/test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V1.test +++ /dev/null @@ -1,215 +0,0 @@ -# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Create 2 entities with NGSIV1 POST. One with the location metadata (defining a location attribute -according to the "old way"), the other without a location metadata (and then without location attribute) -Then check both entities in DB. - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -# -# 01. Create E1 with NGSIV1 with location metadata -# 02. Create E2 with NGSIV1 without location metadata -# 03. Check E1 entity in DB has location metadata and location GeoJSON field -# 04. Check E2 entity in DB has no location metadata nor location GeoJSON field - -echo "01. Create E1 with NGSIV1 with location metadata" -echo "================================================" -payload=' -{ - "attributes": [ - { - "name": "A", - "type": "whatever", - "value": "40,-3", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] -} -' -orionCurl --url '/v1/contextEntities/type/T/id/E1' --payload "$payload" -echo -echo - - -echo "02. Create E2 with NGSIV1 without location metadata" -echo "===================================================" -payload=' -{ - "attributes": [ - { - "name": "A", - "type": "whatever", - "value": "39,-2" - } - ] -} -' -orionCurl --url '/v1/contextEntities/type/T/id/E2' --payload "$payload" -echo -echo - - -echo "03. Check E1 entity in DB has location metadata and location GeoJSON field" -echo "==========================================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find({ "_id" : { "id" : "E1", "type": "T", "servicePath" : "/" } }, {_id:0, attrs: 1, location: 1})' | python -mjson.tool -echo -echo - - -echo "04. Check E2 entity in DB has no location metadata nor location GeoJSON field" -echo "=============================================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.find({ "_id" : { "id" : "E2", "type": "T", "servicePath" : "/" } }, {_id:0, attrs: 1, location: 1})' | python -mjson.tool -echo -echo - - ---REGEXPECT-- -01. Create E1 with NGSIV1 with location metadata -================================================ -HTTP/1.1 200 OK -Content-Length: 236 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "A", - "type": "whatever", - "value": "" - } - ], - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" -} - - -02. Create E2 with NGSIV1 without location metadata -=================================================== -HTTP/1.1 200 OK -Content-Length: 170 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "attributes": [ - { - "name": "A", - "type": "whatever", - "value": "" - } - ], - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "id": "E2", - "isPattern": "false", - "type": "T" -} - - -03. Check E1 entity in DB has location metadata and location GeoJSON field -========================================================================== -{ - "attrs": { - "A": { - "creDate": REGEX(.*), - "md": { - "location": { - "type": "string", - "value": "WGS84" - } - }, - "mdNames": [ - "location" - ], - "modDate": REGEX(.*), - "type": "whatever", - "value": "40,-3" - } - }, - "location": { - "attrName": "A", - "coords": { - "coordinates": [ - -3, - 40 - ], - "type": "Point" - } - } -} - - -04. Check E2 entity in DB has no location metadata nor location GeoJSON field -============================================================================= -{ - "attrs": { - "A": { - "creDate": REGEX(.*), - "mdNames": [], - "modDate": REGEX(.*), - "type": "whatever", - "value": "39,-2" - } - } -} - - ---TEARDOWN-- -brokerStop CB -dbDrop CB 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 deleted file mode 100644 index 2dcf1535a6..0000000000 --- a/test/functionalTest/cases/3122_location_metadata_issues/create_location_attr_V2.test +++ /dev/null @@ -1,166 +0,0 @@ -# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Create 2 entities with NGSIV2 POST. -One with the location metadata, managed as a regular "custom" metadata as it is NGSIV2. -The other without a location metadata but with a geo:point attribute, then managed as -a location attribute for NGSIV2. - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -# -# 01. Create E1 with NGSIV2 with location metadata but not geo:xxx type -# 02. Create E2 with NGSIV2 without location metadata but with geo:xxx type -# 03. Check E1 entity in DB has location metadata but no location GeoJSON field -# 04. Check E2 entity in DB has no location metadata but location GeoJSON field - -echo "01. Create E1 with NGSIV2 with location metadata but not geo:xxx type" -echo "=====================================================================" -payload=' -{ - "id": "E1", - "type": "T", - "A": { - "value": "40, -3", - "type": "whatever", - "metadata": { - "location": { - "type": "string", - "value": "WGS84" - } - } - } -} -' -orionCurl --url '/v2/entities' --payload "$payload" -echo -echo - - -echo "02. Create E2 with NGSIV2 without location metadata but with geo:xxx type" -echo "=========================================================================" -payload=' -{ - "id": "E2", - "type": "T", - "A": { - "value": "39, -2", - "type": "geo:point" - } -} -' -orionCurl --url '/v2/entities' --payload "$payload" -echo -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 -mjson.tool -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 -mjson.tool -echo -echo - - ---REGEXPECT-- -01. Create E1 with NGSIV2 with location metadata but not geo:xxx type -===================================================================== -HTTP/1.1 201 Created -Content-Length: 0 -Location: /v2/entities/E1?type=T -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - - - -02. Create E2 with NGSIV2 without location metadata but with geo:xxx type -========================================================================= -HTTP/1.1 201 Created -Content-Length: 0 -Location: /v2/entities/E2?type=T -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - - - -03. Check E1 entity in DB has location metadata but no location GeoJSON field -============================================================================= -{ - "attrs": { - "A": { - "creDate": REGEX(.*), - "md": { - "location": { - "type": "string", - "value": "WGS84" - } - }, - "mdNames": [ - "location" - ], - "modDate": REGEX(.*), - "type": "whatever", - "value": "40, -3" - } - } -} - - -04. Check E2 entity in DB has no location metadata but location GeoJSON field -============================================================================= -{ - "attrs": { - "A": { - "creDate": REGEX(.*), - "mdNames": [], - "modDate": REGEX(.*), - "type": "geo:point", - "value": "39, -2" - } - }, - "location": { - "attrName": "A", - "coords": { - "coordinates": [ - -2, - 39 - ], - "type": "Point" - } - } -} - - ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_V1_creation.test b/test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_V1_creation.test deleted file mode 100644 index fa3682da77..0000000000 --- a/test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_V1_creation.test +++ /dev/null @@ -1,176 +0,0 @@ -# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Create an entity with a location metadata, old way of creating a location attribute, with NGSIV1 POST. -GET the resulting entity both with NGSIV1 and NGSV2. - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -# -# 01. Create E1 with NGSIV1 with location metadata -# 02. Get E1 with NGSIV1 and check location metadata is included -# 03. Get E1 with NGSIV2 and check location metadata is included - -echo "01. Create E1 with NGSIV1 with location metadata" -echo "================================================" -payload=' -{ - "attributes": [ - { - "name": "A", - "type": "whatever", - "value": "40,-3", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ] - } - ] -} -' -orionCurl --url '/v1/contextEntities/type/T/id/E1' --payload "$payload" -echo -echo - - -echo "02. Get E1 with NGSIV1 and check location metadata is included" -echo "==============================================================" -orionCurl --url '/v1/contextEntities/E1' -echo -echo - - -echo "03. Get E1 with NGSIV2 and check location metadata is included" -echo "==============================================================" -orionCurl --url '/v2/entities/E1' -echo -echo - - ---REGEXPECT-- -01. Create E1 with NGSIV1 with location metadata -================================================ -HTTP/1.1 200 OK -Content-Length: 236 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextResponses": [ - { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "A", - "type": "whatever", - "value": "" - } - ], - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" -} - - -02. Get E1 with NGSIV1 and check location metadata is included -============================================================== -HTTP/1.1 200 OK -Content-Length: 237 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "A", - "type": "whatever", - "value": "40,-3" - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } -} - - -03. Get E1 with NGSIV2 and check location metadata is included -============================================================== -HTTP/1.1 200 OK -Content-Length: 120 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "A": { - "metadata": { - "location": { - "type": "string", - "value": "WGS84" - } - }, - "type": "whatever", - "value": "40,-3" - }, - "id": "E1", - "type": "T" -} - - ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_V2_creation.test b/test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_V2_creation.test deleted file mode 100644 index 4ef0187afb..0000000000 --- a/test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_V2_creation.test +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Create an entity with a location attribute and no metadata with NGSIV2 POST. -GET the resulting entity both with NGSIV1 and NGSV2. - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -# -# 01. Create E1 with NGSIV2 -# 02. Get E1 with NGSIV1 -# 03. Get E1 with NGSIV2 - -echo "01. Create E1 with NGSIV2" -echo "=========================" -payload=' -{ - "id": "E1", - "type": "T", - "A": { - "value": "40, -3", - "type": "geo:point" - } -} -' -orionCurl --url '/v2/entities' --payload "$payload" -echo -echo - - -echo "02. Get E1 with NGSIV1" -echo "======================" -orionCurl --url '/v1/contextEntities/E1' -echo -echo - - -echo "03. Get E1 with NGSIV2" -echo "======================" -orionCurl --url '/v2/entities/E1' -echo -echo - - ---REGEXPECT-- -01. Create E1 with NGSIV2 -========================= -HTTP/1.1 201 Created -Content-Length: 0 -Location: /v2/entities/E1?type=T -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - - - -02. Get E1 with NGSIV1 -====================== -HTTP/1.1 200 OK -Content-Length: 173 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextElement": { - "attributes": [ - { - "name": "A", - "type": "geo:point", - "value": "40, -3" - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } -} - - -03. Get E1 with NGSIV2 -====================== -HTTP/1.1 200 OK -Content-Length: 78 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "A": { - "metadata": {}, - "type": "geo:point", - "value": "40, -3" - }, - "id": "E1", - "type": "T" -} - - ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_db_creation.test b/test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_db_creation.test deleted file mode 100644 index 9b55638961..0000000000 --- a/test/functionalTest/cases/3122_location_metadata_issues/get_location_attr_with_db_creation.test +++ /dev/null @@ -1,152 +0,0 @@ -# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Create an inconsistent entity with a location attribute and no metadata directly in DB. -GET the resulting entity both with NGSIV1 and NGSV2. - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -# -# 01. Create E1 directly in DB with location GeoJSON field but without location metadata nor geo:xxx type -# 02. Get E1 with NGSIV1 with location metadata -# 03. Get E1 with NGSIV2 without location metadata - -echo "01. Create E1 directly in DB with location GeoJSON field but without location metadata nor geo:xxx type" -echo "=======================================================================================================" -mongoCmd ${CB_DB_NAME} 'db.entities.insert({ - "_id": { - "id": "E1", - "type": "T", - "servicePath": "/" - }, - "attrNames": ["A"], - "attrs": { - "A": { - "type": "whatever", - "creDate": 1462826512, - "modDate": 1462826512, - "value": "40,-3" - } - }, - "creDate": 1462826512, - "modDate": 1462826512, - "location" : { - "attrName" : "A", - "coords" : { - "type" : "Point", - "coordinates" : [ - -3.0, - 40.0 - ] - } - } -})' -echo -echo -echo -echo - - -echo "02. Get E1 with NGSIV1 with location metadata" -echo "=============================================" -orionCurl --url '/v1/contextEntities/E1' -echo -echo - - -echo "03. Get E1 with NGSIV2 without location metadata" -echo "================================================" -orionCurl --url '/v2/entities/E1' -echo -echo - - ---REGEXPECT-- -01. Create E1 directly in DB with location GeoJSON field but without location metadata nor geo:xxx type -======================================================================================================= -WriteResult({ "nInserted" : 1 }) - - - - -02. Get E1 with NGSIV1 with location metadata -============================================= -HTTP/1.1 200 OK -Content-Length: 237 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WGS84" - } - ], - "name": "A", - "type": "whatever", - "value": "40,-3" - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } -} - - -03. Get E1 with NGSIV2 without location metadata -================================================ -HTTP/1.1 200 OK -Content-Length: 76 -Content-Type: application/json -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Date: REGEX(.*) - -{ - "A": { - "metadata": {}, - "type": "whatever", - "value": "40,-3" - }, - "id": "E1", - "type": "T" -} - - ---TEARDOWN-- -brokerStop CB -dbDrop CB From 27d4e5ab7045933820b0b584c5d7e615546a2647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 3 Feb 2022 08:52:01 +0100 Subject: [PATCH 03/11] FIX simplify geoloc implementation --- src/lib/mongoBackend/MongoCommonUpdate.cpp | 4 +-- src/lib/mongoBackend/location.cpp | 33 ++++------------------ src/lib/ngsi/ContextAttribute.cpp | 31 ++++++-------------- src/lib/ngsi/ContextAttribute.h | 2 +- 4 files changed, 16 insertions(+), 54 deletions(-) diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index 3de9e1384c..c29033e624 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -2438,7 +2438,6 @@ static bool deleteContextAttributeItem std::string* currentLocAttrName, bool* entityModified, orion::BSONDate* dateExpiration, - ApiVersion apiVersion, OrionError* oe ) { @@ -2448,7 +2447,7 @@ static bool deleteContextAttributeItem *entityModified = true; /* Check aspects related with location */ - if (targetAttr->getLocation(apiVersion)) + if (targetAttr->getLocation()) { std::string details = std::string("action: DELETE") + " - entity: [" + entityDetail + "]" + @@ -2618,7 +2617,6 @@ static bool processContextAttributeVector currentLocAttrName, &entityModified, dateExpiration, - apiVersion, oe)) { return false; diff --git a/src/lib/mongoBackend/location.cpp b/src/lib/mongoBackend/location.cpp index d1014f6390..2327e1f496 100644 --- a/src/lib/mongoBackend/location.cpp +++ b/src/lib/mongoBackend/location.cpp @@ -105,6 +105,8 @@ static bool stringArray2coords * ContextAttribute provided as parameter. * * It returns true, except in the case of error (in which in addition errDetail gets filled) +* +* FIXME PR: try to avoid apiVersion */ static bool getGeoJson ( @@ -118,31 +120,6 @@ static bool getGeoJson std::vector coordLong; orion::BSONArrayBuilder ba; - if ((apiVersion == V1) && (caP->type != GEO_POINT) && (caP->type != GEO_LINE) && (caP->type != GEO_BOX) && - (caP->type != GEO_POLYGON) && (caP->type != GEO_JSON)) - { - // This corresponds to the legacy way in NGSIv1 based in metadata - // The block is the same that for GEO_POINT but it is clearer if we keep it separated - - double aLat; - double aLong; - - if (!string2coords(caP->stringValue, aLat, aLong)) - { - *errDetail = "geo coordinates format error [see Orion user manual]: " + caP->stringValue; - return false; - } - - geoJson->append("type", "Point"); - - orion::BSONArrayBuilder ba; - ba.append(aLong); - ba.append(aLat); - geoJson->append("coordinates", ba.arr()); - - return true; - } - if (caP->type == GEO_POINT) { double aLat; @@ -340,7 +317,7 @@ bool processLocationAtEntityCreation { const ContextAttribute* caP = caV[ix]; - if (!caP->getLocation(apiVersion)) + if (!caP->getLocation()) { continue; } @@ -386,7 +363,7 @@ bool processLocationAtUpdateAttribute // Case 1: // update *to* location. There are 3 sub-cases // - if (targetAttr->getLocation(apiVersion)) + if (targetAttr->getLocation()) { // // Case 1a: @@ -496,7 +473,7 @@ bool processLocationAtAppendAttribute ) { std::string subErr; - bool isALocation = targetAttr->getLocation(apiVersion); + bool isALocation = targetAttr->getLocation(); /* Case 1: append of new location attribute */ if (actualAppend && isALocation) diff --git a/src/lib/ngsi/ContextAttribute.cpp b/src/lib/ngsi/ContextAttribute.cpp index 73a7110b95..45f74fc5bb 100644 --- a/src/lib/ngsi/ContextAttribute.cpp +++ b/src/lib/ngsi/ContextAttribute.cpp @@ -550,36 +550,23 @@ ContextAttribute::ContextAttribute * * ContextAttribute::getLocation() - */ -bool ContextAttribute::getLocation(ApiVersion apiVersion) const +bool ContextAttribute::getLocation() const { - if (apiVersion == V1) + // null value is allowed but inhibits the attribute to be used as location (e.g. in geo-queries) + if ((valueType != orion::ValueTypeNull) && ((type == GEO_POINT) || (type == GEO_LINE) || (type == GEO_BOX) || (type == GEO_POLYGON) || (type == GEO_JSON))) { - // Current way of declaring location in NGSIv1, aligned with NGSIv2 (originally only only geo:point was supported - // but doing so have problems so we need to support all them at the end, - // see https://github.com/telefonicaid/fiware-orion/issues/3442 for details) - if ((type == GEO_POINT) || (type == GEO_LINE) || (type == GEO_BOX) || (type == GEO_POLYGON) || (type == GEO_JSON)) + for (unsigned int ix = 0; ix < metadataVector.size(); ++ix) { - return true; - } - } - else // v2 - { - // null value is allowed but inhibits the attribute to be used as location (e.g. in geo-queries) - if ((valueType != orion::ValueTypeNull) && ((type == GEO_POINT) || (type == GEO_LINE) || (type == GEO_BOX) || (type == GEO_POLYGON) || (type == GEO_JSON))) - { - for (unsigned int ix = 0; ix < metadataVector.size(); ++ix) + // the existence of the ignoreType metadata set to true also inhibits the attribute to be used as location + if (metadataVector[ix]->name == NGSI_MD_IGNORE_TYPE) { - // the existence of the ignoreType metadata set to true also inhibits the attribute to be used as location - if (metadataVector[ix]->name == NGSI_MD_IGNORE_TYPE) + if ((metadataVector[ix]->valueType == orion::ValueTypeBoolean) && (metadataVector[ix]->boolValue == true)) { - if ((metadataVector[ix]->valueType == orion::ValueTypeBoolean) && (metadataVector[ix]->boolValue == true)) - { - return false; - } + return false; } } - return true; } + return true; } return false; diff --git a/src/lib/ngsi/ContextAttribute.h b/src/lib/ngsi/ContextAttribute.h index d490859419..7919d941a2 100644 --- a/src/lib/ngsi/ContextAttribute.h +++ b/src/lib/ngsi/ContextAttribute.h @@ -92,7 +92,7 @@ typedef struct ContextAttribute ContextAttribute(const std::string& _name, const std::string& _type, orion::CompoundValueNode* _compoundValueP); /* Grabbers for metadata to which CB gives a special semantic */ - bool getLocation(ApiVersion apiVersion = V1) const; + bool getLocation(void) const; std::string toJsonV1(bool asJsonObject, RequestType request, From 707f86a051a3546d6a3dbdff07966cadcf72dda1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 9 Feb 2022 12:46:56 +0100 Subject: [PATCH 04/11] FIX remove location from metadata.md --- doc/manuals/user/metadata.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/manuals/user/metadata.md b/doc/manuals/user/metadata.md index 5a49336ebc..eee87660e8 100644 --- a/doc/manuals/user/metadata.md +++ b/doc/manuals/user/metadata.md @@ -10,7 +10,6 @@ You can use any name for your custom metadata except for a few reserved names, u for special metadata that are interpreted by Orion: - [ID](#metadata-id-for-attributes) (deprecated, but still "blocked" as forbidden keyword) -- location, which is currently [deprecated](../deprecated.md), but still supported - The ones defined in "Builtin metadata" section in the NGSIv2 spec ## Custom attribute metadata From 0bedb0e6301c7d9f122eaa983bd2bd3865074ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 21 Dec 2023 08:47:56 +0100 Subject: [PATCH 05/11] FIX broken ftest --- src/lib/mongoBackend/location.cpp | 5 + .../log_deprecate_warning.test | 91 ++----------------- 2 files changed, 14 insertions(+), 82 deletions(-) diff --git a/src/lib/mongoBackend/location.cpp b/src/lib/mongoBackend/location.cpp index d524de1e74..b737e7264e 100644 --- a/src/lib/mongoBackend/location.cpp +++ b/src/lib/mongoBackend/location.cpp @@ -320,6 +320,11 @@ static bool getGeoJson std::vector coordLong; orion::BSONArrayBuilder ba; + if ((logDeprecate) && ((caP->type == GEO_POINT) || (caP->type == GEO_LINE) || (caP->type == GEO_BOX) || (caP->type == GEO_POLYGON))) + { + LM_W(("Deprecated usage of %s detected in attribute %s at entity update, please use geo:json instead", caP->type.c_str(), caP->name.c_str())); + } + if (caP->type == GEO_POINT) { double aLat; diff --git a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test index baf5d43988..663b3c833f 100644 --- a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test +++ b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test @@ -32,10 +32,9 @@ brokerStart CB 0 IPV4 -logDeprecate # # 01. Query E1-T1 # 02. GET /v1/contextEntities/E -# 03. Create entity using NGSIv1 metadata location -# 04. Create entity using NGSIv1 and geo:point -# 05. Create entity using NGSIv2 and geo:point -# 06. Get WARNING trace in logs +# 03. Create entity using NGSIv1 and geo:point +# 04. Create entity using NGSIv2 and geo:point +# 05. Get WARNING trace in logs # echo "01. Query E1-T1" @@ -60,38 +59,7 @@ echo echo -echo "03. Create entity using NGSIv1 metadata location" -echo "================================================" -payload='{ - "contextElements": [ - { - "type": "City", - "isPattern": "false", - "id": "Madrid", - "attributes": [ - { - "name": "location", - "type": "coords", - "value": "40.418889, -3.691944", - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WSG84" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url /v1/updateContext --payload "$payload" -echo -echo - - -echo "04. Create entity using NGSIv1 and geo:point" +echo "03. Create entity using NGSIv1 and geo:point" echo "============================================" payload='{ "contextElements": [ @@ -115,7 +83,7 @@ echo echo -echo "05. Create entity using NGSIv2 and geo:point" +echo "04. Create entity using NGSIv2 and geo:point" echo "============================================" payload='{ "id": "Sevilla", @@ -130,7 +98,7 @@ echo echo -echo "06. Get WARNING trace in logs" +echo "05. Get WARNING trace in logs" echo "=============================" cat /tmp/contextBroker.log | grep 'WARN' | awk -F 'msg=' '{print $2}' echo @@ -171,46 +139,7 @@ Content-Length: 98 } -03. Create entity using NGSIv1 metadata location -================================================ -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 267 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "location", - "type": "string", - "value": "WSG84" - } - ], - "name": "location", - "type": "coords", - "value": "" - } - ], - "id": "Madrid", - "isPattern": "false", - "type": "City" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -04. Create entity using NGSIv1 and geo:point +03. Create entity using NGSIv1 and geo:point ============================================ HTTP/1.1 200 OK Date: REGEX(.*) @@ -242,7 +171,7 @@ Content-Length: 207 } -05. Create entity using NGSIv2 and geo:point +04. Create entity using NGSIv2 and geo:point ============================================ HTTP/1.1 201 Created Date: REGEX(.*) @@ -252,12 +181,10 @@ Content-Length: 0 -06. Get WARNING trace in logs +05. Get WARNING trace in logs ============================= Deprecated NGSIv1 request received: POST /v1/queryContext, request payload (48 bytes): { "entities": [ { "type": "T1", "id": "E1" } ] }, response code: 200 Deprecated NGSIv1 request received: GET /v1/contextEntities/E/attributes/A, response code: 200 -Deprecated usage of metadata location coords detected in attribute location at entity update, please use geo:json instead -Deprecated NGSIv1 request received: POST /v1/updateContext, request payload (279 bytes): { "contextElements": [ { "type": "City", "isPattern": "false", "id": "Madrid", "attributes": [ { "name": "location", "type": "coords", "value": "40.418889, -3.691944", "metadatas": [ { "name": "location", "type": "string", "value": "WSG84" } ] } ] } ], "updateAction": "APPEND" }, response code: 200 Deprecated usage of geo:point detected in attribute location at entity update, please use geo:json instead Deprecated NGSIv1 request received: POST /v1/updateContext, request payload (208 bytes): { "contextElements": [ { "type": "City", "isPattern": "false", "id": "Barcelona", "attributes": [ { "name": "location", "type": "geo:point", "value": "40.418889, -3.691944" } ] } ], "updateAction": "APPEND" }, response code: 200 Deprecated usage of geo:point detected in attribute location at entity update, please use geo:json instead From 338c13e0a42e523b6ba3ccf355ce0a5fe2747996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 24 Jan 2024 13:13:53 +0100 Subject: [PATCH 06/11] FIX remove old check_legac_location_metadata.py --- .../check_legacy_location_metadata.py | 219 ------------------ 1 file changed, 219 deletions(-) delete mode 100644 scripts/managedb/upgrade-3.5.0/check_legacy_location_metadata.py diff --git a/scripts/managedb/upgrade-3.5.0/check_legacy_location_metadata.py b/scripts/managedb/upgrade-3.5.0/check_legacy_location_metadata.py deleted file mode 100644 index 4c66409db3..0000000000 --- a/scripts/managedb/upgrade-3.5.0/check_legacy_location_metadata.py +++ /dev/null @@ -1,219 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright 2022 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 - -# Hint: use 'PYTHONIOENCODING=utf8 python check_legacy_location_metadata.py' -# if you are going to redirect the output of this script to a file - - -__author__ = 'fermin' - -from pymongo import MongoClient -import sys - - -def flatten(_id): - """ - The way in which Python manage dictionaries doesn't make easy to be sure - of field ordering, which is important for MongoDB in the case of using an - embedded document for _id. This function helps. - - :param _id: JSON document containing id, type and servicePath - :return: a "flatten" version of the _id - """ - - r = {'_id.id': _id['id']} - - if 'type' in _id: - r['_id.type'] = _id['type'] - else: - r['_id.type'] = {'$exists': False} - - if 'servicePath' in _id: - r['_id.servicePath'] = _id['servicePath'] - else: - r['_id.servicePath'] = {'$exists': False} - - return r - - -def entity_id(doc): - """ - Extracts entity identification keys and returns an object with them - - :param doc: entity document, as taken from DB - :return: {id, type, servicePath} object - """ - id = doc['_id']['id'] - type = doc['_id']['type'] - sp = doc['_id']['servicePath'] - - return {'id': id, 'type': type, 'servicePath': sp} - - -########################## -# Main program starts here - -autofix = False - -if len(sys.argv) != 2: - print "invalid number of arguments, please check https://fiware-orion.readthedocs.io/en/master/admin/upgrading_crossing_3-5-0/index.html" - sys.exit() - -DB = sys.argv[1] - -# Warn user -if autofix: - print "WARNING!!!! This script modifies your '%s' database. It is STRONGLY RECOMMENDED that you" % DB - print "do a backup of your database before using it as described in https://fiware-orion.readthedocs.io/en/master/admin/database_admin/index.html#backup. Use this script at your own risk." - print "If you are sure you want to continue type 'yes' and press Enter" - - confirm = raw_input() - - if confirm != 'yes': - sys.exit() - -uri = 'mongodb://localhost:27017' -client = MongoClient(uri) -db = client[DB] - -need_fix = False -corrupted = False -verbose = True - -# Counters -processed = 0 -counter_location_ngsiv2 = 0 -counter_location_md_wgs84 = 0 -counter_location_md_not_wgs84 = 0 -counter_location_more_than_one = 0 -counter_untouched = 0 -counter_changed = 0 - -corrupted_entities = [] -affected_entities = [] - -total = db['entities'].count() - -print "- processing entities collection (%d entities) looking for attributes with ID metadata, this may take a while... " % total - -# The sort() is a way of ensuring that a modified document doesn't enter again at the end of the cursor (we have -# observed that this may happen with large collections, e.g ~50,000 entities). In addition, we have to use -# batch_size so the cursor doesn't expire at server (see http://stackoverflow.com/questions/10298354/mongodb-cursor-id-not-valid-error). -# The used batch_size value is a heuristic -for entity in db['entities'].find().sort([('_id.id', 1), ('_id.type', -1), ('_id.servicePath', 1)]).batch_size(100): - - processed += 1 - - sys.stdout.write('- processing entity: %d/%d \r' % (processed, total)) - sys.stdout.flush() - - # It may happen that entity doesn't have any attribute. We early detect that situation and skip in that case - if len(entity['attrs'].keys()) == 0: - # print '- %d: entity without attributes %s. Skipping' % (processed, json.dumps(entity['_id'])) - continue # entities loop - - wgs84_attr = None - for attr in entity['attrs']: - if 'md' in entity['attrs'][attr] and 'location' in entity['attrs'][attr]['md']: - if entity['attrs'][attr]['md']['location']['value'] == 'WGS84' \ - or entity['attrs'][attr]['md']['location']['value'] == 'WSG84': - if wgs84_attr is not None: - # more than one location metadata is not allowed due to the checks done by CB - # in processLocationAtEntityCreation() function. However, we check in - # any case as CB could be buggy. Note in this case we don't append to - # affected_entities as that was done first time the location metadata was detected - counter_location_more_than_one += 1 - corrupted = True - corrupted_entities.append(entity_id(entity)) - continue # entities loop - else: - # Note that location metadata doesn't have any semantic in NGSIv2, so we can - # have an entity created with NGSIv2 with location metadata but not location geo-index. - # We need to detect that situation - if "location" in entity: - counter_location_md_wgs84 += 1 - affected_entities.append(entity_id(entity)) - wgs84_attr = attr - else: - counter_location_ngsiv2 += 1 - else: - # location metadata with a value different to WGS84 is not possible taking into - # account the checks done by CB in processLocationAtEntityCreation() function - # However, we check in any case as CB could be buggy - counter_location_md_not_wgs84 += 1 - corrupted = True - corrupted_entities.append(entity_id(entity)) - continue # entities loop - - if wgs84_attr is not None: - if autofix: - # Autofix consist on: - # 1) Remove location metadata (key in 'md' and item in 'mdNames') - # 2) Change attribute type by "geo:point" - - attr = entity['attrs'][wgs84_attr] - attr['mdNames'] = list(filter(lambda x: x != 'location', attr['mdNames'])) - - attr['md'].pop('location', None) - if len(attr['md'].keys()) == 0: - attr.pop('md', None) - - attr['type'] = 'geo:point' - - # it would be easier db['entities'].save(entity) but it seems it has problems when - # _id value is an object and may lead to duplicating entities instead of updating - # note we removed _id from update doc, to avoid possible problems reported by - # pymongo such as "the (immutable) field '_id' was found to have been altered" - query = flatten(entity['_id']) - entity.pop('_id', None) - db['entities'].update(query, entity) - counter_changed += 1 - else: - # Fix should be done by the user - counter_untouched += 1 - need_fix = True - else: - counter_untouched += 1 - -print '- processing entity: %d/%d' % (processed, total) -print '- documents analyzed: %d' % processed -print ' * entities w/ location md w/ WGS84/WSG84 value: %d' % counter_location_md_wgs84 -print ' * entities w/ location md w/o WGS84/WSG84 value (DB corruption!): %d' % counter_location_md_not_wgs84 -print ' * entities w/ more than one location md (DB corruption!): %d' % counter_location_more_than_one -print ' * entities w/ meaningless location md (created by NGSIv2) %d' % counter_location_ngsiv2 -print '- documents processed: %d' % processed -print ' * untouched: %d' % counter_untouched -print ' * changed: %d' % counter_changed - -if verbose: - if len(affected_entities) > 0: - print '- Affected entities:' - for entity in affected_entities: - print ' * ' + str(entity) - if len(corrupted_entities) > 0: - print '- Corrupted entities:' - for entity in corrupted_entities: - print ' * ' + str(entity) - -if need_fix or corrupted: - print "------------------------------------------------------" - print "WARNING: some problem was found during the process. Please check the documentation at https://fiware-orion.readthedocs.io/en/master/admin/upgrading_crossing_3-5-0/index.html" From db965d6773033763b9f2c5c189c1cf1aa8ea74d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 24 Jan 2024 13:17:28 +0100 Subject: [PATCH 07/11] FIX ftest --- .../statistics_with_full_counters.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test b/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test index ae883641d2..403721e557 100644 --- a/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test +++ b/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test @@ -46,7 +46,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 1645 +Content-Length: 1624 { "counters": { From b279fcbb72e9001b6efcca3eb2b22696e3492d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 24 Jan 2024 13:18:05 +0100 Subject: [PATCH 08/11] FIX docu --- doc/manuals.jp/admin/statistics.md | 1 - doc/manuals/admin/logs.md | 6 ------ doc/manuals/deprecated.md | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/doc/manuals.jp/admin/statistics.md b/doc/manuals.jp/admin/statistics.md index 7d5580f380..2f25673ebb 100644 --- a/doc/manuals.jp/admin/statistics.md +++ b/doc/manuals.jp/admin/statistics.md @@ -44,7 +44,6 @@ Orion Context broker は、`GET /statistics` と `GET /cache/statistics` を介 "counters": { "deprecatedFeatures": { "geoFormat": 2, - "metadataLocation": 1, "ngsiv1Forwarding": 4, "ngsiv1NotifFormat": 4, "ngsiv1Requests": 4 diff --git a/doc/manuals/admin/logs.md b/doc/manuals/admin/logs.md index dd24846b57..f88223e73b 100644 --- a/doc/manuals/admin/logs.md +++ b/doc/manuals/admin/logs.md @@ -431,12 +431,6 @@ time=2024-01-11T16:23:24.701Z | lvl=WARN | corr=be709034-b09d-11ee-b5d1-080027cd time=2024-01-11T16:23:24.716Z | lvl=WARN | corr=be7ae5ac-b09d-11ee-98c8-080027cd35f1 | trans=1704990203-652-00000000015 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=Notifier.cpp[680]:buildSenderParams | msg=Deprecated usage of notification legacy format in notification (subId: 65a015fcda947708d30425eb) ``` -* Usages NGSIv1 usages of location metadata. Example: - -``` -time=2023-06-08T15:14:20.999Z | lvl=WARN | corr=24fd2acc-060f-11ee-94cc-000c29583ca5 | trans=1686237259-703-00000000003 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=location.cpp[329]:getGeoJson | msg=Deprecated usage of metadata location coords detected in attribute location at entity update, please use geo:json instead -``` - * Usages of `geo:point`, `geo:line`, `geo:box` or `geo:line`. ``` diff --git a/doc/manuals/deprecated.md b/doc/manuals/deprecated.md index a786106392..d2d5d65f74 100644 --- a/doc/manuals/deprecated.md +++ b/doc/manuals/deprecated.md @@ -110,9 +110,9 @@ The following table provides information about the last Orion version supporting | `attributes` field in `POST /v2/entities` operation | Not yet defined | Not yet defined | | `APPEND`, `UPDATE`, etc. action types in `POST /v2/op/update` | Not yet defined | Not yet defined | | `dateCreated` and `dateModified` in `options` URI parameter | Not yet defined | Not yet defined | -| `location` metadata to specify entity location | Not yet defined | Not yet defined | | `GET /v2` operation | Not yet defined | Not yet defined | | `geo:point`, `geo:line`, `geo:box` and `geo:polygon` attribute types | Not yet defined | Not yet defined | +| `location` metadata to specify entity location | 3.10.1 | June 12th, 2023 | | NGSIv1 API (along with CLI: `-strictNgsiv1Ids` and `-ngsiv1Autocast`) | 3.9.0 (*) | June 2nd, 2023 | | `/ngsi10` and `/ngsi9` URL prefixes | 3.7.0 (*) | May 26th, 2022 | | Initial notification upon subscription creation or update | 3.1.0 | June 9th, 2021 | From 0a593fbb45ad6913a35c5fbf8f71eeb9e709de67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 24 Jan 2024 13:37:08 +0100 Subject: [PATCH 09/11] FIX code comment --- src/lib/mongoBackend/location.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/mongoBackend/location.cpp b/src/lib/mongoBackend/location.cpp index 939f4bbdac..66498b19a3 100644 --- a/src/lib/mongoBackend/location.cpp +++ b/src/lib/mongoBackend/location.cpp @@ -304,7 +304,7 @@ static bool isSpecialGeoJsonType(const ContextAttribute* caP, orion::BSONObjBuil * * It returns true, except in the case of error (in which in addition errDetail gets filled) * -* FIXME PR: try to avoid apiVersion +* FIXME P6: try to avoid apiVersion * * FIXME P6: review the cases in which this function returns false. Maybe many cases (or all them) * can be moved to checkGeoJson() in the parsing layer, as preconditions. @@ -314,7 +314,7 @@ static bool getGeoJson const ContextAttribute* caP, orion::BSONObjBuilder* geoJson, std::string* errDetail, - ApiVersion apiVersion + //ApiVersion apiVersion ) { std::vector coordLat; From 948f22d922cec9f893231c73f5ddc8e03dfe0ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 24 Jan 2024 13:45:57 +0100 Subject: [PATCH 10/11] FIX broken build --- src/lib/mongoBackend/location.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/mongoBackend/location.cpp b/src/lib/mongoBackend/location.cpp index 66498b19a3..d6de878cba 100644 --- a/src/lib/mongoBackend/location.cpp +++ b/src/lib/mongoBackend/location.cpp @@ -314,7 +314,7 @@ static bool getGeoJson const ContextAttribute* caP, orion::BSONObjBuilder* geoJson, std::string* errDetail, - //ApiVersion apiVersion + ApiVersion apiVersion ) { std::vector coordLat; From dac655a6b50b4f28bdc9e8f4752464641b3d082d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 24 Jan 2024 15:25:52 +0100 Subject: [PATCH 11/11] FIX deprecated.md --- doc/manuals/deprecated.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manuals/deprecated.md b/doc/manuals/deprecated.md index d2d5d65f74..141ab0d6d5 100644 --- a/doc/manuals/deprecated.md +++ b/doc/manuals/deprecated.md @@ -58,7 +58,7 @@ A list of deprecated features and the version in which they were deprecated foll * `/ngsi10` and `/ngsi9` as URL path prefixes are deprecated in Orion 1.2.0. Please, use `/v1` and `/v1/registry` instead. * `/ngsi9` URL paths removed in Orion 3.8.0 -* `location` metadata to specify entity location is deprecated in Orion 1.1.0. The new way +* `location` metadata to specify entity location is deprecated in Orion 1.1.0 (removed in Orion 3.11.0). The new way of specifying entity location is to use `geo:json` type for the attribute (see details in [the corresponding section of the Orion API specification](orion-api.md#geospatial-properties-of-entities). * Deprecated command line argument in Orion 0.26.1 (removed in Orion 1.0.0).