From 128a06afb5c79ee849b6acc106e8dadcf58de771 Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sat, 17 Apr 2021 12:43:34 +0200 Subject: [PATCH 1/9] Setting sysAttrs (createdAt+modifiedAt) for metadata (sub-attributes) at entity creation time --- src/lib/mongoBackend/MongoCommonUpdate.cpp | 173 ++++++------ src/lib/mongoBackend/MongoGlobal.cpp | 12 +- src/lib/ngsi/ContextElementResponse.cpp | 8 + src/lib/ngsi/Metadata.cpp | 42 ++- src/lib/ngsi/Metadata.h | 3 + .../orionld/common/isSpecialSubAttribute.cpp | 2 +- .../kjTree/kjTreeFromQueryContextResponse.cpp | 23 +- .../mongoCppLegacyEntityRetrieve.cpp | 38 +++ .../0000_ngsild/ngsild_adding_attributes.test | 4 + ...entity_creation_one_property_property.test | 2 + ...ty_creation_one_property_relationship.test | 2 + ...ty_creation_one_relationship_property.test | 2 + ...reation_one_relationship_relationship.test | 2 + .../ngsild_entity_post_operations_upsert.test | 2 + .../cases/0000_ngsild/ngsild_issue_0019.test | 8 + .../cases/0000_ngsild/ngsild_issue_0028.test | 4 + .../cases/0000_ngsild/ngsild_issue_0233.test | 18 ++ .../ngsild_issue_0241_notifications.test | 8 + .../cases/0000_ngsild/ngsild_issue_0364.test | 2 + .../ngsild_metadata_with_compound_value.test | 2 + .../0000_ngsild/ngsild_nested-contexts.test | 2 + ...ngsild_patch_entity_attr_with_subattr.test | 28 ++ ...d_query_condition_over_compound_value.test | 2 + ...gsild_query_condition_over_observedAt.test | 8 + ...y_condition_over_property_of_property.test | 8 + .../ngsild_query_with_type_mismatch.test | 8 + ...sild_subattr-timestamps-post-entities.test | 252 ++++++++++++++++++ .../ngsild_testSuite-case-079.test | 12 + .../cases/0000_ngsild/ngsild_tests_01.test | 4 + .../ngsild_uriExpansion_attrs.test | 2 + 30 files changed, 594 insertions(+), 89 deletions(-) create mode 100644 test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entities.test diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index a97a4834e5..c00e45ffd3 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -30,6 +30,12 @@ #include #include +extern "C" +{ +#include "kjson/KjNode.h" // KjNode, kjValueType +#include "kjson/kjLookup.h" // kjLookup +} + #include "logMsg/logMsg.h" #include "logMsg/traceLevels.h" @@ -50,17 +56,11 @@ #include "ngsi/Scope.h" #include "rest/uriParamNames.h" -#ifdef ORIONLD -extern "C" -{ -#include "kjson/KjNode.h" // KjNode, kjValueType -#include "kjson/kjLookup.h" // kjLookup -} - +#include "orionld/types/AttributeType.h" // AttributeType #include "orionld/common/orionldState.h" // orionldState #include "orionld/common/geoJsonCreate.h" // geoJsonCreate +#include "orionld/common/isSpecialSubAttribute.h" // isSpecialSubAttribute #include "orionld/db/dbConfiguration.h" // dbDataFromKjTree -#endif #include "mongoBackend/connectionOperations.h" #include "mongoBackend/safeMongo.h" @@ -352,11 +352,17 @@ static void appendMetadata ( BSONObjBuilder* mdBuilder, BSONArrayBuilder* mdNamesBuilder, - const Metadata* mdP, + Metadata* mdP, bool useDefaultType ) { - std::string type = mdP->type; + BSONObjBuilder bsonmd; + std::string type = mdP->type; + const char* mdName = mdP->name.c_str(); + AttributeType mdType; + bool special = isSpecialSubAttribute(mdName, &mdType, NULL); + + LM_TMP(("MS: appending metadata", mdName)); if (!mdP->typeGiven && useDefaultType) { @@ -373,87 +379,83 @@ static void appendMetadata mdNamesBuilder->append(mdP->name); std::string effectiveName = dbDotEncode(mdP->name); - if (type != "") + // + // Filling in the RHS of the metadata ("mdName": RHS) + // + if (special == false) { - switch (mdP->valueType) + // + // Setting sysAttrs + // + if (orionldState.apiVersion == NGSI_LD_V1) { - case orion::ValueTypeString: - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_TYPE << type << ENT_ATTRS_MD_VALUE << mdP->stringValue)); - return; - - case orion::ValueTypeNumber: - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_TYPE << type << ENT_ATTRS_MD_VALUE << mdP->numberValue)); - return; - - case orion::ValueTypeBoolean: - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_TYPE << type << ENT_ATTRS_MD_VALUE << mdP->boolValue)); - return; - - case orion::ValueTypeNull: - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_TYPE << type << ENT_ATTRS_MD_VALUE << mongo::BSONNULL)); - return; - - case orion::ValueTypeObject: - if (mdP->compoundValueP->valueType == orion::ValueTypeVector) + LM_TMP(("MS: Setting MD SysAttrs")); + if (mdP->createdAt == 0) { - BSONArrayBuilder ba; - compoundValueBson(mdP->compoundValueP->childV, ba); - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_TYPE << type << ENT_ATTRS_MD_VALUE << ba.arr())); + LM_TMP(("MS: Setting createdAt in BSON")); + mdP->createdAt = orionldState.requestTime; + bsonmd.append("createdAt", mdP->createdAt); } - else - { - BSONObjBuilder bo; - compoundValueBson(mdP->compoundValueP->childV, bo); - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_TYPE << type << ENT_ATTRS_MD_VALUE << bo.obj())); - } - break; - - default: - LM_E(("Runtime Error (unknown metadata type: %d)", mdP->valueType)); + LM_TMP(("MS: Setting modifiedAt in BSON")); + mdP->modifiedAt = orionldState.requestTime; + bsonmd.append("modifiedAt", mdP->modifiedAt); } } - else - { - switch (mdP->valueType) - { - case orion::ValueTypeString: - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_VALUE << mdP->stringValue)); - return; - - case orion::ValueTypeNumber: - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_VALUE << mdP->numberValue)); - return; - - case orion::ValueTypeBoolean: - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_VALUE << mdP->boolValue)); - return; - - case orion::ValueTypeNull: - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_VALUE << mongo::BSONNULL)); - return; - - case orion::ValueTypeObject: - if (mdP->compoundValueP->isVector()) - { - BSONArrayBuilder ba; - compoundValueBson(mdP->compoundValueP->childV, ba); - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_VALUE << ba.arr())); - } - else - { - BSONObjBuilder bo; + LM_TMP(("MS: Setting MD Type")); + if (type != "") + bsonmd.append("type", type); + + LM_TMP(("MS: Setting MD Value")); + switch (mdP->valueType) + { + case orion::ValueTypeString: + LM_TMP(("MS: Setting MD String Value")); + bsonmd.append(ENT_ATTRS_MD_VALUE, mdP->stringValue); + break; + + case orion::ValueTypeNumber: + LM_TMP(("MS: Setting MD Number Value (%f)", mdP->numberValue)); + bsonmd.append(ENT_ATTRS_MD_VALUE, mdP->numberValue); + LM_TMP(("MS: Set MD Number Value (%f)", mdP->numberValue)); + break; + + case orion::ValueTypeBoolean: + LM_TMP(("MS: Setting MD Boolean Value")); + bsonmd.append(ENT_ATTRS_MD_VALUE, mdP->boolValue); + break; + + case orion::ValueTypeNull: + LM_TMP(("MS: Setting MD Null Value")); + bsonmd.appendNull(ENT_ATTRS_MD_VALUE); + break; + + case orion::ValueTypeObject: + LM_TMP(("MS: Setting MD Compound Value")); + if (mdP->compoundValueP->isVector()) + { + BSONArrayBuilder ba; - compoundValueBson(mdP->compoundValueP->childV, bo); - mdBuilder->append(effectiveName, BSON(ENT_ATTRS_MD_VALUE << bo.obj())); - } - break; + compoundValueBson(mdP->compoundValueP->childV, ba); + bsonmd.append(ENT_ATTRS_MD_VALUE, ba.arr()); + } + else + { + BSONObjBuilder bo; - default: - LM_E(("Runtime Error (unknown metadata type)")); + compoundValueBson(mdP->compoundValueP->childV, bo); + bsonmd.append(ENT_ATTRS_MD_VALUE, bo.obj()); } + break; + + default: + LM_E(("Runtime Error (unknown metadata type)")); } + + LM_TMP(("MS: Appending MD to mdBuilder")); + mdBuilder->append(effectiveName, bsonmd.obj()); + LM_TMP(("MS: Appended MD '%s' to mdBuilder", effectiveName.c_str())); } @@ -670,14 +672,18 @@ static bool contextAttributeCustomMetadataToBson for (unsigned int ix = 0; ix < ca->metadataVector.size(); ++ix) { - const Metadata* md = ca->metadataVector[ix]; + Metadata* md = ca->metadataVector[ix]; + LM_TMP(("MS: Calling isNotCustomMetadata for '%s'", md->name.c_str())); if (!isNotCustomMetadata(md->name.c_str())) { + LM_TMP(("MS: '%s' is a custom metadata", md->name.c_str())); appendMetadata(&mdToAdd, &mdNamesToAdd, md, useDefaultType); LM_T(LmtMongo, ("new custom metadata: {name: %s, type: %s, value: %s}", md->name.c_str(), md->type.c_str(), md->toStringValue().c_str())); } + else + LM_TMP(("MS: '%s' is NOT a custom metadata", md->name.c_str())); } *md = mdToAdd.obj(); @@ -840,9 +846,11 @@ static bool appendAttribute return false; } + LM_TMP(("MS: APPEND with existing attribute")); // // If updateAttribute fails, the name of the attribute caP is added to the list of erroneous attributes // + LM_TMP(("MS: Calling updateAttribute")); if (updateAttribute(attrs, toSet, toPush, caP, actualUpdate, false, apiVersion) == false) orionldStateErrorAttributeAdd(caP->name.c_str()); @@ -852,6 +860,8 @@ static bool appendAttribute /* Build the attribute to append */ BSONObjBuilder ab; + LM_TMP(("MS: ADDING a new attribute - all MD created/modifiedAt to be added")); + /* 1. Value */ caP->valueBson(ab, caP->type, ngsiv1Autocast && (apiVersion == V1)); @@ -880,6 +890,7 @@ static bool appendAttribute BSONObj md; BSONArray mdNames; + LM_TMP(("MS: Calling contextAttributeCustomMetadataToBson (created/modifiedAt to be added)")); if (contextAttributeCustomMetadataToBson(&md, &mdNames, caP, apiVersion == V2)) { ab.append(ENT_ATTRS_MD, md); @@ -2814,6 +2825,7 @@ static bool processContextAttributeVector bool actualUpdate = true; if ((action == ActionTypeUpdate) || (action == ActionTypeReplace)) { + LM_TMP(("MS: Calling updateContextAttributeItem")); if (!updateContextAttributeItem(cerP, ca, attrs, @@ -2837,6 +2849,7 @@ static bool processContextAttributeVector } else if ((action == ActionTypeAppend) || (action == ActionTypeAppendStrict)) { + LM_TMP(("MS: Calling appendContextAttributeItem")); if (!appendContextAttributeItem(cerP, attrs, targetAttr, diff --git a/src/lib/mongoBackend/MongoGlobal.cpp b/src/lib/mongoBackend/MongoGlobal.cpp index 2d69f61674..802d6e41ab 100644 --- a/src/lib/mongoBackend/MongoGlobal.cpp +++ b/src/lib/mongoBackend/MongoGlobal.cpp @@ -1235,6 +1235,8 @@ static void addDatesForAttrs(ContextElementResponse* cerP, bool includeCreDate, { ContextAttribute* caP = cerP->contextElement.contextAttributeVector[ix]; + LM_TMP(("SA: attribute: '%s'", caP->name.c_str())); + if (includeCreDate && caP->creDate != 0) { // Lookup Metadata NGSI_MD_DATECREATED @@ -1243,6 +1245,8 @@ static void addDatesForAttrs(ContextElementResponse* cerP, bool includeCreDate, { Metadata* mdP = caP->metadataVector[mIx]; + LM_TMP(("SA: metadata '%s'", mdP->name.c_str())); + if (mdP->name == NGSI_MD_DATECREATED) { dateCreatedMetadataP = mdP; @@ -1344,6 +1348,7 @@ bool entitiesQuery ApiVersion apiVersion ) { + LM_TMP(("SA: In entitiesQuery")); /* Query structure is as follows * * { @@ -1650,6 +1655,7 @@ bool entitiesQuery LM_T(LmtMongo, ("retrieved document [%d]: '%s'", docs, r.toString().c_str())); ContextElementResponse* cer = new ContextElementResponse(r, attrL, includeEmpty, apiVersion); + LM_TMP(("SA: Adding dates for attributes")); addDatesForAttrs(cer, metadataList.lookup(NGSI_MD_DATECREATED), metadataList.lookup(NGSI_MD_DATEMODIFIED)); /* All the attributes existing in the request but not found in the response are added with 'found' set to false */ @@ -1721,10 +1727,10 @@ bool entitiesQuery if (needToAdd) { - ContextElementResponse* cerP = new ContextElementResponse(); + ContextElementResponse* cerP = new ContextElementResponse(); - cerP->contextElement.entityId.id = enV[ix]->id; - cerP->contextElement.entityId.type = enV[ix]->type; + cerP->contextElement.entityId.id = enV[ix]->id; + cerP->contextElement.entityId.type = enV[ix]->type; cerP->contextElement.entityId.isPattern = "false"; // diff --git a/src/lib/ngsi/ContextElementResponse.cpp b/src/lib/ngsi/ContextElementResponse.cpp index d4b69654e9..df3982f802 100644 --- a/src/lib/ngsi/ContextElementResponse.cpp +++ b/src/lib/ngsi/ContextElementResponse.cpp @@ -39,6 +39,8 @@ #include "mongoBackend/dbFieldEncoding.h" #include "mongoBackend/compoundResponses.h" +#include "orionld/common/orionldState.h" // orionldState + using namespace mongo; @@ -139,6 +141,8 @@ ContextElementResponse::ContextElementResponse { prune = false; + LM_TMP(("SA: In ContextElementResponse constructor")); + // Entity BSONObj id = getFieldF(entityDoc, "_id").embeddedObject(); @@ -268,12 +272,16 @@ ContextElementResponse::ContextElementResponse BSONObj mds = getObjectFieldF(attr, ENT_ATTRS_MD); std::set mdsSet; + LM_TMP(("SA: mds: %s", mds.toString().c_str())); mds.getFieldNames(mdsSet); for (std::set::iterator i = mdsSet.begin(); i != mdsSet.end(); ++i) { std::string currentMd = *i; Metadata* md = new Metadata(dbDotDecode(currentMd), getObjectFieldF(mds, currentMd)); caP->metadataVector.push_back(md); + LM_TMP(("SA: pushed the metadata '%s' - system attrs set by Metadata constructor", md->name.c_str())); + LM_TMP(("SA: createdAt for '%s': %f", md->name.c_str(), md->createdAt)); + LM_TMP(("SA: modifiedAt for '%s': %f", md->name.c_str(), md->modifiedAt)); } } diff --git a/src/lib/ngsi/Metadata.cpp b/src/lib/ngsi/Metadata.cpp index 66d2672f28..5740216345 100644 --- a/src/lib/ngsi/Metadata.cpp +++ b/src/lib/ngsi/Metadata.cpp @@ -28,6 +28,8 @@ #include "logMsg/logMsg.h" #include "logMsg/traceLevels.h" +#include "orionld/common/orionldState.h" // orionldState + #include "common/globals.h" #include "common/limits.h" #include "common/tag.h" @@ -70,6 +72,8 @@ Metadata::Metadata() valueType = orion::ValueTypeNotGiven; typeGiven = false; compoundValueP = NULL; + createdAt = 0; + modifiedAt = 0; } @@ -80,7 +84,7 @@ Metadata::Metadata() */ Metadata::Metadata(Metadata* mP, bool useDefaultType) { - LM_T(LmtClone, ("'cloning' Metadata '%s'", mP->name.c_str())); + LM_TMP(("SA: 'cloning' Metadata '%s'", mP->name.c_str())); name = mP->name; type = mP->type; @@ -89,6 +93,8 @@ Metadata::Metadata(Metadata* mP, bool useDefaultType) numberValue = mP->numberValue; boolValue = mP->boolValue; typeGiven = mP->typeGiven; + createdAt = mP->createdAt; + modifiedAt = mP->modifiedAt; LM_T(LmtClone, ("mP->compoundValueP at %p", mP->compoundValueP)); compoundValueP = (mP->compoundValueP != NULL)? mP->compoundValueP->clone() : NULL; @@ -120,6 +126,8 @@ Metadata::Metadata(const std::string& _name, const std::string& _type, const cha stringValue = std::string(_value); typeGiven = false; compoundValueP = NULL; + createdAt = 0; + modifiedAt = 0; } @@ -136,6 +144,8 @@ Metadata::Metadata(const std::string& _name, const std::string& _type, const std stringValue = _value; typeGiven = false; compoundValueP = NULL; + createdAt = 0; + modifiedAt = 0; } @@ -152,6 +162,8 @@ Metadata::Metadata(const std::string& _name, const std::string& _type, double _v numberValue = _value; typeGiven = false; compoundValueP = NULL; + createdAt = 0; + modifiedAt = 0; } @@ -168,6 +180,8 @@ Metadata::Metadata(const std::string& _name, const std::string& _type, bool _val boolValue = _value; typeGiven = false; compoundValueP = NULL; + createdAt = 0; + modifiedAt = 0; } @@ -182,6 +196,8 @@ Metadata::Metadata(const std::string& _name, const BSONObj& mdB) type = mdB.hasField(ENT_ATTRS_MD_TYPE) ? getStringFieldF(mdB, ENT_ATTRS_MD_TYPE) : ""; typeGiven = (type == "")? false : true; compoundValueP = NULL; + createdAt = mdB.hasField("createdAt") ? getNumberFieldF(mdB, "createdAt") : 0; + modifiedAt = mdB.hasField("modifiedAt") ? getNumberFieldF(mdB, "modifiedAt") : 0; BSONType bsonType = getFieldF(mdB, ENT_ATTRS_MD_VALUE).type(); switch (bsonType) @@ -304,6 +320,18 @@ std::string Metadata::render(bool comma) out += "\n"; } + // Adding sysAttrs, if NGSI-LD and if explicitly requested + LM_TMP(("MS: orionldState.apiVersion == %d", orionldState.apiVersion)); + LM_TMP(("MS: orionldState.uriParamOptions.sysAttrs == %d", orionldState.uriParamOptions.sysAttrs)); + if ((orionldState.apiVersion == NGSI_LD_V1) && (orionldState.uriParamOptions.sysAttrs == true)) + { + std::string dateTime = isodate2str(createdAt); + out += JSON_STR("createdAt") + ":" + dateTime; + + dateTime = isodate2str(modifiedAt); + out += JSON_STR("modifiedAt") + ":" + dateTime; + } + out += endTag(comma); return out; @@ -535,6 +563,18 @@ std::string Metadata::toJson(bool isLastElement) out += JSON_VALUE("value", stringValue); } + // Adding sysAttrs, if NGSI-LD and if explicitly requested + LM_TMP(("MS: orionldState.apiVersion == %d", orionldState.apiVersion)); + LM_TMP(("MS: orionldState.uriParamOptions.sysAttrs == %d", orionldState.uriParamOptions.sysAttrs)); + if ((orionldState.apiVersion == NGSI_LD_V1) && (orionldState.uriParamOptions.sysAttrs == true)) + { + std::string dateTime = isodate2str(createdAt); + out += JSON_STR("createdAt") + ":" + dateTime; + + dateTime = isodate2str(modifiedAt); + out += JSON_STR("modifiedAt") + ":" + dateTime; + } + out += "}"; if (!isLastElement) diff --git a/src/lib/ngsi/Metadata.h b/src/lib/ngsi/Metadata.h index ca82ed5c45..0007898e60 100644 --- a/src/lib/ngsi/Metadata.h +++ b/src/lib/ngsi/Metadata.h @@ -80,6 +80,9 @@ typedef struct Metadata bool boolValue; // "value" as a Boolean orion::CompoundValueNode* compoundValueP; + double createdAt; + double modifiedAt; + Metadata(); Metadata(Metadata* mP, bool useDefaultType = false); Metadata(const std::string& _name, const std::string& _type, const char* _value); diff --git a/src/lib/orionld/common/isSpecialSubAttribute.cpp b/src/lib/orionld/common/isSpecialSubAttribute.cpp index 01bb50ee70..0f05669aa2 100644 --- a/src/lib/orionld/common/isSpecialSubAttribute.cpp +++ b/src/lib/orionld/common/isSpecialSubAttribute.cpp @@ -77,7 +77,7 @@ bool isSpecialSubAttribute(const char* attrName, AttributeType* aTypeP, KjNode* *aTypeP = ATTRIBUTE_INSTANCEID; return true; } - else if ((*aTypeP == ATTRIBUTE_PROPERTY) && (strcmp(attrName, "unitCode") == 0)) + else if (strcmp(attrName, "unitCode") == 0) { *aTypeP = ATTRIBUTE_UNITCODE; return true; diff --git a/src/lib/orionld/kjTree/kjTreeFromQueryContextResponse.cpp b/src/lib/orionld/kjTree/kjTreeFromQueryContextResponse.cpp index 309cd930a1..70963cbfc3 100644 --- a/src/lib/orionld/kjTree/kjTreeFromQueryContextResponse.cpp +++ b/src/lib/orionld/kjTree/kjTreeFromQueryContextResponse.cpp @@ -155,8 +155,6 @@ bool orionldSysAttrs(double creDate, double modDate, KjNode* containerP) char date[128]; KjNode* nodeP; - // FIXME: Always "keyValues" for 'createdAt' and 'modifiedAt' ? - // createdAt if (numberToDate(creDate, date, sizeof(date)) == false) { @@ -204,7 +202,7 @@ KjNode* kjTreeFromQueryContextResponse(bool oneHit, char* attrList, bool keyValu char* details = NULL; bool sysAttrs = orionldState.uriParamOptions.sysAttrs; - + LM_TMP(("SA: In kjTreeFromQueryContextResponse")); // // No hits when "oneHit == false" is not an error. // We just return an empty array @@ -509,14 +507,21 @@ KjNode* kjTreeFromQueryContextResponse(bool oneHit, char* attrList, bool keyValu if ((strcmp(mdName, "observedAt") != 0) && (strcmp(mdName, "createdAt") != 0) && - (strcmp(mdName, "modifiedAt") != 0)) + (strcmp(mdName, "modifiedAt") != 0) && + (strcmp(mdName, "unitCode") != 0)) { // // Looking up short name for the sub-attribute // mdName = orionldContextItemAliasLookup(orionldState.contextP, mdName, &valueMayBeCompacted, NULL); + + if (sysAttrs) + { + LM_TMP(("SA: Add system attributes for '%s': %f, %f", mdName, mdP->createdAt, mdP->modifiedAt)); + } } + LM_TMP(("SA: metadata '%s'", mdName)); if (mdP->type != "") { const char* valueFieldName = (mdP->type == "Relationship")? "object" : "value"; @@ -528,6 +533,16 @@ KjNode* kjTreeFromQueryContextResponse(bool oneHit, char* attrList, bool keyValu typeP = kjString(orionldState.kjsonP, "type", mdP->type.c_str()); kjChildAdd(nodeP, typeP); + // System Attributes? + if (sysAttrs == true) + { + if (orionldSysAttrs(mdP->createdAt, mdP->modifiedAt, nodeP) == false) + { + LM_E(("sysAttrs error")); + return NULL; + } + } + details = NULL; switch (mdP->valueType) { diff --git a/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityRetrieve.cpp b/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityRetrieve.cpp index 077832ac97..63a08be64a 100644 --- a/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityRetrieve.cpp +++ b/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityRetrieve.cpp @@ -103,6 +103,11 @@ static bool timestampToString(KjNode* nodeP) // static bool presentationAttributeFix(KjNode* attrP, const char* entityId, bool sysAttrs, bool keyValues) { + LM_TMP(("MS: sysAttrs: %d", sysAttrs)); + char buf[1924]; + kjFastRender(orionldState.kjsonP, attrP, buf, sizeof(buf)); + LM_TMP(("MS: attrP: %s", buf)); + if (keyValues == true) { KjNode* typeP = kjLookup(attrP, "type"); @@ -145,9 +150,25 @@ static bool presentationAttributeFix(KjNode* attrP, const char* entityId, bool s if (createdAtP != NULL) kjChildRemove(attrP, createdAtP); + else + LM_TMP(("MS: createdAt not found")); if (modifiedAtP != NULL) kjChildRemove(attrP, modifiedAtP); + + LM_TMP(("MS: Looping over the attributes metadata to remove all createdAt/modifiedAt")); + for (KjNode* mdP = attrP->value.firstChildP; mdP != NULL; mdP = mdP->next) + { + LM_TMP(("MS: metadata named '%s'", mdP->name)); + + createdAtP = kjLookup(mdP, "createdAt"); + modifiedAtP = kjLookup(mdP, "modifiedAt"); + + if (createdAtP != NULL) + kjChildRemove(mdP, createdAtP); + if (modifiedAtP != NULL) + kjChildRemove(mdP, modifiedAtP); + } } else { @@ -159,6 +180,22 @@ static bool presentationAttributeFix(KjNode* attrP, const char* entityId, bool s if (modifiedAtP != NULL) timestampToString(modifiedAtP); + + LM_TMP(("MS: Looping over the attributes metadata to FIX all createdAt/modifiedAt")); + for (KjNode* mdP = attrP->value.firstChildP; mdP != NULL; mdP = mdP->next) + { + LM_TMP(("MS: metadata named '%s'", mdP->name)); + + createdAtP = kjLookup(mdP, "createdAt"); + modifiedAtP = kjLookup(mdP, "modifiedAt"); + + if (createdAtP != NULL) + timestampToString(createdAtP); + + if (modifiedAtP != NULL) + timestampToString(modifiedAtP); + } + } return true; @@ -628,6 +665,7 @@ KjNode* mongoCppLegacyEntityRetrieve if (attrP->type == KjObject) { + LM_TMP(("MS: Calling presentationAttributeFix")); if (presentationAttributeFix(attrP, entityId, sysAttrs, keyValues) == false) { LM_E(("Internal Error (presentationAttributeFix failed)")); diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_adding_attributes.test b/test/functionalTest/cases/0000_ngsild/ngsild_adding_attributes.test index 357b3304a3..9cb0375453 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_adding_attributes.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_adding_attributes.test @@ -229,10 +229,14 @@ MongoDB server version: REGEX(.*) "type" : "Relationship", "md" : { "https://fiware=github=io/tutorials=Step-by-Step/schema/installedBy" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:Person:employee001" }, "https://fiware=github=io/tutorials=Step-by-Step/schema/statusOfWork" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : "completed" } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_property_property.test b/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_property_property.test index 7b3c8f25c7..20174f73c3 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_property_property.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_property_property.test @@ -105,6 +105,8 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 0.8REGEX(.*) } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_property_relationship.test b/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_property_relationship.test index c9e50f0926..77ada5bdf0 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_property_relationship.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_property_relationship.test @@ -105,6 +105,8 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T2:6789" } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_relationship_property.test b/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_relationship_property.test index 58131703cb..c29a5f1b12 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_relationship_property.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_relationship_property.test @@ -101,6 +101,8 @@ MongoDB server version: REGEX(.*) "value" : "urn:ngsi-ld:T2:6789", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/R1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : "V" } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_relationship_relationship.test b/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_relationship_relationship.test index fb889bbe7b..ef6c1ec4ae 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_relationship_relationship.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entity_creation_one_relationship_relationship.test @@ -101,6 +101,8 @@ MongoDB server version: REGEX(.*) "value" : "urn:ngsi-ld:T2:6789", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/R1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T3:A2345" } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entity_post_operations_upsert.test b/test/functionalTest/cases/0000_ngsild/ngsild_entity_post_operations_upsert.test index 89f4f308c1..8049837214 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entity_post_operations_upsert.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entity_post_operations_upsert.test @@ -268,6 +268,8 @@ MongoDB server version: REGEX(.*) "value" : 1501329604 }, "https://uri=etsi=org/ngsi-ld/default-context/providedBy" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:Person:Bob" } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0019.test b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0019.test index 7b0cb8c6c4..3e4e402e0d 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0019.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0019.test @@ -131,10 +131,14 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T2:6789" }, "https://uri=etsi=org/ngsi-ld/default-context/P1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 0.79 } @@ -152,10 +156,14 @@ MongoDB server version: REGEX(.*) "value" : "urn:ngsi-ld:T2:6789", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/R1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T3:A2345" }, "https://uri=etsi=org/ngsi-ld/default-context/R1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : false } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0028.test b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0028.test index a35c2811ab..079142297a 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0028.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0028.test @@ -141,10 +141,14 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T2:6789" }, "https://uri=etsi=org/ngsi-ld/default-context/P1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 0.79 } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0233.test b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0233.test index f85f18470b..36a2e0b0e6 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0233.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0233.test @@ -136,10 +136,14 @@ MongoDB server version: REGEX(.*) "value" : "Property with Property as sub-attr", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/Prop" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : "sub-attr for Prop/Prop" }, "https://uri=etsi=org/ngsi-ld/default-context/Rel" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "http://a.b.c/x.jsonld" } @@ -156,10 +160,14 @@ MongoDB server version: REGEX(.*) "value" : "http://a.b.c/x.jsonld", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/Prop" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : "sub-attr for Rel/Prop" }, "https://uri=etsi=org/ngsi-ld/default-context/Rel" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "http://a.b.c/x.jsonld" } @@ -208,10 +216,14 @@ MongoDB server version: REGEX(.*) "value" : "Property with Property as sub-attr", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/Prop" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : "sub-attr for Prop/Prop" }, "https://uri=etsi=org/ngsi-ld/default-context/Rel" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "http://a.b.c/x.jsonld" } @@ -228,10 +240,14 @@ MongoDB server version: REGEX(.*) "value" : "http://a.b.c/x.jsonld", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/Prop" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : "sub-attr for Rel/Prop" }, "https://uri=etsi=org/ngsi-ld/default-context/Rel" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "http://a.b.c/x.jsonld" } @@ -246,6 +262,8 @@ MongoDB server version: REGEX(.*) "type" : "Property", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/Prop2" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : "sub-attr Prop2/Prop2" } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0241_notifications.test b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0241_notifications.test index f113dae174..698825b43b 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0241_notifications.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0241_notifications.test @@ -251,10 +251,14 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/providedBy" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:Person:Bob" }, "https://uri=etsi=org/ngsi-ld/default-context/subProp" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : "prop-subProp" } @@ -272,10 +276,14 @@ MongoDB server version: REGEX(.*) "value" : "prop with sub-prop", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/providedBy" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:Person:Bob2" }, "https://uri=etsi=org/ngsi-ld/default-context/subProp" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : "prop-subProp" } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0364.test b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0364.test index 10f386da2b..906702db97 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0364.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0364.test @@ -173,6 +173,8 @@ MongoDB server REGEX(.*) }, "md" : { "https://fiware=github=io/tutorials=Step-by-Step/schema/verified" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : false } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_metadata_with_compound_value.test b/test/functionalTest/cases/0000_ngsild/ngsild_metadata_with_compound_value.test index 5e49bfdb25..3df64096df 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_metadata_with_compound_value.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_metadata_with_compound_value.test @@ -105,6 +105,8 @@ MongoDB server version: REGEX(.*) "value" : 12, "md" : { "https://uri=etsi=org/ngsi-ld/default-context/M" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : { "a" : 1, diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_nested-contexts.test b/test/functionalTest/cases/0000_ngsild/ngsild_nested-contexts.test index c26ec383eb..b46b452e1f 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_nested-contexts.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_nested-contexts.test @@ -140,6 +140,8 @@ MongoDB server version: REGEX(.*) }, "md" : { "https://uri=etsi=org/ngsi-ld/default-context/verified" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : true } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_patch_entity_attr_with_subattr.test b/test/functionalTest/cases/0000_ngsild/ngsild_patch_entity_attr_with_subattr.test index 0067d9d1c6..9b1bba4b6d 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_patch_entity_attr_with_subattr.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_patch_entity_attr_with_subattr.test @@ -728,6 +728,8 @@ MongoDB server version: REGEX(.*) "type" : "Property", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/P1-R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:entities:E16" }, @@ -805,6 +807,8 @@ MongoDB server version: REGEX(.*) "type" : "Property", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/P1-R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:entities:E19" }, @@ -882,10 +886,14 @@ MongoDB server version: REGEX(.*) "type" : "Property", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/P1-P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 22 }, "https://uri=etsi=org/ngsi-ld/default-context/P1-R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:entities:E19" }, @@ -968,10 +976,14 @@ MongoDB server version: REGEX(.*) "type" : "Property", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/P1-P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 22 }, "https://uri=etsi=org/ngsi-ld/default-context/P1-R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:entities:E19" }, @@ -1026,10 +1038,14 @@ MongoDB server version: REGEX(.*) "type" : "Property", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/P1-P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 22 }, "https://uri=etsi=org/ngsi-ld/default-context/P1-R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:entities:E19" }, @@ -1084,10 +1100,14 @@ MongoDB server version: REGEX(.*) "type" : "Property", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/P1-P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 22 }, "https://uri=etsi=org/ngsi-ld/default-context/P1-R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:entities:E19" }, @@ -1145,10 +1165,14 @@ MongoDB server version: REGEX(.*) "type" : "Property", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/P1-P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 22 }, "https://uri=etsi=org/ngsi-ld/default-context/P1-R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:entities:E19" }, @@ -1208,10 +1232,14 @@ MongoDB server version: REGEX(.*) "type" : "Property", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/P1-P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 22 }, "https://uri=etsi=org/ngsi-ld/default-context/P1-R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:entities:E19" }, diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_compound_value.test b/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_compound_value.test index 43f14b5d5d..0b52f34f92 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_compound_value.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_compound_value.test @@ -126,6 +126,8 @@ MongoDB server version: REGEX(.*) }, "md" : { "https://uri=etsi=org/ngsi-ld/default-context/P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 2 } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_observedAt.test b/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_observedAt.test index 83bb779b55..98c3ea48ae 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_observedAt.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_observedAt.test @@ -155,10 +155,14 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T2:6789" }, "https://uri=etsi=org/ngsi-ld/default-context/P1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 0.79REGEX(.*) } @@ -176,10 +180,14 @@ MongoDB server version: REGEX(.*) "value" : "urn:ngsi-ld:T2:6789", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/R1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T3:A2345" }, "https://uri=etsi=org/ngsi-ld/default-context/R1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : false } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_property_of_property.test b/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_property_of_property.test index 2a7a39bc34..371a45b001 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_property_of_property.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_query_condition_over_property_of_property.test @@ -131,10 +131,14 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T2:6789" }, "https://uri=etsi=org/ngsi-ld/default-context/P1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 0.79 } @@ -152,10 +156,14 @@ MongoDB server version: REGEX(.*) "value" : "urn:ngsi-ld:T2:6789", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/R1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T3:A2345" }, "https://uri=etsi=org/ngsi-ld/default-context/R1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : false } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_query_with_type_mismatch.test b/test/functionalTest/cases/0000_ngsild/ngsild_query_with_type_mismatch.test index 0c27245b37..5b27359c43 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_query_with_type_mismatch.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_query_with_type_mismatch.test @@ -136,10 +136,14 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T2:6789" }, "https://uri=etsi=org/ngsi-ld/default-context/P1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 0.79 } @@ -164,10 +168,14 @@ MongoDB server version: REGEX(.*) "value" : "urn:ngsi-ld:T2:6789", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/R1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T3:A2345" }, "https://uri=etsi=org/ngsi-ld/default-context/R1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : false } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entities.test b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entities.test new file mode 100644 index 0000000000..18d20dcf43 --- /dev/null +++ b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entities.test @@ -0,0 +1,252 @@ +# Copyright 2021 FIWARE Foundation e.V. +# +# This file is part of Orion-LD Context Broker. +# +# Orion-LD Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion-LD Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# orionld at fiware dot org + +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh + +--NAME-- +Sub-Attribute system attributes + +--SHELL-INIT-- +export BROKER=orionld +dbInit CB +brokerStart CB 0-255 + +--SHELL-- + +# +# 01. Create an entity E1 with attributes A1 having a sub-property MD1 +# 02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 03. Retrieve E1 without sysAttrs +# 04. Retrieve E1 with sysAttrs on +# 05. Query all entities without sysAttrs +# 06. Query all entities with sysAttrs on +# + +echo "01. Create an entity E1 with attributes A1 having a sub-property MD1" +echo "====================================================================" +payload='{ + "id": "urn:ngsi-ld:entities:E1", + "type": "T", + "A1": { + "type": "Property", + "value": "A1", + "MD1": { + "type": "Property", + "value": 1 + } + } +}' +orionCurl --url /ngsi-ld/v1/entities --payload "$payload" +echo +echo + + +echo "02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest "db.entities.findOne()" +echo +echo + + +echo "03. Retrieve E1 without sysAttrs" +echo "================================" +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1 +echo +echo + + +echo "04. Retrieve E1 with sysAttrs on" +echo "================================" +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1?options=sysAttrs +echo +echo + + +echo "05. Query all entities without sysAttrs" +echo "=======================================" +orionCurl --url '/ngsi-ld/v1/entities?type=T' +echo +echo + + +echo "06. Query all entities with sysAttrs on" +echo "=======================================" +orionCurl --url '/ngsi-ld/v1/entities?options=sysAttrs&type=T' +echo +echo + + +--REGEXPECT-- +01. Create an entity E1 with attributes A1 having a sub-property MD1 +==================================================================== +HTTP/1.1 201 Created +Content-Length: 0 +Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1 +Date: REGEX(.*) + + + +02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "type" : "Property", + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "value" : "A1", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : 1 + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ] + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +03. Retrieve E1 without sysAttrs +================================ +HTTP/1.1 200 OK +Content-Length: 117 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +{ + "A1": { + "MD1": { + "type": "Property", + "value": 1 + }, + "type": "Property", + "value": "A1" + }, + "id": "urn:ngsi-ld:entities:E1", + "type": "T" +} + + +04. Retrieve E1 with sysAttrs on +================================ +HTTP/1.1 200 OK +Content-Length: 354 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +{ + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": 1 + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "A1" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E1", + "modifiedAt": "REGEX(.*)", + "type": "T" +} + + +05. Query all entities without sysAttrs +======================================= +HTTP/1.1 200 OK +Content-Length: 119 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +[ + { + "A1": { + "MD1": { + "type": "Property", + "value": 1 + }, + "type": "Property", + "value": "A1" + }, + "id": "urn:ngsi-ld:entities:E1", + "type": "T" + } +] + + +06. Query all entities with sysAttrs on +======================================= +HTTP/1.1 200 OK +Content-Length: 356 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +[ + { + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": 1 + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "A1" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E1", + "modifiedAt": "REGEX(.*)", + "type": "T" + } +] + + +--TEARDOWN-- +brokerStop CB +dbDrop CB diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_testSuite-case-079.test b/test/functionalTest/cases/0000_ngsild/ngsild_testSuite-case-079.test index 5b524e399f..1e88203a6b 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_testSuite-case-079.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_testSuite-case-079.test @@ -198,10 +198,14 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T2:6789" }, "https://uri=etsi=org/ngsi-ld/default-context/P1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 0.79 } @@ -254,10 +258,14 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T2:6789" }, "https://uri=etsi=org/ngsi-ld/default-context/P1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 0.79 } @@ -273,10 +281,14 @@ MongoDB server version: REGEX(.*) "type" : "Relationship", "md" : { "https://uri=etsi=org/ngsi-ld/default-context/R1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T3:A2345" }, "https://uri=etsi=org/ngsi-ld/default-context/R1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : false } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_tests_01.test b/test/functionalTest/cases/0000_ngsild/ngsild_tests_01.test index 85e87df977..e07e423b26 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_tests_01.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_tests_01.test @@ -113,10 +113,14 @@ MongoDB server version: REGEX(.*) "value" : 1543924800 }, "https://uri=etsi=org/ngsi-ld/default-context/P1_R1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "urn:ngsi-ld:T2:6789" }, "https://uri=etsi=org/ngsi-ld/default-context/P1_P1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Property", "value" : 0.79REGEX(.*) } diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_uriExpansion_attrs.test b/test/functionalTest/cases/0000_ngsild/ngsild_uriExpansion_attrs.test index 0100562966..b3d635278d 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_uriExpansion_attrs.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_uriExpansion_attrs.test @@ -115,6 +115,8 @@ MongoDB server version: REGEX(.*) "value" : "123" }, "https://uri=etsi=org/ngsi-ld/default-context/R_R" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), "type" : "Relationship", "value" : "http://a.b.c/R_R" } From dd9b1de46197df7d944a03ecac6963034d7accc2 Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sun, 18 Apr 2021 09:53:58 +0200 Subject: [PATCH 2/9] Functest to check sub-attr sys-attrs for POST /entities/*/attrs --- ...ngsild_subattr-timestamps-post-entity.test | 456 ++++++++++++++++++ 1 file changed, 456 insertions(+) create mode 100644 test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entity.test diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entity.test b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entity.test new file mode 100644 index 0000000000..7e818c5a99 --- /dev/null +++ b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entity.test @@ -0,0 +1,456 @@ +# Copyright 2021 FIWARE Foundation e.V. +# +# This file is part of Orion-LD Context Broker. +# +# Orion-LD Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion-LD Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# orionld at fiware dot org + +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh + +--NAME-- +Sub-Attribute system attributes + +--SHELL-INIT-- +export BROKER=orionld +dbInit CB +brokerStart CB 0-255 + +--SHELL-- + +# +# 01. Create an entity E1 with attributes A1 having a sub-property MD1 +# 02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 03. POST Entity/attrs, replacing A1 (and MD1) +# 04. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 05. POST Entity/attrs, adding A2 (with MD2) +# 06. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD2 +# 07. Retrieve E1 without sysAttrs +# 08. Retrieve E1 with sysAttrs on +# 09. Query all entities without sysAttrs +# 10. Query all entities with sysAttrs on +# + +echo "01. Create an entity E1 with attributes A1 having a sub-property MD1" +echo "====================================================================" +payload='{ + "id": "urn:ngsi-ld:entities:E1", + "type": "T", + "A1": { + "type": "Property", + "value": "A1", + "MD1": { + "type": "Property", + "value": 1 + } + } +}' +orionCurl --url /ngsi-ld/v1/entities --payload "$payload" +echo +echo + + +echo "02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest "db.entities.findOne()" +echo +echo + + +echo "03. POST Entity/attrs, replacing A1 (and MD1)" +echo "=============================================" +payload='{ + "A1": { + "type": "Property", + "value": "A1-Step03", + "MD1": { + "type": "Property", + "value": 3 + } + } +}' +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1/attrs --payload "$payload" +echo +echo + + +echo "04. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest "db.entities.findOne()" +echo +echo + + +echo "05. POST Entity/attrs, adding A2 (with MD2)" +echo "===========================================" +payload='{ + "A2": { + "type": "Property", + "value": "A2", + "MD2": { + "type": "Property", + "value": 5 + } + } +}' +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1/attrs --payload "$payload" +echo +echo + + +echo "06. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD2" +echo "===========================================================================" +mongoCmd2 ftest "db.entities.findOne()" +echo +echo + + +echo "07. Retrieve E1 without sysAttrs" +echo "================================" +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1 +echo +echo + + +echo "08. Retrieve E1 with sysAttrs on" +echo "================================" +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1?options=sysAttrs +echo +echo + + +echo "09. Query all entities without sysAttrs" +echo "=======================================" +orionCurl --url '/ngsi-ld/v1/entities?type=T' +echo +echo + + +echo "10. Query all entities with sysAttrs on" +echo "=======================================" +orionCurl --url '/ngsi-ld/v1/entities?options=sysAttrs&type=T' +echo +echo + + +--REGEXPECT-- +01. Create an entity E1 with attributes A1 having a sub-property MD1 +==================================================================== +HTTP/1.1 201 Created +Content-Length: 0 +Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1 +Date: REGEX(.*) + + + +02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "type" : "Property", + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "value" : "A1", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : 1 + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ] + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +03. POST Entity/attrs, replacing A1 (and MD1) +============================================= +HTTP/1.1 204 No Content +Date: REGEX(.*) + + + +04. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "value" : "A1-Step03", + "type" : "Property", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : 3 + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ], + "creDate" : REGEX(.*), + "modDate" : REGEX(.*) + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +05. POST Entity/attrs, adding A2 (with MD2) +=========================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) + + + +06. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD2 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1", + "https://uri.etsi.org/ngsi-ld/default-context/A2" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "value" : "A1-Step03", + "type" : "Property", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : 3 + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ], + "creDate" : REGEX(.*), + "modDate" : REGEX(.*) + }, + "https://uri=etsi=org/ngsi-ld/default-context/A2" : { + "value" : "A2", + "type" : "Property", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD2" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : 5 + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD2" + ], + "creDate" : REGEX(.*), + "modDate" : REGEX(.*) + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +07. Retrieve E1 without sysAttrs +================================ +HTTP/1.1 200 OK +Content-Length: 198 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +{ + "A1": { + "MD1": { + "type": "Property", + "value": 3 + }, + "type": "Property", + "value": "A1-Step03" + }, + "A2": { + "MD2": { + "type": "Property", + "value": 5 + }, + "type": "Property", + "value": "A2" + }, + "id": "urn:ngsi-ld:entities:E1", + "type": "T" +} + + +08. Retrieve E1 with sysAttrs on +================================ +HTTP/1.1 200 OK +Content-Length: 593 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +{ + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": 3 + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "A1-Step03" + }, + "A2": { + "MD2": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": 5 + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "A2" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E1", + "modifiedAt": "REGEX(.*)", + "type": "T" +} + + +09. Query all entities without sysAttrs +======================================= +HTTP/1.1 200 OK +Content-Length: 200 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +[ + { + "A1": { + "MD1": { + "type": "Property", + "value": 3 + }, + "type": "Property", + "value": "A1-Step03" + }, + "A2": { + "MD2": { + "type": "Property", + "value": 5 + }, + "type": "Property", + "value": "A2" + }, + "id": "urn:ngsi-ld:entities:E1", + "type": "T" + } +] + + +10. Query all entities with sysAttrs on +======================================= +HTTP/1.1 200 OK +Content-Length: 595 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +[ + { + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": 3 + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "A1-Step03" + }, + "A2": { + "MD2": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": 5 + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "A2" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E1", + "modifiedAt": "REGEX(.*)", + "type": "T" + } +] + + +--TEARDOWN-- +brokerStop CB +dbDrop CB From 73428016a09677bb1c2f38f245a282723000ba6e Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sun, 18 Apr 2021 10:08:51 +0200 Subject: [PATCH 3/9] Functest to check sub-attr sys-attrs for Batch Create --- ...gsild_subattr-timestamps-batch-create.test | 238 ++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-batch-create.test diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-batch-create.test b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-batch-create.test new file mode 100644 index 0000000000..235ccb0ce3 --- /dev/null +++ b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-batch-create.test @@ -0,0 +1,238 @@ +# Copyright 2021 FIWARE Foundation e.V. +# +# This file is part of Orion-LD Context Broker. +# +# Orion-LD Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion-LD Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# orionld at fiware dot org + +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh + +--NAME-- +Sub-Attribute system attributes for Batch Create + +--SHELL-INIT-- +export BROKER=orionld +dbInit CB +brokerStart CB 0-255 + +--SHELL-- + +# +# 01. Batch Create two entities E1 and E2 with attributes A1 having a sub-property MD1 +# 02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 03. See E2 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 04. Query entities with sysAttrs +# + +echo "01. Batch Create two entities E1 and E2 with attributes A1 having a sub-property MD1" +echo "====================================================================================" +payload='[ + { + "id": "urn:ngsi-ld:entities:E1", + "type": "T", + "A1": { + "type": "Property", + "value": "E1:A1", + "MD1": { + "type": "Property", + "value": "E1:A1:MD1" + } + } + }, + { + "id": "urn:ngsi-ld:entities:E2", + "type": "T", + "A1": { + "type": "Property", + "value": "E2:A1", + "MD1": { + "type": "Property", + "value": "E2:A1:MD1" + } + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" +echo +echo + + +echo "02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest 'db.entities.findOne({"_id.id": "urn:ngsi-ld:entities:E1"})' +echo +echo + + +echo "03. See E2 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest 'db.entities.findOne({"_id.id": "urn:ngsi-ld:entities:E2"})' +echo +echo + + +echo "04. Query entities with sysAttrs" +echo "================================" +orionCurl --url "/ngsi-ld/v1/entities?type=T&options=sysAttrs" +echo +echo + + +--REGEXPECT-- +01. Batch Create two entities E1 and E2 with attributes A1 having a sub-property MD1 +==================================================================================== +HTTP/1.1 201 Created +Content-Length: 53 +Content-Type: application/json +Date: REGEX(.*) + +[ + "urn:ngsi-ld:entities:E1", + "urn:ngsi-ld:entities:E2" +] + + +02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "type" : "Property", + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "value" : "E1:A1", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : "E1:A1:MD1" + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ] + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +03. See E2 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E2", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "type" : "Property", + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "value" : "E2:A1", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : "E2:A1:MD1" + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ] + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +04. Query entities with sysAttrs +================================ +HTTP/1.1 200 OK +Content-Length: 737 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +[ + { + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "E1:A1:MD1" + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "E1:A1" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E1", + "modifiedAt": "REGEX(.*)", + "type": "T" + }, + { + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "E2:A1:MD1" + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "E2:A1" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E2", + "modifiedAt": "REGEX(.*)", + "type": "T" + } +] + + +--TEARDOWN-- +brokerStop CB +dbDrop CB From 9cfed61272fb19e5eb0c6e6f4ac4a25c8c160559 Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sun, 18 Apr 2021 11:25:44 +0200 Subject: [PATCH 4/9] More correct response for Batch Upsert --- .../orionldPostBatchUpsert.cpp | 18 +- .../ngsild_@id_@type_alias_validation.test | 16 +- ..._update-attempt_to_change_entity_type.test | 8 +- ..._batch_upsert-context_in_payload_data.test | 14 +- ...gsild_batch_upsert-many-geoproperties.test | 8 +- .../ngsild_batch_upsert-options=replace.test | 8 +- ...ions=replace_payload_error_type_field.test | 10 +- .../ngsild_batch_upsert-options=update.test | 8 +- ..._upsert-options=update_error_handling.test | 10 +- .../0000_ngsild/ngsild_batch_upsert.test | 8 +- .../0000_ngsild/ngsild_batch_upsert2.test | 8 +- .../ngsild_batch_upsert_and_contexts.test | 11 +- ...rt_crash_with_and_without_link_header.test | 7 +- ...place_two_entities_different_credates.test | 14 +- .../ngsild_entity_post_operations_upsert.test | 10 +- .../cases/0000_ngsild/ngsild_issue_0393.test | 7 +- .../cases/0000_ngsild/ngsild_issue_0457.test | 8 +- ...gsild_subattr-timestamps-batch-upsert.test | 238 ++++++++++++++++++ ...sild_subattr-timestamps-post-entities.test | 2 +- ...ngsild_subattr-timestamps-post-entity.test | 2 +- 20 files changed, 392 insertions(+), 23 deletions(-) create mode 100644 test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-batch-upsert.test diff --git a/src/lib/orionld/serviceRoutines/orionldPostBatchUpsert.cpp b/src/lib/orionld/serviceRoutines/orionldPostBatchUpsert.cpp index 0df9b25831..4a4fd4a309 100644 --- a/src/lib/orionld/serviceRoutines/orionldPostBatchUpsert.cpp +++ b/src/lib/orionld/serviceRoutines/orionldPostBatchUpsert.cpp @@ -29,6 +29,7 @@ extern "C" #include "kjson/kjBuilder.h" // kjString, kjObject, ... #include "kjson/kjLookup.h" // kjLookup #include "kjson/kjClone.h" // kjClone +#include "kjson/kjRender.h" // kjFastRender } #include "logMsg/logMsg.h" // LM_* @@ -138,6 +139,7 @@ static void entityTypeAndCreDateGet(KjNode* dbEntityP, char** idP, char** typeP, // bool orionldPostBatchUpsert(ConnectionInfo* ciP) { + LM_TMP(("BUPS: In orionldPostBatchUpsert")); // Error or not, the Link header should never be present in the reponse orionldState.noLinkHeader = true; @@ -416,8 +418,20 @@ bool orionldPostBatchUpsert(ConnectionInfo* ciP) } else { - orionldState.httpStatusCode = 204; // No Content - orionldState.responseTree = NULL; + // + // FIXME: "idTypeAndCreDateFromDb == NULL" is not enough to decide whether all the entities were created or just updated + // Need a better check (look inside idTypeAndCreDateFromDb and compare with the EIDs in the payload body) + // + if (idTypeAndCreDateFromDb == NULL) // None of the entities were found in DB - 201 Created + { + orionldState.httpStatusCode = 201; + orionldState.responseTree = successArrayP; + } + else // All entities were found in DB - 204 No Content + { + orionldState.httpStatusCode = 204; // No Content + orionldState.responseTree = NULL; + } } if (troe == true) diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_@id_@type_alias_validation.test b/test/functionalTest/cases/0000_ngsild/ngsild_@id_@type_alias_validation.test index fba8d710b3..8a89287676 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_@id_@type_alias_validation.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_@id_@type_alias_validation.test @@ -430,16 +430,28 @@ Date: REGEX(.*) 08. Upsert of entities - options=update - with entityOperations using @id and @type =================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 57 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:Vehicle:00001", + "urn:ngsi-ld:Vehicle:00002" +] 09. Upsert of entities - options=replace - with entityOperations using @id and @type ==================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 57 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:Vehicle:00004", + "urn:ngsi-ld:Vehicle:00005" +] --TEARDOWN-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_update-attempt_to_change_entity_type.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_update-attempt_to_change_entity_type.test index f5393a7be5..18b84306fc 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_update-attempt_to_change_entity_type.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_update-attempt_to_change_entity_type.test @@ -99,9 +99,15 @@ echo --REGEXPECT-- 01. Batch Creation via UPSERT of two entities, urn:E1 and urn:E2 ================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 19 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:E1", + "urn:E2" +] 02. Attempt to change entity type of entity urn:E1 in a batch update operation diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-context_in_payload_data.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-context_in_payload_data.test index f1555624b8..7504469cc9 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-context_in_payload_data.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-context_in_payload_data.test @@ -200,9 +200,14 @@ Date: REGEX(.*) 03. Batch Upsert, Content-Type is JSON, and no @context present in an item of the array - OK ============================================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 15 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:test:E1" +] 04. Batch Upsert, Content-Type is LD+JSON, @context in payload data but ALSO in HTTP link header @@ -221,9 +226,14 @@ Date: REGEX(.*) 05. Issue a Batch upsert command, creating 3 new entities, each with a different context ======================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 10 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:E1" +] 06. GET all entities without context, see long names for all entity-types and attribute names that weren't expanded using the Core Context diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-many-geoproperties.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-many-geoproperties.test index 7d8fdbeaed..c3e8d57e84 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-many-geoproperties.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-many-geoproperties.test @@ -201,9 +201,15 @@ echo --REGEXPECT-- 01. Batch Creation via UPSERT of two entities with a single GeoProperty each ============================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 85 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:GtfsStation:900000245025:MS", + "urn:ngsi-ld:GtfsStation:900000550090:MS" +] 02. GET the entities diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=replace.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=replace.test index 15a69d8bbb..ea6ef73947 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=replace.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=replace.test @@ -190,9 +190,15 @@ echo --REGEXPECT-- 01. Create entities E1 and E2 using POST /ngsi-ld/v1/entityOperations/upsert?options=replace ============================================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 49 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E1", + "urn:ngsi-ld:entity:E2" +] 02. See the two entities in mongo diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=replace_payload_error_type_field.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=replace_payload_error_type_field.test index f737e50f3f..5d88e6cbc6 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=replace_payload_error_type_field.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=replace_payload_error_type_field.test @@ -193,9 +193,17 @@ echo --REGEXPECT-- 01. POST /ngsi-ld/v1/entityOperations/upsert?options=replace - 4 entities ========================================================================= -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 113 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:Vehicle:00001", + "urn:ngsi-ld:Vehicle:00002", + "urn:ngsi-ld:Vehicle:00003", + "urn:ngsi-ld:Vehicle:00004" +] 02. Update all four entities. Vehicle:00001 with a entity::type that differs diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=update.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=update.test index 1a6dfef979..d9d362bb40 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=update.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=update.test @@ -105,9 +105,15 @@ echo --REGEXPECT-- 01. Create entities E1 and E2 using POST /ngsi-ld/v1/entityOperations/upsert?options=update =========================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 49 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E1", + "urn:ngsi-ld:entity:E2" +] 02. GET the entities diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=update_error_handling.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=update_error_handling.test index 8103e17ef8..5868700924 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=update_error_handling.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert-options=update_error_handling.test @@ -643,9 +643,17 @@ Date: REGEX(.*) 11. POST /ngsi-ld/v1/entityOperations/upsert?options=update - 4 entities ======================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 113 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:Vehicle:00001", + "urn:ngsi-ld:Vehicle:00002", + "urn:ngsi-ld:Vehicle:00003", + "urn:ngsi-ld:Vehicle:00004" +] 12. POST /ngsi-ld/v1/entityOperations/upsert?options=update - 4 same entities from step 11 diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert.test index 8f667c3a6d..57cd89dcf6 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert.test @@ -154,9 +154,15 @@ echo --REGEXPECT-- 01. Create entities E1 and E2 with attributes P1 and R1 ======================================================= -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 49 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E1", + "urn:ngsi-ld:entity:E2" +] 02. Modify E1 with Batch Upsert (replacing with attrs P2 and R2) and add E3, also with attrs P2 and R2 diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert2.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert2.test index 5eaec486b2..f633be8d16 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert2.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert2.test @@ -307,9 +307,15 @@ echo --REGEXPECT-- 01. Create entities E1 and E2 with attributes P1 and R1, using batch upsert =========================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 49 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E1", + "urn:ngsi-ld:entity:E2" +] 02. GET entities, see E1 and E2 with attributes P1 and R1 diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_and_contexts.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_and_contexts.test index 436939eb6c..dfaa8d3fd8 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_and_contexts.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_and_contexts.test @@ -509,9 +509,18 @@ echo --REGEXPECT-- 01. Upsert 5 entities with context arrays in payload ==================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 233 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:WeatherObserved:BMP180:22828", + "urn:ngsi-ld:WeatherObserved:BMP180:15333", + "urn:ngsi-ld:WeatherObserved:BMP180:25514", + "urn:ngsi-ld:WeatherObserved:BMP180:18219", + "urn:ngsi-ld:WeatherObserved:BMP180:16956" +] diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_crash_with_and_without_link_header.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_crash_with_and_without_link_header.test index 9f15393909..86936be31e 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_crash_with_and_without_link_header.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_crash_with_and_without_link_header.test @@ -145,9 +145,14 @@ echo --REGEXPECT-- 01. CREATE a single entity using UPSERT and WITHOUT additional Context in Link header ===================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 49 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:WeatherObserved:BMP180:22828" +] diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_replace_two_entities_different_credates.test b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_replace_two_entities_different_credates.test index b2cb2c40e4..a94f58d8a6 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_replace_two_entities_different_credates.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_batch_upsert_replace_two_entities_different_credates.test @@ -158,9 +158,14 @@ echo --REGEXPECT-- 01. Create entity E1 ==================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E1" +] 02. Sleep 2 secs @@ -170,9 +175,14 @@ Slept 2 seconds 03. Create entity E2 ==================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E2" +] 04. Get the creDates of E1 and E2 diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entity_post_operations_upsert.test b/test/functionalTest/cases/0000_ngsild/ngsild_entity_post_operations_upsert.test index 8049837214..2e3b26c07a 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entity_post_operations_upsert.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entity_post_operations_upsert.test @@ -230,9 +230,17 @@ echo --REGEXPECT-- 01. POST /ngsi-ld/v1/entityOperations/upsert?options=update - 4 Entities ======================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 113 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:Vehicle:00001", + "urn:ngsi-ld:Vehicle:00002", + "urn:ngsi-ld:Vehicle:00003", + "urn:ngsi-ld:Vehicle:00004" +] 02. See the entity urn:ngsi-ld:Vehicle:00001 in mongo diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0393.test b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0393.test index 7dc1730d88..537922ed31 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0393.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0393.test @@ -127,9 +127,14 @@ echo --REGEXPECT-- 01. Create an entity 'urn:ngsi-ld:testunit:125' using batch upsert ================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 28 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:testunit:125" +] 02. See the entity in the database diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0457.test b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0457.test index 0969c3f3b2..039db64686 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_issue_0457.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_issue_0457.test @@ -136,9 +136,15 @@ echo --REGEXPECT-- 01. Create 2 entities ===================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 95 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:WeatherObserved:BMP180:21336", + "urn:ngsi-ld:WeatherObserved:BMP180:30765" +] diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-batch-upsert.test b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-batch-upsert.test new file mode 100644 index 0000000000..6c1389237b --- /dev/null +++ b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-batch-upsert.test @@ -0,0 +1,238 @@ +# Copyright 2021 FIWARE Foundation e.V. +# +# This file is part of Orion-LD Context Broker. +# +# Orion-LD Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion-LD Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# orionld at fiware dot org + +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh + +--NAME-- +Sub-Attribute system attributes for Batch Upsert + +--SHELL-INIT-- +export BROKER=orionld +dbInit CB +brokerStart CB 0-255 + +--SHELL-- + +# +# 01. Batch Upsert two entities E1 and E2 with attributes A1 having a sub-property MD1 +# 02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 03. See E2 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 04. Query entities with sysAttrs +# + +echo "01. Batch Upsert two entities E1 and E2 with attributes A1 having a sub-property MD1" +echo "====================================================================================" +payload='[ + { + "id": "urn:ngsi-ld:entities:E1", + "type": "T", + "A1": { + "type": "Property", + "value": "E1:A1", + "MD1": { + "type": "Property", + "value": "E1:A1:MD1" + } + } + }, + { + "id": "urn:ngsi-ld:entities:E2", + "type": "T", + "A1": { + "type": "Property", + "value": "E2:A1", + "MD1": { + "type": "Property", + "value": "E2:A1:MD1" + } + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/upsert --payload "$payload" +echo +echo + + +echo "02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest 'db.entities.findOne({"_id.id": "urn:ngsi-ld:entities:E1"})' +echo +echo + + +echo "03. See E2 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest 'db.entities.findOne({"_id.id": "urn:ngsi-ld:entities:E2"})' +echo +echo + + +echo "04. Query entities with sysAttrs" +echo "================================" +orionCurl --url "/ngsi-ld/v1/entities?type=T&options=sysAttrs" +echo +echo + + +--REGEXPECT-- +01. Batch Upsert two entities E1 and E2 with attributes A1 having a sub-property MD1 +==================================================================================== +HTTP/1.1 201 Created +Content-Length: 53 +Content-Type: application/json +Date: REGEX(.*) + +[ + "urn:ngsi-ld:entities:E1", + "urn:ngsi-ld:entities:E2" +] + + +02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "type" : "Property", + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "value" : "E1:A1", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : "E1:A1:MD1" + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ] + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +03. See E2 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E2", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "type" : "Property", + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "value" : "E2:A1", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : "E2:A1:MD1" + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ] + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +04. Query entities with sysAttrs +================================ +HTTP/1.1 200 OK +Content-Length: 737 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +[ + { + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "E1:A1:MD1" + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "E1:A1" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E1", + "modifiedAt": "REGEX(.*)", + "type": "T" + }, + { + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "E2:A1:MD1" + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "E2:A1" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E2", + "modifiedAt": "REGEX(.*)", + "type": "T" + } +] + + +--TEARDOWN-- +brokerStop CB +dbDrop CB diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entities.test b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entities.test index 18d20dcf43..2dfdeb1dd4 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entities.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entities.test @@ -21,7 +21,7 @@ # VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh --NAME-- -Sub-Attribute system attributes +Sub-Attribute system attributes for POST /entities --SHELL-INIT-- export BROKER=orionld diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entity.test b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entity.test index 7e818c5a99..3b666702b1 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entity.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-post-entity.test @@ -21,7 +21,7 @@ # VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh --NAME-- -Sub-Attribute system attributes +Sub-Attribute system attributes for POST /entities/*/attrs --SHELL-INIT-- export BROKER=orionld From 527f4ba7f3b9be5f978b6c0987748404aa66b985 Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sun, 18 Apr 2021 11:37:23 +0200 Subject: [PATCH 5/9] Functest to check sub-attr sys-attrs for PATCH Entity Attributes --- ...tr-timestamps-patch-entity-attributes.test | 325 ++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100644 test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-patch-entity-attributes.test diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-patch-entity-attributes.test b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-patch-entity-attributes.test new file mode 100644 index 0000000000..9ccdbd65e4 --- /dev/null +++ b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-patch-entity-attributes.test @@ -0,0 +1,325 @@ +# Copyright 2021 FIWARE Foundation e.V. +# +# This file is part of Orion-LD Context Broker. +# +# Orion-LD Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion-LD Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# orionld at fiware dot org + +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh + +--NAME-- +Sub-Attribute system attributes for PATCH /entities/*/attrs + +--SHELL-INIT-- +export BROKER=orionld +dbInit CB +brokerStart CB 0-255 + +--SHELL-- + +# +# 01. Create an entity E1 with attributes A1 having a sub-property MD1 +# 02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 03. PATCH Entity/attrs, replacing A1 (and MD1) +# 04. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 05. Retrieve E1 without sysAttrs +# 06. Retrieve E1 with sysAttrs on +# 07. Query all entities without sysAttrs +# 08. Query all entities with sysAttrs on +# + +echo "01. Create an entity E1 with attributes A1 having a sub-property MD1" +echo "====================================================================" +payload='{ + "id": "urn:ngsi-ld:entities:E1", + "type": "T", + "A1": { + "type": "Property", + "value": "A1", + "MD1": { + "type": "Property", + "value": 1 + } + } +}' +orionCurl --url /ngsi-ld/v1/entities --payload "$payload" +echo +echo + + +echo "02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest "db.entities.findOne()" +echo +echo + + +echo "03. PATCH Entity/attrs, replacing A1 (and MD1)" +echo "==============================================" +payload='{ + "A1": { + "type": "Property", + "value": "A1-Step03", + "MD1": { + "type": "Property", + "value": 3 + } + } +}' +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1/attrs --payload "$payload" -X PATCH +echo +echo + + +echo "04. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest "db.entities.findOne()" +echo +echo + + +echo "05. Retrieve E1 without sysAttrs" +echo "================================" +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1 +echo +echo + + +echo "06. Retrieve E1 with sysAttrs on" +echo "================================" +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1?options=sysAttrs +echo +echo + + +echo "07. Query all entities without sysAttrs" +echo "=======================================" +orionCurl --url '/ngsi-ld/v1/entities?type=T' +echo +echo + + +echo "08. Query all entities with sysAttrs on" +echo "=======================================" +orionCurl --url '/ngsi-ld/v1/entities?options=sysAttrs&type=T' +echo +echo + + +--REGEXPECT-- +01. Create an entity E1 with attributes A1 having a sub-property MD1 +==================================================================== +HTTP/1.1 201 Created +Content-Length: 0 +Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1 +Date: REGEX(.*) + + + +02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "type" : "Property", + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "value" : "A1", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : 1 + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ] + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +03. PATCH Entity/attrs, replacing A1 (and MD1) +============================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) + + + +04. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "type" : "Property", + "creDate" : REGEX(.*), + "modDate" : REGEX(.*) + "value" : "A1-Step03", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : 3 + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ] + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +05. Retrieve E1 without sysAttrs +================================ +HTTP/1.1 200 OK +Content-Length: 124 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +{ + "A1": { + "MD1": { + "type": "Property", + "value": 3 + }, + "type": "Property", + "value": "A1-Step03" + }, + "id": "urn:ngsi-ld:entities:E1", + "type": "T" +} + + +06. Retrieve E1 with sysAttrs on +================================ +HTTP/1.1 200 OK +Content-Length: 361 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +{ + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": 3 + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "A1-Step03" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E1", + "modifiedAt": "REGEX(.*)", + "type": "T" +} + + +07. Query all entities without sysAttrs +======================================= +HTTP/1.1 200 OK +Content-Length: 126 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +[ + { + "A1": { + "MD1": { + "type": "Property", + "value": 3 + }, + "type": "Property", + "value": "A1-Step03" + }, + "id": "urn:ngsi-ld:entities:E1", + "type": "T" + } +] + + +08. Query all entities with sysAttrs on +======================================= +HTTP/1.1 200 OK +Content-Length: 363 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +[ + { + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": 3 + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "A1-Step03" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E1", + "modifiedAt": "REGEX(.*)", + "type": "T" + } +] + + +--TEARDOWN-- +brokerStop CB +dbDrop CB From 0071cbb371c78451cc64fd42435b3864a233d473 Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sun, 18 Apr 2021 11:47:46 +0200 Subject: [PATCH 6/9] Functest to check sub-attr sys-attrs for PATCH Invividual Entity Attribute --- ...ttr-timestamps-patch-entity-attribute.test | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-patch-entity-attribute.test diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-patch-entity-attribute.test b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-patch-entity-attribute.test new file mode 100644 index 0000000000..0e8f6bfaf5 --- /dev/null +++ b/test/functionalTest/cases/0000_ngsild/ngsild_subattr-timestamps-patch-entity-attribute.test @@ -0,0 +1,239 @@ +# Copyright 2021 FIWARE Foundation e.V. +# +# This file is part of Orion-LD Context Broker. +# +# Orion-LD Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion-LD Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# orionld at fiware dot org + +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh + +--NAME-- +Sub-Attribute system attributes for PATCH /entities/*/attrs/* + +--SHELL-INIT-- +export BROKER=orionld +dbInit CB +brokerStart CB 0-255 + +--SHELL-- + +# +# 01. Create an entity E1 with attributes A1 having a sub-property MD1 +# 02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +# 03. PATCH Entity/attrs/A1, replacing MD1, and adding MD2 +# 04. See E1 in mongo - see createdAt and modifiedAt for the sub-properties +# 05. Retrieve E1 with sysAttrs on +# + +echo "01. Create an entity E1 with attributes A1 having a sub-property MD1" +echo "====================================================================" +payload='{ + "id": "urn:ngsi-ld:entities:E1", + "type": "T", + "A1": { + "type": "Property", + "value": "A1", + "MD1": { + "type": "Property", + "value": 1 + } + } +}' +orionCurl --url /ngsi-ld/v1/entities --payload "$payload" +echo +echo + + +echo "02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1" +echo "===========================================================================" +mongoCmd2 ftest "db.entities.findOne()" +echo +echo + + +echo "03. PATCH Entity/attrs/A1, replacing MD1, and adding MD2" +echo "========================================================" +payload='{ + "value": "A1-Step03", + "MD1": { + "type": "Property", + "value": 3 + }, + "MD2": { + "type": "Relationship", + "object": "urn:ngsi-ld:subattr:MD2" + } +}' +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1/attrs/A1 --payload "$payload" -X PATCH +echo +echo + + +echo "04. See E1 in mongo - see createdAt and modifiedAt for the sub-properties" +echo "=========================================================================" +mongoCmd2 ftest "db.entities.findOne()" +echo +echo + + +echo "05. Retrieve E1 with sysAttrs on" +echo "================================" +orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1?options=sysAttrs +echo +echo + + +--REGEXPECT-- +01. Create an entity E1 with attributes A1 having a sub-property MD1 +==================================================================== +HTTP/1.1 201 Created +Content-Length: 0 +Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1 +Date: REGEX(.*) + + + +02. See E1 in mongo - see createdAt and modifiedAt for the sub-property MD1 +=========================================================================== +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "type" : "Property", + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "value" : "A1", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : 1 + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1" + ] + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +03. PATCH Entity/attrs/A1, replacing MD1, and adding MD2 +======================================================== +HTTP/1.1 204 No Content +Date: REGEX(.*) + + + +04. See E1 in mongo - see createdAt and modifiedAt for the sub-properties +========================================================================= +MongoDB shell version REGEX(.*) +connecting to: REGEX(.*) +MongoDB server version: REGEX(.*) +{ + "_id" : { + "id" : "urn:ngsi-ld:entities:E1", + "type" : "https://uri.etsi.org/ngsi-ld/default-context/T", + "servicePath" : "/" + }, + "attrNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/A1" + ], + "attrs" : { + "https://uri=etsi=org/ngsi-ld/default-context/A1" : { + "value" : "A1-Step03", + "type" : "Property", + "md" : { + "https://uri=etsi=org/ngsi-ld/default-context/MD1" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Property", + "value" : 3 + }, + "https://uri=etsi=org/ngsi-ld/default-context/MD2" : { + "createdAt" : REGEX(.*), + "modifiedAt" : REGEX(.*), + "type" : "Relationship", + "value" : "urn:ngsi-ld:subattr:MD2" + } + }, + "mdNames" : [ + "https://uri.etsi.org/ngsi-ld/default-context/MD1", + "https://uri.etsi.org/ngsi-ld/default-context/MD2" + ], + "creDate" : REGEX(.*), + "modDate" : REGEX(.*) + } + }, + "creDate" : REGEX(.*), + "modDate" : REGEX(.*), + "lastCorrelator" : "" +} +bye + + +05. Retrieve E1 with sysAttrs on +================================ +HTTP/1.1 200 OK +Content-Length: 505 +Content-Type: application/json +Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +Date: REGEX(.*) + +{ + "A1": { + "MD1": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": 3 + }, + "MD2": { + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "object": "urn:ngsi-ld:subattr:MD2", + "type": "Relationship" + }, + "createdAt": "REGEX(.*)", + "modifiedAt": "REGEX(.*)", + "type": "Property", + "value": "A1-Step03" + }, + "createdAt": "REGEX(.*)", + "id": "urn:ngsi-ld:entities:E1", + "modifiedAt": "REGEX(.*)", + "type": "T" +} + + +--TEARDOWN-- +brokerStop CB +dbDrop CB From f9f91b5f910a36fcea49265748dbb26aed06fc91 Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sun, 18 Apr 2021 12:06:01 +0200 Subject: [PATCH 7/9] CHANGES_NEXT_RELEASE --- CHANGES_NEXT_RELEASE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 52965adb67..78a653d7bc 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -6,3 +6,5 @@ * Issue #280 Implemented datasetId for PATCH /entities/{EID}/attrs/{attrName} * Issue #280 Implemented datasetId for DELETE /entities/{EID}/attrs/{attrName} (supporting URI params 'datasetId' and 'deleteAll') * Issue #280 Implemented GET /attributes, but only without details=true +* Issue #280 Slightly increased response from Batch Upsert +* Issue #280 Implemented system attributes (createdAt, modifiedAt) for sub-attributes From cf6be9d38816d88951733444d35f1a6c468742b9 Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sun, 18 Apr 2021 12:22:27 +0200 Subject: [PATCH 8/9] style --- src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityRetrieve.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityRetrieve.cpp b/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityRetrieve.cpp index 63a08be64a..9034242d27 100644 --- a/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityRetrieve.cpp +++ b/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityRetrieve.cpp @@ -195,7 +195,6 @@ static bool presentationAttributeFix(KjNode* attrP, const char* entityId, bool s if (modifiedAtP != NULL) timestampToString(modifiedAtP); } - } return true; From 849f8bd8b3fd23e68e607724d1f04e56e61a7adc Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sun, 18 Apr 2021 18:37:24 +0200 Subject: [PATCH 9/9] The TRoE tests also needed updates for the improvement in Batch Upsert responses --- ...h_upsert-options-update_with_contexts.test | 7 ++- ...t-with-some-entities-already-existing.test | 8 +++- .../0000_troe/troe_batch_upsert_bug.test | 7 ++- .../troe_batch_upsert_with_contexts.test | 7 ++- .../troe_exhaustive_batch_upsert-replace.test | 48 ++++++++++++++++--- .../troe_exhaustive_batch_upsert-update.test | 48 ++++++++++++++++--- ...troe_exhaustive_batch_upsert_subAttrs.test | 36 ++++++++++++-- ...haustive_batch_upsert_update_subAttrs.test | 36 ++++++++++++-- ..._link_and_tenant_header_with_batch_op.test | 7 ++- .../0000_troe/troe_tenants_and_batch_ops.test | 7 ++- 10 files changed, 183 insertions(+), 28 deletions(-) diff --git a/test/functionalTest/cases/0000_troe/troe_batch_upsert-options-update_with_contexts.test b/test/functionalTest/cases/0000_troe/troe_batch_upsert-options-update_with_contexts.test index 6aa73517fa..450924222b 100644 --- a/test/functionalTest/cases/0000_troe/troe_batch_upsert-options-update_with_contexts.test +++ b/test/functionalTest/cases/0000_troe/troe_batch_upsert-options-update_with_contexts.test @@ -109,9 +109,14 @@ echo --REGEXPECT-- 01. Upsert/Create the entity E1, with a user context ==================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 27 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entities:E1" +] 02. GET the entity without context (core) and see the longnames of entity-type and attributes diff --git a/test/functionalTest/cases/0000_troe/troe_batch_upsert-with-some-entities-already-existing.test b/test/functionalTest/cases/0000_troe/troe_batch_upsert-with-some-entities-already-existing.test index 8e989e2ac7..d8435dec58 100644 --- a/test/functionalTest/cases/0000_troe/troe_batch_upsert-with-some-entities-already-existing.test +++ b/test/functionalTest/cases/0000_troe/troe_batch_upsert-with-some-entities-already-existing.test @@ -183,9 +183,15 @@ echo --REGEXPECT-- 01. Create entities E1 and E2 ============================= -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 53 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entities:E1", + "urn:ngsi-ld:entities:E2" +] 02. Batch Upsert entities E1-E4 diff --git a/test/functionalTest/cases/0000_troe/troe_batch_upsert_bug.test b/test/functionalTest/cases/0000_troe/troe_batch_upsert_bug.test index c7bb071065..1a1d43d1f5 100644 --- a/test/functionalTest/cases/0000_troe/troe_batch_upsert_bug.test +++ b/test/functionalTest/cases/0000_troe/troe_batch_upsert_bug.test @@ -142,9 +142,14 @@ echo --REGEXPECT-- 01. Use Batch Upsert to create an entity on tenant openiot, with a user context that is an array ================================================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 33 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:Device:filling001" +] 02. See the entity in mongo diff --git a/test/functionalTest/cases/0000_troe/troe_batch_upsert_with_contexts.test b/test/functionalTest/cases/0000_troe/troe_batch_upsert_with_contexts.test index a5ab13cb3e..21ab2e0228 100644 --- a/test/functionalTest/cases/0000_troe/troe_batch_upsert_with_contexts.test +++ b/test/functionalTest/cases/0000_troe/troe_batch_upsert_with_contexts.test @@ -109,9 +109,14 @@ echo --REGEXPECT-- 01. Upsert/Create the entity E1, with a user context ==================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 27 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entities:E1" +] 02. GET the entity without context (core) and see the longnames of entity-type and attributes diff --git a/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert-replace.test b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert-replace.test index ce6b7bf1fb..a0dbaa36ba 100644 --- a/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert-replace.test +++ b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert-replace.test @@ -993,44 +993,80 @@ Date: REGEX(.*) 05. Upsert E7,E9 on default tenant, with user context in Link Header ==================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 49 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E7", + "urn:ngsi-ld:entity:E9" +] 06. Upsert E8,E10 on T1 tenant, with user context in Link Header ================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 50 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E8", + "urn:ngsi-ld:entity:E10" +] 07. Upsert E11,E13 on default tenant, with user context in payload body ======================================================================= -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 51 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E11", + "urn:ngsi-ld:entity:E13" +] 08. Upsert E12,E14 on T1 tenant, with user context in payload body ================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 51 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E12", + "urn:ngsi-ld:entity:E14" +] 09. Upsert E15 with user context #1 and E17 with user context #2, in payload body, on default tenant ==================================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 51 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E15", + "urn:ngsi-ld:entity:E17" +] 10. Upsert E16 with user context #1 and E18 with user context #2, in payload body, on T1 tenant =============================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 51 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E16", + "urn:ngsi-ld:entity:E18" +] 11. See all entities in TRoE DB, default tenant diff --git a/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert-update.test b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert-update.test index e91c641bda..58102ca41f 100644 --- a/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert-update.test +++ b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert-update.test @@ -993,44 +993,80 @@ Date: REGEX(.*) 05. Upsert E7,E9 on default tenant, with user context in Link Header ==================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 49 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E7", + "urn:ngsi-ld:entity:E9" +] 06. Upsert E8,E10 on T1 tenant, with user context in Link Header ================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 50 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E8", + "urn:ngsi-ld:entity:E10" +] 07. Upsert E11,E13 on default tenant, with user context in payload body ======================================================================= -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 51 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E11", + "urn:ngsi-ld:entity:E13" +] 08. Upsert E12,E14 on T1 tenant, with user context in payload body ================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 51 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E12", + "urn:ngsi-ld:entity:E14" +] 09. Upsert E15 with user context #1 and E17 with user context #2, in payload body, on default tenant ==================================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 51 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E15", + "urn:ngsi-ld:entity:E17" +] 10. Upsert E16 with user context #1 and E18 with user context #2, in payload body, on T1 tenant =============================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 51 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E16", + "urn:ngsi-ld:entity:E18" +] 11. See all entities in TRoE DB, default tenant diff --git a/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert_subAttrs.test b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert_subAttrs.test index 580f1f76ce..08d7bdaf09 100644 --- a/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert_subAttrs.test +++ b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert_subAttrs.test @@ -758,16 +758,26 @@ echo --REGEXPECT-- 01. Batch Upsert entity E1 on default tenant and without context ================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E1" +] 02. Batch Upsert entity E2 on T1 tenant and without context =========================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E2" +] 03. Batch Upsert entity E1+E3 on default tenant and without context - E1 replaced, E3 created @@ -786,23 +796,39 @@ Date: REGEX(.*) 05. Batch Upsert entity E5 on default tenant and with user context in Link header ================================================================================= -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E5" +] 06. Batch Upsert entity E6 on T1 tenant and with user context in Link header ============================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E6" +] 07. Batch Upsert entity E7+E9 on default tenant and with user contexts 1+2 in payload body ========================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 49 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E7", + "urn:ngsi-ld:entity:E9" +] 08. Batch Upsert entity E8+E10 on T1 tenant and with user contexts 1+2 in payload body diff --git a/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert_update_subAttrs.test b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert_update_subAttrs.test index 670cee7107..82f79e81d1 100644 --- a/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert_update_subAttrs.test +++ b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_upsert_update_subAttrs.test @@ -758,16 +758,26 @@ echo --REGEXPECT-- 01. Batch Upsert entity E1 on default tenant and without context ================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E1" +] 02. Batch Upsert entity E2 on T1 tenant and without context =========================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E2" +] 03. Batch Upsert entity E1+E3 on default tenant and without context - E1 updated, E3 created @@ -786,23 +796,39 @@ Date: REGEX(.*) 05. Batch Upsert entity E5 on default tenant and with user context in Link header ================================================================================= -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E5" +] 06. Batch Upsert entity E6 on T1 tenant and with user context in Link header ============================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 25 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E6" +] 07. Batch Upsert entity E7+E9 on default tenant and with user contexts 1+2 in payload body ========================================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 49 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entity:E7", + "urn:ngsi-ld:entity:E9" +] 08. Batch Upsert entity E8+E10 on T1 tenant and with user contexts 1+2 in payload body diff --git a/test/functionalTest/cases/0000_troe/troe_link_and_tenant_header_with_batch_op.test b/test/functionalTest/cases/0000_troe/troe_link_and_tenant_header_with_batch_op.test index 18fc20038a..47f0a0d768 100644 --- a/test/functionalTest/cases/0000_troe/troe_link_and_tenant_header_with_batch_op.test +++ b/test/functionalTest/cases/0000_troe/troe_link_and_tenant_header_with_batch_op.test @@ -77,9 +77,14 @@ echo --REGEXPECT-- 01. Create an entity E1 on tenant t1, with the context in the Link header using batch upsert ============================================================================================ -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 27 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entities:E1" +] 02. Make sure the postgres db ftest_t1 exists and that the entity and its attrs and all sub-attrs are present diff --git a/test/functionalTest/cases/0000_troe/troe_tenants_and_batch_ops.test b/test/functionalTest/cases/0000_troe/troe_tenants_and_batch_ops.test index 815d167e64..bf67482489 100644 --- a/test/functionalTest/cases/0000_troe/troe_tenants_and_batch_ops.test +++ b/test/functionalTest/cases/0000_troe/troe_tenants_and_batch_ops.test @@ -81,9 +81,14 @@ echo --REGEXPECT-- 01. Create an entity E1 on tenant t1 - making the broker create the postgres db =============================================================================== -HTTP/1.1 204 No Content +HTTP/1.1 201 Created +Content-Length: 27 +Content-Type: application/json Date: REGEX(.*) +[ + "urn:ngsi-ld:entities:E1" +] 02. Make sure the entity postgres db exists and that entities, attrs, and sub-attrs are present