From c75596c8bd8d9df059359dc29757c70edbe88c20 Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Sun, 7 Mar 2021 18:01:48 +0100 Subject: [PATCH] Exhaustive TRoE test for Batch Create --- .../troe_exhaustive_batch_create.test | 1277 +++++++++++++++++ 1 file changed, 1277 insertions(+) create mode 100644 test/functionalTest/cases/0000_troe/troe_exhaustive_batch_create.test diff --git a/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_create.test b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_create.test new file mode 100644 index 0000000000..997194cc2a --- /dev/null +++ b/test/functionalTest/cases/0000_troe/troe_exhaustive_batch_create.test @@ -0,0 +1,1277 @@ +# Copyright 2021 FIWARE Foundation e.V. +# +# This file is part of Orion-LD Context Broker. +# +# Orion-LD Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion-LD Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# orionld at fiware dot org + +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh + +--NAME-- +Exhaustive test of batch creation of entities + +--SHELL-INIT-- +export BROKER=orionld +dbInit CB +dbInit CB t1 +pgInit $CB_DB_NAME +pgInit ${CB_DB_NAME}_t1 +brokerStart CB 100 IPv4 -troe -multiservice + +--SHELL-- + +# +# 01. Create E1 on default tenant +# 02. Create E2 on T1 tenant +# 03. Attempt to create E1,E3,E5 on default tenant and without context - E1 must not be recreated +# 04. Attempt to create E2,E4,E6 on T1 tenant and without context - E2 must not be recreated +# 05. Create E7,E9 on default tenant, with user context in Link Header +# 06. Create E8,E10 on T1 tenant, with user context in Link Header +# 07. Create E11,E13 on default tenant, with user context in payload body +# 08. Create E12,E14 on T1 tenant, with user context in payload body +# 09. Create E15 with user context #1 and E17 with user context #2, in payload body, on default tenant +# 10. Create E16 with user context #1 and E18 with user context #2, in payload body, on T1 tenant +# 11. See all entities in TRoE DB, default tenant +# 12. See all attributes in TRoE DB, default tenant +# 13. See all sub-attributes in TRoE DB, default tenant - there aren't any +# 14. See all entities in TRoE DB, tenant T1 +# 15. See all attributes in TRoE DB, tenant T1 +# 16. See all sub-attributes in TRoE DB, tenant T1 - there aren't any +# + +echo "01. Create E1 on default tenant" +echo "===============================" +payload='[ + { + "id": "urn:ngsi-ld:entity:E1", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" +echo +echo + + +echo "02. Create E2 on T1 tenant" +echo "==========================" +payload='[ + { + "id": "urn:ngsi-ld:entity:E2", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" --tenant t1 +echo +echo + + +echo "03. Attempt to create E1,E3,E5 on default tenant and without context - E1 must not be recreated" +echo "===============================================================================================" +payload='[ + { + "id": "urn:ngsi-ld:entity:E1", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "id": "urn:ngsi-ld:entity:E3", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "id": "urn:ngsi-ld:entity:E5", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" +echo +echo + + +echo "04. Attempt to create E2,E4,E6 on T1 tenant and without context - E2 must not be recreated" +echo "==========================================================================================" +payload='[ + { + "id": "urn:ngsi-ld:entity:E2", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "id": "urn:ngsi-ld:entity:E4", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "id": "urn:ngsi-ld:entity:E6", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" --tenant t1 +echo +echo + + +echo "05. Create E7,E9 on default tenant, with user context in Link Header" +echo "====================================================================" +payload='[ + { + "id": "urn:ngsi-ld:entity:E7", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "id": "urn:ngsi-ld:entity:E9", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' +echo +echo + + +echo "06. Create E8,E10 on T1 tenant, with user context in Link Header" +echo "================================================================" +payload='[ + { + "id": "urn:ngsi-ld:entity:E8", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "id": "urn:ngsi-ld:entity:E10", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" --tenant t1 -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' +echo +echo + + +echo "07. Create E11,E13 on default tenant, with user context in payload body" +echo "=======================================================================" +payload='[ + { + "@context": "https://raw.githubusercontent.com/FIWARE/tutorials.NGSI-LD/master/app/public/data-models/ngsi-context.jsonld", + "id": "urn:ngsi-ld:entity:E11", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "@context": "https://raw.githubusercontent.com/FIWARE/tutorials.NGSI-LD/master/app/public/data-models/ngsi-context.jsonld", + "id": "urn:ngsi-ld:entity:E13", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" --in application/ld+json +echo +echo + + +echo "08. Create E12,E14 on T1 tenant, with user context in payload body" +echo "==================================================================" +payload='[ + { + "@context": "https://raw.githubusercontent.com/FIWARE/tutorials.NGSI-LD/master/app/public/data-models/ngsi-context.jsonld", + "id": "urn:ngsi-ld:entity:E12", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "@context": "https://raw.githubusercontent.com/FIWARE/tutorials.NGSI-LD/master/app/public/data-models/ngsi-context.jsonld", + "id": "urn:ngsi-ld:entity:E14", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" --in application/ld+json --tenant t1 +echo +echo + + +echo "09. Create E15 with user context #1 and E17 with user context #2, in payload body, on default tenant" +echo "====================================================================================================" +payload='[ + { + "@context": "https://raw.githubusercontent.com/FIWARE/tutorials.NGSI-LD/master/app/public/data-models/ngsi-context.jsonld", + "id": "urn:ngsi-ld:entity:E15", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "@context": "https://fiware.github.io/NGSI-LD_TestSuite/ldContext/testContext.jsonld", + "id": "urn:ngsi-ld:entity:E17", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" --in application/ld+json +echo +echo + + +echo "10. Create E16 with user context #1 and E18 with user context #2, in payload body, on T1 tenant" +echo "===============================================================================================" +payload='[ + { + "@context": "https://raw.githubusercontent.com/FIWARE/tutorials.NGSI-LD/master/app/public/data-models/ngsi-context.jsonld", + "id": "urn:ngsi-ld:entity:E16", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + }, + { + "@context": "https://fiware.github.io/NGSI-LD_TestSuite/ldContext/testContext.jsonld", + "id": "urn:ngsi-ld:entity:E18", + "type": "Device", + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 2 ] + } + }, + "createdAt": "2021-03-07T08:30:00.123Z", + "modifiedAt": "2021-03-07T08:30:00.123Z", + "observationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 3 ] + } + }, + "operationSpace": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ 1, 4 ] + } + }, + "weight": { + "type": "Property", + "value": 250, + "unitCode": "kg", + "observedAt": "2021-03-07T08:31:00.123Z" + }, + "owner": { + "type": "Relationship", + "object": "urn:ngsi-ld:owner:1", + "observedAt": "2021-03-07T08:32:00.123Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/create --payload "$payload" --in application/ld+json --tenant t1 +echo +echo + + +echo "11. See all entities in TRoE DB, default tenant" +echo "===============================================" +postgresCmd -sql "SELECT opMode,id,type,ts FROM entities" +echo +echo + + +echo "12. See all attributes in TRoE DB, default tenant" +echo "=================================================" +postgresCmd -sql "SELECT opMode,id,valueType,entityId,subProperties,unitcode,datasetid,text,number,boolean,observedAt,ts FROM attributes" +echo +echo + + +echo "13. See all sub-attributes in TRoE DB, default tenant - there aren't any" +echo "========================================================================" +postgresCmd -sql "SELECT id,valueType,entityId,attrInstanceId,unitcode,text,number,boolean FROM subAttributes" +echo +echo + + +echo "14. See all entities in TRoE DB, tenant T1" +echo "==========================================" +postgresCmd -sql "SELECT opMode,id,type,ts FROM entities" -t ftest_t1 +echo +echo + + +echo "15. See all attributes in TRoE DB, tenant T1" +echo "============================================" +postgresCmd -sql "SELECT opMode,id,valueType,entityId,subProperties,unitcode,datasetid,text,number,boolean,observedAt,ts FROM attributes" -t ftest_t1 +echo +echo + + +echo "16. See all sub-attributes in TRoE DB, tenant T1 - there aren't any" +echo "===================================================================" +postgresCmd -sql "SELECT id,valueType,entityId,attrInstanceId,unitcode,text,number,boolean FROM subAttributes" -t ftest_t1 +echo +echo + + +--REGEXPECT-- +01. Create E1 on default tenant +=============================== +HTTP/1.1 200 OK +Content-Length: 49 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [], + "success": [ + "urn:ngsi-ld:entity:E1" + ] +} + + +02. Create E2 on T1 tenant +========================== +HTTP/1.1 200 OK +Content-Length: 49 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [], + "success": [ + "urn:ngsi-ld:entity:E2" + ] +} + + +03. Attempt to create E1,E3,E5 on default tenant and without context - E1 must not be recreated +=============================================================================================== +HTTP/1.1 200 OK +Content-Length: 224 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [ + { + "entityId": "urn:ngsi-ld:entity:E1", + "error": { + "status": 400, + "title": "entity already exists", + "type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData" + } + } + ], + "success": [ + "urn:ngsi-ld:entity:E3", + "urn:ngsi-ld:entity:E5" + ] +} + + +04. Attempt to create E2,E4,E6 on T1 tenant and without context - E2 must not be recreated +========================================================================================== +HTTP/1.1 200 OK +Content-Length: 224 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [ + { + "entityId": "urn:ngsi-ld:entity:E2", + "error": { + "status": 400, + "title": "entity already exists", + "type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData" + } + } + ], + "success": [ + "urn:ngsi-ld:entity:E4", + "urn:ngsi-ld:entity:E6" + ] +} + + +05. Create E7,E9 on default tenant, with user context in Link Header +==================================================================== +HTTP/1.1 200 OK +Content-Length: 73 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [], + "success": [ + "urn:ngsi-ld:entity:E7", + "urn:ngsi-ld:entity:E9" + ] +} + + +06. Create E8,E10 on T1 tenant, with user context in Link Header +================================================================ +HTTP/1.1 200 OK +Content-Length: 74 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [], + "success": [ + "urn:ngsi-ld:entity:E8", + "urn:ngsi-ld:entity:E10" + ] +} + + +07. Create E11,E13 on default tenant, with user context in payload body +======================================================================= +HTTP/1.1 200 OK +Content-Length: 75 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [], + "success": [ + "urn:ngsi-ld:entity:E11", + "urn:ngsi-ld:entity:E13" + ] +} + + +08. Create E12,E14 on T1 tenant, with user context in payload body +================================================================== +HTTP/1.1 200 OK +Content-Length: 75 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [], + "success": [ + "urn:ngsi-ld:entity:E12", + "urn:ngsi-ld:entity:E14" + ] +} + + +09. Create E15 with user context #1 and E17 with user context #2, in payload body, on default tenant +==================================================================================================== +HTTP/1.1 200 OK +Content-Length: 75 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [], + "success": [ + "urn:ngsi-ld:entity:E15", + "urn:ngsi-ld:entity:E17" + ] +} + + +10. Create E16 with user context #1 and E18 with user context #2, in payload body, on T1 tenant +=============================================================================================== +HTTP/1.1 200 OK +Content-Length: 75 +Content-Type: application/json +Date: REGEX(.*) + +{ + "errors": [], + "success": [ + "urn:ngsi-ld:entity:E16", + "urn:ngsi-ld:entity:E18" + ] +} + + +11. See all entities in TRoE DB, default tenant +=============================================== +opmode,id,type,ts +Create,urn:ngsi-ld:entity:E1,https://uri.etsi.org/ngsi-ld/default-context/Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E3,https://uri.etsi.org/ngsi-ld/default-context/Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E5,https://uri.etsi.org/ngsi-ld/default-context/Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E7,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E9,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E11,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E13,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E15,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E17,https://uri.etsi.org/ngsi-ld/default-context/Device,202REGEX(.*) + + +12. See all attributes in TRoE DB, default tenant +================================================= +opmode,id,valuetype,entityid,subproperties,unitcode,datasetid,text,number,boolean,observedat,ts +Create,location,GeoPoint,urn:ngsi-ld:entity:E1,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E1,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E1,f,,,,,,,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/weight,Number,urn:ngsi-ld:entity:E1,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/owner,Relationship,urn:ngsi-ld:entity:E1,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E3,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E3,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E3,f,,,,,,,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/weight,Number,urn:ngsi-ld:entity:E3,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/owner,Relationship,urn:ngsi-ld:entity:E3,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E5,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E5,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E5,f,,,,,,,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/weight,Number,urn:ngsi-ld:entity:E5,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/owner,Relationship,urn:ngsi-ld:entity:E5,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E7,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E7,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E7,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E7,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E7,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E9,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E9,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E9,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E9,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E9,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E11,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E11,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E11,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E11,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E11,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E13,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E13,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E13,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E13,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E13,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E15,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E15,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E15,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E15,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E15,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E17,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E17,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E17,f,,,,,,,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/weight,Number,urn:ngsi-ld:entity:E17,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/owner,Relationship,urn:ngsi-ld:entity:E17,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) + + +13. See all sub-attributes in TRoE DB, default tenant - there aren't any +======================================================================== +id,valuetype,entityid,attrinstanceid,unitcode,text,number,boolean + + +14. See all entities in TRoE DB, tenant T1 +========================================== +opmode,id,type,ts +Create,urn:ngsi-ld:entity:E2,https://uri.etsi.org/ngsi-ld/default-context/Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E4,https://uri.etsi.org/ngsi-ld/default-context/Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E6,https://uri.etsi.org/ngsi-ld/default-context/Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E8,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E10,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E12,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E14,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E16,https://uri.fiware.org/ns/data-models#Device,202REGEX(.*) +Create,urn:ngsi-ld:entity:E18,https://uri.etsi.org/ngsi-ld/default-context/Device,202REGEX(.*) + + +15. See all attributes in TRoE DB, tenant T1 +============================================ +opmode,id,valuetype,entityid,subproperties,unitcode,datasetid,text,number,boolean,observedat,ts +Create,location,GeoPoint,urn:ngsi-ld:entity:E2,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E2,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E2,f,,,,,,,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/weight,Number,urn:ngsi-ld:entity:E2,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/owner,Relationship,urn:ngsi-ld:entity:E2,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E4,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E4,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E4,f,,,,,,,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/weight,Number,urn:ngsi-ld:entity:E4,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/owner,Relationship,urn:ngsi-ld:entity:E4,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E6,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E6,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E6,f,,,,,,,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/weight,Number,urn:ngsi-ld:entity:E6,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/owner,Relationship,urn:ngsi-ld:entity:E6,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E8,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E8,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E8,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E8,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E8,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E10,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E10,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E10,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E10,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E10,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E12,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E12,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E12,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E12,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E12,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E14,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E14,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E14,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E14,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E14,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E16,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E16,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E16,f,,,,,,,202REGEX(.*) +Create,https://w3id.org/saref#weight,Number,urn:ngsi-ld:entity:E16,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.fiware.org/ns/data-models#owner,Relationship,urn:ngsi-ld:entity:E16,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) +Create,location,GeoPoint,urn:ngsi-ld:entity:E18,f,,,,,,,202REGEX(.*) +Create,observationSpace,GeoPoint,urn:ngsi-ld:entity:E18,f,,,,,,,202REGEX(.*) +Create,operationSpace,GeoPoint,urn:ngsi-ld:entity:E18,f,,,,,,,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/weight,Number,urn:ngsi-ld:entity:E18,f,kg,,,250,,2021-03-07 08:31:00.123,202REGEX(.*) +Create,https://uri.etsi.org/ngsi-ld/default-context/owner,Relationship,urn:ngsi-ld:entity:E18,f,,,urn:ngsi-ld:owner:1,,,2021-03-07 08:32:00.123,202REGEX(.*) + + +16. See all sub-attributes in TRoE DB, tenant T1 - there aren't any +=================================================================== +id,valuetype,entityid,attrinstanceid,unitcode,text,number,boolean + + +--TEARDOWN-- +brokerStop CB +dbDrop CB +dbDrop CB t1 +pgDrop $CB_DB_NAME +pgDrop ${CB_DB_NAME}_t1 + +