From 82941cc6b6868a452ff8cc674260936d5a0b2a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 29 Feb 2024 12:24:30 +0100 Subject: [PATCH 01/12] REMOVE deprecated db related CLIs --- CHANGES_NEXT_RELEASE | 1 + doc/manuals/deprecated.md | 4 +- src/app/contextBroker/contextBroker.cpp | 24 +---- src/lib/mongoBackend/MongoGlobal.cpp | 16 ---- src/lib/mongoBackend/MongoGlobal.h | 8 -- src/lib/mongoDriver/mongoConnectionPool.cpp | 100 ++------------------ src/lib/mongoDriver/mongoConnectionPool.h | 8 -- test/unittests/main_UnitTest.cpp | 18 +--- 8 files changed, 16 insertions(+), 163 deletions(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index e69de29bb2..59f9251202 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -0,0 +1 @@ +- Remove: `-dbhost`, `-rplSet`, `-dbTimeout`, `-dbuser`, `-dbAuthMech`, `-dbAuthDb`, `-dbSSL` and `-dbDisableRetryWrites` CLI parameters along with associated env vars, already deprecated in Orion 3.12.0 (use `-dbURI` instead`) \ No newline at end of file diff --git a/doc/manuals/deprecated.md b/doc/manuals/deprecated.md index 9b289331b4..5ed729988b 100644 --- a/doc/manuals/deprecated.md +++ b/doc/manuals/deprecated.md @@ -17,7 +17,7 @@ A list of deprecated features and the version in which they were deprecated foll * CLI parameters (and associated env vars): `-dbhost`, `-rplSet`, `-dbTimeout`, `-dbuser`, `-dbAuthMech`, `-dbAuthDb`, `-dbSSL` and `-dbDisableRetryWrites` in Orion 3.12.0. Use `dbURI` instead, - checking [this section](#mapping-to-mongouri-from-old-cli-parameters) if you need to know hot to build the MongoDB URI. + checking [this section](#mapping-to-mongouri-from-old-cli-parameters) if you need to know hot to build the MongoDB URI (removed in Orion 3.13.0). * `geo:point`, `geo:line`, `geo:box` and `geo:polygon` attribute types in Orion 3.10.0. Use `geo:json` instead. * `GET /v2` operation in Orion 3.8.0. This operation is pretty useless and not actually used. * Initial notification in subscriptions (along with `skipInitialNotification` option) in Orion 3.1.0. @@ -134,12 +134,12 @@ The following table provides information about the last Orion version supporting | **Removed feature** | **Last Orion version supporting feature** | **That version release date** | |----------------------------------------------------------------------------|-------------------------------------------|---------------------------------| -| CLI `-dbhost`, `-rplSet`, `-dbTimeout`, `-dbuser`, `-dbAuthMech`, `-dbAuthDb`, `-dbSSL` and `-dbDisableRetryWrites` (and associated env vars) | Not yet defined | Not yet defined | | `attributes` field in `POST /v2/entities` operation | Not yet defined | Not yet defined | | `APPEND`, `UPDATE`, etc. action types in `POST /v2/op/update` | Not yet defined | Not yet defined | | `dateCreated` and `dateModified` in `options` URI parameter | Not yet defined | Not yet defined | | `GET /v2` operation | Not yet defined | Not yet defined | | `geo:point`, `geo:line`, `geo:box` and `geo:polygon` attribute types | Not yet defined | Not yet defined | +| CLI `-dbhost`, `-rplSet`, `-dbTimeout`, `-dbuser`, `-dbAuthMech`, `-dbAuthDb`, `-dbSSL` and `-dbDisableRetryWrites` (and associated env vars) | 3.12.0 | February 29th, 2024 | | `location` metadata to specify entity location | 3.10.1 | June 12th, 2023 | | NGSIv1 API (along with CLI: `-strictNgsiv1Ids` and `-ngsiv1Autocast`) | 3.9.0 (*) | June 2nd, 2023 | | `/ngsi10` and `/ngsi9` URL prefixes | 3.7.0 (*) | May 26th, 2022 | diff --git a/src/app/contextBroker/contextBroker.cpp b/src/app/contextBroker/contextBroker.cpp index d1cc8a57b2..b8ede361f5 100644 --- a/src/app/contextBroker/contextBroker.cpp +++ b/src/app/contextBroker/contextBroker.cpp @@ -139,15 +139,8 @@ static bool isFatherProcess = false; bool fg; char bindAddress[MAX_LEN_IP]; int port; -char dbHost[256]; -char rplSet[64]; char dbName[64]; -char user[256]; char pwd[256]; -char authMech[64]; -char authDb[64]; -bool dbSSL; -bool dbDisableRetryWrites; char dbURI[1024]; char pidPath[256]; bool harakiri; @@ -159,7 +152,6 @@ bool https; bool mtenant; char allowedOrigin[64]; int maxAge; -long dbTimeout; long httpTimeout; long mqttTimeout; int dbPoolSize; @@ -298,18 +290,9 @@ PaArgument paArgs[] = { "-pidpath", pidPath, "PID_PATH", PaString, PaOpt, PIDPATH, PaNL, PaNL, PIDPATH_DESC }, { "-dbURI", dbURI, "MONGO_URI", PaString, PaOpt, _i "", PaNL, PaNL, DBURI_DESC }, - { "-dbhost", dbHost, "MONGO_HOST", PaString, PaOpt, LOCALHOST, PaNL, PaNL, DBHOST_DESC }, - { "-rplSet", rplSet, "MONGO_REPLICA_SET", PaString, PaOpt, _i "", PaNL, PaNL, RPLSET_DESC }, - { "-dbuser", user, "MONGO_USER", PaString, PaOpt, _i "", PaNL, PaNL, DBUSER_DESC }, { "-dbpwd", pwd, "MONGO_PASSWORD", PaString, PaOpt, _i "", PaNL, PaNL, DBPASSWORD_DESC }, - { "-dbAuthMech", authMech, "MONGO_AUTH_MECH", PaString, PaOpt, _i "", PaNL, PaNL, DBAUTHMECH_DESC }, - { "-dbAuthDb", authDb, "MONGO_AUTH_SOURCE", PaString, PaOpt, _i "", PaNL, PaNL, DBAUTHDB_DESC }, - { "-dbSSL", &dbSSL, "MONGO_SSL", PaBool, PaOpt, false, false, true, DBSSL_DESC }, - { "-dbDisableRetryWrites", &dbDisableRetryWrites, "MONGO_DISABLE_RETRY_WRITES", PaBool, PaOpt, false, false, true, DBDISABLERETRYWRITES_DESC }, - { "-db", dbName, "MONGO_DB", PaString, PaOpt, _i "orion", PaNL, PaNL, DB_DESC }, - { "-dbTimeout", &dbTimeout, "MONGO_TIMEOUT", PaULong, PaOpt, 0, 0, UINT_MAX, DB_TMO_DESC }, { "-dbPoolSize", &dbPoolSize, "MONGO_POOL_SIZE", PaInt, PaOpt, 10, 1, 10000, DBPS_DESC }, { "-ipv4", &useOnlyIPv4, "USEIPV4", PaBool, PaOpt, false, false, true, USEIPV4_DESC }, @@ -1133,11 +1116,6 @@ int main(int argC, char* argV[]) LM_X(1, ("dbName too long (max %d characters)", DB_NAME_MAX_LEN)); } - if ((strlen(authMech) > 0) && (strncmp(authMech, "SCRAM-SHA-1", strlen("SCRAM-SHA-1")) != 0) && (strncmp(authMech, "SCRAM-SHA-256", strlen("SCRAM-SHA-256")) != 0)) - { - LM_X(1, ("Fatal Error (-dbAuthMech must be either SCRAM-SHA-1 or SCRAM-SHA-256")); - } - if (useOnlyIPv6 && useOnlyIPv4) { LM_X(1, ("Fatal Error (-ipv4 and -ipv6 can not be activated at the same time. They are incompatible)")); @@ -1220,7 +1198,7 @@ int main(int argC, char* argV[]) alarmMgr.init(relogAlarms); mqttMgr.init(mqttTimeout); orionInit(orionExit, ORION_VERSION, policy, statCounters, statSemWait, statTiming, statNotifQueue, strictIdv1); - mongoInit(dbURI, dbHost, rplSet, dbName, user, pwd, authMech, authDb, dbSSL, dbDisableRetryWrites, mtenant, dbTimeout, writeConcern, dbPoolSize, statSemWait); + mongoInit(dbURI, dbName, pwd, mtenant, writeConcern, dbPoolSize, statSemWait); metricsMgr.init(!disableMetrics, statSemWait); logSummaryInit(&lsPeriod); diff --git a/src/lib/mongoBackend/MongoGlobal.cpp b/src/lib/mongoBackend/MongoGlobal.cpp index 85308f228b..ed1c979ca5 100644 --- a/src/lib/mongoBackend/MongoGlobal.cpp +++ b/src/lib/mongoBackend/MongoGlobal.cpp @@ -105,17 +105,9 @@ bool mongoMultitenant(void) void mongoInit ( const char* dbURI, - const char* dbHost, - const char* rplSet, std::string dbName, - const char* user, const char* pwd, - const char* mechanism, - const char* authDb, - bool dbSSL, - bool dbDisableRetryWrites, bool mtenant, - int64_t timeout, int writeConcern, int dbPoolSize, bool mutexTimeStat @@ -125,17 +117,9 @@ void mongoInit multitenant = mtenant; if (orion::mongoConnectionPoolInit(dbURI, - dbHost, dbName.c_str(), - rplSet, - user, pwd, - mechanism, - authDb, - dbSSL, - dbDisableRetryWrites, mtenant, - timeout, writeConcern, dbPoolSize, mutexTimeStat) != 0) diff --git a/src/lib/mongoBackend/MongoGlobal.h b/src/lib/mongoBackend/MongoGlobal.h index caa6058e8f..7b951c0784 100644 --- a/src/lib/mongoBackend/MongoGlobal.h +++ b/src/lib/mongoBackend/MongoGlobal.h @@ -72,17 +72,9 @@ extern bool mongoMultitenant(void); void mongoInit ( const char* dbURI, - const char* dbHost, - const char* rplSet, std::string dbName, - const char* user, const char* pwd, - const char* mechanism, - const char* authDb, - bool dbSSL, - bool dbDisableRetryWrites, bool mtenant, - int64_t timeout, int writeConcern, int dbPoolSize, bool mutexTimeStat diff --git a/src/lib/mongoDriver/mongoConnectionPool.cpp b/src/lib/mongoDriver/mongoConnectionPool.cpp index 855896753e..bcde607889 100644 --- a/src/lib/mongoDriver/mongoConnectionPool.cpp +++ b/src/lib/mongoDriver/mongoConnectionPool.cpp @@ -312,100 +312,28 @@ static void mongoDriverLogger /* **************************************************************************** * -* mongoConnectionPoolInit - +* composeMongoUri - */ -static std::string composeMongoUri -( - const char* dbURI, - const char* host, - const char* rplSet, - const char* username, - const char* passwd, - const char* mechanism, - const char* authDb, - bool dbSSL, - bool dbDisableRetryWrites, - int64_t timeout -) +static std::string composeMongoUri(const char* dbURI, const char* passwd) { // Compose the mongoUri, taking into account all information std::string uri; - if (strlen(dbURI) != 0) + const char* pwd = strstr(dbURI, "${PWD}"); + if (pwd != NULL) { - if (strlen(username) != 0 || strlen(authDb) != 0 || strlen(rplSet) != 0 || strlen(mechanism) != 0 || dbSSL || dbDisableRetryWrites || timeout > 0) + if (strlen(passwd) == 0) { - LM_X(1, ("Invalid Command Line Options: -dbURI cannot be combined with -dbhost, -rplSet, -dbTimeout, -dbuser, -dbAuthMech, -dbAuthDb, -dbSSL and -dbDisableRetryWrites")); + LM_X(1, ("Invalid Command Line Options: -dbURI is used with a password substitution, but no password (-dbpwd) is supplied")); } - const char* pwd = strstr(dbURI, "${PWD}"); - if (pwd != NULL) - { - if (strlen(passwd) == 0) - { - LM_X(1, ("Invalid Command Line Options: -dbURI is used with a password substitution, but no password (-dbpwd) is supplied")); - } - - // +6 is the length of the "${PWD}" - uri = std::string(dbURI, pwd - dbURI) + passwd + (pwd + 6); - } - else - { - uri = dbURI; - } + // +6 is the length of the "${PWD}" + uri = std::string(dbURI, pwd - dbURI) + passwd + (pwd + 6); } else { - uri = "mongodb://"; - - // Add auth parameter if included - if (strlen(username) != 0 && strlen(passwd) != 0) - { - uri += username + std::string(":") + passwd + "@"; - } - - uri += host + std::string("/"); - - if (strlen(authDb) != 0) - { - uri += authDb; - } - - // First option prefix is '?' symbol - std::string optionPrefix = "?"; - - if (strlen(rplSet) != 0) - { - uri += optionPrefix + "replicaSet=" + rplSet; - optionPrefix = "&"; - } - - if (strlen(mechanism) != 0) - { - uri += optionPrefix + "authMechanism=" + mechanism; - optionPrefix = "&"; - } - - if (dbSSL) - { - uri += optionPrefix + "tls=true&tlsAllowInvalidCertificates=true"; - optionPrefix = "&"; - } - - if (dbDisableRetryWrites) - { - uri += optionPrefix + "retryWrites=false"; - optionPrefix = "&"; - } - - if (timeout > 0) - { - char buf[STRING_SIZE_FOR_LONG]; - i2s(timeout, buf, sizeof(buf)); - uri += optionPrefix + "connectTimeoutMS=" + buf; - optionPrefix = "&"; - } + uri = dbURI; } LM_T(LmtMongo, ("MongoDB connection URI: '%s'", offuscatePassword(uri, passwd).c_str())); @@ -422,17 +350,9 @@ static std::string composeMongoUri int orion::mongoConnectionPoolInit ( const char* dbURI, - const char* host, const char* db, - const char* rplSet, - const char* username, const char* passwd, - const char* mechanism, - const char* authDb, - bool dbSSL, - bool dbDisableRetryWrites, bool mtenant, - int64_t timeout, int writeConcern, int poolSize, bool semTimeStat @@ -451,7 +371,7 @@ int orion::mongoConnectionPoolInit atexit(shutdownClient); // Set mongo Uri to connect - std::string uri = composeMongoUri(dbURI, host, rplSet, username, passwd, mechanism, authDb, dbSSL, dbDisableRetryWrites, timeout); + std::string uri = composeMongoUri(dbURI, passwd); #ifdef UNIT_TEST /* Basically, we are mocking all the DB pool with a single connection. The getMongoConnection() and mongoReleaseConnection() methods diff --git a/src/lib/mongoDriver/mongoConnectionPool.h b/src/lib/mongoDriver/mongoConnectionPool.h index 0dddc183ae..e5991eb55b 100644 --- a/src/lib/mongoDriver/mongoConnectionPool.h +++ b/src/lib/mongoDriver/mongoConnectionPool.h @@ -47,17 +47,9 @@ extern void mongoVersionGet(int* mayor, int* minor); extern int mongoConnectionPoolInit ( const char* dbURI, - const char* host, const char* db, - const char* rplSet, - const char* username, const char* passwd, - const char* mechanism, - const char* authDb, - bool dbSSL, - bool dbDisableRetryWrites, bool mtenant, - int64_t timeout, int writeConcern = 1, int poolSize = 10, bool semTimeStat = false diff --git a/test/unittests/main_UnitTest.cpp b/test/unittests/main_UnitTest.cpp index 3b7718b0c1..8e1b5c1d8f 100644 --- a/test/unittests/main_UnitTest.cpp +++ b/test/unittests/main_UnitTest.cpp @@ -81,15 +81,8 @@ unsigned long logLineMaxSize = 32 * 1024; bool logDeprecate = false; char dbURI[1024]; -char dbHost[256]; -char rplSet[64]; char dbName[64]; -char user[64]; char pwd[64]; -char authMech[64]; -char authDb[64]; -bool dbSSL; -int64_t dbTimeout; int dbPoolSize; int writeConcern; char gtest_filter[1024]; @@ -109,15 +102,8 @@ unsigned long fcMaxInterval = 0; PaArgument paArgs[] = { { "-dbURI", dbURI, "DB_URI", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" }, - { "-dbhost", dbHost, "DB_HOST", PaString, PaOpt, (int64_t) "localhost", PaNL, PaNL, "" }, - { "-rplSet", rplSet, "RPL_SET", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" }, - { "-dbuser", user, "DB_USER", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" }, { "-dbpwd", pwd, "DB_PASSWORD", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" }, - { "-dbAuthMech", authMech, "DB_AUTH_MECH", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" }, - { "-dbAuthDb", authDb, "DB_AUTH_DB", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" }, - { "-dbSSL", &dbSSL, "DB_AUTH_SSL", PaBool, PaOpt, false, false, true, "" }, { "-db", dbName, "DB", PaString, PaOpt, (int64_t) "orion", PaNL, PaNL, "" }, - { "-dbTimeout", &dbTimeout, "DB_TIMEOUT", PaInt64, PaOpt, 0, PaNL, PaNL, "" }, { "-dbPoolSize", &dbPoolSize, "DB_POOL_SIZE", PaInt, PaOpt, 10, 1, 10000, "" }, { "-writeConcern", &writeConcern, "WRITE_CONCERN", PaInt, PaOpt, 1, 0, 1, "" }, { "--gtest_filter=", gtest_filter, "", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" }, @@ -159,8 +145,8 @@ int main(int argC, char** argV) LM_M(("Init tests")); orionInit(exitFunction, orionUnitTestVersion, SemReadWriteOp, false, false, false, false, false); - // Note that disableRetryTries, multitenancy and mutex time stats are disabled for unit test mongo init - mongoInit(dbURI, dbHost, rplSet, dbName, user, pwd, authMech, authDb, dbSSL, false, false, dbTimeout, writeConcern, dbPoolSize, false); + // Note that multitenancy and mutex time stats are disabled for unit test mongo init + mongoInit(dbURI, dbName, pwd, false, writeConcern, dbPoolSize, false); alarmMgr.init(false); logSummaryInit(&lsPeriod); // setupDatabase(); FIXME #3775: pending on mongo unit test re-enabling From 9558ac9487913e2dde2b43fa0a3bd73b4aa6d83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Fri, 1 Mar 2024 09:50:55 +0100 Subject: [PATCH 02/12] FIX ftest --- .../cases/0000_cli/bool_option_with_value.test | 8 -------- .../cases/0000_cli/command_line_options.test | 8 -------- .../0000_cli/tracelevel_without_logLevel_as_DEBUG.test | 8 -------- test/functionalTest/cases/3658_env_vars/env_vars.test | 8 -------- 4 files changed, 32 deletions(-) diff --git a/test/functionalTest/cases/0000_cli/bool_option_with_value.test b/test/functionalTest/cases/0000_cli/bool_option_with_value.test index 157a33b97a..111fb8dde8 100644 --- a/test/functionalTest/cases/0000_cli/bool_option_with_value.test +++ b/test/functionalTest/cases/0000_cli/bool_option_with_value.test @@ -51,16 +51,8 @@ Usage: contextBroker [option '-U' (extended usage)] [option '-port' ] [option '-pidpath' ] [option '-dbURI' ] - [option '-dbhost' ] - [option '-rplSet' ] - [option '-dbuser' ] [option '-dbpwd' ] - [option '-dbAuthMech' ] - [option '-dbAuthDb' ] - [option '-dbSSL' (enable SSL connection to DB)] - [option '-dbDisableRetryWrites' (set retryWrite parameter to false in DB connections)] [option '-db' ] - [option '-dbTimeout' ] [option '-dbPoolSize' ] [option '-ipv4' (use ip v4 only)] [option '-ipv6' (use ip v6 only)] diff --git a/test/functionalTest/cases/0000_cli/command_line_options.test b/test/functionalTest/cases/0000_cli/command_line_options.test index 20a639175b..f97b786889 100644 --- a/test/functionalTest/cases/0000_cli/command_line_options.test +++ b/test/functionalTest/cases/0000_cli/command_line_options.test @@ -40,16 +40,8 @@ Usage: contextBroker [option '-U' (extended usage)] [option '-port' ] [option '-pidpath' ] [option '-dbURI' ] - [option '-dbhost' ] - [option '-rplSet' ] - [option '-dbuser' ] [option '-dbpwd' ] - [option '-dbAuthMech' ] - [option '-dbAuthDb' ] - [option '-dbSSL' (enable SSL connection to DB)] - [option '-dbDisableRetryWrites' (set retryWrite parameter to false in DB connections)] [option '-db' ] - [option '-dbTimeout' ] [option '-dbPoolSize' ] [option '-ipv4' (use ip v4 only)] [option '-ipv6' (use ip v6 only)] diff --git a/test/functionalTest/cases/0000_cli/tracelevel_without_logLevel_as_DEBUG.test b/test/functionalTest/cases/0000_cli/tracelevel_without_logLevel_as_DEBUG.test index cf566803ce..8c92e4fffc 100644 --- a/test/functionalTest/cases/0000_cli/tracelevel_without_logLevel_as_DEBUG.test +++ b/test/functionalTest/cases/0000_cli/tracelevel_without_logLevel_as_DEBUG.test @@ -41,16 +41,8 @@ Usage: contextBroker [option '-U' (extended usage)] [option '-port' ] [option '-pidpath' ] [option '-dbURI' ] - [option '-dbhost' ] - [option '-rplSet' ] - [option '-dbuser' ] [option '-dbpwd' ] - [option '-dbAuthMech' ] - [option '-dbAuthDb' ] - [option '-dbSSL' (enable SSL connection to DB)] - [option '-dbDisableRetryWrites' (set retryWrite parameter to false in DB connections)] [option '-db' ] - [option '-dbTimeout' ] [option '-dbPoolSize' ] [option '-ipv4' (use ip v4 only)] [option '-ipv6' (use ip v6 only)] diff --git a/test/functionalTest/cases/3658_env_vars/env_vars.test b/test/functionalTest/cases/3658_env_vars/env_vars.test index 2ede8f83af..4c8d70bc64 100644 --- a/test/functionalTest/cases/3658_env_vars/env_vars.test +++ b/test/functionalTest/cases/3658_env_vars/env_vars.test @@ -86,16 +86,8 @@ Extended Usage: contextBroker [option '-U' (extended usage)] [option '-port' ] ORION_PORT 1 <= 1026 /1026/ <= 65535 [option '-pidpath' ] ORION_PID_PATH '/tmp/contextBroker.pid' /'/tmp/contextBroker/ [option '-dbURI' ] ORION_MONGO_URI '' /''/ - [option '-dbhost' ] ORION_MONGO_HOST 'localhost' /'localhost'/ - [option '-rplSet' ] ORION_MONGO_REPLICA_SET '' /''/ - [option '-dbuser' ] ORION_MONGO_USER '' /''/ [option '-dbpwd' ] ORION_MONGO_PASSWORD '' /''/ - [option '-dbAuthMech' ] ORION_MONGO_AUTH_SOURCE '' /''/ - [option '-dbSSL' (enable SSL connection to DB)] ORION_MONGO_SSL FALSE /FALSE/ - [option '-dbDisableRetryWrites' (set retryWrite parameter to false in DB connect] ORION_MONGO_DISABLE_RETRY_WRITES FALSE /FALSE/ [option '-db' ] ORION_MONGO_DB 'orion' /'orion'/ - [option '-dbTimeout' ] ORION_MONGO_POOL_SIZE 1 <= 10 /10/ <= 10000 [option '-ipv4' (use ip v4 only)] ORION_USEIPV4 FALSE /FALSE/ [option '-ipv6' (use ip v6 only)] ORION_USEIPV6 FALSE /FALSE/ From 2312fc43c0649f912ae7b3b599e6ae8ec3c1ba31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Fri, 1 Mar 2024 16:50:18 +0100 Subject: [PATCH 03/12] FIX default dbURI --- src/app/contextBroker/contextBroker.cpp | 3 +- .../cases/3658_env_vars/env_vars.test | 116 +++++++++--------- 2 files changed, 59 insertions(+), 60 deletions(-) diff --git a/src/app/contextBroker/contextBroker.cpp b/src/app/contextBroker/contextBroker.cpp index b8ede361f5..1bd88da146 100644 --- a/src/app/contextBroker/contextBroker.cpp +++ b/src/app/contextBroker/contextBroker.cpp @@ -208,7 +208,6 @@ bool logDeprecate; */ #define PIDPATH _i "/tmp/contextBroker.pid" #define IP_ALL _i "0.0.0.0" -#define LOCALHOST _i "localhost" #define ONE_MONTH_PERIOD (3600 * 24 * 31) #define FG_DESC "don't start as daemon" @@ -289,7 +288,7 @@ PaArgument paArgs[] = { "-port", &port, "PORT", PaInt, PaOpt, 1026, 1, 65535, PORT_DESC }, { "-pidpath", pidPath, "PID_PATH", PaString, PaOpt, PIDPATH, PaNL, PaNL, PIDPATH_DESC }, - { "-dbURI", dbURI, "MONGO_URI", PaString, PaOpt, _i "", PaNL, PaNL, DBURI_DESC }, + { "-dbURI", dbURI, "MONGO_URI", PaString, PaOpt, _i "mongodb://localhost:27017", PaNL, PaNL, DBURI_DESC }, { "-dbpwd", pwd, "MONGO_PASSWORD", PaString, PaOpt, _i "", PaNL, PaNL, DBPASSWORD_DESC }, { "-db", dbName, "MONGO_DB", PaString, PaOpt, _i "orion", PaNL, PaNL, DB_DESC }, diff --git a/test/functionalTest/cases/3658_env_vars/env_vars.test b/test/functionalTest/cases/3658_env_vars/env_vars.test index 4c8d70bc64..60222b9c14 100644 --- a/test/functionalTest/cases/3658_env_vars/env_vars.test +++ b/test/functionalTest/cases/3658_env_vars/env_vars.test @@ -73,64 +73,64 @@ echo --REGEXPECT-- 01. Get the extended usage from the broker withut any alterations - see default state ===================================================================================== -Extended Usage: contextBroker [option '-U' (extended usage)] TRUE /FALSE/ - [option '-u' (usage)] FALSE /FALSE/ - [option '--help' (show help)] FALSE /FALSE/ - [option '--version' (show version)] FALSE /FALSE/ - [option '-logDir' ] ORION_LOG_DIR '/tmp/' - [option '-t' ] ORION_TRACE '' /'(null)'/ - [option '-logLevel' ] ORION_LOG_LEVEL 'WARN' /'WARN'/ - [option '-logAppend' (append to log-file)] ORION_LOG_APPEND FALSE /FALSE/ - [option '-fg' (don't start as daemon)] ORION_FOREGROUND FALSE /FALSE/ - [option '-localIp' ] ORION_LOCALIP '0.0.0.0' /'0.0.0.0'/ - [option '-port' ] ORION_PORT 1 <= 1026 /1026/ <= 65535 - [option '-pidpath' ] ORION_PID_PATH '/tmp/contextBroker.pid' /'/tmp/contextBroker/ - [option '-dbURI' ] ORION_MONGO_URI '' /''/ - [option '-dbpwd' ] ORION_MONGO_PASSWORD '' /''/ - [option '-db' ] ORION_MONGO_DB 'orion' /'orion'/ - [option '-dbPoolSize' ] ORION_MONGO_POOL_SIZE 1 <= 10 /10/ <= 10000 - [option '-ipv4' (use ip v4 only)] ORION_USEIPV4 FALSE /FALSE/ - [option '-ipv6' (use ip v6 only)] ORION_USEIPV6 FALSE /FALSE/ - [option '-https' (use the https 'protocol')] ORION_HTTPS FALSE /FALSE/ - [option '-key' ] ORION_HTTPS_KEYFILE '' /''/ - [option '-cert' ] ORION_HTTPS_CERTFILE '' /''/ - [option '-multiservice' (service multi tenancy mode)] ORION_MULTI_SERVICE FALSE /FALSE/ - [option '-httpTimeout' ] ORION_REQ_TIMEOUT 0 /0/ >= 0 - [option '-reqMutexPolicy' ] ORION_MUTEX_POLICY 'all' /'all'/ - [option '-writeConcern' ] ORION_MONGO_WRITE_CONCERN 0 <= 1 /1/ <= 1 - [option '-corsOrigin' ] ORION_CONN_MEMORY 0 <= 64 /64/ <= 1024 - [option '-maxConnections' ] ORION_MAX_CONN 1020 /1020/ >= 1 - [option '-reqPoolSize' ] ORION_TRQ_POOL_SIZE 0 <= 0 /0/ <= 1024 - [option '-inReqPayloadMaxSize' = 0 - [option '-outReqMsgMaxSize' = 0 - [option '-notificationMode' ] ORION_LOG_LINE_MAX_SIZE 32768 /32768/ >= 100 - [option '-logInfoPayloadMaxSize' = 0 - [option '-disableMetrics' (turn off the 'metrics' feature)] ORION_DISABLE_METRICS FALSE /FALSE/ - [option '-disableNgsiv1' (turn off NGSIv1 request endpoints)] ORION_DISABLE_NGSIV1 FALSE /FALSE/ - [option '-insecureNotif' (allow HTTPS notifications to peers which certificate c] ORION_INSECURE_NOTIF FALSE /FALSE/ - [option '-ngsiv1Autocast' (automatic cast for number, booleans and dates in NGSI] ORION_NGSIV1_AUTOCAST FALSE /FALSE/ - [option '-mqttMaxAge' ] ORION_LOG_DIR '/tmp/' + [option '-t' ] ORION_TRACE '' /'(null)'/ + [option '-logLevel' ] ORION_LOG_LEVEL 'WARN' /'WARN'/ + [option '-logAppend' (append to log-file)] ORION_LOG_APPEND FALSE /FALSE/ + [option '-fg' (don't start as daemon)] ORION_FOREGROUND FALSE /FALSE/ + [option '-localIp' ] ORION_LOCALIP '0.0.0.0' /'0.0.0.0'/ + [option '-port' ] ORION_PORT 1 <= 1026 /1026/ <= 65535 + [option '-pidpath' ] ORION_PID_PATH '/tmp/contextBroker.pid' /'/tmp/contextBroker/ + [option '-dbURI' ] ORION_MONGO_URI 'mongodb://localhost:27017' /'mongodb://localhos/ + [option '-dbpwd' ] ORION_MONGO_PASSWORD '' /''/ + [option '-db' ] ORION_MONGO_DB 'orion' /'orion'/ + [option '-dbPoolSize' ] ORION_MONGO_POOL_SIZE 1 <= 10 /10/ <= 10000 + [option '-ipv4' (use ip v4 only)] ORION_USEIPV4 FALSE /FALSE/ + [option '-ipv6' (use ip v6 only)] ORION_USEIPV6 FALSE /FALSE/ + [option '-https' (use the https 'protocol')] ORION_HTTPS FALSE /FALSE/ + [option '-key' ] ORION_HTTPS_KEYFILE '' /''/ + [option '-cert' ] ORION_HTTPS_CERTFILE '' /''/ + [option '-multiservice' (service multi tenancy mode)] ORION_MULTI_SERVICE FALSE /FALSE/ + [option '-httpTimeout' ] ORION_REQ_TIMEOUT 0 /0/ >= 0 + [option '-reqMutexPolicy' ] ORION_MUTEX_POLICY 'all' /'all'/ + [option '-writeConcern' ] ORION_MONGO_WRITE_CONCERN 0 <= 1 /1/ <= 1 + [option '-corsOrigin' ] ORION_CONN_MEMORY 0 <= 64 /64/ <= 1024 + [option '-maxConnections' ] ORION_MAX_CONN 1020 /1020/ >= 1 + [option '-reqPoolSize' ] ORION_TRQ_POOL_SIZE 0 <= 0 /0/ <= 1024 + [option '-inReqPayloadMaxSize' = 0 + [option '-outReqMsgMaxSize' = 0 + [option '-notificationMode' ] ORION_LOG_LINE_MAX_SIZE 32768 /32768/ >= 100 + [option '-logInfoPayloadMaxSize' = 0 + [option '-disableMetrics' (turn off the 'metrics' feature)] ORION_DISABLE_METRICS FALSE /FALSE/ + [option '-disableNgsiv1' (turn off NGSIv1 request endpoints)] ORION_DISABLE_NGSIV1 FALSE /FALSE/ + [option '-insecureNotif' (allow HTTPS notifications to peers which certificate c] ORION_INSECURE_NOTIF FALSE /FALSE/ + [option '-ngsiv1Autocast' (automatic cast for number, booleans and dates in NGSI] ORION_NGSIV1_AUTOCAST FALSE /FALSE/ + [option '-mqttMaxAge' Date: Sat, 2 Mar 2024 07:56:58 +0900 Subject: [PATCH 04/12] (JP) REMOVE deprecated db related CLIs (#4527) --- doc/manuals.jp/deprecated.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manuals.jp/deprecated.md b/doc/manuals.jp/deprecated.md index a515871299..535ebbf998 100644 --- a/doc/manuals.jp/deprecated.md +++ b/doc/manuals.jp/deprecated.md @@ -8,7 +8,7 @@ 推奨されなくなった機能のリストと、廃止された機能のバージョンは次のとおりです : -* Orion 3.12.0 での CLI パラメータ (および関連する環境変数): `-dbhost`、`-rplSet`、`-dbTimeout`、`-dbuser`、`-dbAuthMech`、`-dbAuthDb`、`-dbSSL`、および `-dbDisableRetryWrites`。MongoDB URI を構築するために必要な情報が必要な場合は、[このセクション](#mapping-to-mongouri-from-old-cli-parameters) をチェックして、代わりに `dbURI` を使用してください +* Orion 3.12.0 での CLI パラメータ (および関連する環境変数): `-dbhost`、`-rplSet`、`-dbTimeout`、`-dbuser`、`-dbAuthMech`、`-dbAuthDb`、`-dbSSL`、および `-dbDisableRetryWrites`。MongoDB URI を構築するために必要な情報が必要な場合は、[このセクション](#mapping-to-mongouri-from-old-cli-parameters) をチェックして、代わりに `dbURI` を使用してください (Orion 3.13.0 で削除されました) * Orion 3.10.0 での `geo:point`, `geo:line`, `geo:box` および `geo:polygon` 属性タイプ。代わりに `geo:json` を使用してください * Orion 3.8.0 での `GET /v2` 操作。この操作はかなり役に立たず、実際には使用されません。 * Orion 3.1.0 のサブスクリプションでの初期通知 (`skipInitialNotification` オプションと共に)。(Orion 3.2.0 で削除)。初期通知の @@ -103,13 +103,13 @@ Notes: | **削除された機能** | **機能をサポートする Orion ラスト・バージョン** | **バージョンのリリース日** | |--------------------------------------------------------------------------------------|-------------------------------------------------|----------------------------| -| CLI `-dbhost`、`-rplSet`、`-dbTimeout`、`-dbuser`、`-dbAuthMech`、`-dbAuthDb`、`-dbSSL`、および `-dbDisableRetryWrites` (および関連する環境変数) | まだ定義されていません | まだ定義されていません | | `POST /v2/entities` オペレーションの `attributes` フィールド | まだ定義されていません | まだ定義されていません | | `APPEND`, `UPDATE`, など。`POST /v2/op/update` でのアクション・タイプ | まだ定義されていません | まだ定義されていません | | URI パラメータでの `dateCreated` および `dateModified` | まだ定義されていません | まだ定義されていません | | エンティティのロケーションを指定する `location` メタデータ | まだ定義されていません | まだ定義されていません | | `GET /v2` 操作 | まだ定義されていません | まだ定義されていません | | `geo:point`, `geo:line`, `geo:box` および `geo:polygon` 属性タイプ | まだ定義されていません | まだ定義されていません | +| CLI `-dbhost`、`-rplSet`、`-dbTimeout`、`-dbuser`、`-dbAuthMech`、`-dbAuthDb`、`-dbSSL`、および `-dbDisableRetryWrites` (および関連する環境変数) | 3.12.0 | 2024年2月29日 | | エンティティの場所を指定するための `location` メタデータ | 3.10.1 | 2023年6月12日 | | NGSIv1 (関連する CLI パラメータ : `-strictNgsiv1Ids`, `-ngsiv1Autocast`) | 3.9.0 (*) | 2023年6月2日 | | `/ngsi10` および `/ngsi9` URL プレフィックス | 3.7.0 (*) | 2022年5月26日 | 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 05/12] 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.
  • attrs: List of attributes to be included in notification messages. It also defines the order in which attributes must appear in notifications when attrsFormat value is used (see [Notification Messages](#notification-messages) section). An empty list means that all attributes are to be included in notifications. See [Filtering out attributes and metadata](#filtering-out-attributes-and-metadata) section for more detail.
  • exceptAttrs: List of attributes to be excluded from the notification message, i.e. a notification message includes all entity attributes except the ones listed in this field. It must be a non-empty list.
  • If neither attrs nor exceptAttrs is specified, all attributes are included in notifications.
| | [`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 06/12] 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 6d5d01beacb5d80987b712039c1131413d5567e5 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 15:05:36 +0200 Subject: [PATCH 07/12] REMOVE archive --- archive/README.md | 1 + archive/proxyCoap/README.md | 59 -- .../cases/0283_coap_support/coap_basic.test | 158 ----- .../coap_command_line_options.test | 51 -- .../cases/0283_coap_support/coap_version.test | 45 -- archive/proxyCoap/harnessFunctions_coap.sh | 251 -------- archive/proxyCoap/src/app/CMakeLists.txt | 96 --- archive/proxyCoap/src/app/CoapController.cpp | 270 --------- archive/proxyCoap/src/app/CoapController.h | 52 -- archive/proxyCoap/src/app/HttpMessage.cpp | 134 ----- archive/proxyCoap/src/app/HttpMessage.h | 44 -- archive/proxyCoap/src/app/HttpProxy.cpp | 236 -------- archive/proxyCoap/src/app/HttpProxy.h | 40 -- archive/proxyCoap/src/app/proxyCoap.cpp | 202 ------- archive/proxyCoap/src/app/version.h | 33 -- archive/proxyCoap/testEnv_coap.sh | 27 - archive/vagrant/Vagrantfile | 42 -- archive/vagrant/doc/manuals/vagrant.md | 28 - archive/xml/README.md | 102 ---- archive/xml/xmlCheck/envVarSubstitute.sh | 108 ---- archive/xml/xmlCheck/xmlCheck.sh | 560 ------------------ archive/xml/xmlCheck/xmlExtractor.py | 190 ------ 22 files changed, 1 insertion(+), 2728 deletions(-) create mode 100644 archive/README.md delete mode 100644 archive/proxyCoap/README.md delete mode 100644 archive/proxyCoap/cases/0283_coap_support/coap_basic.test delete mode 100644 archive/proxyCoap/cases/0283_coap_support/coap_command_line_options.test delete mode 100644 archive/proxyCoap/cases/0283_coap_support/coap_version.test delete mode 100644 archive/proxyCoap/harnessFunctions_coap.sh delete mode 100644 archive/proxyCoap/src/app/CMakeLists.txt delete mode 100644 archive/proxyCoap/src/app/CoapController.cpp delete mode 100644 archive/proxyCoap/src/app/CoapController.h delete mode 100644 archive/proxyCoap/src/app/HttpMessage.cpp delete mode 100644 archive/proxyCoap/src/app/HttpMessage.h delete mode 100644 archive/proxyCoap/src/app/HttpProxy.cpp delete mode 100644 archive/proxyCoap/src/app/HttpProxy.h delete mode 100644 archive/proxyCoap/src/app/proxyCoap.cpp delete mode 100644 archive/proxyCoap/src/app/version.h delete mode 100644 archive/proxyCoap/testEnv_coap.sh delete mode 100644 archive/vagrant/Vagrantfile delete mode 100644 archive/vagrant/doc/manuals/vagrant.md delete mode 100644 archive/xml/README.md delete mode 100755 archive/xml/xmlCheck/envVarSubstitute.sh delete mode 100755 archive/xml/xmlCheck/xmlCheck.sh delete mode 100755 archive/xml/xmlCheck/xmlExtractor.py diff --git a/archive/README.md b/archive/README.md new file mode 100644 index 0000000000..db347d96a9 --- /dev/null +++ b/archive/README.md @@ -0,0 +1 @@ +After 6 years without touching this directory, we are purging it for Orion 4.0.0 release. If you want to get its content check [the previous version GitHub tree](https://github.com/telefonicaid/fiware-orion/tree/3.12.0/archive). diff --git a/archive/proxyCoap/README.md b/archive/proxyCoap/README.md deleted file mode 100644 index d6e03b638d..0000000000 --- a/archive/proxyCoap/README.md +++ /dev/null @@ -1,59 +0,0 @@ -This directory holds proxyCoap, no longer mantained as part of the "mainstream" code in Orion (the one -under the src/ directory at repository root) but maybe useful in the future. - -## Building - -This directory cannot be built in "standalone mode" (as the archiving work described at issue #1202 is not -completed), so by the moment if you want to compile proxyCoap you have to move the -proxyCoap/src/app/proxyCoap directory to its original location at src/app in the repository root, then add -the following to root CMakeLists.txt file: - -``` -ADD_SUBDIRECTORY(src/app/proxyCoap) -``` - -just after the line: - -``` -ADD_SUBDIRECTORY(src/app/contextBroker) -``` - -In addition, you need to do the following before running `make` to compile: - -* Install cantcoap (with dependencies). Note that we are using a particular snapshot of the code (corresponding - to around July 21st, 2014) given that cantcoap repository doesn't provide any releasing mechanism. - - -``` -sudo yum install clang CUnit-devel - -git clone https://github.com/staropram/cantcoap -cd cantcoap -git checkout 749e22376664dd3adae17492090e58882d3b28a7 -make -sudo cp cantcoap.h /usr/local/include -sudo cp dbg.h /usr/local/include -sudo cp nethelper.h /usr/local/include -sudo cp libcantcoap.a /usr/local/lib -``` - - -## Testing - -The cases/ directory contains a set of test harness files used in the past to test the -proxyCoap functionality. You need to install COAP client (an example application included in the -libcoap sources) before to use them: - -``` -wget http://sourceforge.net/projects/libcoap/files/coap-18/libcoap-4.1.1.tar.gz/download -mv download libcoap-4.1.1.tar.gz -tar xvzf libcoap-4.1.1.tar.gz -cd libcoap-4.1.1 -./configure -make -sudo cp examples/coap-client /usr/local/bin -``` - -## Miscellanea - -This directory also includes parts of harnessFunction.sh and testEnv.sh files related with CoAP. diff --git a/archive/proxyCoap/cases/0283_coap_support/coap_basic.test b/archive/proxyCoap/cases/0283_coap_support/coap_basic.test deleted file mode 100644 index 4d17b3e6ec..0000000000 --- a/archive/proxyCoap/cases/0283_coap_support/coap_basic.test +++ /dev/null @@ -1,158 +0,0 @@ -# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -Coap Basic interaction - ---SHELL-INIT-- -dbInit CB -brokerStart CB -valgrindSleep 2 -proxyCoapStart - ---SHELL-- - -valgrindSleep 5 -echo "+++++++ Create entity +++++++++" -payload='{ - "attributes": [ - { - "name": "temperature", - "type": "centigrade", - "value": "30" - } - ] -}' -coapCurl --url /v1/contextEntities/Room1 --payload "$payload" --json -X post - - -echo "+++++++ Query +++++++++" -valgrindSleep 2 -coapCurl --url /v1/contextEntities/Room1 --json - - -echo "+++++++ Update +++++++++" -payload='{ - "attributes": [ - { - "name": "temperature", - "type": "centigrade", - "value": "29" - } - ] -}' -coapCurl --url /v1/contextEntities/Room1 --payload "$payload" --json -X put - -echo "+++++++ Query +++++++++" -valgrindSleep 2 -coapCurl --url /v1/contextEntities/Room1 --json - ---REGEXPECT-- -+++++++ Create entity +++++++++ -v:1 t:0 tkl:0 c:2 id:REGEX(\d+) - -{ - "contextResponses": [ - { - "attributes": [ - { - "name": "temperature", - "type": "centigrade", - "value": "" - } - ], - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ], - "id": "Room1", - "isPattern": "false", - "type": "" -} -+++++++ Query +++++++++ -v:1 t:0 tkl:0 c:1 id:REGEX(\d+) - -{ - "contextElement": { - "attributes": [ - { - "name": "temperature", - "type": "centigrade", - "value": "30" - } - ], - "id": "Room1", - "isPattern": "false", - "type": "" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } -} -+++++++ Update +++++++++ -v:1 t:0 tkl:0 c:3 id:REGEX(\d+) - -{ - "contextResponses": [ - { - "attributes": [ - { - "name": "temperature", - "type": "centigrade", - "value": "" - } - ], - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} -+++++++ Query +++++++++ -v:1 t:0 tkl:0 c:1 id:REGEX(\d+) - -{ - "contextElement": { - "attributes": [ - { - "name": "temperature", - "type": "centigrade", - "value": "29" - } - ], - "id": "Room1", - "isPattern": "false", - "type": "" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } -} ---TEARDOWN-- -proxyCoapStop -brokerStop CB -dbDrop CB diff --git a/archive/proxyCoap/cases/0283_coap_support/coap_command_line_options.test b/archive/proxyCoap/cases/0283_coap_support/coap_command_line_options.test deleted file mode 100644 index 9b850b0cc1..0000000000 --- a/archive/proxyCoap/cases/0283_coap_support/coap_command_line_options.test +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - ---NAME-- -proxyCoap command-line options - ---SHELL-INIT-- - ---SHELL-- -proxyCoap -u - ---REGEXPECT-- -Usage: proxyCoap [option '-U' (extended usage)] - [option '-u' (usage)] - [option '--version' (show version)] - [option '-logDir' ] - [option '-t' ] - [option '--silent' (silent mode)] - [option '-v' (verbose mode)] - [option '-vv' (verbose2 mode)] - [option '-vvv' (verbose3 mode)] - [option '-vvvv' (verbose4 mode)] - [option '-vvvvv' (verbose5 mode)] - [option '-logAppend' (append to log-file)] - - [option '-fg' (don't start as daemon)] - [option '-localIp' ] - [option '-port' ] - [option '-cbHost' ] - [option '-cbPort' ] - [option '-ipv4' (use ip v4 only)] - [option '-ipv6' (use ip v6 only)] - ---TEARDOWN-- diff --git a/archive/proxyCoap/cases/0283_coap_support/coap_version.test b/archive/proxyCoap/cases/0283_coap_support/coap_version.test deleted file mode 100644 index 35bb18c164..0000000000 --- a/archive/proxyCoap/cases/0283_coap_support/coap_version.test +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - ---NAME-- -proxyCoap version ---SHELL-INIT-- - ---SHELL-- -# We have found sometimes problems with using CLI options with two hyphens in the .test files, breaking the testHarness.sh script. -# However, in this case, it seems to work with the double-hyphened "--version" argument. - -contextBroker --version - ---REGEXPECT-- -REGEX(\d+\.\d+\.\d+.*) -Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -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. - -Telefonica I+D ---TEARDOWN-- diff --git a/archive/proxyCoap/harnessFunctions_coap.sh b/archive/proxyCoap/harnessFunctions_coap.sh deleted file mode 100644 index 983c57bc91..0000000000 --- a/archive/proxyCoap/harnessFunctions_coap.sh +++ /dev/null @@ -1,251 +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 -# -# -# In order to "recover" the following functions, they should be moved back -# to harnessFunctions.sh file (and enabled with export -f at the end of that file) - -# ------------------------------------------------------------------------------ -# -# proxyCoapStart -# -function proxyCoapStart() -{ - extraParams=$* - - proxyCoap $extraParams -cbPort $CB_PORT - - # Test to see whether we have a proxy running. If not raise an error - running_proxyCoap=$(ps -fe | grep ' proxyCoap' | grep "cbPort $CB_PORT" | wc -l) - if [ "$running_proxyCoap" == "" ] - then - echo "Unable to start proxyCoap" - exit 1 - fi -} - - - -# ------------------------------------------------------------------------------ -# -# proxyCoapStop -# -function proxyCoapStop -{ - port=$COAP_PORT - - # Test to see if we have a proxy running if so kill it! - running_proxyCoap=$(ps -fe | grep proxyCoap | wc -l) - if [ $running_proxyCoap -ne 1 ]; then - kill $(ps -fe | grep proxyCoap | awk '{print $2}') 2> /dev/null - # Wait some time so the proxy can finish properly - sleep 1 - running_proxyCoap=$(ps -fe | grep proxyCoap | wc -l) - if [ $running_proxyCoap -ne 1 ]; then - # If the proxy refuses to stop politely, kill the process by brute force - kill -9 $(ps -fe | grep proxyCoap | awk '{print $2}') 2> /dev/null - sleep 1 - running_proxyCoap=$(ps -fe | grep proxyCoap | wc -l) - if [ $running_proxyCoap -ne 1 ]; then - echo "Existing proxyCoap is immortal, can not be killed!" - exit 1 - fi - fi - fi -} - - -# ------------------------------------------------------------------------------ -# -# coapCurl -# -# Options: -# -X (default: according to curl. GET if no payload, POST if with payload) -# --host (default: localhost) -# --port (default: $COAP_PORT) -# --url (default: empty string) -# --payload (default: NO PAYLOAD. Possible values: [filename | "${string}"]) -# --in (input payload) (default: xml => application/xml, If 'json': application/json) -# --out (output payload (default: xml => application/xml, If 'json': application/json) -# --json (in/out JSON) (if --in/out is used AFTER --json, it overrides) -# --tenant (tenant in HTTP header) -# --servicePath (Service Path in HTTP header) -# --noPayloadCheck (skip paylosd check filter) -# -# Any parameters are sent as is to 'curl' -# -function coapCurl() -{ - # - # Default values - # - _method="" - _host="0.0.0.0" - _port=$COAP_PORT - _url="" - _payload="" - _inFormat="" - _outFormat="" - _json="" - _tenant="" - _servicePath="" - _xtra='' - _noPayloadCheck='off' - - while [ "$#" != 0 ] - do - if [ "$1" == "-X" ]; then _method="$2"; shift; - elif [ "$1" == "--host" ]; then _host="$2"; shift; - elif [ "$1" == "--port" ]; then _port="$2"; shift; - elif [ "$1" == "--url" ]; then _url="$2"; shift; - elif [ "$1" == "--payload" ]; then _payload="$2"; shift; - elif [ "$1" == "--in" ]; then _inFormat="$2"; shift; - elif [ "$1" == "--out" ]; then _outFormat="$2"; shift; - elif [ "$1" == "--json" ]; then _inFormat=application/json; _outFormat=application/json; - elif [ "$1" == "--tenant" ]; then _tenant="$2"; shift; - elif [ "$1" == "--servicePath" ]; then _servicePath="$2"; shift; - elif [ "$1" == "--noPayloadCheck" ]; then _noPayloadCheck=on; - else _xtra="$_xtra $1"; shift; - fi - - shift - done - - # - # Sanity check of parameters - # - if [ "$_url" == "" ] - then - echo "No URL"; - return 1; - fi - - - # - # Fix for 'Content-Type' and 'Accept' short names 'xml' and 'json' - # - if [ "$_inFormat" == "xml" ]; then _inFormat=application/xml; fi; - if [ "$_outFormat" == "xml" ]; then _outFormat=application/xml; fi; - if [ "$_inFormat" == "json" ]; then _inFormat=application/json; fi; - if [ "$_outFormat" == "json" ]; then _outFormat=application/json; fi; - - - - # - # Cleanup 'compound' variables, so that we don't inherit values from previous calls - # - _METHOD='' - _URL='' - _ACCEPT='' - _CONTENTFORMAT='' - - if [ "$_inFormat" != "" ]; then _CONTENTFORMAT="-t $_inFormat"; fi - if [ "$_outFormat" != "" ]; then _ACCEPT="-A $_outFormat"; fi - if [ "$_method" != "" ]; then _METHOD=' -m '$_method; fi - - _URL="coap://$_host:$_port$_url" - - # usage: coap-client [-A type...] [-t type] [-b [num,]size] [-B seconds] [-e text] - # [-g group] [-m method] [-N] [-o file] [-P addr[:port]] [-p port] - # [-s duration] [-O num,text] [-T string] [-v num] URI - # - # URI can be an absolute or relative coap URI, - # -A type... accepted media types as comma-separated list of - # symbolic or numeric values - # -t type content type for given resource for PUT/POST - # -b [num,]size block size to be used in GET/PUT/POST requests - # (value must be a multiple of 16 not larger than 1024) - # If num is present, the request chain will start at - # block num - # -B seconds break operation after waiting given seconds - # (default is 90) - # -e text include text as payload (use percent-encoding for - # non-ASCII characters) - # -f file file to send with PUT/POST (use '-' for STDIN) - # -g group join the given multicast group - # -m method request method (get|put|post|delete), default is 'get' - # -N send NON-confirmable message - # -o file output received data to this file (use '-' for STDOUT) - # -p port listen on specified port - # -s duration subscribe for given duration [s] - # -v num verbosity level (default: 3) - # -O num,text add option num with contents text to request - # -P addr[:port] use proxy (automatically adds Proxy-Uri option to - # request) - # -T token include specified token - # - # examples: - # coap-client -m get coap://[::1]/ - # coap-client -m get coap://[::1]/.well-known/core - # coap-client -m get -T cafe coap://[::1]/time - # echo 1000 | coap-client -m put -T cafe coap://[::1]/time -f - - - - _BUILTINS='-B 1 -b 1024' - - -# echo '=====================================================================================' - if [ "$_payload" != "" ] - then -# echo "echo "$_payload" | ./coap-client -f - $_BUILTINS $_METHOD $_ACCEPT $_CONTENTFORMAT $_URL" - _response=$(echo "$_payload" | coap-client -f - $_BUILTINS $_METHOD $_ACCEPT $_CONTENTFORMAT $_URL) - else -# echo "./coap-client $_BUILTINS $_METHOD $_ACCEPT $_CONTENTFORMAT $_URL" - _response=$(coap-client $_BUILTINS $_METHOD $_ACCEPT $_CONTENTFORMAT $_URL) - fi -# echo '=====================================================================================' - - - # Get headers - _responseHeaders=$(echo "$_response" | head -n 1) - - # Strip headers and garbage bytes from response - _response=$(echo "$_response" | tail -n +2 | head -c-3) - - - echo $_responseHeaders - echo - - # - # Print and beautify response body (IF ANY) - # - if [ "$_noPayloadCheck" == "on" ] - then - echo $_response - else - if [ "$_response" != "" ] - then - if [ "$_outFormat" == application/xml ] || [ "$_outFormat" == "" ] - then - # FIXME P10: XML removal - #echo $_response | xmllint --format - - echo $_response | python -mjson.tool - elif [ "$_outFormat" == application/json ] - then - vMsg "JSON check for:" $_response - echo $_response | python -mjson.tool - else - # FIXME P10: XML removal - #echo $_response | xmllint --format - - echo $_response | python -mjson.tool - fi - fi - fi -} diff --git a/archive/proxyCoap/src/app/CMakeLists.txt b/archive/proxyCoap/src/app/CMakeLists.txt deleted file mode 100644 index 00d6d28b07..0000000000 --- a/archive/proxyCoap/src/app/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - -SET (SOURCES - proxyCoap.cpp - HttpProxy.cpp - HttpMessage.cpp - CoapController.cpp -) - - -SET (HEADERS - HttpProxy.h - HttpMessage.h - CoapController.h -) - -SET (STATIC_LIBS - lm - pa -) - -# Include directories -# ----------------------------------------------------------------- -include_directories("${PROJECT_SOURCE_DIR}/src/app") -include_directories("${PROJECT_SOURCE_DIR}/src/lib") -include_directories("${RAPIDXML_INCLUDE}") - - -# Lib directories -# ------------------------------------------------------------ -link_directories("/usr/local/lib/") -link_directories("/usr/lib64/") -link_directories("/usr/lib/x86_64-linux-gnu") - -# FIXME P4: Issue #476: remove or keep? -link_directories("/opt/lib/") - - - -# Executable declaration -# ------------------------------------------------------------ -ADD_EXECUTABLE(proxyCoap ${SOURCES} ${HEADERS}) - -IF(${DISTRO} STREQUAL "Fedora_20") - MESSAGE("proxyCoap: Fedora DISTRO: '${DISTRO}'") - TARGET_LINK_LIBRARIES(proxyCoap ${STATIC_LIBS} cantcoap curl -lboost_thread) -ELSEIF(${DISTRO} STREQUAL "Ubuntu_13.10") - MESSAGE("proxyCoap: Ubuntu DISTRO: '${DISTRO}'") - TARGET_LINK_LIBRARIES(proxyCoap ${STATIC_LIBS} cantcoap curl boost_thread boost_system pthread) -ELSEIF(${DISTRO} STREQUAL "Ubuntu_14.04.1_LTS") - # FIXME P4: Issue #476: remove or keep? - MESSAGE("proxyCoap: Ubuntu DISTRO: '${DISTRO}'") - TARGET_LINK_LIBRARIES(proxyCoap ${STATIC_LIBS} cantcoap curl boost_thread boost_system pthread) -ELSEIF(${DISTRO} STREQUAL "Ubuntu_14.04.3_LTS") - # FIXME P4: Issue #476: remove or keep? - MESSAGE("proxyCoap: Ubuntu DISTRO: '${DISTRO}'") - TARGET_LINK_LIBRARIES(proxyCoap ${STATIC_LIBS} cantcoap curl boost_thread boost_system pthread) -ELSEIF(${DISTRO} STREQUAL "Ubuntu_14.10") - # ADDED FOR UBUNTU 14.10 - MESSAGE("contextBroker: Ubuntu DISTRO: '${DISTRO}'") - TARGET_LINK_LIBRARIES(proxyCoap ${STATIC_LIBS} cantcoap curl boost_thread boost_system pthread) -ELSEIF(${DISTRO} STREQUAL "Debian_8.0") - MESSAGE("proxyCoap: Debian DISTRO: '${DISTRO}'") - TARGET_LINK_LIBRARIES(proxyCoap ${STATIC_LIBS} cantcoap curl boost_thread boost_system pthread) -ELSEIF(${DISTRO} MATCHES "CentOS_6.*") - MESSAGE("proxyCoap: CentOS DISTRO: '${DISTRO}'") - TARGET_LINK_LIBRARIES(proxyCoap ${STATIC_LIBS} cantcoap curl -lboost_thread-mt) -ELSE() - MESSAGE("proxyCoap: Other DISTRO: '${DISTRO}'") - TARGET_LINK_LIBRARIES(proxyCoap ${STATIC_LIBS} cantcoap curl -lboost_thread -lboost_system -lpthread) -ENDIF() - -# target_link_libraries (proxyCoap cantcoap curl) - -INSTALL(TARGETS proxyCoap - RUNTIME DESTINATION bin) diff --git a/archive/proxyCoap/src/app/CoapController.cpp b/archive/proxyCoap/src/app/CoapController.cpp deleted file mode 100644 index f9dbbb2b93..0000000000 --- a/archive/proxyCoap/src/app/CoapController.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* -* -* Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: TID Developer -*/ - -#include "CoapController.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "proxyCoap/HttpProxy.h" -#include "proxyCoap/HttpMessage.h" - -#define PORT_STRING_SIZE 6 - -CoapController::CoapController(const char *_host, unsigned short _httpPort, unsigned short _coapPort) -{ - // Read host and port values - httpPort = _httpPort; - coapPort = _coapPort; - host.assign(_host); - - char* portString = new char[PORT_STRING_SIZE]; - snprintf(portString, PORT_STRING_SIZE, "%d", _coapPort); - coapPortStr.assign(portString); -} - -/* **************************************************************************** -* -* sendDatagram - -*/ -int CoapController::sendDatagram(int sockfd, boost::scoped_ptr& res, sockaddr* recvFrom) -{ - socklen_t addrLen = sizeof(struct sockaddr_in); - if (recvFrom->sa_family == AF_INET6) - { - addrLen = sizeof(struct sockaddr_in6); - } - - ssize_t sent = sendto(sockfd, res->getPDUPointer(), res->getPDULength(), 0, recvFrom, addrLen); - - if (sent < 0) - { - LM_W(("Error sending packet: %ld.", sent)); - return 1; - } - else - { - LM_T(LmtCoap, ("Sent: %ld bytes", sent)); - } - - return 0; -} - -int CoapController::sendError(int sockfd, CoapPDU* req, sockaddr* recvFrom, CoapPDU::Code code) -{ - boost::scoped_ptr res(new CoapPDU()); - - res->setVersion(1); - res->setMessageID(req->getMessageID()); - res->setCode(code); - res->setType(CoapPDU::COAP_ACKNOWLEDGEMENT); - res->setToken(req->getTokenPointer(), req->getTokenLength()); - - return sendDatagram(sockfd, res, recvFrom); -} - -/* **************************************************************************** -* -* callback - -*/ -int CoapController::callback(CoapPDU* request, int sockfd, struct sockaddr_storage* recvFrom) -{ - // Translate request from CoAP to HTTP and send it to MHD through loopback - std::string httpResponse; - httpResponse = sendHttpRequest(host.c_str(), httpPort, request); - - if (httpResponse == "") - { - // Could not get an answer from HTTP module - sendError(sockfd, request, (sockaddr*)recvFrom, CoapPDU::COAP_INTERNAL_SERVER_ERROR); - return 1; - } - - // Parse HTTP response - boost::scoped_ptr hm(new HttpMessage(httpResponse)); - - // If CoAP message is too big, must send error to requester - if (hm->contentLength() > COAP_BUFFER_SIZE) - { - sendError(sockfd, request, (sockaddr*)recvFrom, CoapPDU::COAP_REQUEST_ENTITY_TOO_LARGE); - return 1; - } - - // Translate response from HTTP to CoAP - boost::scoped_ptr coapResponse(hm->toCoap()); - - if (!coapResponse) - { - // Could not translate HTTP into CoAP - sendError(sockfd, request, (sockaddr*)recvFrom, CoapPDU::COAP_INTERNAL_SERVER_ERROR); - return 1; - } - - // Prepare appropriate response in CoAP - coapResponse->setVersion(1); - coapResponse->setMessageID(request->getMessageID()); - coapResponse->setToken(request->getTokenPointer(), request->getTokenLength()); - - // Set type - switch (request->getType()) - { - case CoapPDU::COAP_CONFIRMABLE: - case CoapPDU::COAP_NON_CONFIRMABLE: - coapResponse->setType(CoapPDU::COAP_ACKNOWLEDGEMENT); - break; - - case CoapPDU::COAP_ACKNOWLEDGEMENT: - case CoapPDU::COAP_RESET: - break; - - default: - return 1; - break; - }; - - // Send the packet - sendDatagram(sockfd, coapResponse, (sockaddr*) recvFrom); - return 0; -} - - - -/* **************************************************************************** -* -* serve - -*/ -void CoapController::serve() -{ - // Buffers for UDP and URIs - char buffer[COAP_BUFFER_SIZE]; - char uriBuffer[COAP_URI_BUFFER_SIZE]; - int recvURILen = 0; - int ret = 0; - - // Storage for handling receive address - struct sockaddr_storage recvAddr; - socklen_t recvAddrLen = sizeof(struct sockaddr_storage); - - // Prepare binding address - struct addrinfo *bindAddr = NULL; - struct addrinfo hints; - - // Setting up bind address - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags |= AI_NUMERICSERV; - hints.ai_family = AF_INET; // ipv4, PF_INET6 for ipv6 or PF_UNSPEC to let OS decide - - int error = getaddrinfo(host.c_str(), coapPortStr.c_str(), &hints, &bindAddr); - if (error) - { - LM_W(("Could not start CoAP server: Error getting address info: %s.", gai_strerror(error))); - return; - } - - // Setting up the UDP socket - int sd = socket(bindAddr->ai_family, bindAddr->ai_socktype, bindAddr->ai_protocol); - - // Binding socket - if (bind(sd, bindAddr->ai_addr, bindAddr->ai_addrlen) != 0) - { - LM_W(("Could not start CoAP server: Error binding socket")); - return; - } - - while (1) - { - // zero out the buffer - memset(buffer, 0, COAP_BUFFER_SIZE); - - // receive packet - ret = recvfrom(sd, &buffer, COAP_BUFFER_SIZE, 0, (sockaddr*) &recvAddr, &recvAddrLen); - if (ret == -1) - { - LM_W(("Error receiving data")); - continue; - } - - boost::scoped_ptr recvPDU(new CoapPDU((uint8_t*) buffer, COAP_BUFFER_SIZE, COAP_BUFFER_SIZE)); - - // validate packet - if (ret > COAP_BUFFER_SIZE) - { - LM_W(("PDU too large to fit in pre-allocated buffer")); - continue; - } - recvPDU->setPDULength(ret); - if (recvPDU->validate() != 1) - { - LM_W(("Malformed CoAP packet")); - continue; - } - LM_T(LmtCoap, ("Valid CoAP PDU received")); - - // Treat URI - if (recvPDU->getURI(uriBuffer, COAP_URI_BUFFER_SIZE, &recvURILen) != 0) - { - LM_W(("Error retrieving URI")); - continue; - } - - if (recvURILen == 0) - { - LM_T(LmtCoap, ("There is no URI associated with this Coap PDU")); - } - else - { - // Invoke a callback thread - boost::thread* workerThread = new boost::thread(boost::bind(&CoapController::callback, this, recvPDU.get(), sd, &recvAddr)); - - // Wait for thread to finnish (like using no threads at all) for now - workerThread->join(); - - continue; - } - - // no URI, handle cases - - // code == 0, no payload, this is a ping request, send RST? - if ((recvPDU->getPDULength() == 0) && (recvPDU->getCode() == 0)) - { - LM_T(LmtCoap, ("CoAP ping request")); - } - - } -} diff --git a/archive/proxyCoap/src/app/CoapController.h b/archive/proxyCoap/src/app/CoapController.h deleted file mode 100644 index 515a56b2cd..0000000000 --- a/archive/proxyCoap/src/app/CoapController.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef COAP_CONTROLLER_H -#define COAP_CONTROLLER_H -/* -* -* 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: TID Developer -*/ - -#include -#include -#include - -#include "cantcoap.h" - -class CoapController -{ - - std::string host; - std::string coapPortStr; - unsigned short httpPort; - unsigned short coapPort; - - int sendDatagram(int sockfd, boost::scoped_ptr& res, sockaddr* recvFrom); - int sendError(int sockfd, CoapPDU* req, sockaddr* recvFrom, CoapPDU::Code code); - - int callback(CoapPDU* request, int sockfd, struct sockaddr_storage* recvFrom); - -public: - CoapController(const char* _host, unsigned short _httpPort, unsigned short _coapPort); - void serve(); -}; - -#endif // COAP_CONTROLLER_H diff --git a/archive/proxyCoap/src/app/HttpMessage.cpp b/archive/proxyCoap/src/app/HttpMessage.cpp deleted file mode 100644 index a9b04933dd..0000000000 --- a/archive/proxyCoap/src/app/HttpMessage.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* -* -* Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: TID Developer -*/ - -#include "proxyCoap/HttpMessage.h" - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "rest/HttpHeaders.h" - -#include // atoi -#include // istringstream - -HttpMessage::HttpMessage(std::string theMessage) -{ - _httpCode = 0; - _contentLength = 0; - _contentType = ""; - _body = ""; - - std::istringstream iss(theMessage); - std::string line; - - bool isHeader = true; - while (std::getline(iss, line)) - { - // Clean last char in headers - if (isHeader) - { - line = line.substr(0, line.size() - 1); - } - - if (line.empty()) - { - isHeader = false; - } - - if (isHeader) - { - // Is it a header or the first line with the HTTP code? - int pos = line.find(":"); - if (pos < 0) - { - // Get HTTP code - // HTTP code is always 3 chars long starting at position 9 - // - // HTTP/1.1 200 OK - // XXX - // - _httpCode = atoi(line.substr(9, 3).c_str()); - } - else - { - // Get other headers - int temp = line.find(HTTP_CONTENT_LENGTH); - if (temp >= 0) - { - _contentLength = atoi(line.substr(pos + 2).c_str()); - } - - temp = line.find(HTTP_CONTENT_TYPE); - if (temp >= 0) - { - _contentType = line.substr(pos + 2); - } - } - } - else - { - // We are parsing the body now (as is) - _body += line; - } - } -} - -CoapPDU* HttpMessage::toCoap() -{ - CoapPDU* pdu = new CoapPDU(); - - // Set code - switch (this->_httpCode) - { - case 200: - pdu->setCode(CoapPDU::COAP_CONTENT); - break; - - case 415: - pdu->setCode(CoapPDU::COAP_UNSUPPORTED_CONTENT_FORMAT); - break; - - default: - pdu->httpStatusToCode(this->_httpCode); - break; - } - - // Set payload - uint8_t* data = (uint8_t*) this->_body.c_str(); - std::size_t length = this->_body.length(); - pdu->setPayload(data, length); - - // Set content-type - if (this->_contentType == "application/json") - { - pdu->setContentFormat(CoapPDU::COAP_CONTENT_FORMAT_APP_JSON); - } - else - { - pdu->setContentFormat(CoapPDU::COAP_CONTENT_FORMAT_APP_XML); - } - - return pdu; -} diff --git a/archive/proxyCoap/src/app/HttpMessage.h b/archive/proxyCoap/src/app/HttpMessage.h deleted file mode 100644 index 24e533ed8d..0000000000 --- a/archive/proxyCoap/src/app/HttpMessage.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef HTTP_MESSAGE_H -#define HTTP_MESSAGE_H -/* -* -* 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: TID Developer -*/ -#include -#include "cantcoap.h" - -class HttpMessage -{ - int _httpCode; - int _contentLength; - std::string _contentType; - std::string _body; - - public: - HttpMessage(std::string theMessage); - - CoapPDU* toCoap(); - int contentLength() { return _contentLength; } -}; - -#endif // HTTP_MESSAGE_H diff --git a/archive/proxyCoap/src/app/HttpProxy.cpp b/archive/proxyCoap/src/app/HttpProxy.cpp deleted file mode 100644 index 098fc26ee4..0000000000 --- a/archive/proxyCoap/src/app/HttpProxy.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -* -* Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: TID Developer -*/ - -#include "proxyCoap/HttpProxy.h" - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -/* **************************************************************************** -* -* writeMemoryCallback - -*/ -size_t writeMemoryCallback(void* contents, size_t size, size_t nmemb, void* userp) -{ - size_t realsize = size * nmemb; - MemoryStruct* mem = (MemoryStruct *) userp; - - mem->memory = (char*) realloc(mem->memory, mem->size + realsize + 1); - if (mem->memory == NULL) - { - LM_W(("Not enough memory (realloc returned NULL)\n")); - return 0; - } - - memcpy(&(mem->memory[mem->size]), contents, realsize); - mem->size += realsize; - mem->memory[mem->size] = 0; - - return realsize; -} - - -/* **************************************************************************** -* -* sendHttpRequest - -*/ -std::string sendHttpRequest(const char* host, unsigned short port, CoapPDU* request) -{ - int recvURILen = 0; - CURL* curl = curl_easy_init(); - MemoryStruct httpResponse; - CURLcode res; - char uriBuffer[COAP_URI_BUFFER_SIZE]; - - if (curl) - { - // Allocate to hold HTTP response - httpResponse.memory = (char*) malloc(1); // will grow as needed - httpResponse.size = 0; // no data at this point - - // --- Set HTTP verb - std::string httpVerb = ""; - - switch(request->getCode()) - { - case CoapPDU::COAP_POST: - httpVerb = "POST"; - break; - - case CoapPDU::COAP_PUT: - httpVerb = "PUT"; - break; - - case CoapPDU::COAP_DELETE: - httpVerb = "DELETE"; - break; - - case CoapPDU::COAP_EMPTY: - case CoapPDU::COAP_GET: - default: - httpVerb = "GET"; - break; - } - curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, httpVerb.c_str()); - LM_T(LmtCoap, ("Got an HTTP %s", httpVerb.c_str())); - - - // --- Prepare headers - struct curl_slist* headers = NULL; - CoapPDU::CoapOption* options = request->getOptions(); - int numOptions = request->getNumOptions(); - - for (int i = 0; i < numOptions ; i++) - { - u_int16_t opt = options[i].optionNumber; - std::string string = ""; - u_int8_t buffer[options[i].optionValueLength + 1]; - - memcpy(buffer, options[i].optionValuePointer, options[i].optionValueLength); - - switch (opt) - { - case CoapPDU::COAP_OPTION_URI_PATH: - buffer[options[i].optionValueLength] = '\0'; - LM_T(LmtCoap, ("Got URI_PATH option: '%s'", buffer)); - break; - - case CoapPDU::COAP_OPTION_CONTENT_FORMAT: - switch (buffer[0]) - { - case CoapPDU::COAP_CONTENT_FORMAT_APP_JSON: - string = "Content-type: application/json"; - break; - - case CoapPDU::COAP_CONTENT_FORMAT_APP_XML: - string = "Content-type: application/xml"; - break; - - default: - string = "Content-type: application/json"; - break; - } - headers = curl_slist_append(headers, string.c_str()); - LM_T(LmtCoap, ("Got CONTENT-FORMAT option: '%s'", string.c_str())); - break; - - case CoapPDU::COAP_OPTION_ACCEPT: - switch (buffer[0]) - { - case CoapPDU::COAP_CONTENT_FORMAT_APP_JSON: - string = "Accept: application/json"; - break; - - case CoapPDU::COAP_CONTENT_FORMAT_APP_XML: - string = "Accept: application/xml"; - break; - - default: - string = "Accept: application/json"; - break; - } - headers = curl_slist_append(headers, string.c_str()); - LM_T(LmtCoap, ("Got ACCEPT option: '%s'", string.c_str())); - break; - - default: - LM_T(LmtCoap, ("Got unknown option")); - break; - } - } - - - // Set Content-length - if (request->getPayloadLength() > 0) - { - std::stringstream contentLengthStringStream; - contentLengthStringStream << request->getPayloadLength(); - std::string finalString = "Content-length: " + contentLengthStringStream.str(); - headers = curl_slist_append(headers, finalString.c_str()); - LM_T(LmtCoap, ("Got: '%s'", finalString.c_str())); - - // --- Set contents - char* payload = (char*) request->getPayloadCopy(); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (u_int8_t*) payload); - } - - // Set Expect - headers = curl_slist_append(headers, "Expect: "); - - // --- Prepare URL - request->getURI(uriBuffer, COAP_URI_BUFFER_SIZE, &recvURILen); - char url[strlen(host) + recvURILen + 1]; - strncpy(url, host, strlen(host)); - if (recvURILen > 0) - strncat(url, uriBuffer, recvURILen); - url[strlen(host) + recvURILen] = '\0'; - LM_T(LmtCoap, ("URL: '%s'", url)); - - // --- Prepare CURL handle with obtained options - curl_easy_setopt(curl, CURLOPT_URL, url); - curl_easy_setopt(curl, CURLOPT_PORT, port); - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); // Allow redirection (?) - curl_easy_setopt(curl, CURLOPT_HEADER, 1); // Activate include the header in the body output - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); // Put headers in place - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &writeMemoryCallback); // Send data here - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &httpResponse); // Custom data for response handling - - - // --- Do HTTP Request - res = curl_easy_perform(curl); - if (res != CURLE_OK) - { - LM_W(("curl_easy_perform() failed: %s\n", curl_easy_strerror(res))); - - // --- Cleanup curl environment - curl_slist_free_all(headers); - curl_easy_cleanup(curl); - - return ""; - } - - // --- Cleanup curl environment - curl_slist_free_all(headers); - curl_easy_cleanup(curl); - } - - std::string ret; - ret.assign(httpResponse.memory, httpResponse.size); - free(httpResponse.memory); - return ret; -} - diff --git a/archive/proxyCoap/src/app/HttpProxy.h b/archive/proxyCoap/src/app/HttpProxy.h deleted file mode 100644 index 14b9d40350..0000000000 --- a/archive/proxyCoap/src/app/HttpProxy.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef HTTP_PROXY_H -#define HTTP_PROXY_H -/* -* -* 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: TID Developer -*/ -#include "cantcoap.h" -#include "proxyCoap/HttpMessage.h" - -struct MemoryStruct { - char* memory; - size_t size; -}; - -static const int COAP_URI_BUFFER_SIZE = 255; -static const int COAP_BUFFER_SIZE = 1024; - -extern std::string sendHttpRequest(const char* host, unsigned short port, CoapPDU* request); - -#endif // HTTP_PROXY_H diff --git a/archive/proxyCoap/src/app/proxyCoap.cpp b/archive/proxyCoap/src/app/proxyCoap.cpp deleted file mode 100644 index 3d4b34be8c..0000000000 --- a/archive/proxyCoap/src/app/proxyCoap.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* -* -* Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: TID Developer -*/ - -#include -#include -#include -#include -#include -#include // getppid, for, setuid, etc. -#include // open -#include -#include -#include -#include - -#include "parseArgs/parseArgs.h" -#include "parseArgs/paConfig.h" -#include "parseArgs/paBuiltin.h" -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "rest/rest.h" - -#include "common/sem.h" -#include "common/globals.h" -#include "common/Timer.h" -#include "common/compileInfo.h" - - -#include "common/string.h" - -#include "proxyCoap/CoapController.h" -#include "proxyCoap/version.h" - -/* **************************************************************************** -* -* Option variables -*/ -bool fg; -char bindAddress[MAX_LEN_IP]; -int port; -char cbHost[64]; -int cbPort; -bool useOnlyIPv4; -bool useOnlyIPv6; - -/* **************************************************************************** -* -* parse arguments -*/ -PaArgument paArgs[] = -{ - { "-fg", &fg, "FOREGROUND", PaBool, PaOpt, false, false, true, "don't start as daemon" }, - { "-localIp", bindAddress, "LOCALIP", PaString, PaOpt, _i "0.0.0.0", PaNL, PaNL, "IP to receive new connections" }, - { "-port", &port, "PORT", PaInt, PaOpt, 5683, PaNL, PaNL, "port to receive new connections" }, - - { "-cbHost", cbHost, "FWD_HOST", PaString, PaOpt, _i "localhost", PaNL, PaNL, "host for forwarding CoAP requests" }, - { "-cbPort", &cbPort, "FWD_PORT", PaInt, PaOpt, 1026, 0, 65000, "HTTP port for forwarding CoAP requests" }, - - { "-ipv4", &useOnlyIPv4, "USEIPV4", PaBool, PaOpt, false, false, true, "use ip v4 only" }, - { "-ipv6", &useOnlyIPv6, "USEIPV6", PaBool, PaOpt, false, false, true, "use ip v6 only" }, - - - PA_END_OF_ARGS -}; - -/* **************************************************************************** -* -* sigHandler - -*/ -void sigHandler(int sigNo) -{ - LM_T(LmtPresent, ("In sigHandler - caught signal %d", sigNo)); - - switch (sigNo) - { - case SIGINT: - case SIGTERM: - LM_X(1, ("Received signal %d", sigNo)); - break; - } -} - -const char* description = - "\n" - "proxyCoap version details:\n" - " version: " PROXYCOAP_VERSION"\n" - " git hash: " GIT_HASH "\n" - " compile time: " COMPILE_TIME "\n" - " compiled by: " COMPILED_BY "\n" - " compiled in: " COMPILED_IN "\n"; - - - -/* **************************************************************************** -* -* daemonize - -*/ -void daemonize(void) -{ - pid_t pid; - pid_t sid; - - // already daemon - if (getppid() == 1) - return; - - pid = fork(); - if (pid == -1) - LM_X(1, ("fork: %s", strerror(errno))); - - // Exiting father process - if (pid > 0) - exit(0); - - // Change the file mode mask */ - umask(0); - - // Removing the controlling terminal - sid = setsid(); - if (sid == -1) - LM_X(1, ("setsid: %s", strerror(errno))); - - // Change current working directory. - // This prevents the current directory from being locked; hence not being able to remove it. - if (chdir("/") == -1) - LM_X(1, ("chdir: %s", strerror(errno))); -} - - - -/* **************************************************************************** -* -* main - -*/ -int main(int argC, char* argV[]) -{ - - signal(SIGINT, sigHandler); - signal(SIGTERM, sigHandler); - - paConfig("remove builtin", "-d"); - paConfig("remove builtin", "-r"); - paConfig("remove builtin", "-w"); - paConfig("remove builtin", "-F"); - paConfig("remove builtin", "-B"); - paConfig("remove builtin", "-b"); - paConfig("remove builtin", "-?"); - paConfig("remove builtin", "-toDo"); - paConfig("remove builtin", "-lmnc"); - paConfig("remove builtin", "-lmca"); - paConfig("remove builtin", "-lmkl"); - paConfig("remove builtin", "-lmll"); - paConfig("remove builtin", "-assert"); - paConfig("remove builtin", "-version"); - paConfig("remove builtin", "-h"); - paConfig("remove builtin", "-help"); - - paConfig("man synopsis", (void*) "[options]"); - paConfig("man shortdescription", (void*) "Options:"); - paConfig("man description", (void*) description); - paConfig("man author", (void*) "Telefonica I+D"); - paConfig("man exitstatus", (void*) "proxyCoap is a daemon. If it exits, something is wrong ..."); - paConfig("man version", (void*) PROXYCOAP_VERSION); - paConfig("log to screen", (void*) true); - paConfig("log to file", (void*) true); - paConfig("log file line format", (void*) "TYPE:DATE:EXEC-AUX/FILE[LINE] FUNC: TEXT"); - paConfig("screen line format", (void*) "TYPE@TIME FUNC[LINE]: TEXT"); - paConfig("builtin prefix", (void*) "PROXYCOAP_"); - paConfig("usage and exit on any warning", (void*) true); - - paParse(paArgs, argC, (char**) argV, 1, false); - - if (fg == false) - daemonize(); - - CoapController* cc = new CoapController(bindAddress, cbPort, port); - cc->serve(); -} - diff --git a/archive/proxyCoap/src/app/version.h b/archive/proxyCoap/src/app/version.h deleted file mode 100644 index bb2427fa30..0000000000 --- a/archive/proxyCoap/src/app/version.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef PROXYCOAP_VERSION_H -#define PROXYCOAP_VERSION_H - -/* -* -* 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: TID Developer -*/ - - - -#define PROXYCOAP_VERSION "0.0.1-beta" - -#endif diff --git a/archive/proxyCoap/testEnv_coap.sh b/archive/proxyCoap/testEnv_coap.sh deleted file mode 100644 index ad37b76e29..0000000000 --- a/archive/proxyCoap/testEnv_coap.sh +++ /dev/null @@ -1,27 +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 -# -# -# In order to "recover" the following functions, they should be moved back -# to testEnv.sh file - -# o COAP_PORT - port where proxyCoap listens for connections - -export COAP_PORT=${COAP_PORT:-5683} diff --git a/archive/vagrant/Vagrantfile b/archive/vagrant/Vagrantfile deleted file mode 100644 index 645776fd27..0000000000 --- a/archive/vagrant/Vagrantfile +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es -# -# Author: Leandro Guillen - -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - # For a complete reference, please see the online documentation at vagrantup.com. - - # Cent OS 6.5 base image - config.vm.box = "chef/centos-6.5" - - # This script will be run at startup - config.vm.provision :shell, path: "../../scripts/bootstrap/centos65.sh" - - # Network configuration - config.vm.network "forwarded_port", host: 1026, guest: 1026 # Orion port - -end diff --git a/archive/vagrant/doc/manuals/vagrant.md b/archive/vagrant/doc/manuals/vagrant.md deleted file mode 100644 index 3b83c99e82..0000000000 --- a/archive/vagrant/doc/manuals/vagrant.md +++ /dev/null @@ -1,28 +0,0 @@ -## Vagrant support -If you want yo have an Orion Context Broker ready to develop in your machine easily we provide a Vagrant file so that you can get up and running. Just run: - - vagrant up - -You just need to install Vagrant if you want to use this, and at least Virtualbox. Especially useful for those that use virtual machines to develop on a Mac or a Linux distribution that is not CentOS. Keep in mind that the Vagrant file specifies CentOS 6.5 as a base operating system. - -For example, to compile in debug mode and install it in the home directory simply run: - - vagrant ssh -c 'INSTALL_DIR=/home/vagrant make di -C fiware-orion' - -After a few minutes you can run contextBroker. Again, you can either ssh into the machine with - - vagrant ssh - -and run it from the command-line, or directly run the broker with something like - - vagrant ssh -c 'contextBroker -multiservice -t 0-255' - -Orion Context Broker will be accessible at `127.0.0.1:1026`. - -You can also use these commands to automate building and running from your favorite IDE. - -*NOTE:* The virtualbox machine that is created uses additional resources to those from the broker itself. It uses around 512 MiB of RAM and around 1.20 GiB of disk space with Orion already compiled in debug mode. - - - -The bootstrap script basically goes through the installation instructions in the README. \ No newline at end of file diff --git a/archive/xml/README.md b/archive/xml/README.md deleted file mode 100644 index 13c313595b..0000000000 --- a/archive/xml/README.md +++ /dev/null @@ -1,102 +0,0 @@ -Old versions of Orion (0.28.0 and before) supported XML. This directory contains some stuff -related with that functionality that is not longer needed. - -In particular, the xmlCheck checker (which was used to check that XML in unittest testData/ -and test harness fragments were compliant with NGSI XSD). - -In addition, the following XML-based unit tests were removed. If you want to have a look to them, -have a look at code just before merging PR #2104 (this is the commit number: -https://github.com/telefonicaid/fiware-orion/commit/d6969490c8db77b2147fccbd986aab49303b5e8c). - -Deleted files containing only XML-based unit tests: - -* serviceRoutines/badNgsi10Request_test.cpp -* serviceRoutines/badNgsi9Request_test.cpp -* serviceRoutines/badRequest_test.cpp -* serviceRoutines/deleteAttributeValueInstance_test.cpp -* serviceRoutines/deleteIndividualContextEntityAttribute_test.cpp -* serviceRoutines/deleteIndividualContextEntity_test.cpp -* serviceRoutines/getAttributeValueInstance_test.cpp -* serviceRoutines/getContextEntitiesByEntityId_test.cpp -* serviceRoutines/getContextEntityAttributes_test.cpp -* serviceRoutines/getContextEntityTypeAttributeContainer_test.cpp -* serviceRoutines/getContextEntityTypeAttribute_test.cpp -* serviceRoutines/getContextEntityTypes_test.cpp -* serviceRoutines/getEntityByIdAttributeByName_test.cpp -* serviceRoutines/getIndividualContextEntityAttribute_test.cpp -* serviceRoutines/getIndividualContextEntity_test.cpp -* serviceRoutines/getNgsi10ContextEntityTypesAttribute_test.cpp -* serviceRoutines/getNgsi10ContextEntityTypes_test.cpp -* serviceRoutines/leakTreat_test.cpp -* serviceRoutines/logTraceTreat_test.cpp -* serviceRoutines/postContextEntitiesByEntityId_test.cpp -* serviceRoutines/postContextEntityAttributes_test.cpp -* serviceRoutines/postContextEntityTypeAttributeContainer_test.cpp -* serviceRoutines/postContextEntityTypeAttribute_test.cpp -* serviceRoutines/postContextEntityTypes_test.cpp -* serviceRoutines/postDiscoverContextAvailability_test.cpp -* serviceRoutines/postEntityByIdAttributeByName_test.cpp -* serviceRoutines/postIndividualContextEntityAttribute_test.cpp -* serviceRoutines/postIndividualContextEntity_test.cpp -* serviceRoutines/postQueryContext_test.cpp -* serviceRoutines/postRegisterContext_test.cpp -* serviceRoutines/postSubscribeContextAvailability_test.cpp -* serviceRoutines/postSubscribeContext_test.cpp -* serviceRoutines/postUnsubscribeContextAvailability_test.cpp -* serviceRoutines/postUnsubscribeContext_test.cpp -* serviceRoutines/postUpdateContextAvailabilitySubscription_test.cpp -* serviceRoutines/postUpdateContextSubscription_test.cpp -* serviceRoutines/postUpdateContext_test.cpp -* serviceRoutines/putAttributeValueInstance_test.cpp -* serviceRoutines/putIndividualContextEntity_test.cpp - -The following XML-based test were also removed (most of them were in DISABLED -state just before removing it): - -* TEST(compoundValue, DISABLED_updateContextValueVectorFiveItemsPlusBadOne) -* TEST(DiscoverContextAvailabilityRequest, DISABLED_entityIdIdAsAttribute_xml) -* TEST(DiscoverContextAvailabilityRequest, DISABLED_entityIdIsPattern_xml) -* TEST(DiscoverContextAvailabilityRequest, DISABLED_entityIdTypeAsField_xml) -* TEST(DiscoverContextAvailabilityRequest, DISABLED_entityIdType_xml) -* TEST(NotifyContextAvailabilityRequest, DISABLED_badEntityAttribute_xml) -* TEST(NotifyContextRequest, DISABLED_predetectedError) -* TEST(NotifyContextRequest, DISABLED_xml_invalidEntityIdAttribute) -* TEST(QueryContextRequest, DISABLED_emptyEntityList_xml) -* TEST(QueryContextRequest, DISABLED_emptyScopeType_xml) -* TEST(QueryContextRequest, DISABLED_emptyScopeValue_xml) -* TEST(QueryContextRequest, DISABLED_entityIdIdAsAttribute_xml) -* TEST(QueryContextRequest, DISABLED_entityIdIsPattern_xml) -* TEST(QueryContextRequest, DISABLED_entityIdType_xml) -* TEST(QueryContextRequest, DISABLED_fill) -* TEST(QueryContextRequest, DISABLED_noAttributeExpression_xml) -* TEST(QueryContextRequest, DISABLED_noEntityList_xml) -* TEST(QueryContextRequest, DISABLED_noRestriction_xml) -* TEST(QueryContextRequest, DISABLED_noScopeType_xml) -* TEST(QueryContextRequest, DISABLED_noScopeValue_xml) -* TEST(QueryContextRequest, DISABLED_overwriteEntityIdIsPattern_xml) -* TEST(QueryContextRequest, DISABLED_overwriteEntityIdType_xml) -* TEST(QueryContextRequest, DISABLED_unsupportedEntityIdAttribute_xml) -* TEST(QueryContextRequest, emptyEntityIdId_xml) -* TEST(QueryContextResponse, DISABLED_ok_xml) -* TEST(RegisterContextRequest, DISABLED_durationError) -* TEST(RegisterContextRequest, DISABLED_emptyContextMetadataName) -* TEST(RegisterContextRequest, DISABLED_emptyContextMetadataValue) -* TEST(RegisterContextRequest, DISABLED_emptyContextRegistration) -* TEST(RegisterContextRequest, DISABLED_emptyContextRegistrationAttributeIsDomain) -* TEST(RegisterContextRequest, DISABLED_emptyContextRegistrationAttributeName) -* TEST(RegisterContextRequest, DISABLED_emptyEntityIdList) -* TEST(RegisterContextRequest, DISABLED_emptyRegistrationMetadataValue) -* TEST(RegisterContextRequest, DISABLED_entityIdWithEmptyId) -* TEST(RegisterContextRequest, DISABLED_entityIdWithNoId) -* TEST(RegisterContextRequest, DISABLED_invalidAttributeName) -* TEST(RegisterContextRequest, DISABLED_noEntityIdList) -* TEST(RegisterContextRequest, DISABLED_present) -* TEST(restReply, DISABLED_restErrorReplyGet) -* TEST(SubscribeContextAvailabilityRequest, DISABLD_xml_noReference) -* TEST(SubscribeContextAvailabilityRequest, DISABLED_xml_badEntityId) -* TEST(SubscribeContextAvailabilityRequest, DISABLED_xml_entityIdIsPatternAsBothFieldAndAttribute) -* TEST(SubscribeContextAvailabilityRequest, DISABLED_xml_entityIdTypeAsBothFieldAndAttribute) -* TEST(SubscribeContextRequest, DISABLED_invalidEntityIdAttribute_xml) -* TEST(UpdateContextAvailabilitySubscriptionRequest, DISABLED_xml_invalidEntityAttribute) -* TEST(UpdateContextResponse, DISABLED_constructors) -* TEST(UpdateContextSubscriptionResponse, DISABLED_constructors) diff --git a/archive/xml/xmlCheck/envVarSubstitute.sh b/archive/xml/xmlCheck/envVarSubstitute.sh deleted file mode 100755 index 9d03f02c9f..0000000000 --- a/archive/xml/xmlCheck/envVarSubstitute.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash -# Copyright 2013 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 - - - -# ----------------------------------------------------------------------------- -# -# usage -# -function usage() -{ - exitCode=$1 - - spaces=$(echo $0 | tr '0-9a-zA-Z /_.\-' ' ') - - echo $0 "[-u (usage)]" - echo "${spaces} [-v (verbose)]" - echo "${spaces} -f " - - exit $exitCode -} - - - -# ----------------------------------------------------------------------------- -# -# vMsg -# -function vMsg() -{ - if [ "$verbose" = "on" ] - then - echo $* - fi -} - - - -# ------------------------------------------------------------------------------ -# -# command line options -# -verbose="off" -file="" - -while [ "$#" != 0 ] -do - if [ "$1" == "-u" ]; then usage 0; - elif [ "$1" == "-v" ]; then verbose=on; - elif [ "$1" == "-f" ]; then file=$2; shift; - else - echo $0: bad parameter/option: "'"${1}"'" - usage 1 - fi - shift -done - -if [ "$file" == "" ] -then - echo $0: no file specified - exit 2 -fi - - - -# ------------------------------------------------------------------------------ -# -# Just substitute -# -vMsg $file to get variable substitution -unsubstituted=$(cat $file) -vMsg unsubstituted: -vMsg '----------------------------------' -vMsg $unsubstituted -vMsg '----------------------------------' - -substituted1=$(echo $unsubstituted | sed 's/\$SUB_ID/123456789012345678901234/g') -substituted2=$(echo $substituted1 | sed 's/\$SUBID/123456789012345678901234/g') -substituted3=$(echo $substituted2 | sed 's/\${LISTENER_PORT}/9999/g') -substituted4=$(echo $substituted3 | sed 's/\$subscriptionId/123456789012345678901234/g') -substituted5=$(echo $substituted4 | sed 's/\$REG_ID/123456789012345678901234/g') - -substituted=$substituted5 - -vMsg -vMsg '----------------------------------' -vMsg $substituted -vMsg '----------------------------------' - -echo "$substituted" > ${file} diff --git a/archive/xml/xmlCheck/xmlCheck.sh b/archive/xml/xmlCheck/xmlCheck.sh deleted file mode 100755 index 46252d1083..0000000000 --- a/archive/xml/xmlCheck/xmlCheck.sh +++ /dev/null @@ -1,560 +0,0 @@ -#!/bin/bash -# Copyright 2013 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 - - - -# ----------------------------------------------------------------------------- -# -# usage -# -function usage() -{ - exitCode=$1 - - spaces=$(echo $0 | tr '0-9a-zA-Z /_.\-' ' ') - - echo $0 "[-u (usage)]" - echo "${spaces} [-v (verbose)]" - echo "${spaces} [-f (file to check)]" - echo "${spaces} [--filter (test filter)]" - echo "${spaces} [--no-harness (no harness files)]" - echo "${spaces} [--dryrun (don't actually execute anything)]" - echo "${spaces} [--keep (do NOT remove harness files at end of processing)]" - echo "${spaces} [--xsd-download (download XSD files for FIWARE subversion)]" - echo "${spaces} [--xsd-dir (directory for XSD files)]" - - exit $exitCode -} - - - -# ----------------------------------------------------------------------------- -# -# vMsg -# -function vMsg() -{ - if [ "$verbose" = "on" ] - then - echo $* - fi -} - - - -# ------------------------------------------------------------------------------ -# -# xsdGet - -# -function xsdGet() -{ - prefix="$1" - xfile="$2" - - if [ "$prefix" = "ngsi9" ] - then - echo $xsdDir/Ngsi9_Operations.xsd - elif [ "$prefix" == "ngsi10" ] - then - echo $xsdDir/Ngsi10_Operations.xsd - elif [ "$prefix" == "ngsi" ] - then - echo $xsdDir/Ngsi9_10_dataStructures.xsd - else - echo "unknown file prefix: '"${prefix}"' for $xfile" - exit 2 - fi -} - - - -# ------------------------------------------------------------------------------ -# -# processFile - -# -function processFile() -{ - xmlFile=$1 - xsdFile=$2 - - if [ "$xmlFile" == "" ] || [ "$xsdFile" == "" ] - then - echo "bad parameters for file processing '"${xmlFile}"', '"${xsdFile}"'" - return; - fi - - N=$N+1 - - if [ "$dryrun" == "on" ] - then - vMsg dryrun: xmllint "$xmlFile" --schema "$xsdFile" - return - fi - - vMsg XSD: $xsdFile - if [ "$verbose2" == "on" ] - then - xmllint $xmlFile --schema $xsdFile - RESULT=$? - else - xmllint $xmlFile --schema $xsdFile > /dev/null 2>&1 - RESULT=$? - fi - - if [ "$RESULT" == "0" ] - then - echo "$xmlFile: ok" - OK=$OK+1 - else - echo "$xmlFile: FAILS (xmllint error: $RESULT)" - ERR=$ERR+1 - failingList=${failingList}" "$xmlFile - fi -} - - - -# ----------------------------------------------------------------------------- -# -# harnessFiles - -# -function harnessFiles() -{ - harnessList="" - TMP_DIR=$(mktemp -d /tmp/xmlCheck.XXXXX) - vMsg TMP_DIR: $TMP_DIR - for FILE in $(find $SRC_TOP/test/functionalTest/cases -name *.test) - do - PREFIX=$(basename ${FILE%.*}) - FILE_DIR=$(dirname $FILE) - LAST_SUBDIR=$(basename $FILE_DIR) - mkdir -p $TMP_DIR/$LAST_SUBDIR - $SRC_TOP/test/xmlCheck/xmlExtractor.py $FILE $TMP_DIR/$LAST_SUBDIR $PREFIX - done - - for FILE in $(find $TMP_DIR -name ngsi*.valid.xml) - do - grep '\$' $FILE - if [ "$?" != "0" ] - then - continue - fi - - $SRC_TOP/test/xmlCheck/envVarSubstitute.sh -f "$FILE" - done - - harnessList=$(find $TMP_DIR -name "ngsi*.valid.xml") - xmlPartsFound=$(find $TMP_DIR -name "ngsi*.xml" | wc -l) - xmlPartsValid=$(find $TMP_DIR -name "ngsi*.valid.xml" | wc -l) - xmlPartsInvalid=$(find $TMP_DIR -name "ngsi*.invalid.xml" | wc -l) - xmlPartsPostponed=$(find $TMP_DIR -name "ngsi*.postponed.xml" | wc -l) - xmlPartsUnknown=$(find $TMP_DIR -name "unknown*.xml" | wc -l) -} - - - -# ------------------------------------------------------------------------------ -# -# command line options -# -verbose="off" -filter="" -file="" -xsdDir="/tmp/xsd" -harness="on" -dryrun="off" -xsdDownload="off" -keep="off" - -while [ "$#" != 0 ] -do - if [ "$1" == "-u" ]; then usage 0; - elif [ "$1" == "-v" ]; then verbose=on; - elif [ "$1" == "-f" ]; then file=$2; shift; - elif [ "$1" == "--filter" ]; then filter=$2; shift; - elif [ "$1" == "--no-harness" ]; then harness="off"; - elif [ "$1" == "--dryrun" ]; then dryrun="on"; - elif [ "$1" == "--keep" ]; then keep="on"; - elif [ "$1" == "--xsd-download" ]; then xsdDownload="on"; - elif [ "$1" == "--xsd-dir" ]; then xsdDir=$2; shift; - else - echo $0: bad parameter/option: "'"${1}"'" - usage 1 - fi - shift -done - - - -# ----------------------------------------------------------------------------- -# -# SRC_TOP - getting the TOP directory -# -dir=$(dirname $0) -SRC_TOP1=${PWD}/${dir}/../.. # if called with a relative path -SRC_TOP2=${dir}/../.. # if called via $PATH or with an absolute path -if [ -d ${SRC_TOP1} ] -then - SRC_TOP=${SRC_TOP1} -else - SRC_TOP=${SRC_TOP2} -fi - -cd $SRC_TOP -SRC_TOP=$(pwd) -cd - > /dev/null -vMsg Git repo home: $SRC_TOP - - - -# ----------------------------------------------------------------------------- -# -# Checking the XSD directory -# -if [ ! -d "$xsdDir" ] -then - echo "$0: error: '"${xsdDir}"': no such directory" - exit 3 -fi - - - - -# ------------------------------------------------------------------------------ -# -# Download XSD files from FIWARE repo? -# -if [ "$xsdDownload" == "on" ] -then - # Get the .xsd files - echo -n "Enter username: " - read USER - - echo -n "Enter password: " - STTY_ORIG=`stty -g` - stty -echo - read PASS - stty $STTY_ORIG - echo - - \rm Ngsi10_Operations.xsd Ngsi9_Operations.xsd Ngsi9_10_dataStructures.xsd 2> /dev/null - wget -q --no-check-certificate --user=$USER --password=$PASS https://forge.fiware.org/scmrepos/svn/iot/trunk/schemes/Ngsi10_Operations.xsd - wget -q --no-check-certificate --user=$USER --password=$PASS https://forge.fiware.org/scmrepos/svn/iot/trunk/schemes/Ngsi9_Operations.xsd - wget -q --no-check-certificate --user=$USER --password=$PASS https://forge.fiware.org/scmrepos/svn/iot/trunk/schemes/Ngsi9_10_dataStructures.xsd - - if [ ! -f Ngsi10_Operations.xsd ] || [ ! -f Ngsi9_Operations.xsd ] || [ ! -f Ngsi9_10_dataStructures.xsd ] - then - echo $0: error: wget failed to download latest XSD files - exit 4 - fi - - mv Ngsi10_Operations.xsd Ngsi9_Operations.xsd Ngsi9_10_dataStructures.xsd $xsdDir - - vMsg "got XSD files" -fi - - - -# ------------------------------------------------------------------------------ -# -# XSD files there? -# -if [ ! -f $xsdDir/Ngsi10_Operations.xsd ] || [ ! -f $xsdDir/Ngsi9_Operations.xsd ] || [ ! -f $xsdDir/Ngsi9_10_dataStructures.xsd ] -then - echo "$0: error: XSD files missing in $xsdDir" - exit 5 -fi - - - -# ------------------------------------------------------------------------------ -# -# variables -# -typeset -i N -typeset -i OK -typeset -i ERR -N=0 -OK=0 -ERR=0 - - - -# ----------------------------------------------------------------------------- -# -# Setting up the file list -# -if [ "$file" != "" ] -then - fileList=$file - verbose2=on -else - if [ "$harness" == "on" ] - then - harnessFiles - fi - - ngsi9List=$(find $SRC_TOP/test -name "ngsi9.*.valid.xml") - ngsi10List=$(find $SRC_TOP/test -name "ngsi10.*.valid.xml") - fileList=${ngsi9List}" "${ngsi10List} - partList=$harnessList -fi - - - -# ------------------------------------------------------------------------------ -# -# Counters -# -typeset -i xmlFilesFound # Total number of XML files under test/ -typeset -i xmlFilesValid # Number of XML files that are valid -typeset -i xmlFilesInvalid # Number of XML files that are invalid -typeset -i xmlFilesPostponed # Number of XML files that are postponed -typeset -i xmlFilesBadName # Number of XML files whose names don't follow the naming convention - should be zero -typeset -i xmlFilesProcessed # Total number of XML files that were tested -typeset -i xmlFilesOK # Number of XML files that passed the test -typeset -i xmlFilesErrors # Number of XML files that did not pass the test - -typeset -i harnessFilesFound # Number of files in the harness directory - to part in many XML files -typeset -i xmlPartsFound # Number of XML parts created from harness directory -typeset -i xmlPartsValid # Number of XML parts that are valid -typeset -i xmlPartsInvalid # Number of XML parts that are invalid -typeset -i xmlPartsPostponed # Number of XML parts that are postponed -typeset -i xmlPartsUnknown # Number of XML parts that are unknown -typeset -i xmlPartsProcessed # Number of XML parts that were tested -typeset -i xmlPartsOK # Number of XML parts that passed the test -typeset -i xmlPartsErrors # Number of XML parts that did not pass the test -typeset -i xmlDocsFound # xmlFilesFound + xmlPartsFound -typeset -i xmlDocsProcessed # xmlFilesProcessed + xmlPartsProcessed -typeset -i xmlDocsPostponed # xmlFilesPostponed + xmlPartsPostponed -typeset -i xmlDocsOk # xmlFilesOK + xmlPartsOK -typeset -i xmlDocsErrors # xmlFilesErrors + xmlPartsErrors - -xmlFilesFound=$(find $SRC_TOP/test -name "*.xml" | wc -l) -xmlFilesValid=$(find $SRC_TOP/test -name "ngsi*.valid.xml" | wc -l) -xmlFilesInvalid=$(find $SRC_TOP/test -name "ngsi*.invalid.xml" | wc -l) -xmlFilesPostponed=$(find $SRC_TOP/test -name "ngsi*.postponed.xml" | wc -l) -xmlFilesMiddle=$(find $SRC_TOP/test -name "ngsi*.middle.xml" | wc -l) -xmlFilesOrion=$(find $SRC_TOP/test -name "orion.*.xml" | wc -l) -xmlFilesBadName=$(find $SRC_TOP/test -name "*.xml" | egrep -v 'ngsi.*\.valid\.xml' | egrep -v 'ngsi.*\.invalid\.xml' | egrep -v 'ngsi.*\.postponed\.xml' | egrep -v 'ngsi.*\.middle\.xml' | egrep -v 'orion\..*\.xml' | wc -l) -xmlFilesProcessed=0 -xmlFilesOK=0 -xmlFilesErrors=0 -harnessFilesFound=$(find $SRC_TOP/test/functionalTest/cases -name "*.test" | wc -l) -xmlPartsFound=$xmlPartsFound # already taken care of by function 'harnessFiles' -xmlPartsValid=$xmlPartsValid # already taken care of by function 'harnessFiles' -xmlPartsInvalid=$xmlPartsInvalid # already taken care of by function 'harnessFiles' -xmlPartsPostponed=$xmlPartsPostponed # already taken care of by function 'harnessFiles' -xmlPartsUnknown=$xmlPartsUnknown # already taken care of by function 'harnessFiles' -xmlPartsProcessed=0 -xmlPartsOK=0 -xmlPartsErrors=0 -xmlDocsFound=$(expr $xmlFilesFound + $xmlPartsFound) -xmlDocsProcessed=0 -xmlDocsOk=0 -xmlDocsErrors=0 - - - -# ------------------------------------------------------------------------------ -# -# Applying filter to the file lists -# -if [ "$filter" != "" ] -then - vMsg appying filter "'"${filter}"'" - newFileList="" - for xfile in $fileList - do - echo $xfile | grep "$filter" > /dev/null 2>&1 - if [ "$?" == 0 ] - then - newFileList=${newFileList}" "${xfile} - xmlFilesProcessed=$xmlFilesProcessed+1 - fi - done - fileList=$newFileList - - newPartList="" - for part in $partList - do - echo $part | grep "$filter" > /dev/null 2>&1 - if [ "$?" == 0 ] - then - newPartList=${newPartList}" "${part} - xmlPartsProcessed=$xmlPartsProcessed+1 - fi - done - partList=$newPartList -fi - - - -# ------------------------------------------------------------------------------ -# -# process the list of files to check -# -OK=0 -ERR=0 -N=0 -for xfile in $fileList -do - fileName=$(basename $xfile) - prefix=$(echo $fileName | cut -d . -f 1) - xsd=$(xsdGet "$prefix" "$xfile") - processFile "$xfile" "$xsd" -done - -xmlFilesProcessed=$N -xmlFilesOK=$OK; -xmlFilesErrors=$ERR - - - -# ------------------------------------------------------------------------------ -# -# process the list of parts to check -# -OK=0 -ERR=0 -N=0 -for part in $partList -do - partName=$(basename $part) - prefix=$(echo $partName | cut -d . -f 1) - xsd=$(xsdGet "$prefix" "$part") - processFile "$part" "$xsd" -done - -xmlPartsProcessed=$N -xmlPartsOK=$OK; -xmlPartsErrors=$ERR - - -xmlDocsProcessed=$(expr $xmlFilesProcessed + $xmlPartsProcessed) -xmlDocsOk=$(expr $xmlFilesOK + $xmlPartsOK) -xmlDocsErrors=$(expr $xmlFilesErrors + $xmlPartsErrors) - - - - - -# ------------------------------------------------------------------------------ -# -# Statistics not shown if the option '-f' is set -# -if [ "$file" != "" ] -then - if [ "$ERR" != "0" ] - then - exit 6 - else - exit 0 - fi -fi - - - -# ------------------------------------------------------------------------------ -# -# Statistics -# -echo "=====================================================================" -if [ "$xmlDocsErrors" != "0" ] -then - echo - echo "XML docs that did not pass the XML Validity test:" - - for item in $failingList - do - echo " o " $item - done - - echo - echo "=====================================================================" -fi - - -echo "Tested ${xmlDocsProcessed} (${xmlFilesProcessed} files + ${xmlPartsProcessed} parts) out of ${xmlDocsFound} (${xmlFilesFound} files + ${xmlPartsFound} parts) XML documents:" -echo " ${xmlDocsOk} documents passed the XML validity test" - -exitCode=7 - -if [ "$xmlDocsErrors" != 0 ] -then - echo " ${xmlDocsErrors} documents did not pass" -else - echo " -----------------------" - echo " ALL documents passed!!!" - echo " -----------------------" - exitCode=0 -fi - -echo -echo "${xmlFilesInvalid} documents were not tested as they on purpose don't follow the XSD" -xmlDocsPostponed=$xmlFilesPostponed+$xmlPartsPostponed -echo "${xmlDocsPostponed} documents were not tested as they still have no XSD" -echo "${xmlFilesMiddle} documents were not tested as they don't start the way the XSD states (middle)" - - -if [ "$xmlFilesBadName" != 0 ] -then - echo - if [ "$xmlFilesBadName" != "0" ] - then - echo "WARNING: $xmlFilesBadName XML files do not conform to the naming convention" - for xfile in $(find $SRC_TOP/test -name "*.xml" | grep -v "ngsi*.valid.xml" | grep -v "ngsi*.invalid.xml" | grep -v "ngsi*.postponed.xml" | grep -v "ngsi*.middle.xml" | grep -v "orion.*.xml") - do - echo " o $xfile" - done - fi - exitCode=8 -fi - - -if [ "$xmlPartsUnknown" != 0 ] -then - echo - echo "WARNING: parts marked as unknown" - for xfile in $(find $TMP_DIR -name "unknown*.xml") - do - echo " o $xfile" - done - exitCode=9 -fi - - - -# ------------------------------------------------------------------------------ -# -# Keep? -# -if [ "$keep" == "off" ] -then - rm -rf $TMP_DIR -fi - -if [ "$exitCode" != "0" ] -then - echo exiting with error code $exitCode -fi - -exit $exitCode diff --git a/archive/xml/xmlCheck/xmlExtractor.py b/archive/xml/xmlCheck/xmlExtractor.py deleted file mode 100755 index f924d4f612..0000000000 --- a/archive/xml/xmlCheck/xmlExtractor.py +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/python -# -*- coding: latin-1 -*- -# Copyright 2013 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 - -# This script extract XML fragments of a given file (passed as first arguments), -# each fragment put in a separate file in a given directory (passed as second argument). -# This is mainly aimed at processing test harness files (.test files) to pass the -# xmlCheck.sh on then afterwards. Note that the heuristic used by the script is not -# bullet-proof: it assumes that the starting and ending tag of the root element is -# in its own line, without other child starting or ending tags (but it should suffice -# for .test files) - -__author__ = 'fermin' - -from sys import argv -import re - -def write_fragment(lines, filename): - f = open(filename, 'w') - f.writelines(lines) - f.close() - -tokens_map = { - # NGSI9 standard operations - 'registerContextRequest': ['ngsi9', 'valid'], - 'registerContextResponse': ['ngsi9', 'valid'], - 'discoverContextAvailabilityRequest': ['ngsi9', 'valid'], - 'discoverContextAvailabilityResponse': ['ngsi9', 'valid'], - 'subscribeContextAvailabilityRequest': ['ngsi9', 'valid'], - 'subscribeContextAvailabilityResponse': ['ngsi9', 'valid'], - 'updateContextAvailabilitySubscriptionRequest': ['ngsi9', 'valid'], - 'updateContextAvailabilitySubscriptionResponse': ['ngsi9', 'valid'], - 'unsubscribeContextAvailabilityRequest': ['ngsi9', 'valid'], - 'unsubscribeContextAvailabilityResponse': ['ngsi9', 'valid'], - 'notifyContextAvailabilityRequest': ['ngsi9', 'valid'], - 'notifyContextAvailabilityResponse': ['ngsi9', 'valid'], - # NGSI10 standard operatoins - 'queryContextRequest': ['ngsi10', 'valid'], - 'queryContextResponse': ['ngsi10', 'valid'], - 'updateContextRequest': ['ngsi10', 'valid'], - 'updateContextResponse': ['ngsi10', 'valid'], - 'subscribeContextRequest': ['ngsi10', 'valid'], - 'subscribeContextResponse': ['ngsi10', 'valid'], - 'updateContextSubscriptionRequest': ['ngsi10', 'valid'], - 'updateContextSubscriptionResponse': ['ngsi10', 'valid'], - 'unsubscribeContextRequest': ['ngsi10', 'valid'], - 'unsubscribeContextResponse': ['ngsi10', 'valid'], - 'notifyContextRequest': ['ngsi10', 'valid'], - 'notifyContextResponse': ['ngsi10', 'valid'], - # NGSI convenience operations exclusive types - 'registerProviderRequest': ['ngsi9', 'postponed'], - 'updateContextElementRequest': ['ngsi10', 'postponed'], - 'updateContextElementResponse': ['ngsi10', 'postponed'], - 'appendContextElementRequest': ['ngsi10', 'postponed'], - 'appendContextElementResponse': ['ngsi10', 'postponed'], - 'updateContextAttributeRequest': ['ngsi10', 'postponed'], - 'contextElementResponse': ['ngsi10', 'postponed'], - 'contextAttributeResponse': ['ngsi10', 'postponed'], - 'statusCode': ['ngsi', 'valid'], - # New operations - 'entityTypeAttributesResponse': ['ngsi10', 'postponed'], - 'entityTypesResponse': ['ngsi10', 'postponed'], - # Orion own types - 'orion': ['orion', 'invalid'], - 'orionError': ['orion', 'invalid'] -} - -if len (argv) != 4: - print 'Wrong number of arguments' - print argv[0] + ' ' - exit(1) - -file = str(argv[1]) -dir = str(argv[2]) -base_name = str(argv[3]) - -buffer = [] -xml_headers_counter = 0 -xml_headers_correction = 0 -xml_fragments_counter = 0 -search_mode = True -next_xml_invalid = False -buffer = [] - -with open (file, 'r') as f: - for l in f: - line = l - - if re.search('#SORT_START', line) or re.search('#SORT_END', line): - # Just skip these marks (they must not appear in the XML string) - continue - - if search_mode: - # Search mode is on: looking for a root element or for an 'invalid' - if re.search('<\?xml', line): - xml_headers_counter += 1 - elif re.search('User-Agent:', line): - # Heuristic: each time a User-Agent is detected, then a nofityContextRequest or notifyContextAvailabiltiyRequest - # if found in the .test file. These are fragments of code that comes from accumulator-script.py dumps, outside - # the usual "xmllint decoration" that adds the XML preamble in that case. Thus, we have to count then and apply as - # a correction factor in the warning generation - xml_headers_correction += 1 - elif re.search('#INVALID_XML', line): - next_xml_invalid = True - else: - m = re.match('\s*<(.*)>', line) - if m != None: - xml_fragments_counter += 1 - root_element = m.group(1) - - # Add XML header and root element as first elements of the buffer - buffer.append('\n') - buffer.append(line) - - search_mode = False - - else: - # Search mode is off: accumulate each line until the ending tag is found - # Note we remove any heading or trailing ' or ", that may occur in the - # case of using variables to store XMLs, e.g.: - # - # payload = ' - # - # '" - # ... - # "' - # ... - # ' - # - line = line.rstrip("'\"\n") - line = line.lstrip(" '\"") - - # We have found that strings like "http://localhost:'$CP1_PORT'/v1" that breaks validation, - # as they are not anyURI. In order to fix, we replace the "'$...'" part with a number - line = re.sub("'\$.*PORT.*'", "9999", line) - - # We have found that we cannot use things like 'REGEX((PT5S|PT7S))', given that - # duration uses type xs:duration, which has a predefined sytanx incompatible with REGEX(). Thus, we - # change these cases on the fly - if re.match('\s*', line): - line = re.sub("REGEX\(.*\)", "PT1M", line) - - # Similar case with providingApplication - if re.match('\s*', line): - line = re.sub("REGEX\(.*\)", "9997", line) - - buffer.append(line + "\n") - - if re.search('<\/'+ root_element + '>', line): - # We use some tokens in the filename to help xmlCheck.sh script - if tokens_map.has_key(root_element): - family = tokens_map[root_element][0] - vality = tokens_map[root_element][1] - else: - family = 'unknown' - vality = 'invalid' - - # No matter the result of the map, if the invalid mark was used in the .test, then - # file is alawys marked as 'invalid' - if next_xml_invalid: - vality = 'invalid' - - filename = dir + '/' + family + '.' + base_name + '.part_' + str(xml_fragments_counter) + '.' + vality + '.xml' - - write_fragment(buffer, filename) - buffer = [] - search_mode = True - next_xml_invalid = False - -if xml_headers_counter != xml_fragments_counter - xml_headers_correction: - print 'Warning in ' + base_name + ': XML headers (' + str(xml_headers_counter) + ', correction: ' + str(xml_headers_correction) + ') and ' \ - 'generated fragments (' + str(xml_fragments_counter) + ') differ' From e78c240be99cff6b51de6272e60f70cc5e162e8e 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 15:51:10 +0200 Subject: [PATCH 08/12] FIX to reference presentation and version numbers --- README.md | 2 +- doc/manuals.jp/devel/README.md | 2 +- doc/manuals/devel/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9cfac12e21..2606236355 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ recommended to have a look to the brief ### Introductory presentations - Orion Context Broker - [(en)](https://www.slideshare.net/slideshows/orion-context-broker-introduction-20240227/266516824) + [(en)](https://www.slideshare.net/slideshow/orion-context-broker-introduction-20240604/269503234) [(jp)](https://www.slideshare.net/slideshows/orion-context-broker-introduction-20240227/266517846) - NGSIv2 Overview for Developers That Already Know NGSIv1 [(en)](https://www.slideshare.net/fermingalan/orion-context-broker-ngsiv2-overview-for-developers-that-already-know-ngsiv1-20220523) diff --git a/doc/manuals.jp/devel/README.md b/doc/manuals.jp/devel/README.md index 603da17228..bfbf13e1d1 100644 --- a/doc/manuals.jp/devel/README.md +++ b/doc/manuals.jp/devel/README.md @@ -1,6 +1,6 @@ # 開発マニュアル -*注 : このドキュメントでは、リリース 3.12.x の Orion Context Broker について説明しています。* +*注 : このドキュメントでは、リリース 4.0.x の Orion Context Broker について説明しています。* ## 対象読者 diff --git a/doc/manuals/devel/README.md b/doc/manuals/devel/README.md index 87fc4f4e02..dd6d690c79 100644 --- a/doc/manuals/devel/README.md +++ b/doc/manuals/devel/README.md @@ -1,6 +1,6 @@ # Development Manual -*Note: This document describes Orion Context Broker as of release 3.12.x.* +*Note: This document describes Orion Context Broker as of release 4.0.x.* ## Intended audience The intended audience of this manual is developers that need to understand the internals of the Orion Context Broker From 8a43ab04303ef18e124bf0b4151abb3a67e74b92 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 15:58:10 +0200 Subject: [PATCH 09/12] FIX orion version date --- doc/manuals.jp/deprecated.md | 2 +- doc/manuals/deprecated.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manuals.jp/deprecated.md b/doc/manuals.jp/deprecated.md index 535ebbf998..d535d129c7 100644 --- a/doc/manuals.jp/deprecated.md +++ b/doc/manuals.jp/deprecated.md @@ -8,7 +8,7 @@ 推奨されなくなった機能のリストと、廃止された機能のバージョンは次のとおりです : -* Orion 3.12.0 での CLI パラメータ (および関連する環境変数): `-dbhost`、`-rplSet`、`-dbTimeout`、`-dbuser`、`-dbAuthMech`、`-dbAuthDb`、`-dbSSL`、および `-dbDisableRetryWrites`。MongoDB URI を構築するために必要な情報が必要な場合は、[このセクション](#mapping-to-mongouri-from-old-cli-parameters) をチェックして、代わりに `dbURI` を使用してください (Orion 3.13.0 で削除されました) +* Orion 3.12.0 での CLI パラメータ (および関連する環境変数): `-dbhost`、`-rplSet`、`-dbTimeout`、`-dbuser`、`-dbAuthMech`、`-dbAuthDb`、`-dbSSL`、および `-dbDisableRetryWrites`。MongoDB URI を構築するために必要な情報が必要な場合は、[このセクション](#mapping-to-mongouri-from-old-cli-parameters) をチェックして、代わりに `dbURI` を使用してください (Orion 4.0.0 で削除されました) * Orion 3.10.0 での `geo:point`, `geo:line`, `geo:box` および `geo:polygon` 属性タイプ。代わりに `geo:json` を使用してください * Orion 3.8.0 での `GET /v2` 操作。この操作はかなり役に立たず、実際には使用されません。 * Orion 3.1.0 のサブスクリプションでの初期通知 (`skipInitialNotification` オプションと共に)。(Orion 3.2.0 で削除)。初期通知の diff --git a/doc/manuals/deprecated.md b/doc/manuals/deprecated.md index 5ed729988b..cef27a61bf 100644 --- a/doc/manuals/deprecated.md +++ b/doc/manuals/deprecated.md @@ -17,7 +17,7 @@ A list of deprecated features and the version in which they were deprecated foll * CLI parameters (and associated env vars): `-dbhost`, `-rplSet`, `-dbTimeout`, `-dbuser`, `-dbAuthMech`, `-dbAuthDb`, `-dbSSL` and `-dbDisableRetryWrites` in Orion 3.12.0. Use `dbURI` instead, - checking [this section](#mapping-to-mongouri-from-old-cli-parameters) if you need to know hot to build the MongoDB URI (removed in Orion 3.13.0). + checking [this section](#mapping-to-mongouri-from-old-cli-parameters) if you need to know hot to build the MongoDB URI (removed in Orion 4.0.0). * `geo:point`, `geo:line`, `geo:box` and `geo:polygon` attribute types in Orion 3.10.0. Use `geo:json` instead. * `GET /v2` operation in Orion 3.8.0. This operation is pretty useless and not actually used. * Initial notification in subscriptions (along with `skipInitialNotification` option) in Orion 3.1.0. 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 10/12] 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 11/12] 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 From 5ad0f34e728bc9e8ec1a57a0824ea8c99e8d29ae Mon Sep 17 00:00:00 2001 From: Kazuhito Suda Date: Wed, 5 Jun 2024 17:03:50 +0900 Subject: [PATCH 12/12] (JP) FIX to reference presentation (#4566) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2606236355..c3a2834151 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ recommended to have a look to the brief - Orion Context Broker [(en)](https://www.slideshare.net/slideshow/orion-context-broker-introduction-20240604/269503234) - [(jp)](https://www.slideshare.net/slideshows/orion-context-broker-introduction-20240227/266517846) + [(jp)](https://www.slideshare.net/slideshow/orion-context-broker-introduction-20240605/269515246) - NGSIv2 Overview for Developers That Already Know NGSIv1 [(en)](https://www.slideshare.net/fermingalan/orion-context-broker-ngsiv2-overview-for-developers-that-already-know-ngsiv1-20220523) [(jp)](https://www.slideshare.net/fisuda/orion-context-broker-ngsiv2-overview-for-developers-that-already-know-ngsiv1-20220526)