diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 24210f743..bcaef7923 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,5 +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) diff --git a/config.js b/config.js index d9ad2e7a4..0d7b9ec26 100644 --- a/config.js +++ b/config.js @@ -78,6 +78,7 @@ var config = { deviceRegistrationDuration: 'P1M', defaultType: 'Thing', expressLimit: '1Mb', + useCBflowControl: false, storeLastMeasure: false }; diff --git a/doc/admin.md b/doc/admin.md index 7f7b687f3..62c79e15a 100644 --- a/doc/admin.md +++ b/doc/admin.md @@ -422,8 +422,8 @@ environment variable). #### `storeLastMeasure` If this flag is activated, last measure arrived to Device IoTAgent without be processed will be stored in Device under -`lastMeasure` field (composed of sub-fields `timestamp` and `measure` for the measure itself, in multi-measure format). This flag is overwritten by `storeLastMeasure` flag in group or device. This flag -is disabled by default. +`lastMeasure` field (composed of sub-fields `timestamp` and `measure` for the measure itself, in multi-measure format). +This flag is overwritten by `storeLastMeasure` flag in group or device. This flag is disabled by default. For example in a device document stored in MongoDB will be extended with a subdocument named lastMeasure like this: @@ -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](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 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 30d05f06e..a6eda0674 100644 --- a/doc/api.md +++ b/doc/api.md @@ -1777,7 +1777,8 @@ Config group is represented by a JSON object with the following fields: | `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`. | | `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 | +| `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 @@ -1999,7 +2000,11 @@ the API resource fields and the same fields in the database model. | `ngsiVersion` | ✓ | `string` | | string value used in mixed mode to switch between **NGSI-v2** and **NGSI-LD** payloads. The default is `v2`. When not running in mixed mode, this field is ignored. | | `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. | +| `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. ### Device operations diff --git a/lib/commonConfig.js b/lib/commonConfig.js index d10c26a9c..13ce45304 100644 --- a/lib/commonConfig.js +++ b/lib/commonConfig.js @@ -158,6 +158,7 @@ function processEnvironmentVariables() { 'IOTA_LD_SUPPORT_NULL', 'IOTA_LD_SUPPORT_DATASET_ID', 'IOTA_EXPRESS_LIMIT', + 'IOTA_USE_CB_FLOW_CONTROL', 'IOTA_STORE_LAST_MEASURE' ]; const iotamVariables = [ @@ -475,6 +476,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; + } if (process.env.IOTA_STORE_LAST_MEASURE) { config.storeLastMeasure = process.env.IOTA_STORE_LAST_MEASURE === 'true'; } else { @@ -510,6 +516,7 @@ function getConfigForTypeInformation() { relaxTemplateValidation: config.relaxTemplateValidation, defaultEntityNameConjunction: config.defaultEntityNameConjunction, defaultType: config.defaultType, + useCBflowControl: config.useCBflowControl, storeLastMeasure: config.storeLastMeasure }; return conf; diff --git a/lib/model/Device.js b/lib/model/Device.js index 8513eba04..6f7d44920 100644 --- a/lib/model/Device.js +++ b/lib/model/Device.js @@ -54,6 +54,7 @@ const Device = new Schema({ explicitAttrs: Group.ExplicitAttrsType, ngsiVersion: String, payloadType: String, + useCBflowControl: Boolean, storeLastMeasure: Boolean, lastMeasure: Object }); diff --git a/lib/model/Group.js b/lib/model/Group.js index 83b2e1a3f..2955d932a 100644 --- a/lib/model/Group.js +++ b/lib/model/Group.js @@ -66,6 +66,7 @@ const Group = new Schema({ ngsiVersion: String, entityNameExp: String, payloadType: String, + useCBflowControl: Boolean, storeLastMeasure: Boolean }); diff --git a/lib/services/common/iotManagerService.js b/lib/services/common/iotManagerService.js index 911ed3e26..3a6b14e26 100644 --- a/lib/services/common/iotManagerService.js +++ b/lib/services/common/iotManagerService.js @@ -64,6 +64,7 @@ function register(callback) { payloadType: service.payloadType, endpoint: service.endpoint, transport: service.transport, + useCBflowControl: service.useCBflowControl, storeLastMeasure: service.storeLastMeasure }; } diff --git a/lib/services/devices/deviceRegistryMongoDB.js b/lib/services/devices/deviceRegistryMongoDB.js index 6d013df2e..b77fe4a29 100644 --- a/lib/services/devices/deviceRegistryMongoDB.js +++ b/lib/services/devices/deviceRegistryMongoDB.js @@ -58,6 +58,7 @@ const attributeList = [ 'ngsiVersion', 'subscriptions', 'payloadType', + 'useCBflowControl', 'storeLastMeasure' ]; @@ -320,6 +321,7 @@ function update(previousDevice, device, callback) { data.timestamp = device.timestamp; data.subscriptions = device.subscriptions; data.payloadType = device.payloadType; + data.useCBflowControl = device.useCBflowControl; data.storeLastMeasure = device.storeLastMeasure; /* eslint-disable-next-line new-cap */ diff --git a/lib/services/devices/deviceService.js b/lib/services/devices/deviceService.js index c3af24053..a31726071 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; + } if (configuration && configuration.storeLastMeasure !== undefined && deviceData.storeLastMeasure === undefined) { deviceData.storeLastMeasure = configuration.storeLastMeasure; } diff --git a/lib/services/devices/devices-NGSI-v2.js b/lib/services/devices/devices-NGSI-v2.js index 52f4ab72f..e3148c4c9 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; + } if ('storeLastMeasure' in newDevice && newDevice.storeLastMeasure !== undefined) { oldDevice.storeLastMeasure = newDevice.storeLastMeasure; } diff --git a/lib/services/groups/groupRegistryMongoDB.js b/lib/services/groups/groupRegistryMongoDB.js index 20e408744..08643a456 100644 --- a/lib/services/groups/groupRegistryMongoDB.js +++ b/lib/services/groups/groupRegistryMongoDB.js @@ -62,6 +62,7 @@ const attributeList = [ 'ngsiVersion', 'entityNameExp', 'payloadType', + 'useCBflowControl', 'storeLastMeasure' ]; diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index 4a0d89460..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'; + if (originTypeInformation.useCBflowControl) { + url += '?options=flowControl'; + } let options = NGSIUtils.createRequestObject(url, originTypeInformation, token); options.json = payload; @@ -680,6 +682,9 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, if (!multi) { // recreate options object to use single entity update 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 bc5d468a6..cac2a61c4 100644 --- a/lib/services/northBound/deviceProvisioningServer.js +++ b/lib/services/northBound/deviceProvisioningServer.js @@ -65,6 +65,7 @@ const provisioningAPITranslation = { ngsiVersion: 'ngsiVersion', entityNameExp: 'entityNameExp', payloadType: 'payloadType', + useCBflowControl: 'useCBflowControl', storeLastMeasure: 'storeLastMeasure', lastMeasure: 'lastMeasure' }; @@ -146,6 +147,7 @@ function handleProvision(req, res, next) { explicitAttrs: body.explicitAttrs, ngsiVersion: body.ngsiVersion, payloadType: body.payloadType, + useCBflowControl: body.useCBflowControl, storeLastMeasure: body.storeLastMeasure, lastMeasure: body.lastMeasure }); @@ -225,6 +227,7 @@ function toProvisioningAPIFormat(device) { explicitAttrs: device.explicitAttrs, ngsiVersion: device.ngsiVersion, payloadType: device.payloadType, + useCBflowControl: device.useCBflowControl, storeLastMeasure: device.storeLastMeasure, lastMeasure: device.lastMeasure }; diff --git a/lib/templates/updateDevice.json b/lib/templates/updateDevice.json index 9a27f32a7..c5536b30e 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 32e73ff2c..d0ee3eed6 100644 --- a/lib/templates/updateDeviceLax.json +++ b/lib/templates/updateDeviceLax.json @@ -147,6 +147,10 @@ "description": "Payload type allowed for measures for this device", "type": "string" }, + "useCBflowControl": { + "description": "use CB flowControl option", + "type": "boolean" + } "storeLastMeasure": { "description": "Store last measure", "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/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 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/general/contextBrokerKeystoneSecurityAccess-test.js b/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js index 165333f74..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 () { @@ -128,7 +129,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 +166,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 +198,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..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', @@ -222,7 +223,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 +256,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 +291,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 +327,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..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; @@ -64,7 +65,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 +117,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 +160,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 +203,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..a2fedd04d 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'); @@ -68,6 +69,7 @@ const optionsCreationDefault = { apikey: 'default-test', entity_type: 'Device', resource: '/iot/default', + useCBflowControl: true, attributes: [ { object_id: 's', @@ -93,6 +95,7 @@ const optionsCreationV2 = { ngsiVersion: 'v2', entity_type: 'Device', resource: '/iot/v2', + useCBflowControl: true, attributes: [ { object_id: 's', @@ -189,7 +192,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 +213,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 +257,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(); diff --git a/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js b/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js index 9595b0abf..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 () { @@ -849,7 +851,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 +884,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 +940,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 +996,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 +1060,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 +1124,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 +1181,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 +1221,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 +1255,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 +1289,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 +1324,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 +1359,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 +1393,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 +1428,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 +1462,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 +1497,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 +1551,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 +1589,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 +1622,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 +1663,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 +1696,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 +1739,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 +1782,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 +1830,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 +1873,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 +1916,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 +1964,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 +2002,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 +2035,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 +2083,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 +2130,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 +2165,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 +2208,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 +2255,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 +2298,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 +2345,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 +2393,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 +2469,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 +2510,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..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 () { @@ -130,7 +131,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 +170,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 +205,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 +387,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 +526,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 +613,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 +625,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 +740,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 +818,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..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', @@ -219,7 +220,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 +249,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 +282,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 +315,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..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', @@ -82,7 +83,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 +104,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..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', @@ -159,7 +160,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 +265,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 +289,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 +310,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..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', @@ -170,7 +171,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 +209,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 +280,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 +342,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 +415,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 +486,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 +518,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 +556,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 +635,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 +718,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 +790,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 +853,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 +918,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 +985,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 +1053,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..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', @@ -158,7 +159,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 +181,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 +265,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 +294,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 +321,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 +347,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 +407,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 +431,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..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 () { @@ -239,7 +240,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 +284,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 +332,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 +384,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 +476,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 +530,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 +586,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 +640,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 +694,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 +726,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 +755,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 +787,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 +820,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 +855,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 +881,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 +930,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 +985,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 +1032,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 +1072,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..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 () { @@ -208,10 +209,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 +259,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 +304,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 +348,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 +389,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..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 () { @@ -146,7 +147,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 +177,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 +207,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 +238,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 +269,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 +300,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 +330,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 +361,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 +392,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 +423,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..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 () { @@ -111,7 +112,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..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 () { @@ -674,7 +675,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 +713,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 +745,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 +782,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 +820,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 +863,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 +906,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 +949,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 +997,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 +1045,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 +1078,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 +1121,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 +1154,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 +1178,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 +1212,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 +1250,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 +1292,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 +1334,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 +1376,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 +1411,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 +1462,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 +1501,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 +1571,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 +1609,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 +1648,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 +1702,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..e32ac35bd 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', @@ -65,6 +66,7 @@ const optionsCreation = { cbHost: 'http://unexistentHost:1026', transport: 'HTTP', endpoint: 'http://myendpoint.com', + useCBflowControl: true, commands: [ { name: 'wheel1', @@ -519,7 +521,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 +539,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 +1093,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..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 () { @@ -74,7 +75,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 +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' ) @@ -491,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' @@ -557,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' @@ -631,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' @@ -700,7 +701,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 +773,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 +978,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 +987,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 +1138,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..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 () { @@ -74,7 +75,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 +421,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 +493,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 +559,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 +633,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 +707,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 +915,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 +924,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 +1075,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..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', @@ -215,7 +216,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 +322,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 +331,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..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 () { @@ -96,7 +97,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 +106,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 +115,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 +309,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..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 () { @@ -97,7 +98,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 +116,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 +131,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..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 () { @@ -107,7 +108,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 +127,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 +182,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 +375,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 +443,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 +505,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);