From 131bac2add7889aa1c22c44e8427c2844840ede7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 4 Jun 2024 11:20:13 +0200 Subject: [PATCH 1/4] REMOVE subs legacy format --- CHANGES_NEXT_RELEASE | 1 + doc/manuals/admin/database_model.md | 3 +- doc/manuals/admin/logs.md | 9 -- doc/manuals/admin/statistics.md | 1 - doc/manuals/orion-api.md | 37 +------- src/lib/common/RenderFormat.cpp | 3 - src/lib/common/RenderFormat.h | 15 ++-- src/lib/common/statistics.cpp | 1 - .../mongoBackend/mongoCreateSubscription.cpp | 9 -- .../mongoBackend/mongoGetSubscriptions.cpp | 12 +-- .../mongoBackend/mongoUpdateSubscription.cpp | 9 -- src/lib/ngsi10/SubscribeContextRequest.cpp | 2 +- src/lib/ngsiNotify/Notifier.cpp | 32 +------ src/lib/serviceRoutines/statisticsTreat.cpp | 2 - .../log_deprecate_warning.test | 1 - .../statistics_with_full_counters.test | 1 - .../mongoSubscribeContext_test.cpp | 48 +++++----- .../mongoUpdateContextSubscription_test.cpp | 48 +++++----- ..._withOnchangeSubscriptionsNoCache_test.cpp | 76 ++++++++-------- ...Context_withOnchangeSubscriptions_test.cpp | 88 +++++++++---------- 20 files changed, 145 insertions(+), 253 deletions(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 2728600db4..c8e938dfd6 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -5,3 +5,4 @@ - Fix: simplified GET /version operation, without including "libversions" field (add ?options=libVersions to get it) - Fix: lighter operation to get databases list from MongoDB (#4517) - Hardening: compile code using C++14 standard +- Remove: legacy subscription format diff --git a/doc/manuals/admin/database_model.md b/doc/manuals/admin/database_model.md index ae438dbef6..f11c762b4c 100644 --- a/doc/manuals/admin/database_model.md +++ b/doc/manuals/admin/database_model.md @@ -304,8 +304,7 @@ Fields: fields: q, mq, georel, geometry and/or coords (optional) - **count**: the number of notifications sent associated to the subscription. -- **format**: the format to use to send notification, possible values are **JSON** - (meaning JSON notifications in NGSIv1 legacy format), **normalized**, **keyValues**, **simplifiedNormalized**, **simplifiedKeyValues** and **values** (the last five used in NGSIv2 format). +- **format**: the format to use to send notification, possible values are **normalized**, **keyValues**, **simplifiedNormalized**, **simplifiedKeyValues** and **values**. - **status**: either `active` (for active subscriptions), `inactive` (for inactive subscriptions) or `oneshot` (for [oneshot subscriptions](../orion-api.md#oneshot-subscriptions)). Note that Orion API consider additional states (e.g. `expired`) but they never hit the DB (they are managed by Orion). diff --git a/doc/manuals/admin/logs.md b/doc/manuals/admin/logs.md index f88223e73b..bf711aba94 100644 --- a/doc/manuals/admin/logs.md +++ b/doc/manuals/admin/logs.md @@ -422,15 +422,6 @@ time=2024-01-11T13:57:13.595Z | lvl=WARN | corr=527c0912-b089-11ee-bb8c-080027cd time=2024-01-11T13:57:13.624Z | lvl=WARN | corr=52808938-b089-11ee-9835-080027cd35f1 | trans=1704981432-655-00000000010 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=postUpdateContext.cpp[163]:updateForward | msg=Deprecated usage of legacyForwarding mode in update forwarding operation (regId: 659ff3b9691855f16d00ec5a) ``` -* Usages of [`"attrsFormat": "legacy"`](../orion-api.md#subscriptionnotification). For instance: - -``` -time=2024-01-11T16:23:24.646Z | lvl=WARN | corr=be709034-b09d-11ee-b5d1-080027cd35f1 | trans=1704990203-652-00000000012 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=MongoCommonSubscription.cpp[598]:setFormat | msg=Deprecated usage of notification legacy format in subscription creation (subId: 65a015fcda947708d30425eb) -time=2024-01-11T16:23:24.675Z | lvl=WARN | corr=be74dc98-b09d-11ee-b2d6-080027cd35f1 | trans=1704990203-652-00000000013 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=mongoGetSubscriptions.cpp[217]:setNotification | msg=Deprecated usage of notification legacy format detected in existing subscription (subId: 65a015fcda947708d30425eb) -time=2024-01-11T16:23:24.701Z | lvl=WARN | corr=be709034-b09d-11ee-b5d1-080027cd35f1 | trans=1704990203-652-00000000012 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=MongoCommonSubscription.cpp[598]:setFormat | msg=Deprecated usage of notification legacy format in subscription modification (subId: 65a015fcda947708d30425eb) -time=2024-01-11T16:23:24.716Z | lvl=WARN | corr=be7ae5ac-b09d-11ee-98c8-080027cd35f1 | trans=1704990203-652-00000000015 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=Notifier.cpp[680]:buildSenderParams | msg=Deprecated usage of notification legacy format in notification (subId: 65a015fcda947708d30425eb) -``` - * Usages of `geo:point`, `geo:line`, `geo:box` or `geo:line`. ``` diff --git a/doc/manuals/admin/statistics.md b/doc/manuals/admin/statistics.md index a44bafcb74..2f8bf60f17 100644 --- a/doc/manuals/admin/statistics.md +++ b/doc/manuals/admin/statistics.md @@ -57,7 +57,6 @@ The counter block provides information about counters for the times a particular "deprecatedFeatures": { "geoFormat": 2, "ngsiv1Forwarding": 4, - "ngsiv1NotifFormat": 4, "ngsiv1Requests": 4 }, "invalidRequests": 2, diff --git a/doc/manuals/orion-api.md b/doc/manuals/orion-api.md index 294fdd7dce..3b2951b08c 100644 --- a/doc/manuals/orion-api.md +++ b/doc/manuals/orion-api.md @@ -1993,40 +1993,7 @@ If `attrsFormat` is `values` then values partial entity representation mode is u } ``` -If `attrsFormat` is `legacy` then subscription representation follows NGSIv1 format. This way, users -can benefit from the enhancements of Orion subscriptions (e.g. filtering) with NGSIv1 legacy notification receivers. - -Note that NGSIv1 is deprecated. Thus, we don't recommend to use `legacy` notification format any longer. - -```json -{ - "subscriptionId": "56e2ad4e8001ff5e0a5260ec", - "originator": "localhost", - "contextResponses": [{ - "contextElement": { - "type": "Car", - "isPattern": "false", - "id": "Car1", - "attributes": [{ - "name": "temperature", - "type": "centigrade", - "value": "26.5", - "metadatas": [{ - "name": "TimeInstant", - "type": "recvTime", - "value": "2015-12-12 11:11:11.123" - }] - }] - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - }] -} -``` - -Notifications must include the `Ngsiv2-AttrsFormat` (expect when `attrsFormat` is `legacy`) +Notifications must include the `Ngsiv2-AttrsFormat` HTTP header with the value of the format of the associated subscription, so that notification receivers are aware of the format without needing to process the notification payload. @@ -4712,7 +4679,7 @@ A `notification` object contains the following subfields: |--------------------|-------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `attrs` or `exceptAttrs` | | array | Both cannot be used at the same time. | | [`http`](#subscriptionnotificationhttp), [`httpCustom`](#subscriptionnotificationhttpcustom), [`mqtt`](#subscriptionnotificationmqtt) or [`mqttCustom`](#subscriptionnotificationmqttcustom)| ✓ | object | One of them must be present, but not more than one at the same time. It is used to convey parameters for notifications delivered through the transport protocol. | -| `attrsFormat` | ✓ | string | Specifies how the entities are represented in notifications. Accepted values are `normalized` (default), `simplifiedNormalized`, `keyValues`, `simplifiedKeyValues`, `values` or `legacy`.
If `attrsFormat` takes any value different than those, an error is raised. See detail in [Notification Messages](#notification-messages) section. | +| `attrsFormat` | ✓ | string | Specifies how the entities are represented in notifications. Accepted values are `normalized` (default), `simplifiedNormalized`, `keyValues`, `simplifiedKeyValues`, or `values`.
If `attrsFormat` takes any value different than those, an error is raised. See detail in [Notification Messages](#notification-messages) section. | | `metadata` | ✓ | string | List of metadata to be included in notification messages. See [Filtering out attributes and metadata](#filtering-out-attributes-and-metadata) section for more detail. | | `onlyChangedAttrs` | ✓ | boolean | If `true` then notifications will include only attributes that changed in the triggering update request, in combination with the `attrs` or `exceptAttrs` field. (default is `false` if the field is omitted)) | | `covered` | ✓ | boolean | If `true` then notifications will include all the attributes defined in `attrs` field, even if they are not present in the entity (in this, case, with `null` value). (default value is false). For further information see [Covered subscriptions](#covered-subscriptions) section | diff --git a/src/lib/common/RenderFormat.cpp b/src/lib/common/RenderFormat.cpp index e65c009203..9c29536216 100644 --- a/src/lib/common/RenderFormat.cpp +++ b/src/lib/common/RenderFormat.cpp @@ -41,7 +41,6 @@ const char* renderFormatToString(RenderFormat format, bool noDefault, bool useLe { switch (format) { - case NGSI_V1_LEGACY: return useLegacyWord ? "legacy" : "JSON"; case NGSI_V2_NORMALIZED: return "normalized"; case NGSI_V2_KEYVALUES: return "keyValues"; case NGSI_V2_VALUES: return "values"; @@ -71,8 +70,6 @@ const char* renderFormatToString(RenderFormat format, bool noDefault, bool useLe */ RenderFormat stringToRenderFormat(const std::string& s, bool noDefault) { - if (s == "JSON") { return NGSI_V1_LEGACY; } // DB content for NGSIv1 rendering due to legacy reasons - if (s == "legacy") { return NGSI_V1_LEGACY; } if (s == "normalized") { return NGSI_V2_NORMALIZED; } if (s == "keyValues") { return NGSI_V2_KEYVALUES; } if (s == "values") { return NGSI_V2_VALUES; } diff --git a/src/lib/common/RenderFormat.h b/src/lib/common/RenderFormat.h index 8d6d8f1660..8307896052 100644 --- a/src/lib/common/RenderFormat.h +++ b/src/lib/common/RenderFormat.h @@ -44,14 +44,13 @@ typedef enum RenderFormat { NO_FORMAT = 0, - NGSI_V1_LEGACY = 1, - NGSI_V2_NORMALIZED = 2, - NGSI_V2_KEYVALUES = 3, - NGSI_V2_VALUES = 4, - NGSI_V2_UNIQUE_VALUES = 5, - NGSI_V2_CUSTOM = 6, - NGSI_V2_SIMPLIFIEDNORMALIZED = 7, - NGSI_V2_SIMPLIFIEDKEYVALUES = 8 + NGSI_V2_NORMALIZED = 1, + NGSI_V2_KEYVALUES = 2, + NGSI_V2_VALUES = 3, + NGSI_V2_UNIQUE_VALUES = 4, + NGSI_V2_CUSTOM = 5, + NGSI_V2_SIMPLIFIEDNORMALIZED = 6, + NGSI_V2_SIMPLIFIEDKEYVALUES = 7 } RenderFormat; diff --git a/src/lib/common/statistics.cpp b/src/lib/common/statistics.cpp index 10dd8b1631..1a6dd710ff 100644 --- a/src/lib/common/statistics.cpp +++ b/src/lib/common/statistics.cpp @@ -152,7 +152,6 @@ int noOfSimulatedNotifications = -1; // Deprecated features int noOfDprNgsiv1Request = -1; int noOfDprLegacyForwarding = -1; -int noOfDprLegacyNotif = -1; int noOfDprGeoformat = -1; diff --git a/src/lib/mongoBackend/mongoCreateSubscription.cpp b/src/lib/mongoBackend/mongoCreateSubscription.cpp index 91192349f5..d5579884bb 100644 --- a/src/lib/mongoBackend/mongoCreateSubscription.cpp +++ b/src/lib/mongoBackend/mongoCreateSubscription.cpp @@ -198,15 +198,6 @@ std::string mongoCreateSubscription return ""; } - if (sub.attrsFormat == NGSI_V1_LEGACY) - { - __sync_fetch_and_add(&noOfDprLegacyNotif, 1); - if (logDeprecate) - { - LM_W(("Deprecated usage of notification legacy format in subscription creation (subId: %s)", subId.c_str())); - } - } - reqSemGive(__FUNCTION__, "ngsiv2 create subscription request", reqSemTaken); return subId; diff --git a/src/lib/mongoBackend/mongoGetSubscriptions.cpp b/src/lib/mongoBackend/mongoGetSubscriptions.cpp index c682955d0b..c14866017c 100644 --- a/src/lib/mongoBackend/mongoGetSubscriptions.cpp +++ b/src/lib/mongoBackend/mongoGetSubscriptions.cpp @@ -210,17 +210,7 @@ static void setNotification(Subscription* subP, const orion::BSONObj& r, const s nP->lastSuccessCode = r.hasField(CSUB_LASTSUCCESSCODE)? getIntOrLongFieldAsLongF(r, CSUB_LASTSUCCESSCODE) : -1; // Attributes format - subP->attrsFormat = r.hasField(CSUB_FORMAT)? stringToRenderFormat(getStringFieldF(r, CSUB_FORMAT)) : NGSI_V1_LEGACY; - - if (subP->attrsFormat == NGSI_V1_LEGACY) - { - __sync_fetch_and_add(&noOfDprLegacyNotif, 1); - if (logDeprecate) - { - LM_W(("Deprecated usage of notification legacy format detected in existing subscription (subId: %s)", subP->id.c_str())); - } - } - + subP->attrsFormat = r.hasField(CSUB_FORMAT)? stringToRenderFormat(getStringFieldF(r, CSUB_FORMAT)) : NGSI_V2_NORMALIZED; // // Check values from subscription cache, update object from cache-values if necessary diff --git a/src/lib/mongoBackend/mongoUpdateSubscription.cpp b/src/lib/mongoBackend/mongoUpdateSubscription.cpp index 93d71ccb2b..134a9910e4 100644 --- a/src/lib/mongoBackend/mongoUpdateSubscription.cpp +++ b/src/lib/mongoBackend/mongoUpdateSubscription.cpp @@ -370,15 +370,6 @@ std::string mongoUpdateSubscription if (subUp.notifyOnMetadataChangeProvided) setNotifyOnMetadataChange(subUp, &setB); if (subUp.attrsFormatProvided) setFormat(subUp, &setB); - if (subUp.attrsFormat == NGSI_V1_LEGACY) - { - __sync_fetch_and_add(&noOfDprLegacyNotif, 1); - if (logDeprecate) - { - LM_W(("Deprecated usage of notification legacy format in subscription modification (subId: %s)", subUp.id.c_str())); - } - } - // Description is special, as "" value removes the field if (subUp.descriptionProvided) { diff --git a/src/lib/ngsi10/SubscribeContextRequest.cpp b/src/lib/ngsi10/SubscribeContextRequest.cpp index 5038ef83ec..a0e2b19022 100644 --- a/src/lib/ngsi10/SubscribeContextRequest.cpp +++ b/src/lib/ngsi10/SubscribeContextRequest.cpp @@ -180,7 +180,7 @@ void SubscribeContextRequest::toNgsiv2Subscription(Subscription* sub) // description and expression are not touched, so default empty string provided by constructor will be used sub->status = STATUS_ACTIVE; sub->descriptionProvided = false; - sub->attrsFormat = NGSI_V1_LEGACY; + sub->attrsFormat = NGSI_V2_NORMALIZED; sub->notification.blacklist = false; sub->notification.httpInfo.custom = false; diff --git a/src/lib/ngsiNotify/Notifier.cpp b/src/lib/ngsiNotify/Notifier.cpp index e26fc31e37..14724c9a1e 100644 --- a/src/lib/ngsiNotify/Notifier.cpp +++ b/src/lib/ngsiNotify/Notifier.cpp @@ -151,20 +151,7 @@ static bool setPayload ncr.subscriptionId = subscriptionId; ncr.contextElementResponseVector.push_back(&cer); - if (*renderFormatP == NGSI_V1_LEGACY) - { - __sync_fetch_and_add(&noOfDprLegacyNotif, 1); - if (logDeprecate) - { - LM_W(("Deprecated usage of notification legacy format in notification (subId: %s)", subscriptionId.c_str())); - } - - *payloadP = ncr.toJsonV1(false, attrsFilter, blacklist, metadataFilter); - } - else - { - *payloadP = ncr.toJson(*renderFormatP, attrsFilter, blacklist, metadataFilter); - } + *payloadP = ncr.toJson(*renderFormatP, attrsFilter, blacklist, metadataFilter); *mimeTypeP = "application/json"; } @@ -681,22 +668,7 @@ SenderThreadParams* Notifier::buildSenderParams ci.outMimeType = JSON; - std::string payloadString; - if (renderFormat == NGSI_V1_LEGACY) - { - __sync_fetch_and_add(&noOfDprLegacyNotif, 1); - if (logDeprecate) - { - LM_W(("Deprecated usage of notification legacy format in notification (subId: %s)", subId.c_str())); - } - - bool asJsonObject = (ci.uriParam[URI_PARAM_ATTRIBUTE_FORMAT] == "object" && ci.outMimeType == JSON); - payloadString = ncr.toJsonV1(asJsonObject, attrsFilter, blacklist, metadataFilter); - } - else - { - payloadString = ncr.toJson(renderFormat, attrsFilter, blacklist, metadataFilter); - } + std::string payloadString = ncr.toJson(renderFormat, attrsFilter, blacklist, metadataFilter); /* Parse URL */ std::string host; diff --git a/src/lib/serviceRoutines/statisticsTreat.cpp b/src/lib/serviceRoutines/statisticsTreat.cpp index a0a003a874..ec734f51a9 100644 --- a/src/lib/serviceRoutines/statisticsTreat.cpp +++ b/src/lib/serviceRoutines/statisticsTreat.cpp @@ -93,7 +93,6 @@ static void resetStatistics(void) noOfDprNgsiv1Request = -1; noOfDprLegacyForwarding = -1; - noOfDprLegacyNotif = -1; noOfDprGeoformat = -1; statisticsTime = getCurrentTime(); @@ -221,7 +220,6 @@ std::string renderCounterStats(bool fullCounters) JsonObjectHelper jsDeprecated; renderUsedCounter(&jsDeprecated, "ngsiv1Requests", noOfDprNgsiv1Request, fullCounters); renderUsedCounter(&jsDeprecated, "ngsiv1Forwarding", noOfDprLegacyForwarding, fullCounters); - renderUsedCounter(&jsDeprecated, "ngsiv1NotifFormat", noOfDprLegacyNotif, fullCounters); renderUsedCounter(&jsDeprecated, "geoFormat", noOfDprGeoformat, fullCounters); std::string deprecation = jsDeprecated.str(); diff --git a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test index 31092ef852..fe57f14647 100644 --- a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test +++ b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test @@ -488,7 +488,6 @@ Content-Length: 566 "deprecatedFeatures": { "geoFormat": 2, "ngsiv1Forwarding": 4, - "ngsiv1NotifFormat": 4, "ngsiv1Requests": 3 }, "jsonRequests": 8, diff --git a/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test b/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test index 403721e557..14dda84090 100644 --- a/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test +++ b/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test @@ -53,7 +53,6 @@ Content-Length: 1624 "deprecatedFeatures": { "geoFormat": 0, "ngsiv1Forwarding": 0, - "ngsiv1NotifFormat": 0, "ngsiv1Requests": 0 }, "discoveryErrors": 0, diff --git a/test/unittests/mongoBackend/mongoSubscribeContext_test.cpp b/test/unittests/mongoBackend/mongoSubscribeContext_test.cpp index d3e00359c3..314969b4d3 100644 --- a/test/unittests/mongoBackend/mongoSubscribeContext_test.cpp +++ b/test/unittests/mongoBackend/mongoSubscribeContext_test.cpp @@ -1366,7 +1366,7 @@ TEST(mongoSubscribeContext, matchEnt1_Attr0_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -1470,7 +1470,7 @@ TEST(mongoSubscribeContext, matchEnt1_Attr0_C1_JSON) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -1575,7 +1575,7 @@ TEST(mongoSubscribeContext, matchEnt1_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1684,7 +1684,7 @@ TEST(mongoSubscribeContext, matchEnt1_AttrN_C1_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1809,7 +1809,7 @@ TEST(mongoSubscribeContext, matchEnt1NoType_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1934,7 +1934,7 @@ TEST(mongoSubscribeContext, matchEnt1NoType_AttrN_C1_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2051,7 +2051,7 @@ TEST(mongoSubscribeContext, matchEnt1Pattern_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2168,7 +2168,7 @@ TEST(mongoSubscribeContext, matchEnt1Pattern_AttrN_C1_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2299,7 +2299,7 @@ TEST(mongoSubscribeContext, matchEnt1PatternNoType_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2430,7 +2430,7 @@ TEST(mongoSubscribeContext, matchEnt1PatternNoType_AttrN_C1_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2537,7 +2537,7 @@ TEST(mongoSubscribeContext, matchEnt1_Attr0_CN) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2644,7 +2644,7 @@ TEST(mongoSubscribeContext, matchEnt1_Attr0_CN_partial) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2752,7 +2752,7 @@ TEST(mongoSubscribeContext, matchEnt1_Attr0_CNbis) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2858,7 +2858,7 @@ TEST(mongoSubscribeContext, matchEnt1_AttrN_CN_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2971,7 +2971,7 @@ TEST(mongoSubscribeContext, matchEnt1_AttrN_CN_partial) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3084,7 +3084,7 @@ TEST(mongoSubscribeContext, matchEnt1_AttrN_CN_partial_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3197,7 +3197,7 @@ TEST(mongoSubscribeContext, matchEnt1_AttrN_CNbis) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3310,7 +3310,7 @@ TEST(mongoSubscribeContext, matchEnt1_AttrN_CN) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3433,7 +3433,7 @@ TEST(mongoSubscribeContext, matchEntN_Attr0_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3551,7 +3551,7 @@ TEST(mongoSubscribeContext, matchEntN_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3673,7 +3673,7 @@ TEST(mongoSubscribeContext, matchEntN_Attr0_CN) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3796,7 +3796,7 @@ TEST(mongoSubscribeContext, matchEntN_Attr0_CNbis) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3916,7 +3916,7 @@ TEST(mongoSubscribeContext, matchEntN_AttrN_CN) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -4040,7 +4040,7 @@ TEST(mongoSubscribeContext, matchEntN_AttrN_CNbis) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); diff --git a/test/unittests/mongoBackend/mongoUpdateContextSubscription_test.cpp b/test/unittests/mongoBackend/mongoUpdateContextSubscription_test.cpp index 0559c70094..6e26762847 100644 --- a/test/unittests/mongoBackend/mongoUpdateContextSubscription_test.cpp +++ b/test/unittests/mongoBackend/mongoUpdateContextSubscription_test.cpp @@ -1737,7 +1737,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_Attr0_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -1836,7 +1836,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_Attr0_C1_JSON) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -1933,7 +1933,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2033,7 +2033,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_AttrN_C1_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2148,7 +2148,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1NoType_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2263,7 +2263,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1NoType_AttrN_C1_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2370,7 +2370,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1Pattern_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2477,7 +2477,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1Pattern_AttrN_C1_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2598,7 +2598,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1PatternNoType_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2719,7 +2719,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1PatternNoType_AttrN_C1_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2821,7 +2821,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_Attr0_CN) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -2925,7 +2925,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_Attr0_CN_partial) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3030,7 +3030,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_Attr0_CNbis) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3130,7 +3130,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_AttrN_CN_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3234,7 +3234,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_AttrN_CN_partial) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3338,7 +3338,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_AttrN_CN_partial_disjoint) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3442,7 +3442,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_AttrN_CNbis) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3546,7 +3546,7 @@ TEST(mongoUpdateContextSubscription, matchEnt1_AttrN_CN) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3663,7 +3663,7 @@ TEST(mongoUpdateContextSubscription, matchEntN_Attr0_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3772,7 +3772,7 @@ TEST(mongoUpdateContextSubscription, matchEntN_AttrN_C1) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -3887,7 +3887,7 @@ TEST(mongoUpdateContextSubscription, matchEntN_Attr0_CN) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -4004,7 +4004,7 @@ TEST(mongoUpdateContextSubscription, matchEntN_Attr0_CNbis) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -4115,7 +4115,7 @@ TEST(mongoUpdateContextSubscription, matchEntN_AttrN_CN) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); @@ -4228,7 +4228,7 @@ TEST(mongoUpdateContextSubscription, matchEntN_AttrN_CNbis) "", "no correlator", 0, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(1); diff --git a/test/unittests/mongoBackend/mongoUpdateContext_withOnchangeSubscriptionsNoCache_test.cpp b/test/unittests/mongoBackend/mongoUpdateContext_withOnchangeSubscriptionsNoCache_test.cpp index 88d1d0ed18..65e84375cd 100644 --- a/test/unittests/mongoBackend/mongoUpdateContext_withOnchangeSubscriptionsNoCache_test.cpp +++ b/test/unittests/mongoBackend/mongoUpdateContext_withOnchangeSubscriptionsNoCache_test.cpp @@ -447,7 +447,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_updateMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -521,7 +521,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_appendMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -591,7 +591,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_appendMatch_type "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -660,7 +660,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_appendMatch_idAn "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -729,7 +729,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_deleteMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -805,7 +805,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_updateMatch_noTy "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -816,7 +816,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_updateMatch_noTy "", "", 2, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -894,7 +894,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_appendMatch_noTy "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -905,7 +905,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_appendMatch_noTy "", "", 2, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -978,7 +978,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_deleteMatch_noTy "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -989,7 +989,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_deleteMatch_noTy "", "", 2, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1060,7 +1060,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_updateMatch_patt "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1132,7 +1132,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_appendMatch_patt "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1200,7 +1200,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_deleteMatch_patt "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1270,7 +1270,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_updateMatch_patt "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1342,7 +1342,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_appendMatch_patt "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1410,7 +1410,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_deleteMatch_patt "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1480,7 +1480,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_updateMatchDisjo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1550,7 +1550,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_appendMatchDisjo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1620,7 +1620,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_deleteMatchDisjo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1858,7 +1858,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_updateMixMatchNo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1932,7 +1932,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_appendMixMatchNo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2002,7 +2002,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_deleteMixMatchNo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2074,7 +2074,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_update2Matches1N "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2148,7 +2148,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_append2Matches1N "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2218,7 +2218,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, Cond1_delete2Matches1N "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2288,7 +2288,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_updateMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2361,7 +2361,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_appendMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2429,7 +2429,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_deleteMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2499,7 +2499,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_updateMatchDisjo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2569,7 +2569,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_appendMatchDisjo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2639,7 +2639,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_deleteMatchDisjo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2877,7 +2877,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_updateMixMatchNo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2951,7 +2951,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_appendMixMatchNo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3021,7 +3021,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_deleteMixMatchNo "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3093,7 +3093,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_update2Matches1N "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3167,7 +3167,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_append2Matches1N "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3237,7 +3237,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptionsNoCache, CondN_delete2Matches1N "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); diff --git a/test/unittests/mongoBackend/mongoUpdateContext_withOnchangeSubscriptions_test.cpp b/test/unittests/mongoBackend/mongoUpdateContext_withOnchangeSubscriptions_test.cpp index aec62730c8..402b725eac 100644 --- a/test/unittests/mongoBackend/mongoUpdateContext_withOnchangeSubscriptions_test.cpp +++ b/test/unittests/mongoBackend/mongoUpdateContext_withOnchangeSubscriptions_test.cpp @@ -402,7 +402,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_updateMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -477,7 +477,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_appendMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -547,7 +547,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_deleteMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -624,7 +624,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_updateMatch_noType) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -635,7 +635,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_updateMatch_noType) "", "", 2, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -720,7 +720,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_appendMatch_noType) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -731,7 +731,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_appendMatch_noType) "", "", 2, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -812,7 +812,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_deleteMatch_noType) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -823,7 +823,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_deleteMatch_noType) "", "", 2, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -902,7 +902,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_updateMatch_pattern) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -980,7 +980,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_appendMatch_pattern) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1052,7 +1052,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_deleteMatch_pattern) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1126,7 +1126,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_updateMatch_pattern_noT "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1202,7 +1202,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_appendMatch_pattern_noT "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1274,7 +1274,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_deleteMatch_pattern_noT "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1348,7 +1348,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_updateMatchDisjoint) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1422,7 +1422,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_appendMatchDisjoint) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1496,7 +1496,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_deleteMatchDisjoint) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1553,7 +1553,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_updateNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, _, _, _)).Times(0); @@ -1610,7 +1610,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_appendNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, _, _, _)).Times(0); @@ -1666,7 +1666,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_deleteNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, _, _, _)).Times(0); @@ -1723,7 +1723,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_updateMatchWithoutChang "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(0); @@ -1796,7 +1796,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_updateMixMatchNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -1868,7 +1868,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_appendMixMatchNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, _, _, _)).Times(1); @@ -1936,7 +1936,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_deleteMixMatchNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, _, _, _)).Times(1); @@ -2013,7 +2013,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_update2Matches1Notifica "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2093,7 +2093,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_append2Matches1Notifica "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2168,7 +2168,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, Cond1_delete2Matches1Notifica "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2242,7 +2242,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_updateMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2319,7 +2319,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_appendMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2391,7 +2391,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_deleteMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2465,7 +2465,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_updateMatchDisjoint) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2540,7 +2540,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_appendMatchDisjoint) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2614,7 +2614,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_deleteMatchDisjoint) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2671,7 +2671,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_updateNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, _, _, _)).Times(0); @@ -2727,7 +2727,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_appendNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, _, _, _)).Times(0); @@ -2783,7 +2783,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_deleteNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, _, _, _)).Times(0); @@ -2840,7 +2840,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_updateMatchWithoutChang "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, emptyV, false, emptyV)).Times(0); @@ -2913,7 +2913,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_updateMixMatchNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -2991,7 +2991,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_appendMixMatchNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3065,7 +3065,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_deleteMixMatchNoMatch) "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3141,7 +3141,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_update2Matches1Notifica "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3220,7 +3220,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_append2Matches1Notifica "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); @@ -3295,7 +3295,7 @@ TEST(mongoUpdateContext_withOnchangeSubscriptions, CondN_delete2Matches1Notifica "", "", 1, - NGSI_V1_LEGACY, + NGSI_V2_NORMALIZED, attrsFilter, false, emptyV)).Times(1); From f49fb58c83a9d762d68a9fd67e196e18024e9fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 4 Jun 2024 14:57:26 +0200 Subject: [PATCH 2/4] FIX ftest --- doc/manuals/deprecated.md | 1 + src/lib/common/errorMessages.h | 2 +- .../log_deprecate_warning.test | 177 +-- .../notification_different_sizes.test | 10 +- .../statistics_with_full_counters.test | 4 +- .../previous_value_with_compounds_ngsiv1.test | 403 ------ ...cial_metadata_in_notifications_ngsiv1.test | 943 ------------- .../patch_subscription_bugfix_to_attrs.test | 7 +- ...ch_subscription_bugfix_to_except_attr.test | 7 +- ...tification_problem_with_custom_header.test | 295 ---- test/functionalTest/testHarness.sh | 1243 ----------------- 11 files changed, 31 insertions(+), 3061 deletions(-) delete mode 100644 test/functionalTest/cases/2507_csub_metadata_field/previous_value_with_compounds_ngsiv1.test delete mode 100644 test/functionalTest/cases/2507_csub_metadata_field/special_metadata_in_notifications_ngsiv1.test delete mode 100644 test/functionalTest/cases/3154_notification_problem_with_custom_header/notification_problem_with_custom_header.test delete mode 100755 test/functionalTest/testHarness.sh diff --git a/doc/manuals/deprecated.md b/doc/manuals/deprecated.md index 9b289331b4..c2d1f2ed69 100644 --- a/doc/manuals/deprecated.md +++ b/doc/manuals/deprecated.md @@ -39,6 +39,7 @@ A list of deprecated features and the version in which they were deprecated foll * `POST /NGSI10/updateContext` * `POST /v1/queryContext` * `POST /NGSI10/queryContext` + * NGSIv1 format in subscription notifications (`notification.atttrsFormat` set to `legacy`) removed in Orion 4.0.0 * `attributes` field in `POST /v2/op/query` is in Orion 1.15.0. It is a combination of `attrs` (to select which attributes to include in the response to the query) and unary attribute filter in `q` within `expression` (to return only entities which have these attributes). Use them instead. diff --git a/src/lib/common/errorMessages.h b/src/lib/common/errorMessages.h index a638981806..d50bf8acf7 100644 --- a/src/lib/common/errorMessages.h +++ b/src/lib/common/errorMessages.h @@ -62,7 +62,7 @@ #define ERROR_DESC_BAD_REQUEST_INVALID_JTYPE_ENTID "Invalid JSON type for entity id" #define ERROR_DESC_BAD_REQUEST_INVALID_JTYPE_ENTTYPE "Invalid JSON type for entity type" #define ERROR_DESC_BAD_REQUEST_INVALID_JTYPE_SCOPE "invalid JSON type for scope value: must be string" -#define ERROR_DESC_BAD_REQUEST_INVALID_ATTRSFORMAT "invalid attrsFormat, accepted values: legacy, normalized, simplifiedNormalized, keyValues, simplifiedkeyValues, values" +#define ERROR_DESC_BAD_REQUEST_INVALID_ATTRSFORMAT "invalid attrsFormat, accepted values: normalized, simplifiedNormalized, keyValues, simplifiedkeyValues, values" #define ERROR_DESC_BAD_REQUEST_INVALID_STATUS "status is not valid: it has to be either active, inactive or oneshot" #define ERROR_DESC_BAD_REQUEST_INVALID_RANGE "ranges only valid for equal and not equal ops" #define ERROR_DESC_BAD_REQUEST_INVALID_LIST "lists only valid for equal and not equal ops" diff --git a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test index fe57f14647..a340c8cd99 100644 --- a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test +++ b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test @@ -41,12 +41,8 @@ brokerStart CB 0 IPV4 -logDeprecate -statCounters # 06. Retrieve registrations (which uses legacyForwarding mode) # 07. Forwarded query using legacyForwarding mode # 08. Update query using legacyForwarding mode -# 09. Create subscription using attrsFormat legacy -# 10. Retrieve subscriptions (which uses attrsFormat legacy) -# 11. Update subscription using attrsFormat legacy -# 12. Trigger notification using attrsFormat legacy -# 13. Get WARNING trace in logs -# 14. Get statistics and see deprecatedFeatures counters +# 09. Get WARNING trace in logs +# 10. Get statistics and see deprecatedFeatures counters # echo "01. Query E1-T1" @@ -163,77 +159,14 @@ echo echo -echo "09. Create subscription using attrsFormat legacy" -echo "================================================" -payload='{ - "subject": { - "entities": [ - { - "id": "E2", - "type": "T2" - } - ] - }, - "notification": { - "http": { - "url": "http://localhost:1234" - }, - "attrsFormat": "legacy" - } -}' -orionCurl --url /v2/subscriptions --payload "$payload" -echo -echo - - -SUB_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") - - -echo "10. Retrieve subscriptions (which uses attrsFormat legacy)" -echo "==========================================================" -orionCurl --url /v2/subscriptions -echo -echo - - -echo "11. Update subscription using attrsFormat legacy" -echo "================================================" -payload='{ - "notification": { - "http": { - "url": "http://localhost:1234" - }, - "attrsFormat": "legacy" - } -}' -orionCurl --url /v2/subscriptions/$SUB_ID -X PATCH --payload "$payload" -echo -echo - - -echo "12. Trigger notification using attrsFormat legacy" -echo "=================================================" -payload='{ - "id": "E2", - "type": "T2", - "A": { - "value": 1, - "type": "Number" - } -}' -orionCurl --url /v2/entities --payload "$payload" -echo -echo - - -echo "13. Get WARNING trace in logs" +echo "09. Get WARNING trace in logs" echo "=============================" -cat /tmp/contextBroker.log | grep 'WARN' | awk -F 'msg=' '{print $2}' | sed -e "s/$REG_ID/REG_ID/g" | sed -e "s/$SUB_ID/SUB_ID/g" +cat /tmp/contextBroker.log | grep 'WARN' | awk -F 'msg=' '{print $2}' | sed -e "s/$REG_ID/REG_ID/g" echo echo -echo "14. Get statistics and see deprecatedFeatures counters" +echo "10. Get statistics and see deprecatedFeatures counters" echo "======================================================" orionCurl --url /statistics echo @@ -388,72 +321,7 @@ Content-Length: 95 } -09. Create subscription using attrsFormat legacy -================================================ -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/subscriptions/REGEX([0-9a-f\-]{24}) -Content-Length: 0 - - - -10. Retrieve subscriptions (which uses attrsFormat legacy) -========================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 288 - -[ - { - "id": "REGEX([0-9a-f\-]{24})", - "notification": { - "attrs": [], - "attrsFormat": "legacy", - "covered": false, - "http": { - "url": "http://localhost:1234" - }, - "onlyChangedAttrs": false - }, - "status": "active", - "subject": { - "condition": { - "attrs": [], - "notifyOnMetadataChange": true - }, - "entities": [ - { - "id": "E2", - "type": "T2" - } - ] - } - } -] - - -11. Update subscription using attrsFormat legacy -================================================ -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -12. Trigger notification using attrsFormat legacy -================================================= -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/entities/E2?type=T2 -Content-Length: 0 - - - -13. Get WARNING trace in logs +09. Get WARNING trace in logs ============================= Deprecated NGSIv1 request received: POST /v1/queryContext, request payload (48 bytes): { "entities": [ { "type": "T1", "id": "E1" } ] }, response code: 200 Deprecated NGSIv1 request received: GET /v1/contextEntities/E/attributes/A, response code: 200 @@ -463,25 +331,23 @@ Deprecated usage of geo:point detected in attribute location at entity update, p Deprecated usage of legacyForwarding mode in registration creation (regId: REG_ID) Deprecated usage of legacyForwarding mode detected in existing registration (regId: REG_ID) Deprecated usage of legacyForwarding mode in query forwarding operation (regId: REG_ID) -Raising alarm ForwardingError localhost:9801/v2/queryContext: forwarding failure for sender-thread: Couldn't connect to server -Deprecated usage of legacyForwarding mode in update forwarding operation (regId: REG_ID) -Raising alarm ForwardingError localhost:9801/v2/updateContext: forwarding failure for sender-thread: Couldn't connect to server -Raising alarm BadInput 127.0.0.1: The requested entity has not been found. Check type and id +Notification (regId: REG_ID) response NOT OK, http code: 400 +Raising alarm BadInput 127.0.0.1: JSON Parse Error: unknown field: /error +Raising alarm ForwardingError localhost:9801/v2/queryContext: error parsing reply from prov app: {"error":"BadRequest","description":"JSON Parse Error: unknown field: /error"} Releasing alarm BadInput 127.0.0.1 -Deprecated usage of notification legacy format in subscription creation (subId: SUB_ID) -Deprecated usage of notification legacy format detected in existing subscription (subId: SUB_ID) -Deprecated usage of notification legacy format in subscription modification (subId: SUB_ID) -Deprecated usage of notification legacy format in notification (subId: SUB_ID) -Raising alarm NotificationError localhost:1234/: notification failure for queue worker: Couldn't connect to server +Deprecated usage of legacyForwarding mode in update forwarding operation (regId: REG_ID) +Notification (regId: REG_ID) response NOT OK, http code: 400 +Raising alarm BadInput 127.0.0.1: JSON Parse Error: unknown field: /error +Raising alarm ForwardingError localhost:9801/v2/updateContext: error parsing reply from prov app: {"error":"BadRequest","description":"JSON Parse Error: unknown field: /error"} -14. Get statistics and see deprecatedFeatures counters +10. Get statistics and see deprecatedFeatures counters ====================================================== HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 566 +Content-Length: 468 { "counters": { @@ -490,14 +356,14 @@ Content-Length: 566 "ngsiv1Forwarding": 4, "ngsiv1Requests": 3 }, - "jsonRequests": 8, - "noPayloadRequests": 5, + "jsonRequests": 5, + "noPayloadRequests": 4, "requests": { "/statistics": { "GET": 1 }, "/v2/entities": { - "POST": 2 + "POST": 1 }, "/v2/entities/{id}/attrs/{name}": { "GET": 1, @@ -506,13 +372,6 @@ Content-Length: 566 "/v2/registrations": { "GET": 1, "POST": 1 - }, - "/v2/subscriptions": { - "GET": 1, - "POST": 1 - }, - "/v2/subscriptions/{id}": { - "PATCH": 1 } }, "requestsLegacy": { diff --git a/test/functionalTest/cases/0000_large_requests/notification_different_sizes.test b/test/functionalTest/cases/0000_large_requests/notification_different_sizes.test index 79b31be3bd..3c50b6e889 100644 --- a/test/functionalTest/cases/0000_large_requests/notification_different_sizes.test +++ b/test/functionalTest/cases/0000_large_requests/notification_different_sizes.test @@ -63,7 +63,6 @@ payload='{ ] }, "notification": { - "attrsFormat": "legacy", "http": { "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" }, @@ -87,7 +86,6 @@ payload='{ ] }, "notification": { - "attrsFormat": "legacy", "http": { "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" }, @@ -111,7 +109,6 @@ payload='{ ] }, "notification": { - "attrsFormat": "legacy", "http": { "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" }, @@ -135,7 +132,6 @@ payload='{ ] }, "notification": { - "attrsFormat": "legacy", "http": { "url": "http://127.0.0.1:'${LISTENER_PORT}'/notify" }, @@ -298,9 +294,9 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}) 08. Check notification sizes ============================ -Sending message 1 to HTTP server: sending message of REGEX((19496|19501|19497|19502)) bytes to HTTP server -Sending message 2 to HTTP server: sending message of REGEX((21496|21501|21497|21502)) bytes to HTTP server -Sending message 3 to HTTP server: sending message of REGEX((8100498|8100503|8100499|8100504)) bytes to HTTP server +Sending message 1 to HTTP server: sending message of REGEX((19400|19401|19405|19406)) bytes to HTTP server +Sending message 2 to HTTP server: sending message of REGEX((21400|21401|21405|21406)) bytes to HTTP server +Sending message 3 to HTTP server: sending message of REGEX((8100402|8100403|8100407|8100408)) bytes to HTTP server --TEARDOWN-- diff --git a/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test b/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test index 14dda84090..dfc021a52d 100644 --- a/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test +++ b/test/functionalTest/cases/0000_statistics_operation/statistics_with_full_counters.test @@ -31,7 +31,7 @@ brokerStart CB 0 IPv4 -statCounters # # This test is special and doesn't follow the typical steps pattern -# Instead of that, we just stimulate some possible API rute (without output) +# Instead of that, we just stimulate some possible API routes (without output) # and do GET /statistics after that # @@ -46,7 +46,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 1624 +Content-Length: 1602 { "counters": { diff --git a/test/functionalTest/cases/2507_csub_metadata_field/previous_value_with_compounds_ngsiv1.test b/test/functionalTest/cases/2507_csub_metadata_field/previous_value_with_compounds_ngsiv1.test deleted file mode 100644 index 5e8d90fb59..0000000000 --- a/test/functionalTest/cases/2507_csub_metadata_field/previous_value_with_compounds_ngsiv1.test +++ /dev/null @@ -1,403 +0,0 @@ -# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -previousValue with compound cases - ---SHELL-INIT-- -dbInit CB -brokerStart CB -accumulatorStart --pretty-print - ---SHELL-- - -# -# Same script as previous_value_with_compounds.test but using "legacy" as attrsFormat -# -# 01. Create subscription with previousValue as metadata -# 02. Create E1 with attributes A: 1 -# 03. Dump and reset: see notification A:1 and no previousValue -# 04. Update A: [1, {b: foo} ] -# 05. Dump and reset: see notification A: [1, {b: foo} ], previousValue: 1 -# 06. Update A: {x: 1, y: [true, foo] } -# 07. Dump and reset: see notification A: {x: 1, y: [true: foo] }, previousValue: [1, {b: foo} ] -# 08. Update A: x -# 09. Dump and reset: see notification A: x, previousValue: {x: 1, y: [true, foo] } -# - -echo "01. Create subscription with previousValue as metadata" -echo "======================================================" -payload='{ - "subject": { - "entities": [ - { - "id": "E1", - "type": "T" - } - ], - "condition": { - "attrs": [ ] - } - }, - "notification": { - "http": { - "url": "http://localhost:'$LISTENER_PORT'/notify" - }, - "attrs": [ ], - "attrsFormat": "legacy", - "metadata": [ "previousValue" ] - } -}' -orionCurl --url /v2/subscriptions --payload "$payload" -echo -echo - - -echo "02. Create E1 with attributes A: 1" -echo "==================================" -payload='{ - "type": "T", - "id": "E1", - "A": { - "type": "Number", - "value": 1 - } -}' -orionCurl --url /v2/entities --payload "$payload" -echo -echo - - -echo "03. Dump and reset: see notification A:1 and no previousValue" -echo "=============================================================" -accumulatorDump -accumulatorReset -echo -echo - - -echo "04. Update A: [1, {b: foo} ]" -echo "============================" -payload='{ - "A": { - "type": "ComplexVector", - "value": [1, {"b": "foo"} ] - } -}' -orionCurl --url /v2/entities/E1/attrs -X PATCH --payload "$payload" -echo -echo - - -echo "05. Dump and reset: see notification A: [1, {b: foo} ], previousValue: 1" -echo "========================================================================" -accumulatorDump -accumulatorReset -echo -echo - - -echo "06. Update A: {x: 1, y: [true, foo] }" -echo "=====================================" -payload='{ - "A": { - "type": "ComplexObject", - "value": {"x": 1, "y": [true, "foo"] } - } -}' -orionCurl --url /v2/entities/E1/attrs -X PATCH --payload "$payload" -echo -echo - - -echo "07. Dump and reset: see notification A: {x: 1, y: [true: foo] }, previousValue: [1, {b: foo} ]" -echo "==============================================================================================" -accumulatorDump -accumulatorReset -echo -echo - -echo "08. Update A: x" -echo "===============" -payload='{ - "A": { - "type": "Text", - "value": "x" - } -}' -orionCurl --url /v2/entities/E1/attrs -X PATCH --payload "$payload" -echo -echo - - -echo "09. Dump and reset: see notification A: x, previousValue: {x: 1, y: [true, foo] }" -echo "=================================================================================" -accumulatorDump -accumulatorReset -echo -echo - - ---REGEXPECT-- -01. Create subscription with previousValue as metadata -====================================================== -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/subscriptions/REGEX([0-9a-f]{24}) -Content-Length: 0 - - - -02. Create E1 with attributes A: 1 -================================== -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/entities/E1?type=T -Content-Length: 0 - - - -03. Dump and reset: see notification A:1 and no previousValue -============================================================= -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 255 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "name": "A", - "type": "Number", - "value": 1 - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - -04. Update A: [1, {b: foo} ] -============================ -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -05. Dump and reset: see notification A: [1, {b: foo} ], previousValue: 1 -======================================================================== -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 341 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "previousValue", - "type": "Number", - "value": 1 - } - ], - "name": "A", - "type": "ComplexVector", - "value": [ - 1, - { - "b": "foo" - } - ] - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - -06. Update A: {x: 1, y: [true, foo] } -===================================== -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -07. Dump and reset: see notification A: {x: 1, y: [true: foo] }, previousValue: [1, {b: foo} ] -============================================================================================== -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 371 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "previousValue", - "type": "ComplexVector", - "value": [ - 1, - { - "b": "foo" - } - ] - } - ], - "name": "A", - "type": "ComplexObject", - "value": { - "x": 1, - "y": [ - true, - "foo" - ] - } - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - -08. Update A: x -=============== -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -09. Dump and reset: see notification A: x, previousValue: {x: 1, y: [true, foo] } -================================================================================= -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 350 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "previousValue", - "type": "ComplexObject", - "value": { - "x": 1, - "y": [ - true, - "foo" - ] - } - } - ], - "name": "A", - "type": "Text", - "value": "x" - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - ---TEARDOWN-- -brokerStop CB -accumulatorStop $LISTENER_PORT -dbDrop CB diff --git a/test/functionalTest/cases/2507_csub_metadata_field/special_metadata_in_notifications_ngsiv1.test b/test/functionalTest/cases/2507_csub_metadata_field/special_metadata_in_notifications_ngsiv1.test deleted file mode 100644 index d04b13c74c..0000000000 --- a/test/functionalTest/cases/2507_csub_metadata_field/special_metadata_in_notifications_ngsiv1.test +++ /dev/null @@ -1,943 +0,0 @@ -# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Special metadata in NGSIv1 notifications - ---SHELL-INIT-- -dbInit CB -brokerStart CB -accumulatorStart --pretty-print - ---SHELL-- - -# -# Same script as special_metadata_in_notifications_ngsiv1.test but using "legacy" as attrsFormat -# -# 01. Subscribe to E.* for A, B and C; triggered by B, C or D -# 02. Create E1 with attributes A:1, B:2, C:3, D:4 -# 03. Dump and reset: see notification with A, B and C -# 04. Update B:20 -# 05. Dump and reset: see notification with actionType=update and previousValue=2 for B -# 06. Update B:20, C:30 -# 07. Dump and reset: see notification with actionType=update for B and C, previousValue=20 for B, previousValue=3 for C -# 08. Update A:1, D:40 -# 09. Dump and reset: see notification with actionType=update and previousValue=1 for A -# 10. Update A:10, D:41 -# 11. Dump and reset: see notification with actionType=update and previousValue=10 for A -# 12. Create E2 with attributes A:x, B:y, C:z, D:u -# 13. Dump and reset: see notification with actionType=append for A, B, C -# 14. Update subscription conditions -# 15. Update E1 A:10, D:41 (forced) -# 16. Update E2 A:x, B:y, C:z, D:u (forced) -# 15. Dump and reset: see notification with 2 entities with A, B and C -# - - -echo "01. Subscribe to E.* for A, B and C; triggered by B, C or D" -echo "===========================================================" -payload='{ - "subject": { - "entities": [ - { - "idPattern": "E.*", - "type": "T" - } - ], - "condition": { - "attrs": [ "B", "C", "D" ] - } - }, - "notification": { - "http": { - "url": "http://localhost:'$LISTENER_PORT'/notify" - }, - "attrs": [ "A", "B", "C" ], - "attrsFormat": "legacy", - "metadata": [ "actionType", "previousValue" ] - } -}' -orionCurl --url /v2/subscriptions --payload "$payload" -echo -echo - -SUB_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") - - -echo "02. Create E1 with attributes A:1, B:2, C:3, D:4" -echo "================================================" -payload='{ - "type": "T", - "id": "E1", - "A": { - "type": "Number", - "value": 1 - }, - "B": { - "type": "Number", - "value": 2 - }, - "C": { - "type": "Number", - "value": 3 - }, - "D": { - "type": "Number", - "value": 4 - } -}' -orionCurl --url /v2/entities --payload "$payload" -echo -echo - - -echo "03. Dump and reset: see notification with A, B and C" -echo "====================================================" -accumulatorDump -accumulatorReset -echo -echo - - -echo "04. Update B:20" -echo "===============" -payload='{ - "B": { - "type": "Number", - "value": 20 - } -}' -orionCurl --url /v2/entities/E1/attrs -X PATCH --payload "$payload" -echo -echo - - -echo "05. Dump and reset: see notification with actionType=update and previousValue=2 for B" -echo "=====================================================================================" -accumulatorDump -accumulatorReset -echo -echo - - -echo "06. Update B:20, C:30" -echo "=====================" -payload='{ - "B": { - "type": "Number", - "value": 20 - }, - "C": { - "type": "Number", - "value": 30 - } -}' -orionCurl --url /v2/entities/E1/attrs -X PATCH --payload "$payload" -echo -echo - - -echo "07. Dump and reset: see notification with actionType=update for B and C, previousValue=20 for B, previousValue=3 for C" -echo "======================================================================================================================" -accumulatorDump -accumulatorReset -echo -echo - -echo "08. Update A:1, D:40" -echo "====================" -payload='{ - "A": { - "type": "Number", - "value": 1 - }, - "D": { - "type": "Number", - "value": 40 - } -}' -orionCurl --url /v2/entities/E1/attrs -X PATCH --payload "$payload" -echo -echo - - -echo "09. Dump and reset: see notification with actionType=update and previousValue=1 for A" -echo "=====================================================================================" -accumulatorDump -accumulatorReset -echo -echo - - -echo "10. Update A:10, D:41" -echo "=====================" -payload='{ - "A": { - "type": "Number", - "value": 10 - }, - "D": { - "type": "Number", - "value": 41 - } -}' -orionCurl --url /v2/entities/E1/attrs -X PATCH --payload "$payload" -echo -echo - - -echo "11. Dump and reset: see notification with actionType=update and previousValue=10 for A" -echo "======================================================================================" -accumulatorDump -accumulatorReset -echo -echo - - -echo "12. Create E2 with attributes A:x, B:y, C:z, D:u" -echo "================================================" -payload='{ - "type": "T", - "id": "E2", - "A": { - "type": "Text", - "value": "x" - }, - "B": { - "type": "Text", - "value": "y" - }, - "C": { - "type": "Text", - "value": "z" - }, - "D": { - "type": "Text", - "value": "u" - } -}' -orionCurl --url /v2/entities --payload "$payload" -echo -echo - - -echo "13. Dump and reset: see notification with actionType=append for A, B, C" -echo "=======================================================================" -accumulatorDump -accumulatorReset -echo -echo -echo - - -echo "14. Update subscription conditions" -echo "==================================" -payload='{ - "subject": { - "entities": [ - { - "idPattern": "E.*", - "type": "T" - } - ], - "condition": { - "attrs": [ "B", "C", "D" ] - } - } -}' -orionCurl --url /v2/subscriptions/$SUB_ID -X PATCH --payload "$payload" -echo -echo - - -echo "15. Update E1 A:10, D:41 (forced)" -echo "=================================" -payload='{ - "A": { - "type": "Number", - "value": 10 - }, - "D": { - "type": "Number", - "value": 41 - } -}' -orionCurl --url /v2/entities/E1/attrs?options=forcedUpdate -X PATCH --payload "$payload" -echo -echo - - -echo "16. Update E2 A:x, B:y, C:z, D:u (forced)" -echo "=========================================" -payload='{ - "A": { - "type": "Text", - "value": "x" - }, - "B": { - "type": "Text", - "value": "y" - }, - "C": { - "type": "Text", - "value": "z" - }, - "D": { - "type": "Text", - "value": "u" - } -}' -orionCurl --url /v2/entities/E2/attrs?options=forcedUpdate --payload "$payload" -echo -echo - - -echo "17. Dump and reset: see notification with 2 entities with A, B and C" -echo "====================================================================" -accumulatorDump -accumulatorReset -echo -echo - - ---REGEXPECT-- -01. Subscribe to E.* for A, B and C; triggered by B, C or D -=========================================================== -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/subscriptions/REGEX([0-9a-f]{24}) -Content-Length: 0 - - - -02. Create E1 with attributes A:1, B:2, C:3, D:4 -================================================ -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/entities/E1?type=T -Content-Length: 0 - - - -03. Dump and reset: see notification with A, B and C -==================================================== -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 534 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "append" - } - ], - "name": "A", - "type": "Number", - "value": 1 - }, - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "append" - } - ], - "name": "B", - "type": "Number", - "value": 2 - }, - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "append" - } - ], - "name": "C", - "type": "Number", - "value": 3 - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - -04. Update B:20 -=============== -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -05. Dump and reset: see notification with actionType=update and previousValue=2 for B -===================================================================================== -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 452 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "name": "A", - "type": "Number", - "value": 1 - }, - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "update" - }, - { - "name": "previousValue", - "type": "Number", - "value": 2 - } - ], - "name": "B", - "type": "Number", - "value": 20 - }, - { - "name": "C", - "type": "Number", - "value": 3 - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - -06. Update B:20, C:30 -===================== -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -07. Dump and reset: see notification with actionType=update for B and C, previousValue=20 for B, previousValue=3 for C -====================================================================================================================== -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 572 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "name": "A", - "type": "Number", - "value": 1 - }, - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "update" - }, - { - "name": "previousValue", - "type": "Number", - "value": 20 - } - ], - "name": "B", - "type": "Number", - "value": 20 - }, - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "update" - }, - { - "name": "previousValue", - "type": "Number", - "value": 3 - } - ], - "name": "C", - "type": "Number", - "value": 30 - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - -08. Update A:1, D:40 -==================== -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -09. Dump and reset: see notification with actionType=update and previousValue=1 for A -===================================================================================== -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 453 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "update" - }, - { - "name": "previousValue", - "type": "Number", - "value": 1 - } - ], - "name": "A", - "type": "Number", - "value": 1 - }, - { - "name": "B", - "type": "Number", - "value": 20 - }, - { - "name": "C", - "type": "Number", - "value": 30 - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - -10. Update A:10, D:41 -===================== -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -11. Dump and reset: see notification with actionType=update and previousValue=10 for A -====================================================================================== -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 454 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "update" - }, - { - "name": "previousValue", - "type": "Number", - "value": 1 - } - ], - "name": "A", - "type": "Number", - "value": 10 - }, - { - "name": "B", - "type": "Number", - "value": 20 - }, - { - "name": "C", - "type": "Number", - "value": 30 - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - -12. Create E2 with attributes A:x, B:y, C:z, D:u -================================================ -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/entities/E2?type=T -Content-Length: 0 - - - -13. Dump and reset: see notification with actionType=append for A, B, C -======================================================================= -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 534 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "append" - } - ], - "name": "A", - "type": "Text", - "value": "x" - }, - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "append" - } - ], - "name": "B", - "type": "Text", - "value": "y" - }, - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "append" - } - ], - "name": "C", - "type": "Text", - "value": "z" - } - ], - "id": "E2", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - - -14. Update subscription conditions -================================== -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -15. Update E1 A:10, D:41 (forced) -================================= -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -16. Update E2 A:x, B:y, C:z, D:u (forced) -========================================= -HTTP/1.1 204 No Content -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) - - - -17. Dump and reset: see notification with 2 entities with A, B and C -==================================================================== -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 455 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "update" - }, - { - "name": "previousValue", - "type": "Number", - "value": 10 - } - ], - "name": "A", - "type": "Number", - "value": 10 - }, - { - "name": "B", - "type": "Number", - "value": 20 - }, - { - "name": "C", - "type": "Number", - "value": 30 - } - ], - "id": "E1", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 687 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "update" - }, - { - "name": "previousValue", - "type": "Text", - "value": "x" - } - ], - "name": "A", - "type": "Text", - "value": "x" - }, - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "update" - }, - { - "name": "previousValue", - "type": "Text", - "value": "y" - } - ], - "name": "B", - "type": "Text", - "value": "y" - }, - { - "metadatas": [ - { - "name": "actionType", - "type": "Text", - "value": "update" - }, - { - "name": "previousValue", - "type": "Text", - "value": "z" - } - ], - "name": "C", - "type": "Text", - "value": "z" - } - ], - "id": "E2", - "isPattern": "false", - "type": "T" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "originator": "localhost", - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= - - ---TEARDOWN-- -brokerStop CB -accumulatorStop $LISTENER_PORT -dbDrop CB diff --git a/test/functionalTest/cases/2647_patch_subscription_bugfix/patch_subscription_bugfix_to_attrs.test b/test/functionalTest/cases/2647_patch_subscription_bugfix/patch_subscription_bugfix_to_attrs.test index c9277dbbae..762a14683a 100644 --- a/test/functionalTest/cases/2647_patch_subscription_bugfix/patch_subscription_bugfix_to_attrs.test +++ b/test/functionalTest/cases/2647_patch_subscription_bugfix/patch_subscription_bugfix_to_attrs.test @@ -67,8 +67,7 @@ payload='{ "url": "http://localhost:1234" }, "exceptAttrs": ["temperature", "humidity"], - "metadata": [ "previousValue", "actionType" , "*"], - "attrsFormat": "legacy" + "metadata": [ "previousValue", "actionType" , "*"] }, "throttling": 5, "expires": "2016-04-05T14:00:00.00Z", @@ -128,14 +127,14 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 670 +Content-Length: 674 { "description": "One subscription to rule them all", "expires": "2016-04-05T14:00:00.000Z", "id": "REGEX([0-9a-f]{24})", "notification": { - "attrsFormat": "legacy", + "attrsFormat": "normalized", "covered": false, "exceptAttrs": [ "temperature", diff --git a/test/functionalTest/cases/2647_patch_subscription_bugfix/patch_subscription_bugfix_to_except_attr.test b/test/functionalTest/cases/2647_patch_subscription_bugfix/patch_subscription_bugfix_to_except_attr.test index bc90656ff9..2f59d462b8 100644 --- a/test/functionalTest/cases/2647_patch_subscription_bugfix/patch_subscription_bugfix_to_except_attr.test +++ b/test/functionalTest/cases/2647_patch_subscription_bugfix/patch_subscription_bugfix_to_except_attr.test @@ -67,8 +67,7 @@ payload='{ "url": "http://localhost:1234" }, "attrs": ["temperature", "humidity"], - "metadata": [ "previousValue", "actionType" , "*"], - "attrsFormat": "legacy" + "metadata": [ "previousValue", "actionType" , "*"] }, "throttling": 5, "expires": "2016-04-05T14:00:00.00Z", @@ -128,7 +127,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 664 +Content-Length: 668 { "description": "One subscription to rule them all", @@ -139,7 +138,7 @@ Content-Length: 664 "temperature", "humidity" ], - "attrsFormat": "legacy", + "attrsFormat": "normalized", "covered": false, "http": { "url": "http://localhost:1234" diff --git a/test/functionalTest/cases/3154_notification_problem_with_custom_header/notification_problem_with_custom_header.test b/test/functionalTest/cases/3154_notification_problem_with_custom_header/notification_problem_with_custom_header.test deleted file mode 100644 index b4e9cc5695..0000000000 --- a/test/functionalTest/cases/3154_notification_problem_with_custom_header/notification_problem_with_custom_header.test +++ /dev/null @@ -1,295 +0,0 @@ -# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Notification Templates, with refresh of the subscription cache - ---SHELL-INIT-- -dbInit CB -brokerStart CB 0 -accumulatorStart --pretty-print - ---SHELL-- - -# -# 01. Create custom subscription -# 02. Create custom subscription with payload inside httpCustom and with "attrsFormat" == "legacy" -# 03. Create entity to trigger the subscriptions -# 04. GET the subscriptions -# 05. Dump accumulator and see first notification in legacy mode, second notification not in legacy mode, as custom payload overrides -# - -echo "01. Create custom subscription" -echo "==============================" -payload='{ - "description": "not custom", - "expires": "2040-01-01T14:00:00.00Z", - "subject": { - "entities": [ - { - "idPattern" : ".*" - } - ], - "condition": { - "attrs": [] - } - }, - "notification": { - "attrs": [], - "attrsFormat": "legacy", - "httpCustom": { - "url": "http://localhost:'${LISTENER_PORT}'/notify" - } - } -}' -orionCurl --url /v2/subscriptions --payload "$payload" -echo -echo - - -echo '02. Create custom subscription with payload inside httpCustom and with "attrsFormat" == "legacy"' -echo "================================================================================================" -payload='{ - "description": "custom", - "expires": "2040-01-01T14:00:00.00Z", - "subject": { - "entities": [ - { - "idPattern" : ".*" - } - ], - "condition": { - "attrs": [] - } - }, - "notification": { - "attrs": [], - "attrsFormat": "legacy", - "httpCustom": { - "url": "http://localhost:'${LISTENER_PORT}'/notify", - "payload": "{ %22A1%22: %22Value of A1: ${A1}%22 }" - } - } -}' -orionCurl --url /v2/subscriptions --payload "$payload" -echo -echo - - -echo "03. Create entity to trigger the subscriptions" -echo "==============================================" -payload='{ - "id": "E1", - "A1": "a1", - "A2": "a2", - "A3": 13 -}' -orionCurl --url /v2/entities?options=keyValues --payload "$payload" -echo -echo - - -echo "04. GET the subscriptions" -echo "=========================" -orionCurl --url /v2/subscriptions -echo -echo - - -echo "05. Dump accumulator and see first notification in legacy mode, second notification not in legacy mode, as custom payload overrides" -echo "===================================================================================================================================" -accumulatorDump -echo -echo - - ---REGEXPECT-- -01. Create custom subscription -============================== -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/subscriptions/REGEX([0-9a-f]{24}) -Content-Length: 0 - - - -02. Create custom subscription with payload inside httpCustom and with "attrsFormat" == "legacy" -================================================================================================ -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/subscriptions/REGEX([0-9a-f]{24}) -Content-Length: 0 - - - -03. Create entity to trigger the subscriptions -============================================== -HTTP/1.1 201 Created -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Location: /v2/entities/E1?type=Thing -Content-Length: 0 - - - -04. GET the subscriptions -========================= -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 1012 - -[ - { - "description": "not custom", - "expires": "2040-01-01T14:00:00.000Z", - "id": "REGEX([0-9a-f]{24})", - "notification": { - "attrs": [], - "attrsFormat": "legacy", - "covered": false, - "httpCustom": { - "url": "http://localhost:9997/notify" - }, - "lastNotification": "REGEX(.*)", - "lastSuccess": "REGEX(.*)", - "lastSuccessCode": 200, - "onlyChangedAttrs": false, - "timesSent": 1 - }, - "status": "active", - "subject": { - "condition": { - "attrs": [], - "notifyOnMetadataChange": true - }, - "entities": [ - { - "idPattern": ".*" - } - ] - } - }, - { - "description": "custom", - "expires": "2040-01-01T14:00:00.000Z", - "id": "REGEX([0-9a-f]{24})", - "notification": { - "attrs": [], - "attrsFormat": "legacy", - "covered": false, - "httpCustom": { - "payload": "{ %22A1%22: %22Value of A1: ${A1}%22 }", - "url": "http://localhost:9997/notify" - }, - "lastNotification": "REGEX(.*)", - "lastSuccess": "REGEX(.*)", - "lastSuccessCode": 200, - "onlyChangedAttrs": false, - "timesSent": 1 - }, - "status": "active", - "subject": { - "condition": { - "attrs": [], - "notifyOnMetadataChange": true - }, - "entities": [ - { - "idPattern": ".*" - } - ] - } - } -] - - -05. Dump accumulator and see first notification in legacy mode, second notification not in legacy mode, as custom payload overrides -=================================================================================================================================== -#SORT_START -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 316 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: application/json; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[12]) - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "name": "A1", - "type": "Text", - "value": "a1" - }, - { - "name": "A2", - "type": "Text", - "value": "a2" - }, - { - "name": "A3", - "type": "Number", - "value": 13 - } - ], - "id": "E1", - "isPattern": "false", - "type": "Thing" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "" - } - } - ], - "subscriptionId": "REGEX([0-9a-f]{24})" -} -======================================= -POST http://localhost:REGEX(\d+)/notify -Fiware-Servicepath: / -Content-Length: 27 -User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) -Ngsiv2-Attrsformat: custom -Host: localhost:REGEX(\d+) -Accept: application/json -Content-Type: text/plain; charset=utf-8 -Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[12]) - -{ - "A1": "Value of A1: a1" -} -======================================= -#SORT_END - - ---TEARDOWN-- -brokerStop CB -dbDrop CB -accumulatorStop diff --git a/test/functionalTest/testHarness.sh b/test/functionalTest/testHarness.sh deleted file mode 100755 index 9b30488480..0000000000 --- a/test/functionalTest/testHarness.sh +++ /dev/null @@ -1,1243 +0,0 @@ -#!/bin/bash -# -*- coding: latin-1 -*- -# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es -# -# Author: Ken Zangelin - - -date -testStartTime=$(date +%s.%2N) -MAX_TRIES=${CB_MAX_TRIES:-3} -echo $testStartTime > /tmp/brokerStartCounter - - -# ----------------------------------------------------------------------------- -# -# DISABLED - funct tests that are disabled, for some reason -# -DISABLED=('test/functionalTest/cases/0000_bad_requests/exit.test' \ - 'test/functionalTest/cases/0917_queryContext_behaves_differently/query_with_and_without_forwarding.test' \ - 'test/functionalTest/cases/0000_ipv6_support/ipv4_only.test' \ - 'test/functionalTest/cases/0000_ipv6_support/ipv6_only.test' \ - 'test/functionalTest/cases/1310_suspect_200OK/suspect_200OK.test'); - - - -# ------------------------------------------------------------------------------ -# -# Find out in which directory this script resides -# -dirname=$(dirname $0) - -if [ "$dirname" == "" ] -then - dirname="." -fi - -cd $dirname -export SCRIPT_HOME=$(pwd) -cd - > /dev/null 2>&1 - - - -# ------------------------------------------------------------------------------ -# -# Debug mode? -# -if [ "$ORION_FT_DEBUG" == "1" ] -then - _debug='on' -fi - - - -# ----------------------------------------------------------------------------- -# -# Log file for debugging -# -rm -f /tmp/orionFuncTestDebug.log -echo $(date) > /tmp/orionFuncTestDebug.log - - - -# ----------------------------------------------------------------------------- -# -# Env vars -# -export LC_ALL=C -export NAME="testFile" -declare -A testErrorV -typeset -i testError -declare -A okOnSecondV -typeset -i okOnSecond -declare -A okOnThirdV -typeset -i okOnThird -declare -A okOnPlus3V -typeset -i okOnPlus3 -declare -A skipV -typeset -i skips -declare -A disabledTestV -typeset -i disabledTests -declare -A notInFlavourTestV -typeset -i notInFlavourTests - -export DIFF=$SCRIPT_HOME/testDiff.py -testError=0 -okOnSecond=0 -okOnThird=0 -okOnPlus3=0 -skips=0 -disabledTests=0 -notInFlavourTests=0 - - -# ----------------------------------------------------------------------------- -# -# Default value of skipList taken from an env var, to make things a little -# easier in distros with constantly failing tests -# -skipList="$CB_SKIP_LIST" - - - -# ----------------------------------------------------------------------------- -# -# usage -# -function usage() -{ - sfile="Usage: "$(basename $0) - empty=$(echo $sfile | tr 'a-zA-z/0-9.:' ' ') - echo "$sfile [-u (usage)]" - echo "$empty [-v (verbose)]" - echo "$empty [--filter ]" - echo "$empty [--match ]" - echo "$empty [--keep (don't remove output files)]" - echo "$empty [--dryrun (don't execute any tests)]" - echo "$empty [--dir ]" - echo "$empty [--fromIx ]" - echo "$empty [--toIx ]" - echo "$empty [--ixList ]" - echo "$empty [--skipList ]" - echo "$empty [--stopOnError (stop at first error encountered)]" - echo "$empty [--no-duration (removes duration mark on successful tests)]" - echo "$empty [--noCache (force broker to be started with the option --noCache)]" - echo "$empty [--cache (force broker to be started without the option --noCache)]" - echo "$empty [--noThreadpool (do not use a threadpool, unless specified by a test case. If not set, a thread pool of 200:20 is used by default in test cases which do not set notificationMode options)]" - echo "$empty [--xbroker (use external brokers, i.e. this script will *not* start any brokers, including context providers)]" - echo "$empty [ ]*" - echo - echo "* Please note that if a directory is passed as parameter, its entire path must be given, not only the directory-name" - echo "* If a file is passed as parameter, its entire file-name must be given, including '.test'" - echo "" - echo "Env Vars:" - echo "CB_MAX_TRIES: The number of tries before giving up on a failing test case" - echo "CB_SKIP_LIST: Default value for option --skipList" - echo "CB_SKIP_FUNC_TESTS: List of names of func tests to skip" - echo "CB_NO_CACHE: Start the broker without subscription cache (if set to 'ON')" - echo "CB_THREADPOOL: Start the broker without thread pool (if set to 'OFF')" - echo "CB_DIFF_TOOL: To view diff of failing tests with diff/tkdiff/meld/... (e.g. export CB_DIFF_TOOL=tkdiff)" - echo "CB_WITH_EXTERNAL_BROKER: The broker is started externally - not 'automatically' by the test harness (if set to 'ON')" - echo "" - echo "FT_FROM_IX: alternative to commandline parameter 'fromIx', index of test where to start (inclusive) " - echo "FT_TO_IX: alternative to commandline parameter 'toIx', index of test where to end (inclusive)" - echo - echo "Please note that, if using CB_WITH_EXTERNAL_BROKER (or --xbroker, which is the same), only a single test case should be run." - echo - exit $1 -} - - - -# ----------------------------------------------------------------------------- -# -# vMsg -# -function vMsg() -{ - if [ "$verbose" = "on" ] - then - echo $ME: $* - fi -} - - - -# ----------------------------------------------------------------------------- -# -# exitFunction -# -function exitFunction() -{ - exitCode=$1 - errorText=$2 - testFile=$3 - errorString=$4 - errorFile=$5 - forced=$6 - - echo -n "(FAIL $exitCode - $errorText) " - - if [ "$stopOnError" == "on" ] || [ "$forced" == "DIE" ] - then - echo $ME/$NAME: $errorString - - if [ "$errorFile" != "" ] && [ -f "$errorFile" ] - then - cat $errorFile 2> /dev/null - fi - - exit $exitCode - fi - - echo >> /tmp/orionFuncTestLog - echo '----- ' $NAME ' -----' >> /tmp/orionFuncTestLog - echo $errorString >> /tmp/orionFuncTestLog - - if [ "$errorFile" != "" ] && [ -f "$errorFile" ] - then - cat $errorFile >> /tmp/orionFuncTestLog 2> /dev/null - echo >> /tmp/orionFuncTestLog - fi - - echo >> /tmp/orionFuncTestLog - - testErrorV[$testError]=$testFile - testError=$testError+1 - toBeStopped=true; -} - - - -# ------------------------------------------------------------------------------ -# -# ME - name of script, to be used in error and verbose messages -# -ME=$(basename $0) -vMsg "$ME, in directory $SCRIPT_HOME" - - - -# ------------------------------------https://github.com/telefonicaid/fiware-orion/pull/394#discussion_r13321709------------------------------------------ -# -# Argument parsing -# -typeset -i fromIx -typeset -i toIx -verbose=off -dryrun=off -keep=off -stopOnError=off -testFilter=${TEST_FILTER:-"*.test"} -match="" -dir=$SCRIPT_HOME/cases -dirOrFile="" -dirGiven=no -filterGiven=no -showDuration=on -fromIx=0 -toIx=0 -ixList="" -noCache="" -threadpool=ON -xbroker=off - -vMsg "parsing options" -while [ "$#" != 0 ] -do - if [ "$1" == "-u" ]; then usage 0; - elif [ "$1" == "-v" ]; then verbose=on; - elif [ "$1" == "--dryrun" ]; then dryrun=on; - elif [ "$1" == "--keep" ]; then keep=on; - elif [ "$1" == "--stopOnError" ]; then stopOnError=on; - elif [ "$1" == "--filter" ]; then testFilter="$2"; filterGiven=yes; shift; - elif [ "$1" == "--match" ]; then match="$2"; shift; - elif [ "$1" == "--dir" ]; then dir="$2"; dirGiven=yes; shift; - elif [ "$1" == "--fromIx" ]; then fromIx=$2; shift; - elif [ "$1" == "--toIx" ]; then toIx=$2; shift; - elif [ "$1" == "--ixList" ]; then ixList=$2; shift; - elif [ "$1" == "--skipList" ]; then skipList=$2; shift; - elif [ "$1" == "--no-duration" ]; then showDuration=off; - elif [ "$1" == "--noCache" ]; then noCache=ON; - elif [ "$1" == "--cache" ]; then noCache=OFF; - elif [ "$1" == "--noThreadpool" ]; then threadpool=OFF; - elif [ "$1" == "--xbroker" ]; then xbroker=ON; - else - if [ "$dirOrFile" == "" ] - then - dirOrFile="$1" - else - echo $0: bad parameter/option: "'"${1}"'"; - echo - usage 1 - fi - fi - shift -done - -vMsg "options parsed" - -# ----------------------------------------------------------------------------- -# -# The function brokerStart looks at the env var CB_NO_CACHE to decide -# whether to start the broker with the --noCache option or not -# -if [ "$noCache" != "" ] -then - export CB_NO_CACHE=$noCache -fi - -# ----------------------------------------------------------------------------- -# -# The function brokerStart looks at the env var CB_THREADPOOL to decide -# whether to start the broker with pool of threads or not. -# Do not overwrite if a value is passed from environment -# -if [ "$CB_THREADPOOL" == "" ] -then - export CB_THREADPOOL=$threadpool -fi - -# ----------------------------------------------------------------------------- -# -# Check if fromIx is set through an env var and use if nothing -# else is set through commandline parameter -# -if [ "$FT_FROM_IX" != "" ] && [ $fromIx == 0 ] -then - fromIx=$FT_FROM_IX -fi - -# ----------------------------------------------------------------------------- -# -# Check if toIx is set through an env var and use if nothing -# else is set through commandline parameter -# -if [ "$FT_TO_IX" != "" ] && [ $toIx == 0 ] -then - toIx=$FT_TO_IX -fi - -echo "Run tests $fromIx to $toIx" - -# ------------------------------------------------------------------------------ -# -# Check unmatching --dir and 'parameter that is a directory' AND -# unmatching --filter and 'parameter that is a file' -# -# 1. If it is a directory - just change the 'dir' variable and continue -# 2. Else, it must be a file, or a filter. -# If the -# -singleFile=No -if [ "$dirOrFile" != "" ] -then - vMsg dirOrFile: $dirOrFile - vMsg dirGiven: $dirGiven - vMsg filterGiven: $filterGiven - vMsg dir: $dir - vMsg testFilter: $testFilter - - if [ -d "$dirOrFile" ] - then - if [ "$dirGiven" == "yes" ] - then - echo "$0: both '--dir' option and directory parameter given - not allowed" - exit 1 - fi - dir="$dirOrFile" - else - if [ "$filterGiven" == "yes" ] - then - echo "$0: both '--filter' option and file parameter given - not allowed" - exit 1 - fi - - singleFile=Yes - # - # If just a filename is given, keep the directory as is. - # If a whole path is given, use the directory-part as directory and the file-part as filter - # - dirPart=$(dirname $dirOrFile) - filePath=$(basename $dirOrFile) - xdir=$(basename $dirPart); - vMsg "dirPart: $dirPart" - vMsg "filePath: $filePath" - - if [ "$dirPart" != "." ] - then - dir=$(dirname $dirOrFile) - testFilter=$(basename $dirOrFile) - - # Last dir + test file ? - if [ -d test/functionalTest/cases/$dirPart ] - then - dirOrFile=test/functionalTest/cases/$dirPart - fi - else - testFilter=$(basename $dirOrFile) - fi - fi -fi - -# -# The option of running against an external broker "--xbroker" only works (for now, at least) with a single test case. -# Strange things may happen (due to the state inside the broker) if more that one test case are launched. -# This check avoid this situation. -# -# If in the future we want to be able to run more than one test case against an external broker, we'd need to make sure -# that each test case undoes all internal state inside the external broker. E.g. delete subscriptions, entities, etc. -# -if [ "$singleFile" == "No" ] && [ "$xbroker" == "ON" ] -then - echo "External broker can only be used with individual test cases" - exit 1 -fi - -vMsg directory: $dir -vMsg testFilter: $testFilter -vMsg "Script in $SCRIPT_HOME" - - - -# ----------------------------------------------------------------------------- -# -# Other global variables -# -toBeStopped=false - - - -# ------------------------------------------------------------------------------ -# -# xbroker - if this CLI is set, then the broker is not to be started as part of -# the test suite - another broker is assumed to be running already -# -if [ "$xbroker" == "ON" ] -then - export CB_WITH_EXTERNAL_BROKER=ON -fi - - - -# ----------------------------------------------------------------------------- -# -# Init files already sourced? -# -if [ "$CONTEXTBROKER_TESTENV_SOURCED" != "YES" ] -then - if [ -f "$SCRIPT_HOME/testEnv.sh" ] - then - # First, we try with a testEnv.sh file in the script home - vMsg Sourcing $SCRIPT_HOME/testEnv.sh - source $SCRIPT_HOME/testEnv.sh - elif [ -f "$SCRIPT_HOME/../../scripts/testEnv.sh" ] - then - # Second, we try with a testEnv.sh file in the script/testEnv.sh (realtive to git repo home). - # Note that the script home in this case is test/functionalTest - vMsg Sourcing $SCRIPT_HOME/../../scripts/testEnv.sh - source $SCRIPT_HOME/../../scripts/testEnv.sh - else - echo "------------------------------------------------------------------" - echo "Please source testEnv.sh before running the functional test suite." - echo "------------------------------------------------------------------" - exit 1 - fi -fi - -if [ "$CONTEXTBROKER_HARNESS_FUNCTIONS_SOURCED" != "YES" ] -then - if [ -f $SCRIPT_HOME/harnessFunctions.sh ] - then - vMsg Sourcing $SCRIPT_HOME/harnessFunctions.sh - source $SCRIPT_HOME/harnessFunctions.sh - else - echo "--------------------------------------------------------------------------------------------" - echo "Please source $SCRIPT_HOME/harnessFunctions.sh before running the functional test suite." - echo "--------------------------------------------------------------------------------------------" - exit 1 - fi -fi - - - -# ------------------------------------------------------------------------------ -# -# Preparations - cd to the test directory -# -dMsg Functional Tests Starting ... - -if [ "$dirOrFile" != "" ] && [ -d "$dirOrFile" ] -then - cd $dirOrFile -elif [ ! -d "$dir" ] -then - exitFunction 1 "$dir is not a directory" "HARNESS" "$dir" "" DIE -else - cd $dir -fi - -echo "Orion Functional tests starting" > /tmp/orionFuncTestLog -date >> /tmp/orionFuncTestLog - - - -# ------------------------------------------------------------------------------ -# -# Preparations - number of test cases -# -vMsg find in $(pwd), filter: $testFilter -if [ "$match" == "" ] -then - fileList=$(find . -name "$testFilter" | sort | sed 's/^.\///') -else - fileList=$(find . -name "$testFilter" | grep "$match" | sort | sed 's/^.\///') -fi -vMsg "fileList: $fileList" -typeset -i noOfTests -typeset -i testNo - - - -# ------------------------------------------------------------------------------ -# -# Count total number of tests (for progressing info in messages) -# -for i in $fileList -do - noOfTests=$noOfTests+1 -done - - - -# ------------------------------------------------------------------------------ -# -# fileCleanup - -# -function fileCleanup() -{ - filename=$1 - keepOutputFiles=$2 - path=$3 - dir=$(dirname $path) - - vMsg "---------------------------------------------------------" - vMsg "In fileCleanup for $filename in $dir" - vMsg "---------------------------------------------------------" - - if [ "$keepOutputFiles" != "on" ] - then - olddir=$PWD - cd $dir - - rm $filename.name 2> /dev/null - rm $filename.shellInit 2> /dev/null - rm $filename.shellInit.* 2> /dev/null - rm $filename.shell 2> /dev/null - rm $filename.shell.* 2> /dev/null - rm $filename.teardown 2> /dev/null - rm $filename.teardown.* 2> /dev/null - rm $filename.valgrind.out 2> /dev/null - rm $filename.valgrind.stop.out 2> /dev/null - rm $filename.out 2> /dev/null - rm $filename.regexpect 2> /dev/null - rm $filename.out.sorted 2> /dev/null - rm $filename.regexpect.sorted 2> /dev/null - rm $filename.blockSortDiff.out 2> /dev/null - rm $filename.diff 2> /dev/null - - cd $olddir - fi -} - - - -# ------------------------------------------------------------------------------ -# -# fileCreation - create the files for test execution -# -function fileCreation() -{ - path=$1 - filename=$2 - ret=0 - - dirname=$(dirname $path) - filename=$(basename $path .test) - - if [ "$dirname" != "." ] && [ "$dirname" != "" ] - then - pathWithoutExt=$dirname/$filename - vMsg New path: $path - else - pathWithoutExt=$filename - fi - - vMsg Creating test files for $pathWithoutExt - - - # - # Extract the NAME - # - NAME=$(sed -n '/--NAME--/,/^--/p' $path | grep -v "^--") - if [ "$NAME" == "" ] - then - exitFunction 2 "--NAME-- part is missing" "$path" "($path)" "" DIE - exit 2 # Just in case - fi - - # - # Extract the shell init script - # - if [ $(grep "\-\-SHELL\-INIT\-\-" $path | wc -l) -eq 1 ] - then - TEST_SHELL_INIT=${pathWithoutExt}.shellInit - vMsg "Creating $TEST_SHELL_INIT at $PWD" - sed -n '/--SHELL-INIT--/,/^--/p' $path | grep -v "^--" > $TEST_SHELL_INIT - else - exitFunction 3 "--SHELL-INIT-- part is missing" $path "($path)" "" DIE - fi - - # - # Extract the test shell script - # - if [ $(grep "\-\-SHELL\-\-" $path | wc -l) -eq 1 ] - then - TEST_SHELL=${pathWithoutExt}.shell - vMsg "Creating $TEST_SHELL at $PWD" - sed -n '/--SHELL--/,/^--/p' $path | grep -v "^--" > $TEST_SHELL - else - exitFunction 4 "--SHELL-- part is missing" $path "($path)" "" DIE - fi - - # - # Extract the REGEXPECT part - # - if [ $(grep "\-\-REGEXPECT\-\-" $path | wc -l) -eq 1 ] - then - TEST_REGEXPECT=${pathWithoutExt}.regexpect - vMsg "Creating $TEST_REGEXPECT at $PWD" - sed -n '/--REGEXPECT--/,/^--/p' $path | grep -v "^--" | sed '/^##/d' > $TEST_REGEXPECT - else - exitFunction 5 "--REGEXPECT-- part is missing" $path "($path)" "" DIE - fi - - # - # Extract the teardown script - # - if [ $(grep "\-\-TEARDOWN\-\-" $path | wc -l) -eq 1 ] - then - TEST_TEARDOWN=${pathWithoutExt}.teardown - vMsg "Creating $TEST_TEARDOWN at $PWD" - sed -n '/--TEARDOWN--/,/^--/p' $path | grep -v "^--" > $TEST_TEARDOWN - else - exitFunction 6 "--TEARDOWN-- part is missing" $path "($path)" "" DIE - fi -} - - - -# ------------------------------------------------------------------------------ -# -# partExecute -# -function partExecute() -{ - what=$1 - path=$2 - forcedDie=$3 - __tryNo=$4 - - vMsg Executing $what part for $path - dirname=$(dirname $path) - filename=$(basename $path .test) - - if [ "$dirname" != "." ] && [ "$dirname" != "" ] - then - path=$dirname/$filename.test - fi - - # - # Prepare to execute - # - chmod 755 $dirname/$filename.$what - rm -f $dirname/$filename.$what.stderr - rm -f $dirname/$filename.$what.stdout - $dirname/$filename.$what > $dirname/$filename.$what.stdout 2> $dirname/$filename.$what.stderr - exitCode=$? - linesInStderr=$(wc -l $dirname/$filename.$what.stderr | awk '{ print $1}' 2> /dev/null) - - # - # Check that stdout is empty - # - if [ "$linesInStderr" != "" ] && [ "$linesInStderr" != "0" ] - then - if [ $__tryNo == $MAX_TRIES ] - then - exitFunction 7 "$what: output on stderr" $path "($path): $what produced output on stderr" $dirname/$filename.$what.stderr "$forcedDie" - else - echo -n "(ERROR 7 - $what: output on stderr) " - fi - - partExecuteResult=7 - return - fi - - - # - # Check that exit code is ZERO - # - if [ "$exitCode" != "0" ] - then - if [ $__tryNo == $MAX_TRIES ] - then - exitFunction 8 $path "$what exited with code $exitCode" "($path)" $dirname/$filename.$what.stderr "$forcedDie" - else - echo -n "(ERROR 8 - $what: exited with code $exitCode) " - fi - - partExecuteResult=8 - return - fi - - - # - # Compare produced output with expected output - # - if [ "$what" == "shell" ] - then - mv $dirname/$filename.$what.stdout $dirname/$filename.out # We are very much used to this name ... - sed -i 's/[[:space:]]*$//' $dirname/$filename.out # Remove trailing whitespace in .out (reduces diff noise) - - # - # Special sorted diff or normal REGEX diff ? - # - blockDiff='no' - grep '^#SORT_START$' $dirname/$filename.regexpect > /dev/null 2>&1 - if [ $? == 0 ] - then - $SCRIPT_HOME/blockSortDiff.sh --referenceFile $dirname/$filename.regexpect --brokerOutputFile $dirname/$filename.out > $dirname/$filename.blockSortDiff.out - exitCode=$? - blockDiff='yes' - else - PYTHONIOENCODING=utf8 $DIFF -r $dirname/$filename.regexpect -i $dirname/$filename.out > $dirname/$filename.diff - exitCode=$? - fi - - if [ "$exitCode" != "0" ] - then - if [ $__tryNo == $MAX_TRIES ] - then - exitFunction 9 ".out and .regexpect differ" $path "($path) output not as expected" $dirname/$filename.diff - else - echo -n "(ERROR 9 - .out and .regexpect differ) " - fi - - if [ "$CB_DIFF_TOOL" != "" ] && [ $__tryNo == $MAX_TRIES ] - then - endDate=$(date) - if [ $blockDiff == 'yes' ] - then - $CB_DIFF_TOOL $dirname/$filename.regexpect.sorted $dirname/$filename.out.sorted - else - $CB_DIFF_TOOL $dirname/$filename.regexpect $dirname/$filename.out - fi - fi - partExecuteResult=9 - return - fi - fi - - partExecuteResult=0 -} - - - -# ------------------------------------------------------------------------------ -# -# runTest - the function that runs ONE test case -# -# 1. Remove old output files -# 2.1. Create the various test files from '$path' -# 3.1. Run the SHELL-INIT part -# 3.2. If [ $? != 0 ] || [ STDERR != empty ] ERROR -# 4.1. Run the SHELL part -# 4.2. If [ $? != 0 ] || [ STDERR != empty ] ERROR -# 5.1. Run the TEARDOWN part -# 5.2. If [ $? != 0 ] || [ STDERR != empty ] ERROR -# 6.1. Compare output with regexpect (or expect) -# 6.2. Not EQUAL: ERROR -# 7. If [ "$keep" != "yes" ] Remove all output files -# -# -function runTest() -{ - path=$1 - _tryNo=$2 - - runTestStatus="ok" - - vMsg path=$path - dirname=$(dirname $path) - filename=$(basename $path .test) - dir="" - - if [ "$dirname" != "." ] && [ "$dirname" != "" ] - then - path=$dirname/$filename.test - vMsg New path: $path - fi - - vMsg running test $path - - # 1. Remove old output files - fileCleanup $filename removeAll $path - if [ "$toBeStopped" == "yes" ] - then - echo toBeStopped == yes - runTestStatus="stopped" - return - fi - - # 2. Create the various test files from '$path' - fileCreation $path $filename - if [ "$toBeStopped" == "yes" ] - then - runTestStatus="stopped2" - return - fi - - # 3. Run the SHELL-INIT part - vMsg Executing SHELL-INIT part for $path - chmod 755 $dirname/$filename.shellInit - rm -f $dirname/$filename.shellInit.stderr - rm -f $dirname/$filename.shellInit.stdout - $dirname/$filename.shellInit > $dirname/$filename.shellInit.stdout 2> $dirname/$filename.shellInit.stderr - exitCode=$? - linesInStderr=$(wc -l $dirname/$filename.shellInit.stderr | awk '{ print $1}' 2> /dev/null) - - if [ "$linesInStderr" != "" ] && [ "$linesInStderr" != "0" ] - then - exitFunction 10 "SHELL-INIT produced output on stderr" $path "($path)" $dirname/$filename.shellInit.stderr - runTestStatus="shell-init-error" - return - fi - - if [ "$exitCode" != "0" ] - then - - # - # 3.2 Run the SHELL-INIT part AGAIN - # - # This 're-run' of the SHELL-INIT part is due to errors we've seen that seem to be caused by - # a try to start a broker while the old one (from the previous functest) is still running. - # No way to test this, except with some patience. - # - # We have seen 'ERROR 11' around once every 500-1000 functests (the suite is of almost 400 tests) - # and this fix, if working, will make us not see those 'ERROR 11' again. - # If we keep seeing 'ERROR 11' after this change then we will need to investigate further. - # - sleep 1 - rm -f $dirname/$filename.shellInit.stderr - rm -f $dirname/$filename.shellInit.stdout - $dirname/$filename.shellInit > $dirname/$filename.shellInit.stdout 2> $dirname/$filename.shellInit.stderr - exitCode=$? - linesInStderr=$(wc -l $dirname/$filename.shellInit.stderr | awk '{ print $1}' 2> /dev/null) - - if [ "$linesInStderr" != "" ] && [ "$linesInStderr" != "0" ] - then - exitFunction 20 "SHELL-INIT II produced output on stderr" $path "($path)" $dirname/$filename.shellInit.stderr - runTestStatus="shell-init-output-on-stderr" - return - fi - - if [ "$exitCode" != "0" ] - then - exitFunction 11 "SHELL-INIT exited with code $exitCode" $path "($path)" "" DIE - runTestStatus="shell-init-exited-with-"$exitCode - return - fi - fi - - # 4. Run the SHELL part (which also compares - FIXME P2: comparison should be moved to separate function) - partExecute shell $path "DontDie - only for SHELL-INIT" $_tryNo - shellResult=$partExecuteResult - if [ "$toBeStopped" == "yes" ] - then - runTestStatus="shell-failed" - return - fi - - # 5. Run the TEARDOWN part - partExecute teardown $path "DIE" 0 - teardownResult=$partExecuteResult - vMsg "teardownResult: $teardownResult" - vMsg "shellResult: $shellResult" - - if [ "$shellResult" == "0" ] && [ "$teardownResult" == "0" ] - then - # 6. Remove output files - vMsg "Remove output files: fileCleanup $filename $keep" - fileCleanup $filename $keep $path - else - file=$(basename $path .test) - cp /tmp/contextBroker.log $file.contextBroker.log - runTestStatus="test-failed" - fi -} - - - -# ----------------------------------------------------------------------------- -# -# testDisabled -# -function testDisabled -{ - testcase=$1 - typeset -i dIx - dIx=0 - while [ $dIx -lt ${#DISABLED[@]} ] - do - # Comparison is done based in filename, skipping the path (see https://stackdiary.com/tutorials/bash-get-filename-from-path/) - if [ "${testcase##*/}" == "${DISABLED[$dIx]##*/}" ] - then - echo "Disabled" - - # - # NOTE: In a non-disabled test, running inside the valgrind test suite, the function 'localBrokerStart()' (from harnessFunctions.sh) - # redirects the output of "valgrind contextBroker" to the file /tmp/valgrind.out. - # Later, the valgrind test suite uses the existence of this file (/tmp/valgrind.out) to detect errors in the valgrind execution. - # But, in the case of a disabled func test, we will not start the test case. and thus we will not reach 'localBrokerStart()', so the - # file will not be created and an error will be flagged by the valgrind test suite. - # The simplest solution is to simply create the file here, in the case of a disabled test. - # - echo "Disabled" > /tmp/valgrind.out - return - fi - dIx=$dIx+1 - done - echo NOT Disabled -} - - - -# ----------------------------------------------------------------------------- -# -# testMatchExprFlavour -# -function testMatchExprFlavour -{ - testcase=$1 - - if grep -q JEXL_EXPR_FLAVOUR $testcase - then - if $(contextBroker --version | grep -q jexl-expr) - then - echo NOT Disabled - else - echo "Disabled" - echo "Disabled" > /tmp/valgrind.out - fi - else - echo NOT Disabled - fi -} - - - -# ------------------------------------------------------------------------------ -# -# Main loop -# -vMsg Total number of tests: $noOfTests -testNo=0 -for testFile in $fileList -do - if [ -d "$testFile" ] - then - continue - fi - - testNo=$testNo+1 - - if [ $fromIx != 0 ] && [ $testNo -lt $fromIx ] - then - continue; - fi - - if [ $toIx != 0 ] && [ $testNo -gt $toIx ] - then - continue; - fi - - # - # Disabled test? - # - disabled=$(testDisabled $testFile) - if [ "$disabled" == "Disabled" ] - then - disabledTestV[$disabledTests]=$testNo': '$testFile - disabledTests=$disabledTests+1 - continue - fi - - # - # Should the test be skipped due to it doesn't mach in the contextBroker flavour? - # - notInFlavour=$(testMatchExprFlavour $testFile) - if [ "$notInFlavour" == "Disabled" ] - then - notInFlavourTestV[$notInFlavourTests]=$testNo': '$testFile - notInFlavourTests=$notInFlavourTests+1 - continue - fi - - if [ "$ixList" != "" ] - then - hit=$(echo ' '$ixList' ' | grep ' '$testNo' ') - if [ "$hit" == "" ] - then - # Test case not found in ix-list, so it is not executed - continue - fi - fi - - if [ "$CB_SKIP_FUNC_TESTS" != "" ] - then - hit=$(echo ' '$CB_SKIP_FUNC_TESTS' ' | grep ' '$testFile' ') - if [ "$hit" != "" ] - then - # Test case found in skip-list, so it is skipped - skipV[$skips]=$testNo': '$testFile - skips=$skips+1 - continue - fi - fi - - if [ "$skipList" != "" ] - then - hit=$(echo ' '$skipList' ' | grep ' '$testNo' ') - if [ "$hit" != "" ] - then - # Test case found in skip-list, so it is skipped - skipV[$skips]=$testNo': '$testFile - skips=$skips+1 - continue - fi - fi - - startDate=$(date) - start=$(date --date="$startDate" +%s) - endDate="" - typeset -i tryNo - tryNo=1 - - if [ "$dryrun" == "off" ] - then - while [ $tryNo -le $MAX_TRIES ] - do - if [ "$verbose" == "off" ] - then - tryNoInfo="" - if [ $tryNo != "1" ] - then - tryNoInfo="(intent $tryNo)" - fi - - init=$testFile" ................................................................................................................." - init=${init:0:110} - printf "%04d/%d: %s %s " "$testNo" "$noOfTests" "$init" "$tryNoInfo" - else - printf "Running test %04d/%d: %s\n" "$testNo" "$noOfTests" "$testFile" - fi - - runTest $testFile $tryNo - if [ "$shellResult" == "0" ] - then - if [ $tryNo != 1 ] - then - if [ $tryNo == 2 ] - then - okOnSecondV[$okOnSecond]=$testFile - okOnSecond=$okOnSecond+1 - elif [ $tryNo == 3 ] - then - okOnThirdV[$okOnThird]=$testFile - okOnThird=$okOnThird+1 - else - okOnPlus3V[$okOnPlus3]=$testFile - okOnPlus3=$okOnPlus3+1 - fi - echo "OK" - fi - break - else - tryNo=$tryNo+1 - echo - fi - done - else - if [ "$verbose" == "off" ] - then - init=$testFile" ................................................................................................................." - init=${init:0:110} - printf "%04d/%d: %s " "$testNo" "$noOfTests" "$init" - else - printf "Running test %04d/%d: %s\n" "$testNo" "$noOfTests" "$testFile" - fi - fi - - if [ "$endDate" == "" ] # Could have been set in 'partExecute' - then - endDate=$(date) - fi - - end=$(date --date="$endDate" +%s) - typeset -i secs - secs=$end-$start - if [ "$showDuration" == "on" ] - then - if [ $secs -lt 10 ] - then - xsecs=0$secs - else - xsecs=$secs - fi - echo $xsecs seconds - else - echo "SUCCESS" - fi -done - - -testEndTime=$(date +%s.%2N) -testDiffTime=$(echo $testEndTime - $testStartTime | bc)" seconds" -echo Total test time: $testDiffTime - - -typeset -i ix -exitCode=0 -# ------------------------------------------------------------------------------ -# -# Check for errors - if any, print to stdout -# -if [ "$testError" != "0" ] -then - echo - echo "Orion Functional Test Log File:" - echo "================================================================================" - cat /tmp/orionFuncTestLog 2> /dev/null - echo "================================================================================" - echo - echo "----------- Failing tests ------------------" - - ix=0 - while [ $ix -lt $testError ] - do - echo " o " ${testErrorV[$ix]} - ix=$ix+1 - done - exitCode=1 -fi - - - -# ------------------------------------------------------------------------------ -# -# Check for reintents -# -if [ "$okOnSecond" != "0" ] -then - echo - echo "$okOnSecond test cases OK in the second attempt:" - - ix=0 - while [ $ix -lt $okOnSecond ] - do - echo " o " ${okOnSecondV[$ix]} - ix=$ix+1 - done -fi - -if [ "$okOnThird" != "0" ] -then - echo - echo "$okOnThird test cases OK in the third attempt:" - - ix=0 - while [ $ix -lt $okOnThird ] - do - echo " o " ${okOnThirdV[$ix]} - ix=$ix+1 - done -fi - -if [ "$okOnPlus3" != "0" ] -then - echo - echo "$okOnPlus3 test cases OK after three or more failed attempts:" - - ix=0 - while [ $ix -lt $okOnPlus3 ] - do - echo " o " ${okOnPlus3V[$ix]} - ix=$ix+1 - done -fi - -if [ $skips != 0 ] -then - echo - echo WARNING: $skips test cases skipped: - ix=0 - while [ $ix -lt $skips ] - do - echo " o " ${skipV[$ix]} - ix=$ix+1 - done -fi - -if [ $disabledTests != 0 ] -then - echo - echo WARNING: $disabledTests test cases disabled: - ix=0 - while [ $ix -lt $disabledTests ] - do - echo " o " ${disabledTestV[$ix]} - ix=$ix+1 - done -fi - -if [ $notInFlavourTests != 0 ] -then - echo - echo WARNING: $notInFlavourTests test cases were not executed due to contexBroker not matching flavour: - ix=0 - while [ $ix -lt $notInFlavourTests ] - do - echo " o " ${notInFlavourTestV[$ix]} - ix=$ix+1 - done -fi - -exit $exitCode From 7d2e97e9520bc633a2fdc4326e05f1d42d751c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 4 Jun 2024 16:05:47 +0200 Subject: [PATCH 3/4] FIX testHarnes.sh wrongly deleted in previous commit --- test/functionalTest/testHarness.sh | 1243 ++++++++++++++++++++++++++++ 1 file changed, 1243 insertions(+) create mode 100755 test/functionalTest/testHarness.sh diff --git a/test/functionalTest/testHarness.sh b/test/functionalTest/testHarness.sh new file mode 100755 index 0000000000..9b30488480 --- /dev/null +++ b/test/functionalTest/testHarness.sh @@ -0,0 +1,1243 @@ +#!/bin/bash +# -*- coding: latin-1 -*- +# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U +# +# This file is part of Orion Context Broker. +# +# Orion Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# iot_support at tid dot es +# +# Author: Ken Zangelin + + +date +testStartTime=$(date +%s.%2N) +MAX_TRIES=${CB_MAX_TRIES:-3} +echo $testStartTime > /tmp/brokerStartCounter + + +# ----------------------------------------------------------------------------- +# +# DISABLED - funct tests that are disabled, for some reason +# +DISABLED=('test/functionalTest/cases/0000_bad_requests/exit.test' \ + 'test/functionalTest/cases/0917_queryContext_behaves_differently/query_with_and_without_forwarding.test' \ + 'test/functionalTest/cases/0000_ipv6_support/ipv4_only.test' \ + 'test/functionalTest/cases/0000_ipv6_support/ipv6_only.test' \ + 'test/functionalTest/cases/1310_suspect_200OK/suspect_200OK.test'); + + + +# ------------------------------------------------------------------------------ +# +# Find out in which directory this script resides +# +dirname=$(dirname $0) + +if [ "$dirname" == "" ] +then + dirname="." +fi + +cd $dirname +export SCRIPT_HOME=$(pwd) +cd - > /dev/null 2>&1 + + + +# ------------------------------------------------------------------------------ +# +# Debug mode? +# +if [ "$ORION_FT_DEBUG" == "1" ] +then + _debug='on' +fi + + + +# ----------------------------------------------------------------------------- +# +# Log file for debugging +# +rm -f /tmp/orionFuncTestDebug.log +echo $(date) > /tmp/orionFuncTestDebug.log + + + +# ----------------------------------------------------------------------------- +# +# Env vars +# +export LC_ALL=C +export NAME="testFile" +declare -A testErrorV +typeset -i testError +declare -A okOnSecondV +typeset -i okOnSecond +declare -A okOnThirdV +typeset -i okOnThird +declare -A okOnPlus3V +typeset -i okOnPlus3 +declare -A skipV +typeset -i skips +declare -A disabledTestV +typeset -i disabledTests +declare -A notInFlavourTestV +typeset -i notInFlavourTests + +export DIFF=$SCRIPT_HOME/testDiff.py +testError=0 +okOnSecond=0 +okOnThird=0 +okOnPlus3=0 +skips=0 +disabledTests=0 +notInFlavourTests=0 + + +# ----------------------------------------------------------------------------- +# +# Default value of skipList taken from an env var, to make things a little +# easier in distros with constantly failing tests +# +skipList="$CB_SKIP_LIST" + + + +# ----------------------------------------------------------------------------- +# +# usage +# +function usage() +{ + sfile="Usage: "$(basename $0) + empty=$(echo $sfile | tr 'a-zA-z/0-9.:' ' ') + echo "$sfile [-u (usage)]" + echo "$empty [-v (verbose)]" + echo "$empty [--filter ]" + echo "$empty [--match ]" + echo "$empty [--keep (don't remove output files)]" + echo "$empty [--dryrun (don't execute any tests)]" + echo "$empty [--dir ]" + echo "$empty [--fromIx ]" + echo "$empty [--toIx ]" + echo "$empty [--ixList ]" + echo "$empty [--skipList ]" + echo "$empty [--stopOnError (stop at first error encountered)]" + echo "$empty [--no-duration (removes duration mark on successful tests)]" + echo "$empty [--noCache (force broker to be started with the option --noCache)]" + echo "$empty [--cache (force broker to be started without the option --noCache)]" + echo "$empty [--noThreadpool (do not use a threadpool, unless specified by a test case. If not set, a thread pool of 200:20 is used by default in test cases which do not set notificationMode options)]" + echo "$empty [--xbroker (use external brokers, i.e. this script will *not* start any brokers, including context providers)]" + echo "$empty [ ]*" + echo + echo "* Please note that if a directory is passed as parameter, its entire path must be given, not only the directory-name" + echo "* If a file is passed as parameter, its entire file-name must be given, including '.test'" + echo "" + echo "Env Vars:" + echo "CB_MAX_TRIES: The number of tries before giving up on a failing test case" + echo "CB_SKIP_LIST: Default value for option --skipList" + echo "CB_SKIP_FUNC_TESTS: List of names of func tests to skip" + echo "CB_NO_CACHE: Start the broker without subscription cache (if set to 'ON')" + echo "CB_THREADPOOL: Start the broker without thread pool (if set to 'OFF')" + echo "CB_DIFF_TOOL: To view diff of failing tests with diff/tkdiff/meld/... (e.g. export CB_DIFF_TOOL=tkdiff)" + echo "CB_WITH_EXTERNAL_BROKER: The broker is started externally - not 'automatically' by the test harness (if set to 'ON')" + echo "" + echo "FT_FROM_IX: alternative to commandline parameter 'fromIx', index of test where to start (inclusive) " + echo "FT_TO_IX: alternative to commandline parameter 'toIx', index of test where to end (inclusive)" + echo + echo "Please note that, if using CB_WITH_EXTERNAL_BROKER (or --xbroker, which is the same), only a single test case should be run." + echo + exit $1 +} + + + +# ----------------------------------------------------------------------------- +# +# vMsg +# +function vMsg() +{ + if [ "$verbose" = "on" ] + then + echo $ME: $* + fi +} + + + +# ----------------------------------------------------------------------------- +# +# exitFunction +# +function exitFunction() +{ + exitCode=$1 + errorText=$2 + testFile=$3 + errorString=$4 + errorFile=$5 + forced=$6 + + echo -n "(FAIL $exitCode - $errorText) " + + if [ "$stopOnError" == "on" ] || [ "$forced" == "DIE" ] + then + echo $ME/$NAME: $errorString + + if [ "$errorFile" != "" ] && [ -f "$errorFile" ] + then + cat $errorFile 2> /dev/null + fi + + exit $exitCode + fi + + echo >> /tmp/orionFuncTestLog + echo '----- ' $NAME ' -----' >> /tmp/orionFuncTestLog + echo $errorString >> /tmp/orionFuncTestLog + + if [ "$errorFile" != "" ] && [ -f "$errorFile" ] + then + cat $errorFile >> /tmp/orionFuncTestLog 2> /dev/null + echo >> /tmp/orionFuncTestLog + fi + + echo >> /tmp/orionFuncTestLog + + testErrorV[$testError]=$testFile + testError=$testError+1 + toBeStopped=true; +} + + + +# ------------------------------------------------------------------------------ +# +# ME - name of script, to be used in error and verbose messages +# +ME=$(basename $0) +vMsg "$ME, in directory $SCRIPT_HOME" + + + +# ------------------------------------https://github.com/telefonicaid/fiware-orion/pull/394#discussion_r13321709------------------------------------------ +# +# Argument parsing +# +typeset -i fromIx +typeset -i toIx +verbose=off +dryrun=off +keep=off +stopOnError=off +testFilter=${TEST_FILTER:-"*.test"} +match="" +dir=$SCRIPT_HOME/cases +dirOrFile="" +dirGiven=no +filterGiven=no +showDuration=on +fromIx=0 +toIx=0 +ixList="" +noCache="" +threadpool=ON +xbroker=off + +vMsg "parsing options" +while [ "$#" != 0 ] +do + if [ "$1" == "-u" ]; then usage 0; + elif [ "$1" == "-v" ]; then verbose=on; + elif [ "$1" == "--dryrun" ]; then dryrun=on; + elif [ "$1" == "--keep" ]; then keep=on; + elif [ "$1" == "--stopOnError" ]; then stopOnError=on; + elif [ "$1" == "--filter" ]; then testFilter="$2"; filterGiven=yes; shift; + elif [ "$1" == "--match" ]; then match="$2"; shift; + elif [ "$1" == "--dir" ]; then dir="$2"; dirGiven=yes; shift; + elif [ "$1" == "--fromIx" ]; then fromIx=$2; shift; + elif [ "$1" == "--toIx" ]; then toIx=$2; shift; + elif [ "$1" == "--ixList" ]; then ixList=$2; shift; + elif [ "$1" == "--skipList" ]; then skipList=$2; shift; + elif [ "$1" == "--no-duration" ]; then showDuration=off; + elif [ "$1" == "--noCache" ]; then noCache=ON; + elif [ "$1" == "--cache" ]; then noCache=OFF; + elif [ "$1" == "--noThreadpool" ]; then threadpool=OFF; + elif [ "$1" == "--xbroker" ]; then xbroker=ON; + else + if [ "$dirOrFile" == "" ] + then + dirOrFile="$1" + else + echo $0: bad parameter/option: "'"${1}"'"; + echo + usage 1 + fi + fi + shift +done + +vMsg "options parsed" + +# ----------------------------------------------------------------------------- +# +# The function brokerStart looks at the env var CB_NO_CACHE to decide +# whether to start the broker with the --noCache option or not +# +if [ "$noCache" != "" ] +then + export CB_NO_CACHE=$noCache +fi + +# ----------------------------------------------------------------------------- +# +# The function brokerStart looks at the env var CB_THREADPOOL to decide +# whether to start the broker with pool of threads or not. +# Do not overwrite if a value is passed from environment +# +if [ "$CB_THREADPOOL" == "" ] +then + export CB_THREADPOOL=$threadpool +fi + +# ----------------------------------------------------------------------------- +# +# Check if fromIx is set through an env var and use if nothing +# else is set through commandline parameter +# +if [ "$FT_FROM_IX" != "" ] && [ $fromIx == 0 ] +then + fromIx=$FT_FROM_IX +fi + +# ----------------------------------------------------------------------------- +# +# Check if toIx is set through an env var and use if nothing +# else is set through commandline parameter +# +if [ "$FT_TO_IX" != "" ] && [ $toIx == 0 ] +then + toIx=$FT_TO_IX +fi + +echo "Run tests $fromIx to $toIx" + +# ------------------------------------------------------------------------------ +# +# Check unmatching --dir and 'parameter that is a directory' AND +# unmatching --filter and 'parameter that is a file' +# +# 1. If it is a directory - just change the 'dir' variable and continue +# 2. Else, it must be a file, or a filter. +# If the +# +singleFile=No +if [ "$dirOrFile" != "" ] +then + vMsg dirOrFile: $dirOrFile + vMsg dirGiven: $dirGiven + vMsg filterGiven: $filterGiven + vMsg dir: $dir + vMsg testFilter: $testFilter + + if [ -d "$dirOrFile" ] + then + if [ "$dirGiven" == "yes" ] + then + echo "$0: both '--dir' option and directory parameter given - not allowed" + exit 1 + fi + dir="$dirOrFile" + else + if [ "$filterGiven" == "yes" ] + then + echo "$0: both '--filter' option and file parameter given - not allowed" + exit 1 + fi + + singleFile=Yes + # + # If just a filename is given, keep the directory as is. + # If a whole path is given, use the directory-part as directory and the file-part as filter + # + dirPart=$(dirname $dirOrFile) + filePath=$(basename $dirOrFile) + xdir=$(basename $dirPart); + vMsg "dirPart: $dirPart" + vMsg "filePath: $filePath" + + if [ "$dirPart" != "." ] + then + dir=$(dirname $dirOrFile) + testFilter=$(basename $dirOrFile) + + # Last dir + test file ? + if [ -d test/functionalTest/cases/$dirPart ] + then + dirOrFile=test/functionalTest/cases/$dirPart + fi + else + testFilter=$(basename $dirOrFile) + fi + fi +fi + +# +# The option of running against an external broker "--xbroker" only works (for now, at least) with a single test case. +# Strange things may happen (due to the state inside the broker) if more that one test case are launched. +# This check avoid this situation. +# +# If in the future we want to be able to run more than one test case against an external broker, we'd need to make sure +# that each test case undoes all internal state inside the external broker. E.g. delete subscriptions, entities, etc. +# +if [ "$singleFile" == "No" ] && [ "$xbroker" == "ON" ] +then + echo "External broker can only be used with individual test cases" + exit 1 +fi + +vMsg directory: $dir +vMsg testFilter: $testFilter +vMsg "Script in $SCRIPT_HOME" + + + +# ----------------------------------------------------------------------------- +# +# Other global variables +# +toBeStopped=false + + + +# ------------------------------------------------------------------------------ +# +# xbroker - if this CLI is set, then the broker is not to be started as part of +# the test suite - another broker is assumed to be running already +# +if [ "$xbroker" == "ON" ] +then + export CB_WITH_EXTERNAL_BROKER=ON +fi + + + +# ----------------------------------------------------------------------------- +# +# Init files already sourced? +# +if [ "$CONTEXTBROKER_TESTENV_SOURCED" != "YES" ] +then + if [ -f "$SCRIPT_HOME/testEnv.sh" ] + then + # First, we try with a testEnv.sh file in the script home + vMsg Sourcing $SCRIPT_HOME/testEnv.sh + source $SCRIPT_HOME/testEnv.sh + elif [ -f "$SCRIPT_HOME/../../scripts/testEnv.sh" ] + then + # Second, we try with a testEnv.sh file in the script/testEnv.sh (realtive to git repo home). + # Note that the script home in this case is test/functionalTest + vMsg Sourcing $SCRIPT_HOME/../../scripts/testEnv.sh + source $SCRIPT_HOME/../../scripts/testEnv.sh + else + echo "------------------------------------------------------------------" + echo "Please source testEnv.sh before running the functional test suite." + echo "------------------------------------------------------------------" + exit 1 + fi +fi + +if [ "$CONTEXTBROKER_HARNESS_FUNCTIONS_SOURCED" != "YES" ] +then + if [ -f $SCRIPT_HOME/harnessFunctions.sh ] + then + vMsg Sourcing $SCRIPT_HOME/harnessFunctions.sh + source $SCRIPT_HOME/harnessFunctions.sh + else + echo "--------------------------------------------------------------------------------------------" + echo "Please source $SCRIPT_HOME/harnessFunctions.sh before running the functional test suite." + echo "--------------------------------------------------------------------------------------------" + exit 1 + fi +fi + + + +# ------------------------------------------------------------------------------ +# +# Preparations - cd to the test directory +# +dMsg Functional Tests Starting ... + +if [ "$dirOrFile" != "" ] && [ -d "$dirOrFile" ] +then + cd $dirOrFile +elif [ ! -d "$dir" ] +then + exitFunction 1 "$dir is not a directory" "HARNESS" "$dir" "" DIE +else + cd $dir +fi + +echo "Orion Functional tests starting" > /tmp/orionFuncTestLog +date >> /tmp/orionFuncTestLog + + + +# ------------------------------------------------------------------------------ +# +# Preparations - number of test cases +# +vMsg find in $(pwd), filter: $testFilter +if [ "$match" == "" ] +then + fileList=$(find . -name "$testFilter" | sort | sed 's/^.\///') +else + fileList=$(find . -name "$testFilter" | grep "$match" | sort | sed 's/^.\///') +fi +vMsg "fileList: $fileList" +typeset -i noOfTests +typeset -i testNo + + + +# ------------------------------------------------------------------------------ +# +# Count total number of tests (for progressing info in messages) +# +for i in $fileList +do + noOfTests=$noOfTests+1 +done + + + +# ------------------------------------------------------------------------------ +# +# fileCleanup - +# +function fileCleanup() +{ + filename=$1 + keepOutputFiles=$2 + path=$3 + dir=$(dirname $path) + + vMsg "---------------------------------------------------------" + vMsg "In fileCleanup for $filename in $dir" + vMsg "---------------------------------------------------------" + + if [ "$keepOutputFiles" != "on" ] + then + olddir=$PWD + cd $dir + + rm $filename.name 2> /dev/null + rm $filename.shellInit 2> /dev/null + rm $filename.shellInit.* 2> /dev/null + rm $filename.shell 2> /dev/null + rm $filename.shell.* 2> /dev/null + rm $filename.teardown 2> /dev/null + rm $filename.teardown.* 2> /dev/null + rm $filename.valgrind.out 2> /dev/null + rm $filename.valgrind.stop.out 2> /dev/null + rm $filename.out 2> /dev/null + rm $filename.regexpect 2> /dev/null + rm $filename.out.sorted 2> /dev/null + rm $filename.regexpect.sorted 2> /dev/null + rm $filename.blockSortDiff.out 2> /dev/null + rm $filename.diff 2> /dev/null + + cd $olddir + fi +} + + + +# ------------------------------------------------------------------------------ +# +# fileCreation - create the files for test execution +# +function fileCreation() +{ + path=$1 + filename=$2 + ret=0 + + dirname=$(dirname $path) + filename=$(basename $path .test) + + if [ "$dirname" != "." ] && [ "$dirname" != "" ] + then + pathWithoutExt=$dirname/$filename + vMsg New path: $path + else + pathWithoutExt=$filename + fi + + vMsg Creating test files for $pathWithoutExt + + + # + # Extract the NAME + # + NAME=$(sed -n '/--NAME--/,/^--/p' $path | grep -v "^--") + if [ "$NAME" == "" ] + then + exitFunction 2 "--NAME-- part is missing" "$path" "($path)" "" DIE + exit 2 # Just in case + fi + + # + # Extract the shell init script + # + if [ $(grep "\-\-SHELL\-INIT\-\-" $path | wc -l) -eq 1 ] + then + TEST_SHELL_INIT=${pathWithoutExt}.shellInit + vMsg "Creating $TEST_SHELL_INIT at $PWD" + sed -n '/--SHELL-INIT--/,/^--/p' $path | grep -v "^--" > $TEST_SHELL_INIT + else + exitFunction 3 "--SHELL-INIT-- part is missing" $path "($path)" "" DIE + fi + + # + # Extract the test shell script + # + if [ $(grep "\-\-SHELL\-\-" $path | wc -l) -eq 1 ] + then + TEST_SHELL=${pathWithoutExt}.shell + vMsg "Creating $TEST_SHELL at $PWD" + sed -n '/--SHELL--/,/^--/p' $path | grep -v "^--" > $TEST_SHELL + else + exitFunction 4 "--SHELL-- part is missing" $path "($path)" "" DIE + fi + + # + # Extract the REGEXPECT part + # + if [ $(grep "\-\-REGEXPECT\-\-" $path | wc -l) -eq 1 ] + then + TEST_REGEXPECT=${pathWithoutExt}.regexpect + vMsg "Creating $TEST_REGEXPECT at $PWD" + sed -n '/--REGEXPECT--/,/^--/p' $path | grep -v "^--" | sed '/^##/d' > $TEST_REGEXPECT + else + exitFunction 5 "--REGEXPECT-- part is missing" $path "($path)" "" DIE + fi + + # + # Extract the teardown script + # + if [ $(grep "\-\-TEARDOWN\-\-" $path | wc -l) -eq 1 ] + then + TEST_TEARDOWN=${pathWithoutExt}.teardown + vMsg "Creating $TEST_TEARDOWN at $PWD" + sed -n '/--TEARDOWN--/,/^--/p' $path | grep -v "^--" > $TEST_TEARDOWN + else + exitFunction 6 "--TEARDOWN-- part is missing" $path "($path)" "" DIE + fi +} + + + +# ------------------------------------------------------------------------------ +# +# partExecute +# +function partExecute() +{ + what=$1 + path=$2 + forcedDie=$3 + __tryNo=$4 + + vMsg Executing $what part for $path + dirname=$(dirname $path) + filename=$(basename $path .test) + + if [ "$dirname" != "." ] && [ "$dirname" != "" ] + then + path=$dirname/$filename.test + fi + + # + # Prepare to execute + # + chmod 755 $dirname/$filename.$what + rm -f $dirname/$filename.$what.stderr + rm -f $dirname/$filename.$what.stdout + $dirname/$filename.$what > $dirname/$filename.$what.stdout 2> $dirname/$filename.$what.stderr + exitCode=$? + linesInStderr=$(wc -l $dirname/$filename.$what.stderr | awk '{ print $1}' 2> /dev/null) + + # + # Check that stdout is empty + # + if [ "$linesInStderr" != "" ] && [ "$linesInStderr" != "0" ] + then + if [ $__tryNo == $MAX_TRIES ] + then + exitFunction 7 "$what: output on stderr" $path "($path): $what produced output on stderr" $dirname/$filename.$what.stderr "$forcedDie" + else + echo -n "(ERROR 7 - $what: output on stderr) " + fi + + partExecuteResult=7 + return + fi + + + # + # Check that exit code is ZERO + # + if [ "$exitCode" != "0" ] + then + if [ $__tryNo == $MAX_TRIES ] + then + exitFunction 8 $path "$what exited with code $exitCode" "($path)" $dirname/$filename.$what.stderr "$forcedDie" + else + echo -n "(ERROR 8 - $what: exited with code $exitCode) " + fi + + partExecuteResult=8 + return + fi + + + # + # Compare produced output with expected output + # + if [ "$what" == "shell" ] + then + mv $dirname/$filename.$what.stdout $dirname/$filename.out # We are very much used to this name ... + sed -i 's/[[:space:]]*$//' $dirname/$filename.out # Remove trailing whitespace in .out (reduces diff noise) + + # + # Special sorted diff or normal REGEX diff ? + # + blockDiff='no' + grep '^#SORT_START$' $dirname/$filename.regexpect > /dev/null 2>&1 + if [ $? == 0 ] + then + $SCRIPT_HOME/blockSortDiff.sh --referenceFile $dirname/$filename.regexpect --brokerOutputFile $dirname/$filename.out > $dirname/$filename.blockSortDiff.out + exitCode=$? + blockDiff='yes' + else + PYTHONIOENCODING=utf8 $DIFF -r $dirname/$filename.regexpect -i $dirname/$filename.out > $dirname/$filename.diff + exitCode=$? + fi + + if [ "$exitCode" != "0" ] + then + if [ $__tryNo == $MAX_TRIES ] + then + exitFunction 9 ".out and .regexpect differ" $path "($path) output not as expected" $dirname/$filename.diff + else + echo -n "(ERROR 9 - .out and .regexpect differ) " + fi + + if [ "$CB_DIFF_TOOL" != "" ] && [ $__tryNo == $MAX_TRIES ] + then + endDate=$(date) + if [ $blockDiff == 'yes' ] + then + $CB_DIFF_TOOL $dirname/$filename.regexpect.sorted $dirname/$filename.out.sorted + else + $CB_DIFF_TOOL $dirname/$filename.regexpect $dirname/$filename.out + fi + fi + partExecuteResult=9 + return + fi + fi + + partExecuteResult=0 +} + + + +# ------------------------------------------------------------------------------ +# +# runTest - the function that runs ONE test case +# +# 1. Remove old output files +# 2.1. Create the various test files from '$path' +# 3.1. Run the SHELL-INIT part +# 3.2. If [ $? != 0 ] || [ STDERR != empty ] ERROR +# 4.1. Run the SHELL part +# 4.2. If [ $? != 0 ] || [ STDERR != empty ] ERROR +# 5.1. Run the TEARDOWN part +# 5.2. If [ $? != 0 ] || [ STDERR != empty ] ERROR +# 6.1. Compare output with regexpect (or expect) +# 6.2. Not EQUAL: ERROR +# 7. If [ "$keep" != "yes" ] Remove all output files +# +# +function runTest() +{ + path=$1 + _tryNo=$2 + + runTestStatus="ok" + + vMsg path=$path + dirname=$(dirname $path) + filename=$(basename $path .test) + dir="" + + if [ "$dirname" != "." ] && [ "$dirname" != "" ] + then + path=$dirname/$filename.test + vMsg New path: $path + fi + + vMsg running test $path + + # 1. Remove old output files + fileCleanup $filename removeAll $path + if [ "$toBeStopped" == "yes" ] + then + echo toBeStopped == yes + runTestStatus="stopped" + return + fi + + # 2. Create the various test files from '$path' + fileCreation $path $filename + if [ "$toBeStopped" == "yes" ] + then + runTestStatus="stopped2" + return + fi + + # 3. Run the SHELL-INIT part + vMsg Executing SHELL-INIT part for $path + chmod 755 $dirname/$filename.shellInit + rm -f $dirname/$filename.shellInit.stderr + rm -f $dirname/$filename.shellInit.stdout + $dirname/$filename.shellInit > $dirname/$filename.shellInit.stdout 2> $dirname/$filename.shellInit.stderr + exitCode=$? + linesInStderr=$(wc -l $dirname/$filename.shellInit.stderr | awk '{ print $1}' 2> /dev/null) + + if [ "$linesInStderr" != "" ] && [ "$linesInStderr" != "0" ] + then + exitFunction 10 "SHELL-INIT produced output on stderr" $path "($path)" $dirname/$filename.shellInit.stderr + runTestStatus="shell-init-error" + return + fi + + if [ "$exitCode" != "0" ] + then + + # + # 3.2 Run the SHELL-INIT part AGAIN + # + # This 're-run' of the SHELL-INIT part is due to errors we've seen that seem to be caused by + # a try to start a broker while the old one (from the previous functest) is still running. + # No way to test this, except with some patience. + # + # We have seen 'ERROR 11' around once every 500-1000 functests (the suite is of almost 400 tests) + # and this fix, if working, will make us not see those 'ERROR 11' again. + # If we keep seeing 'ERROR 11' after this change then we will need to investigate further. + # + sleep 1 + rm -f $dirname/$filename.shellInit.stderr + rm -f $dirname/$filename.shellInit.stdout + $dirname/$filename.shellInit > $dirname/$filename.shellInit.stdout 2> $dirname/$filename.shellInit.stderr + exitCode=$? + linesInStderr=$(wc -l $dirname/$filename.shellInit.stderr | awk '{ print $1}' 2> /dev/null) + + if [ "$linesInStderr" != "" ] && [ "$linesInStderr" != "0" ] + then + exitFunction 20 "SHELL-INIT II produced output on stderr" $path "($path)" $dirname/$filename.shellInit.stderr + runTestStatus="shell-init-output-on-stderr" + return + fi + + if [ "$exitCode" != "0" ] + then + exitFunction 11 "SHELL-INIT exited with code $exitCode" $path "($path)" "" DIE + runTestStatus="shell-init-exited-with-"$exitCode + return + fi + fi + + # 4. Run the SHELL part (which also compares - FIXME P2: comparison should be moved to separate function) + partExecute shell $path "DontDie - only for SHELL-INIT" $_tryNo + shellResult=$partExecuteResult + if [ "$toBeStopped" == "yes" ] + then + runTestStatus="shell-failed" + return + fi + + # 5. Run the TEARDOWN part + partExecute teardown $path "DIE" 0 + teardownResult=$partExecuteResult + vMsg "teardownResult: $teardownResult" + vMsg "shellResult: $shellResult" + + if [ "$shellResult" == "0" ] && [ "$teardownResult" == "0" ] + then + # 6. Remove output files + vMsg "Remove output files: fileCleanup $filename $keep" + fileCleanup $filename $keep $path + else + file=$(basename $path .test) + cp /tmp/contextBroker.log $file.contextBroker.log + runTestStatus="test-failed" + fi +} + + + +# ----------------------------------------------------------------------------- +# +# testDisabled +# +function testDisabled +{ + testcase=$1 + typeset -i dIx + dIx=0 + while [ $dIx -lt ${#DISABLED[@]} ] + do + # Comparison is done based in filename, skipping the path (see https://stackdiary.com/tutorials/bash-get-filename-from-path/) + if [ "${testcase##*/}" == "${DISABLED[$dIx]##*/}" ] + then + echo "Disabled" + + # + # NOTE: In a non-disabled test, running inside the valgrind test suite, the function 'localBrokerStart()' (from harnessFunctions.sh) + # redirects the output of "valgrind contextBroker" to the file /tmp/valgrind.out. + # Later, the valgrind test suite uses the existence of this file (/tmp/valgrind.out) to detect errors in the valgrind execution. + # But, in the case of a disabled func test, we will not start the test case. and thus we will not reach 'localBrokerStart()', so the + # file will not be created and an error will be flagged by the valgrind test suite. + # The simplest solution is to simply create the file here, in the case of a disabled test. + # + echo "Disabled" > /tmp/valgrind.out + return + fi + dIx=$dIx+1 + done + echo NOT Disabled +} + + + +# ----------------------------------------------------------------------------- +# +# testMatchExprFlavour +# +function testMatchExprFlavour +{ + testcase=$1 + + if grep -q JEXL_EXPR_FLAVOUR $testcase + then + if $(contextBroker --version | grep -q jexl-expr) + then + echo NOT Disabled + else + echo "Disabled" + echo "Disabled" > /tmp/valgrind.out + fi + else + echo NOT Disabled + fi +} + + + +# ------------------------------------------------------------------------------ +# +# Main loop +# +vMsg Total number of tests: $noOfTests +testNo=0 +for testFile in $fileList +do + if [ -d "$testFile" ] + then + continue + fi + + testNo=$testNo+1 + + if [ $fromIx != 0 ] && [ $testNo -lt $fromIx ] + then + continue; + fi + + if [ $toIx != 0 ] && [ $testNo -gt $toIx ] + then + continue; + fi + + # + # Disabled test? + # + disabled=$(testDisabled $testFile) + if [ "$disabled" == "Disabled" ] + then + disabledTestV[$disabledTests]=$testNo': '$testFile + disabledTests=$disabledTests+1 + continue + fi + + # + # Should the test be skipped due to it doesn't mach in the contextBroker flavour? + # + notInFlavour=$(testMatchExprFlavour $testFile) + if [ "$notInFlavour" == "Disabled" ] + then + notInFlavourTestV[$notInFlavourTests]=$testNo': '$testFile + notInFlavourTests=$notInFlavourTests+1 + continue + fi + + if [ "$ixList" != "" ] + then + hit=$(echo ' '$ixList' ' | grep ' '$testNo' ') + if [ "$hit" == "" ] + then + # Test case not found in ix-list, so it is not executed + continue + fi + fi + + if [ "$CB_SKIP_FUNC_TESTS" != "" ] + then + hit=$(echo ' '$CB_SKIP_FUNC_TESTS' ' | grep ' '$testFile' ') + if [ "$hit" != "" ] + then + # Test case found in skip-list, so it is skipped + skipV[$skips]=$testNo': '$testFile + skips=$skips+1 + continue + fi + fi + + if [ "$skipList" != "" ] + then + hit=$(echo ' '$skipList' ' | grep ' '$testNo' ') + if [ "$hit" != "" ] + then + # Test case found in skip-list, so it is skipped + skipV[$skips]=$testNo': '$testFile + skips=$skips+1 + continue + fi + fi + + startDate=$(date) + start=$(date --date="$startDate" +%s) + endDate="" + typeset -i tryNo + tryNo=1 + + if [ "$dryrun" == "off" ] + then + while [ $tryNo -le $MAX_TRIES ] + do + if [ "$verbose" == "off" ] + then + tryNoInfo="" + if [ $tryNo != "1" ] + then + tryNoInfo="(intent $tryNo)" + fi + + init=$testFile" ................................................................................................................." + init=${init:0:110} + printf "%04d/%d: %s %s " "$testNo" "$noOfTests" "$init" "$tryNoInfo" + else + printf "Running test %04d/%d: %s\n" "$testNo" "$noOfTests" "$testFile" + fi + + runTest $testFile $tryNo + if [ "$shellResult" == "0" ] + then + if [ $tryNo != 1 ] + then + if [ $tryNo == 2 ] + then + okOnSecondV[$okOnSecond]=$testFile + okOnSecond=$okOnSecond+1 + elif [ $tryNo == 3 ] + then + okOnThirdV[$okOnThird]=$testFile + okOnThird=$okOnThird+1 + else + okOnPlus3V[$okOnPlus3]=$testFile + okOnPlus3=$okOnPlus3+1 + fi + echo "OK" + fi + break + else + tryNo=$tryNo+1 + echo + fi + done + else + if [ "$verbose" == "off" ] + then + init=$testFile" ................................................................................................................." + init=${init:0:110} + printf "%04d/%d: %s " "$testNo" "$noOfTests" "$init" + else + printf "Running test %04d/%d: %s\n" "$testNo" "$noOfTests" "$testFile" + fi + fi + + if [ "$endDate" == "" ] # Could have been set in 'partExecute' + then + endDate=$(date) + fi + + end=$(date --date="$endDate" +%s) + typeset -i secs + secs=$end-$start + if [ "$showDuration" == "on" ] + then + if [ $secs -lt 10 ] + then + xsecs=0$secs + else + xsecs=$secs + fi + echo $xsecs seconds + else + echo "SUCCESS" + fi +done + + +testEndTime=$(date +%s.%2N) +testDiffTime=$(echo $testEndTime - $testStartTime | bc)" seconds" +echo Total test time: $testDiffTime + + +typeset -i ix +exitCode=0 +# ------------------------------------------------------------------------------ +# +# Check for errors - if any, print to stdout +# +if [ "$testError" != "0" ] +then + echo + echo "Orion Functional Test Log File:" + echo "================================================================================" + cat /tmp/orionFuncTestLog 2> /dev/null + echo "================================================================================" + echo + echo "----------- Failing tests ------------------" + + ix=0 + while [ $ix -lt $testError ] + do + echo " o " ${testErrorV[$ix]} + ix=$ix+1 + done + exitCode=1 +fi + + + +# ------------------------------------------------------------------------------ +# +# Check for reintents +# +if [ "$okOnSecond" != "0" ] +then + echo + echo "$okOnSecond test cases OK in the second attempt:" + + ix=0 + while [ $ix -lt $okOnSecond ] + do + echo " o " ${okOnSecondV[$ix]} + ix=$ix+1 + done +fi + +if [ "$okOnThird" != "0" ] +then + echo + echo "$okOnThird test cases OK in the third attempt:" + + ix=0 + while [ $ix -lt $okOnThird ] + do + echo " o " ${okOnThirdV[$ix]} + ix=$ix+1 + done +fi + +if [ "$okOnPlus3" != "0" ] +then + echo + echo "$okOnPlus3 test cases OK after three or more failed attempts:" + + ix=0 + while [ $ix -lt $okOnPlus3 ] + do + echo " o " ${okOnPlus3V[$ix]} + ix=$ix+1 + done +fi + +if [ $skips != 0 ] +then + echo + echo WARNING: $skips test cases skipped: + ix=0 + while [ $ix -lt $skips ] + do + echo " o " ${skipV[$ix]} + ix=$ix+1 + done +fi + +if [ $disabledTests != 0 ] +then + echo + echo WARNING: $disabledTests test cases disabled: + ix=0 + while [ $ix -lt $disabledTests ] + do + echo " o " ${disabledTestV[$ix]} + ix=$ix+1 + done +fi + +if [ $notInFlavourTests != 0 ] +then + echo + echo WARNING: $notInFlavourTests test cases were not executed due to contexBroker not matching flavour: + ix=0 + while [ $ix -lt $notInFlavourTests ] + do + echo " o " ${notInFlavourTestV[$ix]} + ix=$ix+1 + done +fi + +exit $exitCode From 945d2ee8da668fb68c03f516267efd8f27d762f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 4 Jun 2024 19:52:06 +0200 Subject: [PATCH 4/4] FIX ftest --- .../log_deprecate_warning.test | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test index a340c8cd99..0d75384406 100644 --- a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test +++ b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test @@ -331,14 +331,10 @@ Deprecated usage of geo:point detected in attribute location at entity update, p Deprecated usage of legacyForwarding mode in registration creation (regId: REG_ID) Deprecated usage of legacyForwarding mode detected in existing registration (regId: REG_ID) Deprecated usage of legacyForwarding mode in query forwarding operation (regId: REG_ID) -Notification (regId: REG_ID) response NOT OK, http code: 400 -Raising alarm BadInput 127.0.0.1: JSON Parse Error: unknown field: /error -Raising alarm ForwardingError localhost:9801/v2/queryContext: error parsing reply from prov app: {"error":"BadRequest","description":"JSON Parse Error: unknown field: /error"} -Releasing alarm BadInput 127.0.0.1 +Raising alarm ForwardingError localhost:9801/v2/queryContext: forwarding failure for sender-thread: Couldn't connect to server Deprecated usage of legacyForwarding mode in update forwarding operation (regId: REG_ID) -Notification (regId: REG_ID) response NOT OK, http code: 400 -Raising alarm BadInput 127.0.0.1: JSON Parse Error: unknown field: /error -Raising alarm ForwardingError localhost:9801/v2/updateContext: error parsing reply from prov app: {"error":"BadRequest","description":"JSON Parse Error: unknown field: /error"} +Raising alarm ForwardingError localhost:9801/v2/updateContext: forwarding failure for sender-thread: Couldn't connect to server +Raising alarm BadInput 127.0.0.1: The requested entity has not been found. Check type and id 10. Get statistics and see deprecatedFeatures counters