From 5f517cf223df097fbe801d93b5428c3f5bae6514 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 18 Dec 2024 10:27:07 +0100 Subject: [PATCH 01/12] use options=flowControl when update --- lib/services/ngsi/entities-NGSI-v2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index 4a0d89460..cbcbd9a9f 100644 --- a/lib/services/ngsi/entities-NGSI-v2.js +++ b/lib/services/ngsi/entities-NGSI-v2.js @@ -654,7 +654,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, } } // end for (let measures of originMeasures) - let url = '/v2/op/update'; + let url = '/v2/op/update?options=flowControl'; let options = NGSIUtils.createRequestObject(url, originTypeInformation, token); options.json = payload; @@ -679,7 +679,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, if (!multi) { // recreate options object to use single entity update - url = '/v2/entities?options=upsert'; + url = '/v2/entities?options=upsert,flowControl'; options = NGSIUtils.createRequestObject(url, originTypeInformation, token); delete payload.actionType; From 3c5cf105c3c5f942a4cda77e7ae352de24722901 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 18 Dec 2024 17:17:15 +0100 Subject: [PATCH 02/12] update tests --- .../jexlBasedTransformations-test.js | 78 +++++++++---------- .../contextBrokerOAuthSecurityAccess-test.js | 18 ++--- .../unit/ngsiv2/general/deviceService-test.js | 8 +- .../unit/ngsiv2/general/https-support-test.js | 2 +- .../active-devices-attribute-update-test.js | 4 +- .../ngsiv2/lazyAndCommands/command-test.js | 8 +- .../lazyAndCommands/lazy-devices-test.js | 30 +++---- .../lazyAndCommands/polling-commands-test.js | 16 ++-- .../ngsiv2/ngsiService/active-devices-test.js | 38 ++++----- .../ngsiService/staticAttributes-test.js | 12 +-- test/unit/ngsiv2/plugins/alias-plugin_test.js | 20 ++--- .../unit/ngsiv2/plugins/custom-plugin_test.js | 2 +- .../ngsiv2/plugins/multientity-plugin_test.js | 52 ++++++------- .../provisioning/device-group-api-test.js | 6 +- .../device-provisioning-api_test.js | 20 ++--- ...evice-provisioning-configGroup-api_test.js | 18 ++--- .../provisioning/device-registration_test.js | 6 +- .../listProvisionedDevices-test.js | 8 +- .../provisionDeviceMultientity-test.js | 2 +- .../removeProvisionedDevice-test.js | 6 +- .../updateProvisionedDevices-test.js | 12 +-- 21 files changed, 183 insertions(+), 183 deletions(-) diff --git a/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js b/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js index 9595b0abf..2c984b477 100644 --- a/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +++ b/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js @@ -849,7 +849,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json' ) @@ -882,7 +882,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'testNull1', type: 'testNull', v: { @@ -938,7 +938,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'testNull2', type: 'testNull', z: { @@ -994,7 +994,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'testNullSkip1', type: 'testNullSkip', v: { @@ -1058,7 +1058,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'testNullSkip2', type: 'testNullSkip', z: { @@ -1122,7 +1122,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'testNullExplicit1', type: 'testNullExplicit', c: { @@ -1179,7 +1179,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json' ) @@ -1219,7 +1219,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json' ) @@ -1253,7 +1253,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json' ) @@ -1287,7 +1287,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json' ) @@ -1322,7 +1322,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json' ) @@ -1357,7 +1357,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json' ) @@ -1391,7 +1391,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json' ) @@ -1426,7 +1426,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json' ) @@ -1460,7 +1460,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json' ) @@ -1495,7 +1495,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json' ) @@ -1549,7 +1549,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json' ) @@ -1587,7 +1587,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json' ) @@ -1620,7 +1620,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json' ) @@ -1661,7 +1661,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json' ) @@ -1694,7 +1694,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json' ) @@ -1737,7 +1737,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json' ) @@ -1780,7 +1780,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json' ) @@ -1828,7 +1828,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json' ) @@ -1871,7 +1871,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json' ) @@ -1914,7 +1914,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json' ) @@ -1962,7 +1962,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json' ) @@ -2000,7 +2000,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json' ) @@ -2033,7 +2033,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json' ) @@ -2081,7 +2081,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json' ) @@ -2128,7 +2128,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json' ) @@ -2163,7 +2163,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'nested1', type: 'nestedExpressionsObj', v: { @@ -2206,7 +2206,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'nested2', type: 'nestedExpressionsName', t: { @@ -2253,7 +2253,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'nested3', type: 'nestedExpressionsSkip', prefix: { @@ -2296,7 +2296,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'nestedDirect', type: 'nestedExpressionsDirect', level: { @@ -2343,7 +2343,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'nestedReverse', type: 'nestedExpressionsReverse', level: { @@ -2391,7 +2391,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'nestedAnti', type: 'nestedExpressionsAnti', a: { @@ -2467,7 +2467,7 @@ describe('Java expression language (JEXL) based transformations plugin - Timesta .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json' ) @@ -2508,7 +2508,7 @@ describe('Java expression language (JEXL) based transformations plugin - Timesta .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json' ) diff --git a/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js b/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js index 87f492189..8b2e74a08 100644 --- a/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +++ b/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js @@ -130,7 +130,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') ) .reply(204, {}); @@ -169,7 +169,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') ) .reply(403, {}); @@ -204,7 +204,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ3cHdWclJ3') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') ) .reply(204, {}); @@ -386,7 +386,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') ) .reply(204, {}); @@ -525,7 +525,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider (F .matchHeader('fiware-servicepath', 'electricity') .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext1.json') ) .reply(401, 'Auth-token not found in request header'); @@ -612,7 +612,7 @@ describe( .matchHeader('fiware-servicepath', '/testingPath') .matchHeader('Authorization', 'Bearer c1b752e377680acd1349a3ed59db855a1db07605') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json' ) @@ -624,7 +624,7 @@ describe( .matchHeader('fiware-servicepath', '/testingPath') .matchHeader('Authorization', 'Bearer bbb752e377680acd1349a3ed59db855a1db076aa') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json' ) @@ -739,7 +739,7 @@ describe( .matchHeader('fiware-servicepath', '/testingPath') .matchHeader('authorization', 'Bearer bea752e377680acd1349a3ed59db855a1db07zxc') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext4.json') ) .reply(204, {}); @@ -817,7 +817,7 @@ describe( .matchHeader('fiware-servicepath', '/testingPath') .matchHeader('Authorization', 'Bearer 000210dacf913772606c95dd0b895d5506cbc700') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json' ) diff --git a/test/unit/ngsiv2/general/deviceService-test.js b/test/unit/ngsiv2/general/deviceService-test.js index e42ed3e36..55492ed30 100644 --- a/test/unit/ngsiv2/general/deviceService-test.js +++ b/test/unit/ngsiv2/general/deviceService-test.js @@ -219,7 +219,7 @@ describe('NGSI-v2 - Device Service: utils', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series( @@ -248,7 +248,7 @@ describe('NGSI-v2 - Device Service: utils', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series( @@ -281,7 +281,7 @@ describe('NGSI-v2 - Device Service: utils', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([utils.request.bind(utils.request, groupCreation)], function (error, results) { @@ -314,7 +314,7 @@ describe('NGSI-v2 - Device Service: utils', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([utils.request.bind(utils.request, configGroupCreation)], function (error, results) { diff --git a/test/unit/ngsiv2/general/https-support-test.js b/test/unit/ngsiv2/general/https-support-test.js index d92b9daa9..7fbb6f6cf 100644 --- a/test/unit/ngsiv2/general/https-support-test.js +++ b/test/unit/ngsiv2/general/https-support-test.js @@ -175,7 +175,7 @@ describe('NGSI-v2 - HTTPS support tests', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json' ) diff --git a/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js b/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js index a25cf914b..1e98e22be 100644 --- a/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js @@ -82,7 +82,7 @@ describe('NGSI-v2 - Update attribute functionalities', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentLib.activate(iotAgentConfig, done); @@ -103,7 +103,7 @@ describe('NGSI-v2 - Update attribute functionalities', function () { describe('When a attribute update arrives to the IoT Agent as Context Provider', function () { const options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl', method: 'POST', json: { actionType: 'update', diff --git a/test/unit/ngsiv2/lazyAndCommands/command-test.js b/test/unit/ngsiv2/lazyAndCommands/command-test.js index 51438919a..f8964de32 100644 --- a/test/unit/ngsiv2/lazyAndCommands/command-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/command-test.js @@ -159,7 +159,7 @@ describe('NGSI-v2 - Command functionalities', function () { }); describe('When a command update arrives to the IoT Agent as Context Provider', function () { const options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl', method: 'POST', json: { actionType: 'update', @@ -264,7 +264,7 @@ describe('NGSI-v2 - Command functionalities', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json') ) .reply(204); @@ -288,7 +288,7 @@ describe('NGSI-v2 - Command functionalities', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json') ) .reply(204); @@ -309,7 +309,7 @@ describe('NGSI-v2 - Command functionalities', function () { describe('When a command update with metadata arrives to the IoT Agent as Context Provider', function () { const options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl', method: 'POST', json: { actionType: 'update', diff --git a/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js b/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js index 105726366..2eea25025 100644 --- a/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js @@ -170,7 +170,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { describe('When the IoT Agent receives an update on the device data in JSON format', function () { const options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl', method: 'POST', json: { actionType: 'update', @@ -208,7 +208,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); @@ -279,7 +279,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); @@ -341,7 +341,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series( @@ -414,7 +414,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); @@ -485,7 +485,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device2)], done); @@ -517,7 +517,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { 'internalAttributes', function () { const options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl', method: 'POST', json: { actionType: 'update', @@ -555,7 +555,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device3)], done); @@ -634,7 +634,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .times(3) .reply(204); @@ -717,7 +717,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .times(3) .reply(204); @@ -789,7 +789,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); @@ -852,7 +852,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentLib.activate(iotAgentConfig, done); @@ -917,7 +917,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentLib.activate(iotAgentConfig, done); @@ -984,7 +984,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done); @@ -1052,7 +1052,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentLib.activate(iotAgentConfig, done); diff --git a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js index c3c2f2d4a..cdcccd182 100644 --- a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js @@ -158,7 +158,7 @@ describe('NGSI-v2 - Polling commands', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentLib.activate(iotAgentConfig, done); @@ -180,7 +180,7 @@ describe('NGSI-v2 - Polling commands', function () { describe('When a command update arrives to the IoT Agent for a device with polling', function () { const options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl', method: 'POST', json: { actionType: 'update', @@ -264,7 +264,7 @@ describe('NGSI-v2 - Polling commands', function () { describe('When a command arrives with multiple values in the value field', function () { const options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl', method: 'POST', json: { actionType: 'update', @@ -293,7 +293,7 @@ describe('NGSI-v2 - Polling commands', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json') ) .reply(204); @@ -320,7 +320,7 @@ describe('NGSI-v2 - Polling commands', function () { describe('When a polling command expires', function () { const options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl', method: 'POST', json: { actionType: 'update', @@ -346,7 +346,7 @@ describe('NGSI-v2 - Polling commands', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json' ) @@ -406,7 +406,7 @@ describe('NGSI-v2 - Polling commands expressions', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentConfig.pollingExpiration = 0; @@ -430,7 +430,7 @@ describe('NGSI-v2 - Polling commands expressions', function () { describe('When a command update arrives to the IoT Agent for a device with polling', function () { const options = { - url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update', + url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl', method: 'POST', json: { actionType: 'update', diff --git a/test/unit/ngsiv2/ngsiService/active-devices-test.js b/test/unit/ngsiv2/ngsiService/active-devices-test.js index 090d2d3d1..313352e24 100644 --- a/test/unit/ngsiv2/ngsiService/active-devices-test.js +++ b/test/unit/ngsiv2/ngsiService/active-devices-test.js @@ -239,7 +239,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') ) .reply(204); @@ -283,7 +283,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json') ) .reply(204); @@ -331,7 +331,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json' ) @@ -383,7 +383,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json' ) @@ -475,7 +475,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json' ) @@ -529,7 +529,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json' ) @@ -585,7 +585,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json' ) @@ -639,7 +639,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json' ) @@ -693,7 +693,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') ) .reply( @@ -725,7 +725,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') ) .reply( @@ -754,7 +754,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') ) .reply( @@ -786,7 +786,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext5.json') ) .reply(204); @@ -819,7 +819,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json' ) @@ -854,7 +854,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json' ) @@ -880,7 +880,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json') ) .reply(204); @@ -929,7 +929,7 @@ describe('NGSI-v2 - Active attributes test', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'stupiddevice1', type: 'StupidDevice', meas: { @@ -984,7 +984,7 @@ describe('NGSI-v2 - Active attributes test', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'stupiddevice2', type: 'StupidDevice', meas: { @@ -1031,7 +1031,7 @@ describe('NGSI-v2 - Active attributes test', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'stupiddevice3', type: 'StupidDevice2', meas: { @@ -1071,7 +1071,7 @@ describe('NGSI-v2 - Active attributes test', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext6.json') ) .reply(204); diff --git a/test/unit/ngsiv2/ngsiService/staticAttributes-test.js b/test/unit/ngsiv2/ngsiService/staticAttributes-test.js index 200eddd53..f65b439a3 100644 --- a/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +++ b/test/unit/ngsiv2/ngsiService/staticAttributes-test.js @@ -208,10 +208,10 @@ describe('NGSI-v2 - Static attributes test', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .times(4) .reply(204) - .post('/v2/entities?options=upsert', function (body) { + .post('/v2/entities?options=upsert,flowControl', function (body) { let metadatas = 0; for (const i in body) { if (body[i].metadata) { @@ -258,7 +258,7 @@ describe('NGSI-v2 - Static attributes test', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'light2', type: 'Light_Explicit_True', pressure: { @@ -303,7 +303,7 @@ describe('NGSI-v2 - Static attributes test', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'light2', type: 'Light_Explicit_True', pressure: { @@ -347,7 +347,7 @@ describe('NGSI-v2 - Static attributes test', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'light2', type: 'Light_Explicit_Array', pressure: { @@ -388,7 +388,7 @@ describe('NGSI-v2 - Static attributes test', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert', { + .post('/v2/entities?options=upsert,flowControl', { id: 'light2', type: 'Light_Explicit_Expression', pressure: { diff --git a/test/unit/ngsiv2/plugins/alias-plugin_test.js b/test/unit/ngsiv2/plugins/alias-plugin_test.js index 3c624ab33..be3ea0ae5 100644 --- a/test/unit/ngsiv2/plugins/alias-plugin_test.js +++ b/test/unit/ngsiv2/plugins/alias-plugin_test.js @@ -146,7 +146,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json') ) .reply(204); @@ -176,7 +176,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json') ) .reply(204); @@ -206,7 +206,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json') ) .reply(204); @@ -237,7 +237,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json') ) .reply(204); @@ -268,7 +268,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json') ) .reply(204); @@ -299,7 +299,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json') ) .reply(204); @@ -329,7 +329,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json') ) .reply(204); @@ -360,7 +360,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json') ) .reply(204); @@ -391,7 +391,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json') ) .reply(204); @@ -422,7 +422,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json') ) .reply(204); diff --git a/test/unit/ngsiv2/plugins/custom-plugin_test.js b/test/unit/ngsiv2/plugins/custom-plugin_test.js index 75eed04cf..0fbc7d7a9 100644 --- a/test/unit/ngsiv2/plugins/custom-plugin_test.js +++ b/test/unit/ngsiv2/plugins/custom-plugin_test.js @@ -111,7 +111,7 @@ describe('NGSI-v2 - Custom plugin', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); }); diff --git a/test/unit/ngsiv2/plugins/multientity-plugin_test.js b/test/unit/ngsiv2/plugins/multientity-plugin_test.js index a1c716e96..65793d7b7 100644 --- a/test/unit/ngsiv2/plugins/multientity-plugin_test.js +++ b/test/unit/ngsiv2/plugins/multientity-plugin_test.js @@ -674,7 +674,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json' ) @@ -712,7 +712,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json' ) @@ -744,7 +744,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json' ) @@ -781,7 +781,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json' ) @@ -819,7 +819,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json' ) @@ -862,7 +862,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json' ) @@ -905,7 +905,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json' ) @@ -948,7 +948,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json' ) @@ -996,7 +996,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json' ) @@ -1044,7 +1044,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json' ) @@ -1077,7 +1077,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json' ) @@ -1120,7 +1120,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json' ) @@ -1153,7 +1153,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json' ) @@ -1177,7 +1177,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( // Updated test same case that updateContextMultientityPlugin4.json './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json' @@ -1211,7 +1211,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json' ) @@ -1249,7 +1249,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json' ) @@ -1291,7 +1291,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json' ) @@ -1333,7 +1333,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json' ) @@ -1375,7 +1375,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json' ) @@ -1410,7 +1410,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json' ) @@ -1461,7 +1461,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json' ) @@ -1500,7 +1500,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json' ) @@ -1570,7 +1570,7 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', function (body) { + .post('/v2/op/update?options=flowControl', function (body) { const expectedBody = utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json' ); @@ -1608,7 +1608,7 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/op/update', function (body) { + .post('/v2/op/update?options=flowControl', function (body) { const expectedBody = utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json' ); @@ -1647,7 +1647,7 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/op/update', + '/v2/op/update?options=flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json' ) @@ -1701,7 +1701,7 @@ describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a r .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json' ) diff --git a/test/unit/ngsiv2/provisioning/device-group-api-test.js b/test/unit/ngsiv2/provisioning/device-group-api-test.js index 832837d13..f1c25bcbe 100644 --- a/test/unit/ngsiv2/provisioning/device-group-api-test.js +++ b/test/unit/ngsiv2/provisioning/device-group-api-test.js @@ -519,7 +519,7 @@ describe('NGSI-v2 - Device Group Configuration API', function () { contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); contextBrokerMock @@ -537,7 +537,7 @@ describe('NGSI-v2 - Device Group Configuration API', function () { contextBrokerMock .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series( @@ -1091,7 +1091,7 @@ describe('NGSI-v2 - Device Group Configuration API', function () { .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json') ) .reply(204, {}); diff --git a/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js b/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js index 2ab22b23d..0abd5d645 100644 --- a/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +++ b/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js @@ -74,7 +74,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentLib.clearAll(done); @@ -419,7 +419,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json' ) @@ -491,7 +491,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/' + 'contextRequests/createStaticAttributesProvisionDevice.json' @@ -557,7 +557,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/' + 'contextRequests/createStaticAttributesProvisionDevice.json' @@ -631,7 +631,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/' + 'contextRequests/createStaticAttributesProvisionDevice2.json' @@ -700,7 +700,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json' ) @@ -772,7 +772,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/' + 'contextRequests/createStaticAttributesProvisionDevice3.json' @@ -977,7 +977,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json' ) @@ -986,7 +986,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { contextBrokerMock .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json' ) @@ -1137,7 +1137,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); done(); diff --git a/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js b/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js index 6248ca7dc..0a40a5f76 100644 --- a/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js +++ b/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js @@ -74,7 +74,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentLib.clearAll(done); @@ -420,7 +420,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json' ) @@ -492,7 +492,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/' + 'contextRequests/createStaticAttributesProvisionDevice.json' @@ -558,7 +558,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/' + 'contextRequests/createStaticAttributesProvisionDevice.json' @@ -632,7 +632,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/' + 'contextRequests/createStaticAttributesProvisionDevice2.json' @@ -706,7 +706,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/' + 'contextRequests/createStaticAttributesProvisionDevice3.json' @@ -914,7 +914,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json' ) @@ -923,7 +923,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { contextBrokerMock .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json' ) @@ -1074,7 +1074,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); done(); diff --git a/test/unit/ngsiv2/provisioning/device-registration_test.js b/test/unit/ngsiv2/provisioning/device-registration_test.js index ba881d4ed..d964365b5 100644 --- a/test/unit/ngsiv2/provisioning/device-registration_test.js +++ b/test/unit/ngsiv2/provisioning/device-registration_test.js @@ -215,7 +215,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentLib.activate(iotAgentConfig, function (error) { @@ -321,7 +321,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () { // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock.post('/v2/entities?options=upsert').reply(204); + contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204); contextBrokerMock = nock('http://192.168.1.1:1026') .post('/v2/registrations') @@ -330,7 +330,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () { // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock.post('/v2/entities?options=upsert').reply(204); + contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204); contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d', '').reply(500); diff --git a/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js b/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js index b2e31db77..c5dd6c8cf 100644 --- a/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +++ b/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js @@ -96,7 +96,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock.post('/v2/entities?options=upsert').reply(204); + contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204); contextBrokerMock .post('/v2/registrations') @@ -105,7 +105,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock.post('/v2/entities?options=upsert').reply(204); + contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204); contextBrokerMock .post('/v2/registrations') @@ -114,7 +114,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock.post('/v2/entities?options=upsert').reply(204); + contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204); async.series( [ @@ -308,7 +308,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function // This mock does not check the payload since the aim of the test is not to verify // device provisioning functionality. Appropriate verification is done in tests under // provisioning folder - contextBrokerMock.post('/v2/entities?options=upsert').times(10).reply(204); + contextBrokerMock.post('/v2/entities?options=upsert,flowControl').times(10).reply(204); iotAgentLib.clearAll(function () { async.times(10, createDeviceRequest, function (error, results) { diff --git a/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js b/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js index 3072f7439..d2398bf15 100644 --- a/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +++ b/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js @@ -84,7 +84,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () { .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile( './test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceMultientity.json' ) diff --git a/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js b/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js index 76843db36..821eff0fe 100644 --- a/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +++ b/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js @@ -97,7 +97,7 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); const nockBody2 = utils.readExampleFile( @@ -115,7 +115,7 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); contextBrokerMock @@ -130,7 +130,7 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series( diff --git a/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js b/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js index 81974beaf..6ff3318fc 100644 --- a/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +++ b/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js @@ -107,7 +107,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); const nockBody2 = utils.readExampleFile( @@ -126,7 +126,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); // FIXME: When https://github.com/telefonicaid/fiware-orion/issues/3007 is merged into master branch, @@ -181,7 +181,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') .post( - '/v2/entities?options=upsert', + '/v2/entities?options=upsert,flowControl', utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateProvisionDevice.json') ) .reply(204); @@ -374,7 +374,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); contextBrokerMock @@ -442,7 +442,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); contextBrokerMock @@ -504,7 +504,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([iotAgentLib.clearAll, async.apply(request, provisioning4Options)], done); From 08aaf4f157ca2aa20873765fa35dd8a243946482 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 19 Dec 2024 10:14:06 +0100 Subject: [PATCH 03/12] upgrade tests --- .../general/contextBrokerKeystoneSecurityAccess-test.js | 6 +++--- test/unit/general/deviceService-test.js | 8 ++++---- test/unit/memoryRegistry/deviceRegistryMemory_test.js | 8 ++++---- test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js b/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js index 165333f74..ee08397b0 100644 --- a/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +++ b/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js @@ -128,7 +128,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with Keystone', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('X-Auth-Token', '12345679ABCDEF') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); iotAgentLib.activate(iotAgentConfig, done); }); @@ -165,7 +165,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with Keystone', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('X-Auth-Token', '12345679ABCDEF') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(403, { name: 'ACCESS_FORBIDDEN' }); iotAgentLib.activate(iotAgentConfig, done); @@ -197,7 +197,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with Keystone', functio .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'electricity') .matchHeader('X-Auth-Token', '12345679ABCDEF') - .post('/v2/entities?options=upsert'); + .post('/v2/entities?options=upsert,flowControl'); iotAgentLib.activate(iotAgentConfig, done); }); diff --git a/test/unit/general/deviceService-test.js b/test/unit/general/deviceService-test.js index 3b62b4684..58db3d076 100644 --- a/test/unit/general/deviceService-test.js +++ b/test/unit/general/deviceService-test.js @@ -222,7 +222,7 @@ describe('NGSI-v2 - Device Service: utils', function () { contextBrokerMock .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series( @@ -255,7 +255,7 @@ describe('NGSI-v2 - Device Service: utils', function () { contextBrokerMock .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series( @@ -290,7 +290,7 @@ describe('NGSI-v2 - Device Service: utils', function () { contextBrokerMock .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([request.bind(request, groupCreation)], function (error, results) { @@ -326,7 +326,7 @@ describe('NGSI-v2 - Device Service: utils', function () { contextBrokerMock .matchHeader('fiware-service', 'testservice') .matchHeader('fiware-servicepath', '/testingPath') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); async.series([request.bind(request, configGroupCreation)], function (error, results) { diff --git a/test/unit/memoryRegistry/deviceRegistryMemory_test.js b/test/unit/memoryRegistry/deviceRegistryMemory_test.js index 776ad0f25..642dd2f84 100644 --- a/test/unit/memoryRegistry/deviceRegistryMemory_test.js +++ b/test/unit/memoryRegistry/deviceRegistryMemory_test.js @@ -64,7 +64,7 @@ describe('NGSI-v2 - In memory device registry', function () { describe('When a the registry is queried for a device using an arbitrary attribute', function () { beforeEach(function (done) { contextBrokerMock = nock('http://192.168.1.1:1026') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .times(10) .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') @@ -116,7 +116,7 @@ describe('NGSI-v2 - In memory device registry', function () { describe('When a the registry is queried for devices in multiple services', function () { beforeEach(function (done) { contextBrokerMock = nock('http://192.168.1.1:1026') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .times(10) .reply(204); @@ -159,7 +159,7 @@ describe('NGSI-v2 - In memory device registry', function () { describe('When a the registry is queried for devices in a particular service', function () { beforeEach(function (done) { contextBrokerMock = nock('http://192.168.1.1:1026') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .times(10) .reply(204); @@ -202,7 +202,7 @@ describe('NGSI-v2 - In memory device registry', function () { describe('When a the registry is queried for device in a particular name and type', function () { beforeEach(function (done) { contextBrokerMock = nock('http://192.168.1.1:1026') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .times(10) .reply(204); diff --git a/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js b/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js index 9332f47e5..09ad467fd 100644 --- a/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +++ b/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js @@ -189,7 +189,7 @@ describe('Mixed Mode: ngsiVersion test', function () { nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); request(optionsCreationDefault, function (error, response, body) { @@ -210,7 +210,7 @@ describe('Mixed Mode: ngsiVersion test', function () { nock.cleanAll(); contextBrokerMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') - .post('/v2/entities?options=upsert') + .post('/v2/entities?options=upsert,flowControl') .reply(204); request(optionsCreationV2, function (error, response, body) { @@ -254,10 +254,10 @@ describe('Mixed Mode: ngsiVersion test', function () { // contextBrokerMock = nock('http://192.168.1.1:1026') // .matchHeader('fiware-service', 'smartgondor') // .matchHeader('fiware-servicepath', 'gardens') - // .post('/v2/entities?options=upsert') + // .post('/v2/entities?options=upsert,flowControl') // .reply(204); - // contextBrokerMock = nock('http://192.168.1.1:1026').post('/v2/entities?options=upsert').reply(204); + // contextBrokerMock = nock('http://192.168.1.1:1026').post('/v2/entities?options=upsert,flowControl').reply(204); // request(optionsCreationLD, function (error, response, body) { // request(deviceCreationV2, function (error, response, body) { // done(); From 3d8ef7ea2a7bef3253b276c49cca45df838eac1f Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 19 Dec 2024 10:49:23 +0100 Subject: [PATCH 04/12] Update functional tests --- test/functional/testUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/testUtils.js b/test/functional/testUtils.js index 495e8d470..6bf772a49 100644 --- a/test/functional/testUtils.js +++ b/test/functional/testUtils.js @@ -204,9 +204,9 @@ async function testCase(measure, expectation, provision, env, config, type, tran let cbMockRoute = ''; // Set the correct route depending if the test is multientity or not if (type === 'multientity' || type === 'multimeasure') { - cbMockRoute = '/v2/op/update'; + cbMockRoute = '/v2/op/update?options=flowControl'; } else { - cbMockRoute = '/v2/entities?options=upsert'; + cbMockRoute = '/v2/entities?options=upsert,flowControl'; } // Set the correct mock times depending if the test is multimeasure or not From 57c6a32cebbd9d41ebfb4f9ca62055d9b7240c01 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Mon, 13 Jan 2025 12:22:46 +0100 Subject: [PATCH 05/12] add option useCBflowControl to global, group and device level --- config.js | 3 ++- lib/commonConfig.js | 11 +++++++++-- lib/model/Device.js | 3 ++- lib/model/Group.js | 3 ++- lib/services/common/iotManagerService.js | 3 ++- lib/services/devices/deviceRegistryMongoDB.js | 4 +++- lib/services/devices/deviceService.js | 3 +++ lib/services/devices/devices-NGSI-v2.js | 3 +++ lib/services/groups/groupRegistryMongoDB.js | 3 ++- lib/services/ngsi/entities-NGSI-v2.js | 11 ++++++++--- lib/services/northBound/deviceProvisioningServer.js | 9 ++++++--- lib/templates/updateDevice.json | 4 ++++ lib/templates/updateDeviceLax.json | 4 ++++ test/functional/config-test.js | 5 +++-- .../contextBrokerKeystoneSecurityAccess-test.js | 3 ++- test/unit/general/deviceService-test.js | 3 ++- test/unit/memoryRegistry/deviceRegistryMemory_test.js | 3 ++- .../ngsi-mixed/provisioning/ngsi-versioning-test.js | 3 ++- .../expressions/jexlBasedTransformations-test.js | 6 ++++-- .../general/contextBrokerOAuthSecurityAccess-test.js | 3 ++- test/unit/ngsiv2/general/deviceService-test.js | 3 ++- .../active-devices-attribute-update-test.js | 3 ++- test/unit/ngsiv2/lazyAndCommands/command-test.js | 3 ++- test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js | 3 ++- .../ngsiv2/lazyAndCommands/polling-commands-test.js | 3 ++- test/unit/ngsiv2/ngsiService/active-devices-test.js | 3 ++- test/unit/ngsiv2/ngsiService/staticAttributes-test.js | 3 ++- test/unit/ngsiv2/plugins/alias-plugin_test.js | 3 ++- test/unit/ngsiv2/plugins/multientity-plugin_test.js | 3 ++- .../unit/ngsiv2/provisioning/device-group-api-test.js | 3 ++- .../provisioning/device-provisioning-api_test.js | 3 ++- .../device-provisioning-configGroup-api_test.js | 3 ++- .../ngsiv2/provisioning/device-registration_test.js | 3 ++- .../provisioning/listProvisionedDevices-test.js | 3 ++- .../provisioning/removeProvisionedDevice-test.js | 3 ++- .../provisioning/updateProvisionedDevices-test.js | 3 ++- 36 files changed, 99 insertions(+), 39 deletions(-) diff --git a/config.js b/config.js index 88b4e610d..1ae79bb58 100644 --- a/config.js +++ b/config.js @@ -77,7 +77,8 @@ var config = { providerUrl: 'http://192.168.56.1:4041', deviceRegistrationDuration: 'P1M', defaultType: 'Thing', - expressLimit: '1Mb' + expressLimit: '1Mb', + useCBflowControl: false }; module.exports = config; diff --git a/lib/commonConfig.js b/lib/commonConfig.js index d16908615..8ff162de5 100644 --- a/lib/commonConfig.js +++ b/lib/commonConfig.js @@ -157,7 +157,8 @@ function processEnvironmentVariables() { 'IOTA_FALLBACK_PATH', 'IOTA_LD_SUPPORT_NULL', 'IOTA_LD_SUPPORT_DATASET_ID', - 'IOTA_EXPRESS_LIMIT' + 'IOTA_EXPRESS_LIMIT', + 'IOTA_USE_CB_FLOW_CONTROL' ]; const iotamVariables = [ 'IOTA_IOTAM_URL', @@ -474,6 +475,11 @@ function processEnvironmentVariables() { } else { config.expressLimit = config.expressLimit ? config.expressLimit : '1mb'; } + if (process.env.IOTA_USE_CB_FLOW_CONTROL) { + config.useCBflowControl = process.env.IOTA_USE_CB_FLOW_CONTROL === 'true'; + } else { + config.useCBflowControl = config.useCBflowControl === true; + } } function setConfig(newConfig) { @@ -503,7 +509,8 @@ function getConfigForTypeInformation() { multiCore: config.multiCore, relaxTemplateValidation: config.relaxTemplateValidation, defaultEntityNameConjunction: config.defaultEntityNameConjunction, - defaultType: config.defaultType + defaultType: config.defaultType, + useCBflowControl: config.useCBflowControl }; return conf; } diff --git a/lib/model/Device.js b/lib/model/Device.js index a6611fe73..9c8ece605 100644 --- a/lib/model/Device.js +++ b/lib/model/Device.js @@ -53,7 +53,8 @@ const Device = new Schema({ autoprovision: Boolean, explicitAttrs: Group.ExplicitAttrsType, ngsiVersion: String, - payloadType: String + payloadType: String, + useCBflowControl: Boolean }); function load() { diff --git a/lib/model/Group.js b/lib/model/Group.js index cf710be26..b6236bc6e 100644 --- a/lib/model/Group.js +++ b/lib/model/Group.js @@ -65,7 +65,8 @@ const Group = new Schema({ defaultEntityNameConjunction: String, ngsiVersion: String, entityNameExp: String, - payloadType: String + payloadType: String, + useCBflowControl: Boolean }); function load() { diff --git a/lib/services/common/iotManagerService.js b/lib/services/common/iotManagerService.js index b56fe9858..6562defcd 100644 --- a/lib/services/common/iotManagerService.js +++ b/lib/services/common/iotManagerService.js @@ -63,7 +63,8 @@ function register(callback) { entityNameExp: service.entityNameExp, payloadType: service.payloadType, endpoint: service.endpoint, - transport: service.transport + transport: service.transport, + useCBflowControl: service.useCBflowControl }; } diff --git a/lib/services/devices/deviceRegistryMongoDB.js b/lib/services/devices/deviceRegistryMongoDB.js index 4086f1933..6a4567b58 100644 --- a/lib/services/devices/deviceRegistryMongoDB.js +++ b/lib/services/devices/deviceRegistryMongoDB.js @@ -57,7 +57,8 @@ const attributeList = [ 'explicitAttrs', 'ngsiVersion', 'subscriptions', - 'payloadType' + 'payloadType', + 'useCBflowControl' ]; /** @@ -319,6 +320,7 @@ function update(previousDevice, device, callback) { data.timestamp = device.timestamp; data.subscriptions = device.subscriptions; data.payloadType = device.payloadType; + data.useCBflowControl = device.useCBflowControl; /* eslint-disable-next-line new-cap */ const deviceObj = new Device.model(data); diff --git a/lib/services/devices/deviceService.js b/lib/services/devices/deviceService.js index 03be2722c..03b64d424 100644 --- a/lib/services/devices/deviceService.js +++ b/lib/services/devices/deviceService.js @@ -179,6 +179,9 @@ function mergeDeviceWithConfiguration(fields, defaults, deviceData, configuratio if (configuration && configuration.payloadType !== undefined && deviceData.payloadType === undefined) { deviceData.payloadType = configuration.payloadType; } + if (configuration && configuration.useCBflowControl !== undefined && deviceData.useCBflowControl === undefined) { + deviceData.useCBflowControl = configuration.useCBflowControl; + } logger.debug(context, 'deviceData after merge with conf: %j', deviceData); callback(null, deviceData); } diff --git a/lib/services/devices/devices-NGSI-v2.js b/lib/services/devices/devices-NGSI-v2.js index f5942467f..c69332504 100644 --- a/lib/services/devices/devices-NGSI-v2.js +++ b/lib/services/devices/devices-NGSI-v2.js @@ -285,6 +285,9 @@ function updateRegisterDeviceNgsi2(deviceObj, previousDevice, entityInfoUpdated, if ('transport' in newDevice && newDevice.transport !== undefined) { oldDevice.transport = newDevice.transport; } + if ('useCBflowControl' in newDevice && newDevice.useCBflowControl !== undefined) { + oldDevice.useCBflowControl = newDevice.useCBflowControl; + } callback(null, oldDevice); } else { diff --git a/lib/services/groups/groupRegistryMongoDB.js b/lib/services/groups/groupRegistryMongoDB.js index 4cd8c4fdb..14debb8c9 100644 --- a/lib/services/groups/groupRegistryMongoDB.js +++ b/lib/services/groups/groupRegistryMongoDB.js @@ -61,7 +61,8 @@ const attributeList = [ 'defaultEntityNameConjunction', 'ngsiVersion', 'entityNameExp', - 'payloadType' + 'payloadType', + 'useCBflowControl' ]; function createGroup(group, callback) { diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index cbcbd9a9f..9f8a6e19c 100644 --- a/lib/services/ngsi/entities-NGSI-v2.js +++ b/lib/services/ngsi/entities-NGSI-v2.js @@ -653,8 +653,10 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, } } } // end for (let measures of originMeasures) - - let url = '/v2/op/update?options=flowControl'; + let url = '/v2/op/update'; + if (originTypeInformation.useCBflowControl) { + url += '?options=flowControl'; + } let options = NGSIUtils.createRequestObject(url, originTypeInformation, token); options.json = payload; @@ -679,7 +681,10 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, if (!multi) { // recreate options object to use single entity update - url = '/v2/entities?options=upsert,flowControl'; + url = '/v2/entities?options=upsert'; + if (originTypeInformation.useCBflowControl) { + url += ',flowControl'; + } options = NGSIUtils.createRequestObject(url, originTypeInformation, token); delete payload.actionType; diff --git a/lib/services/northBound/deviceProvisioningServer.js b/lib/services/northBound/deviceProvisioningServer.js index 2099cba45..7d357c17c 100644 --- a/lib/services/northBound/deviceProvisioningServer.js +++ b/lib/services/northBound/deviceProvisioningServer.js @@ -64,7 +64,8 @@ const provisioningAPITranslation = { explicitAttrs: 'explicitAttrs', ngsiVersion: 'ngsiVersion', entityNameExp: 'entityNameExp', - payloadType: 'payloadType' + payloadType: 'payloadType', + useCBflowControl: 'useCBflowControl' }; /** @@ -143,7 +144,8 @@ function handleProvision(req, res, next) { autoprovision: body.autoprovision, explicitAttrs: body.explicitAttrs, ngsiVersion: body.ngsiVersion, - payloadType: body.payloadType + payloadType: body.payloadType, + useCBflowControl: body.useCBflowControl }); } @@ -220,7 +222,8 @@ function toProvisioningAPIFormat(device) { autoprovision: device.autoprovision, explicitAttrs: device.explicitAttrs, ngsiVersion: device.ngsiVersion, - payloadType: device.payloadType + payloadType: device.payloadType, + useCBflowControl: device.useCBflowControl }; } diff --git a/lib/templates/updateDevice.json b/lib/templates/updateDevice.json index 3b6c0835a..ad2e45521 100644 --- a/lib/templates/updateDevice.json +++ b/lib/templates/updateDevice.json @@ -149,6 +149,10 @@ "description": "Payload type", "type": "string" }, + "useCBflowControl": { + "description": "use CB flowControl option", + "type": "boolean" + }, "contentType": { "description": "Content type", "type": "string" diff --git a/lib/templates/updateDeviceLax.json b/lib/templates/updateDeviceLax.json index a40bf59ed..ca3c395b2 100644 --- a/lib/templates/updateDeviceLax.json +++ b/lib/templates/updateDeviceLax.json @@ -146,6 +146,10 @@ "payloadType": { "description": "Payload type allowed for measures for this device", "type": "string" + }, + "useCBflowControl": { + "description": "use CB flowControl option", + "type": "boolean" } } } diff --git a/test/functional/config-test.js b/test/functional/config-test.js index 2bebb2c6b..5bc6518c2 100644 --- a/test/functional/config-test.js +++ b/test/functional/config-test.js @@ -45,7 +45,7 @@ config.amqp = { }; config.iota = { - logLevel: 'FATAL', + logLevel: 'DEBUG', contextBroker: { host: '192.168.1.1', port: '1026', @@ -61,7 +61,8 @@ config.iota = { service: 'smartgondor', subservice: '/gardens', providerUrl: 'http://localhost:4041', - types: {} + types: {}, + useCBflowControl: true }; config.defaultKey = '1234'; diff --git a/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js b/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js index ee08397b0..ea74cf674 100644 --- a/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +++ b/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js @@ -85,7 +85,8 @@ const iotAgentConfig = { service: 'smartgondor', subservice: 'gardens', providerUrl: 'http://smartgondor.com', - deviceRegistrationDuration: 'P1M' + deviceRegistrationDuration: 'P1M', + useCBflowControl: true }; describe('NGSI-v2 - Secured access to the Context Broker with Keystone', function () { diff --git a/test/unit/general/deviceService-test.js b/test/unit/general/deviceService-test.js index 58db3d076..720f46365 100644 --- a/test/unit/general/deviceService-test.js +++ b/test/unit/general/deviceService-test.js @@ -123,7 +123,8 @@ const iotAgentConfig = { service: 'smartgondor', subservice: 'gardens', providerUrl: 'http://smartgondor.com', - deviceRegistrationDuration: 'P1M' + deviceRegistrationDuration: 'P1M', + useCBflowControl: true }; const groupCreation = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services', diff --git a/test/unit/memoryRegistry/deviceRegistryMemory_test.js b/test/unit/memoryRegistry/deviceRegistryMemory_test.js index 642dd2f84..aa2df9f47 100644 --- a/test/unit/memoryRegistry/deviceRegistryMemory_test.js +++ b/test/unit/memoryRegistry/deviceRegistryMemory_test.js @@ -48,7 +48,8 @@ const iotAgentConfig = { service: 'smartgondor', subservice: 'gardens', providerUrl: 'http://smartgondor.com', - deviceRegistrationDuration: 'P1M' + deviceRegistrationDuration: 'P1M', + useCBflowControl: true }; let contextBrokerMock; diff --git a/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js b/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js index 09ad467fd..9a763f56c 100644 --- a/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +++ b/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js @@ -55,7 +55,8 @@ const iotAgentConfig = { service: 'smartgondor', subservice: 'gardens', providerUrl: 'http://smartgondor.com', - deviceRegistrationDuration: 'P1M' + deviceRegistrationDuration: 'P1M', + useCBflowControl: true }; const mongo = require('mongodb').MongoClient; const mongoUtils = require('../../mongodb/mongoDBUtils'); diff --git a/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js b/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js index 2c984b477..913a6f3ae 100644 --- a/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +++ b/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js @@ -730,7 +730,8 @@ const iotAgentConfig = { subservice: 'gardens', providerUrl: 'http://smartgondor.com', deviceRegistrationDuration: 'P1M', - throttling: 'PT5S' + throttling: 'PT5S', + useCBflowControl: true }; const iotAgentConfigTS = { @@ -812,7 +813,8 @@ const iotAgentConfigTS = { timestamp: true, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('Java expression language (JEXL) based transformations plugin', function () { diff --git a/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js b/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js index 8b2e74a08..08eb3f6e5 100644 --- a/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +++ b/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js @@ -88,7 +88,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider', function () { diff --git a/test/unit/ngsiv2/general/deviceService-test.js b/test/unit/ngsiv2/general/deviceService-test.js index 55492ed30..92819f9d2 100644 --- a/test/unit/ngsiv2/general/deviceService-test.js +++ b/test/unit/ngsiv2/general/deviceService-test.js @@ -126,7 +126,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; const groupCreation = { url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services', diff --git a/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js b/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js index 1e98e22be..2599cd16e 100644 --- a/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js @@ -58,7 +58,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; const device = { id: 'somelight', diff --git a/test/unit/ngsiv2/lazyAndCommands/command-test.js b/test/unit/ngsiv2/lazyAndCommands/command-test.js index f8964de32..4291d12e6 100644 --- a/test/unit/ngsiv2/lazyAndCommands/command-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/command-test.js @@ -103,7 +103,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; const device3 = { id: 'r2d2', diff --git a/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js b/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js index 2eea25025..c16de39e1 100644 --- a/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js @@ -114,7 +114,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; const device1 = { id: 'light1', diff --git a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js index cdcccd182..63d8ef086 100644 --- a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js @@ -126,7 +126,8 @@ const iotAgentConfig = { subservice: 'gardens', providerUrl: 'http://smartgondor.com', pollingExpiration: 200, - pollingDaemonFrequency: 20 + pollingDaemonFrequency: 20, + useCBflowControl: true }; const device3 = { id: 'r2d2', diff --git a/test/unit/ngsiv2/ngsiService/active-devices-test.js b/test/unit/ngsiv2/ngsiService/active-devices-test.js index 313352e24..ecf954527 100644 --- a/test/unit/ngsiv2/ngsiService/active-devices-test.js +++ b/test/unit/ngsiv2/ngsiService/active-devices-test.js @@ -206,7 +206,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('NGSI-v2 - Active attributes test', function () { diff --git a/test/unit/ngsiv2/ngsiService/staticAttributes-test.js b/test/unit/ngsiv2/ngsiService/staticAttributes-test.js index f65b439a3..bcd434b82 100644 --- a/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +++ b/test/unit/ngsiv2/ngsiService/staticAttributes-test.js @@ -176,7 +176,8 @@ const iotAgentConfig = { timestamp: true, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('NGSI-v2 - Static attributes test', function () { diff --git a/test/unit/ngsiv2/plugins/alias-plugin_test.js b/test/unit/ngsiv2/plugins/alias-plugin_test.js index be3ea0ae5..7bf354695 100644 --- a/test/unit/ngsiv2/plugins/alias-plugin_test.js +++ b/test/unit/ngsiv2/plugins/alias-plugin_test.js @@ -107,7 +107,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('NGSI-v2 - Attribute alias plugin', function () { diff --git a/test/unit/ngsiv2/plugins/multientity-plugin_test.js b/test/unit/ngsiv2/plugins/multientity-plugin_test.js index 65793d7b7..246ca6dac 100644 --- a/test/unit/ngsiv2/plugins/multientity-plugin_test.js +++ b/test/unit/ngsiv2/plugins/multientity-plugin_test.js @@ -633,7 +633,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('NGSI-v2 - Multi-entity plugin', function () { diff --git a/test/unit/ngsiv2/provisioning/device-group-api-test.js b/test/unit/ngsiv2/provisioning/device-group-api-test.js index f1c25bcbe..7ee1d7765 100644 --- a/test/unit/ngsiv2/provisioning/device-group-api-test.js +++ b/test/unit/ngsiv2/provisioning/device-group-api-test.js @@ -50,7 +50,8 @@ const iotAgentConfig = { service: 'smartgondor', subservice: 'gardens', providerUrl: 'http://smartgondor.com', - deviceRegistrationDuration: 'P1M' + deviceRegistrationDuration: 'P1M', + useCBflowControl: true }; const optionsCreation = { url: 'http://localhost:4041/iot/services', diff --git a/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js b/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js index 0abd5d645..4b382c03b 100644 --- a/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +++ b/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js @@ -49,7 +49,8 @@ const iotAgentConfig = { service: 'smartgondor', subservice: 'gardens', providerUrl: 'http://smartgondor.com', - explicitAttrs: false + explicitAttrs: false, + useCBflowControl: true }; describe('NGSI-v2 - Device provisioning API: Provision devices', function () { diff --git a/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js b/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js index 0a40a5f76..0f8f44d6c 100644 --- a/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js +++ b/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js @@ -49,7 +49,8 @@ const iotAgentConfig = { service: 'smartgondor', subservice: 'gardens', providerUrl: 'http://smartgondor.com', - explicitAttrs: false + explicitAttrs: false, + useCBflowControl: true }; describe('NGSI-v2 - Device provisioning API: Provision devices', function () { diff --git a/test/unit/ngsiv2/provisioning/device-registration_test.js b/test/unit/ngsiv2/provisioning/device-registration_test.js index d964365b5..49c6df78b 100644 --- a/test/unit/ngsiv2/provisioning/device-registration_test.js +++ b/test/unit/ngsiv2/provisioning/device-registration_test.js @@ -76,7 +76,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; const device1 = { id: 'light1', diff --git a/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js b/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js index c5dd6c8cf..f08930833 100644 --- a/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +++ b/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js @@ -48,7 +48,8 @@ const iotAgentConfig = { types: {}, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('NGSI-v2 - Device provisioning API: List provisioned devices', function () { diff --git a/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js b/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js index 821eff0fe..5051ac85b 100644 --- a/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +++ b/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js @@ -48,7 +48,8 @@ const iotAgentConfig = { types: {}, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', function () { diff --git a/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js b/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js index 6ff3318fc..e4cd5730d 100644 --- a/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +++ b/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js @@ -48,7 +48,8 @@ const iotAgentConfig = { types: {}, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('NGSI-v2 - Device provisioning API: Update provisioned devices', function () { From b6611653cc3596cafb796f574dafe26c7514af8a Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 14 Jan 2025 08:42:03 +0100 Subject: [PATCH 06/12] update doc --- doc/admin.md | 6 ++++++ doc/api.md | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/admin.md b/doc/admin.md index 8e44d8279..d266516c2 100644 --- a/doc/admin.md +++ b/doc/admin.md @@ -444,6 +444,11 @@ For example in a device document stored in MongoDB will be extended with a subdo } ``` +#### `useCBflowControl` + +If this flag is activated, when iotAgent invokes Context Broker will use flowControl option. This flag is overwritten by +`useCBflowControl` flag in group or device. This flag is disabled by default. + ### Configuration using environment variables Some of the configuration parameters can be overriden with environment variables, to ease the use of those parameters @@ -507,6 +512,7 @@ overrides. | IOTA_RELAX_TEMPLATE_VALIDATION | `relaxTemplateValidation` | | IOTA_EXPRESS_LIMIT | `expressLimit` | | IOTA_STORE_LAST_MEASURE | `storeLastMeasure` | +| IOTA_CB_FLOW_CONTROL | `useCBflowControl` | Note: diff --git a/doc/api.md b/doc/api.md index 215c43b62..a6eda0674 100644 --- a/doc/api.md +++ b/doc/api.md @@ -1778,6 +1778,7 @@ Config group is represented by a JSON object with the following fields: | `transport` | ✓ | `string` | | Transport protocol used by the group of devices to send updates, for the IoT Agents with multiple transport protocols. | | `endpoint` | ✓ | `string` | | Endpoint where the group of device is going to receive commands, if any. | | `storeLastMeasure` | ✓ | `boolean` | | Store in device last measure received. See more info [in this section](admin.md#storelastmeasure). False by default | +| `useCBflowControl` | ✓ | `boolean` | | Use Context Broker flow control. See more info [in this section](admin.md#useCBflowControl). False by default | ### Config group operations @@ -2000,7 +2001,10 @@ the API resource fields and the same fields in the database model. | `payloadType` | ✓ | `string` | | optional string value used to switch between **IoTAgent**, **NGSI-v2** and **NGSI-LD** measure payloads types. Possible values are: `iotagent`, `ngsiv2` or `ngsild`. The default is `iotagent`. | | `storeLastMeasure` | ✓ | `boolean` | | Store in device last measure received. See more info -[in this section](admin.md#storelastmeasure). False by default. | +[in this section](admin.md#storelastmeasure). False by default. + +| `useCBflowControl` | ✓ | `boolean` | | Use Context Broker flow control. See more info +[in this section](admin.md#useCBflowControl). False by default. ### Device operations From 1e18a57314bc875af8424ea4b736235cfc7b785f Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 14 Jan 2025 10:05:55 +0100 Subject: [PATCH 07/12] update tests to enable useCBflowControl --- .../examples/groupProvisioningRequests/provisionFullGroup.json | 1 + test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js | 2 ++ test/unit/ngsiv2/provisioning/device-group-api-test.js | 1 + 3 files changed, 4 insertions(+) diff --git a/test/unit/examples/groupProvisioningRequests/provisionFullGroup.json b/test/unit/examples/groupProvisioningRequests/provisionFullGroup.json index cd2a11174..82bf528bc 100644 --- a/test/unit/examples/groupProvisioningRequests/provisionFullGroup.json +++ b/test/unit/examples/groupProvisioningRequests/provisionFullGroup.json @@ -6,6 +6,7 @@ "entity_type": "SensorMachine", "trust": "8970A9078A803H3BL98PINEQRW8342HBAMS", "cbHost": "http://unexistentHost:1026", + "useCBflowControl": true, "commands": [ { "name": "wheel1", diff --git a/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js b/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js index 9a763f56c..a2fedd04d 100644 --- a/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +++ b/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js @@ -69,6 +69,7 @@ const optionsCreationDefault = { apikey: 'default-test', entity_type: 'Device', resource: '/iot/default', + useCBflowControl: true, attributes: [ { object_id: 's', @@ -94,6 +95,7 @@ const optionsCreationV2 = { ngsiVersion: 'v2', entity_type: 'Device', resource: '/iot/v2', + useCBflowControl: true, attributes: [ { object_id: 's', diff --git a/test/unit/ngsiv2/provisioning/device-group-api-test.js b/test/unit/ngsiv2/provisioning/device-group-api-test.js index 7ee1d7765..e32ac35bd 100644 --- a/test/unit/ngsiv2/provisioning/device-group-api-test.js +++ b/test/unit/ngsiv2/provisioning/device-group-api-test.js @@ -66,6 +66,7 @@ const optionsCreation = { cbHost: 'http://unexistentHost:1026', transport: 'HTTP', endpoint: 'http://myendpoint.com', + useCBflowControl: true, commands: [ { name: 'wheel1', From d7a97945dd69036347d6f181c565920503583b3f Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 14 Jan 2025 10:16:26 +0100 Subject: [PATCH 08/12] update test --- test/unit/ngsiv2/plugins/custom-plugin_test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/ngsiv2/plugins/custom-plugin_test.js b/test/unit/ngsiv2/plugins/custom-plugin_test.js index 0fbc7d7a9..f5d6bb8c2 100644 --- a/test/unit/ngsiv2/plugins/custom-plugin_test.js +++ b/test/unit/ngsiv2/plugins/custom-plugin_test.js @@ -57,7 +57,8 @@ const iotAgentConfig = { }, service: 'smartgondor', subservice: 'gardens', - providerUrl: 'http://smartgondor.com' + providerUrl: 'http://smartgondor.com', + useCBflowControl: true }; describe('NGSI-v2 - Custom plugin', function () { From e59c31c3d55c3602b0b218d106095f185cea783d Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 14 Jan 2025 11:50:16 +0100 Subject: [PATCH 09/12] Update CHANGES_NEXT_RELEASE --- CHANGES_NEXT_RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 00cd9db67..1ec992c0f 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,4 +1,4 @@ -- Add useCBflowControl option to global, group and device level to force to use CB flow control +- Add useCBflowControl option to global, group and device level to force to use CB flow control (#1420) - Add: store last measure in device (by id, apikey, service and subservice) and new API field storeLastMeasure at group and device levels (#1669) - Add: IOTA_STORE_LAST_MEASURE env var to set default store last measure behaviour at instance level (#1669) - Upgrade express dep from 4.19.2 to 4.20.0 From a5ad97151aeffc6f2bed78994e84cd78d872b9bd Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 14 Jan 2025 12:59:58 +0100 Subject: [PATCH 10/12] Update CHANGES_NEXT_RELEASE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fermín Galán Márquez --- CHANGES_NEXT_RELEASE | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 1ec992c0f..bb17f46d8 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,4 +1,5 @@ -- Add useCBflowControl option to global, group and device level to force to use CB flow control (#1420) +- Add: option to force to use CB flow control with new API field useCBflowControl at group and device device level (#1420) +- Add: useCBflowControl config setting (IOTA_CB_FLOW_CONTROL env var) to set CB flow control behaviour at instance level (#1420) - Add: store last measure in device (by id, apikey, service and subservice) and new API field storeLastMeasure at group and device levels (#1669) - Add: IOTA_STORE_LAST_MEASURE env var to set default store last measure behaviour at instance level (#1669) - Upgrade express dep from 4.19.2 to 4.20.0 From b92364cf538eef19caef5c71caa6de33909ebc70 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 14 Jan 2025 13:00:11 +0100 Subject: [PATCH 11/12] Update CHANGES_NEXT_RELEASE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fermín Galán Márquez --- CHANGES_NEXT_RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index bb17f46d8..bcaef7923 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,7 +1,7 @@ - Add: option to force to use CB flow control with new API field useCBflowControl at group and device device level (#1420) - Add: useCBflowControl config setting (IOTA_CB_FLOW_CONTROL env var) to set CB flow control behaviour at instance level (#1420) - Add: store last measure in device (by id, apikey, service and subservice) and new API field storeLastMeasure at group and device levels (#1669) -- Add: IOTA_STORE_LAST_MEASURE env var to set default store last measure behaviour at instance level (#1669) +- Add: storeLastMeasure config setting (IOTA_STORE_LAST_MEASURE env var) to set default store last measure behaviour at instance level (#1669) - Upgrade express dep from 4.19.2 to 4.20.0 - Upgrade mongodb devdep from 4.17.1 to 4.17.2 - Upgrade mongoose dep from 5.13.20 to 8.8.4 (solving vulnerability CVE-2024-53900) (#1674) From 5327af3451c1fd665a622e9d521e2d492c3e0e4d Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 14 Jan 2025 13:00:21 +0100 Subject: [PATCH 12/12] Update doc/admin.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fermín Galán Márquez --- doc/admin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/admin.md b/doc/admin.md index d266516c2..62c79e15a 100644 --- a/doc/admin.md +++ b/doc/admin.md @@ -446,7 +446,7 @@ For example in a device document stored in MongoDB will be extended with a subdo #### `useCBflowControl` -If this flag is activated, when iotAgent invokes Context Broker will use flowControl option. This flag is overwritten by +If this flag is activated, when iotAgent invokes Context Broker will use [flowControl option](https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/admin/perf_tuning.md#updates-flow-control-mechanism). This flag is overwritten by `useCBflowControl` flag in group or device. This flag is disabled by default. ### Configuration using environment variables