Skip to content

Commit e8245c1

Browse files
Increasing test coverage and cii best practices (#55)
* update readme * update documentation to increase cii best practices * increase test coverage * minor issues fixing
1 parent b556ff7 commit e8245c1

15 files changed

+936
-573
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ jobs:
7575
run: |
7676
npm install
7777
npm test
78-
7978
code-coverage:
8079
name: Coveralls Code Coverage
8180
runs-on: ubuntu-latest

AGECONF/config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"logLevel": "DEBUG",
2+
"logLevel": "INFO",
33
"multiCore": false,
44
"relaxTemplateValidation": true,
55
"contextBroker": {
@@ -71,6 +71,8 @@
7171
"contexts": [{
7272
"id": "urn:ngsi-ld:Device:age01_Car",
7373
"type": "Device",
74+
"ngsiVersion": "ld",
75+
"jsonLdContext": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
7476
"service": "opcua_car",
7577
"subservice": "/demo",
7678
"polling": false,
@@ -104,6 +106,8 @@
104106
"contextSubscriptions": [{
105107
"id": "urn:ngsi-ld:Device:age01_Car",
106108
"type": "Device",
109+
"ngsiVersion": "ld",
110+
"jsonLdContext": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
107111
"mappings": [{
108112
"ocb_id": "Error",
109113
"opcua_id": "ns=3;s=Error",

CHANGES_NEXT_RELEASE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade NodeJS version from 8.12.0 to 8.15.0 in Dockerfile due to security issues
1+
Code refactoring and increase test coverage

CONTRIBUTING.md

Lines changed: 230 additions & 20 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ For checking current status of the Agent, send a request to /status service
131131

132132
Documentation about OPC UA Client Secure connection can be found [here](docs/opc_ua_secure_connection_configuration.md)
133133

134-
135134
### How to get access to the advanced API and Documentation topics
136135

137136
Documentation about the OPC UA Administration API can be found [here](https://opcuaiotagent.docs.apiary.io)
@@ -160,12 +159,12 @@ The **IoT Agent for OPC UA** project is part of [FIWARE](https://fiware.org/) an
160159

161160
The IoT Agent for OPC UA is licensed under [Affero General Public License (GPL) version 3](./LICENSE).
162161

163-
© 2020 Engineering Ingegneria Informatica S.p.A.
162+
© 2021 Engineering Ingegneria Informatica S.p.A.
164163

165164
The following third-party libraries are used under license
166165

167-
1. [node-opcua](http://node-opcua.github.io/) - **MIT** - © 2014-2018 Etienne Rossignon
168-
2. [iotagent-node-lib](https://github.com/telefonicaid/iotagent-node-lib) - **AGPL** © 2014-2018 Telefonica
166+
1. [node-opcua](http://node-opcua.github.io/) - **MIT** - © 2014-2021 Etienne Rossignon
167+
2. [iotagent-node-lib](https://github.com/telefonicaid/iotagent-node-lib) - **AGPL** © 2014-2021 Telefonica
169168
Investigación y Desarrollo
170169

171170
The full list of third-party libraries licenses can be found

conf/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
"contexts": [{
7272
"id": "urn:ngsi-ld:Device:age01_Car",
7373
"type": "Device",
74+
"ngsiVersion": "ld",
75+
"jsonLdContext": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
7476
"service": "opcua_car",
7577
"subservice": "/demo",
7678
"polling": false,
@@ -104,6 +106,8 @@
104106
"contextSubscriptions": [{
105107
"id": "urn:ngsi-ld:Device:age01_Car",
106108
"type": "Device",
109+
"ngsiVersion": "ld",
110+
"jsonLdContext": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
107111
"mappings": [{
108112
"ocb_id": "Error",
109113
"opcua_id": "ns=3;s=Error",
Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
{
22
"logLevel": "INFO",
3-
"multiCore" : false,
4-
"relaxTemplateValidation":true,
3+
"multiCore": false,
4+
"relaxTemplateValidation": true,
55
"contextBroker": {
66
"host": "TEST_MACHINE_IP",
77
"port": 1026,
8-
"url": "http://TEST_MACHINE_IP:1026",
9-
"ngsiVersion":"ld",
10-
"jsonLdContext":"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
11-
"fallbackTenant":"opcua_car"
8+
"service": "opcua_car",
9+
"subservice": "/demo"
1210
},
1311
"server": {
14-
"port": 4003,
12+
"port": 4001,
1513
"baseRoot": "/"
1614
},
1715
"deviceRegistry": {
@@ -29,82 +27,68 @@
2927
"service": "opcua_car",
3028
"subservice": "/demo",
3129
"active": [
32-
{
33-
"name": "MissingContextSubElementForThis",
34-
"type": "Number",
35-
"object_id": "MissingContextSubElementForThis"
36-
},
3730
{
3831
"name": "EngineBrake",
39-
"type": "Number",
40-
"object_id": "EngineBrake"
41-
},
42-
{
43-
"name": "Speed",
44-
"type": "Number",
45-
"object_id": "Speed"
32+
"type": "Number"
4633
},
4734
{
4835
"name": "Acceleration",
49-
"type": "Number",
50-
"object_id": "Acceleration"
36+
"type": "Number"
5137
},
5238
{
5339
"name": "EngineStopped",
54-
"type": "Boolean",
55-
"object_id": "EngineStopped"
40+
"type": "Boolean"
5641
},
5742
{
5843
"name": "Engine_Temperature",
59-
"type": "Number",
60-
"object_id": "Engine_Temperature"
44+
"type": "Number"
6145
},
6246
{
6347
"name": "Engine_Oxigen",
64-
"type": "Number",
65-
"object_id": "Engine_Oxigen"
48+
"type": "Number"
49+
}
50+
],
51+
"lazy": [
52+
{
53+
"name": "Speed",
54+
"type": "Number"
6655
}
6756
],
68-
"lazy": [],
6957
"commands": [
58+
{
59+
"name": "Error",
60+
"type": "command"
61+
},
7062
{
7163
"name": "Stop",
72-
"type": "command",
73-
"object_id": "Stop"
64+
"type": "command"
7465
},
7566
{
7667
"name": "Accelerate",
77-
"type": "command",
78-
"object_id": "Accelerate"
68+
"type": "command"
7969
}
8070
]
8171
}
8272
},
8373
"browseServerOptions": null,
8474
"service": "opcua_car",
8575
"subservice": "/demo",
86-
"providerUrl": "http://TEST_MACHINE_IP:4003",
76+
"providerUrl": "http://TEST_MACHINE_IP:4001",
8777
"pollingExpiration": "200000",
8878
"pollingDaemonFrequency": "20000",
8979
"deviceRegistrationDuration": "P1M",
9080
"defaultType": null,
9181
"contexts": [
9282
{
93-
"id": "urn:ngsi-ld:Device:age01_Car",
83+
"id": "age01_Car",
9484
"type": "Device",
9585
"service": "opcua_car",
9686
"subservice": "/demo",
9787
"polling": false,
9888
"mappings": [
9989
{
100-
"ocb_id": "EngineBrake",
101-
"opcua_id": "ns=3;s=EngineBrake",
102-
"object_id": null,
103-
"inputArguments": []
104-
},
105-
{
106-
"ocb_id": "Speed",
107-
"opcua_id": "ns=3;s=Speed",
90+
"ocb_id": "Error",
91+
"opcua_id": "ns=3;s=Error",
10892
"object_id": null,
10993
"inputArguments": []
11094
},
@@ -137,9 +121,26 @@
137121
],
138122
"contextSubscriptions": [
139123
{
140-
"id": "urn:ngsi-ld:Device:age01_Car",
124+
"id": "age01_Car",
141125
"type": "Device",
142126
"mappings": [
127+
{
128+
"ocb_id": "Error",
129+
"opcua_id": "ns=3;s=Error",
130+
"object_id": "ns=3;i=1000",
131+
"inputArguments": [
132+
{
133+
"dataType": 12,
134+
"type": "Error Type"
135+
}
136+
]
137+
},
138+
{
139+
"ocb_id": "Speed",
140+
"opcua_id": "ns=3;s=Speed",
141+
"object_id": "ns=3;i=1000",
142+
"inputArguments": []
143+
},
143144
{
144145
"ocb_id": "Stop",
145146
"opcua_id": "ns=3;s=Stop",
@@ -153,13 +154,11 @@
153154
"inputArguments": [
154155
{
155156
"dataType": 6,
156-
"type": "Intensity",
157-
"value": 2,
158-
"arrayType": 0
157+
"type": "Intensity"
159158
}
160159
]
161160
}
162161
]
163162
}
164163
]
165-
}
164+
}

conf/config.properties.WITH_PLACEHOLDER

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespaceNumericIdentifier=1000
66
context-broker-host=TEST_MACHINE_IP
77
context-broker-port=1026
88
server-base-root=/
9-
server-port=4003
9+
server-port=4001
1010
device-registry-type=memory
1111
mongodb-host=TEST_MACHINE_IP
1212
mongodb-port=27017
@@ -15,11 +15,11 @@ mongodb-retries=5
1515
mongodb-retry-time=5
1616
fiware-service=opcua_car
1717
fiware-service-path=/demo
18-
provider-url=http://TEST_MACHINE_IP:4003
18+
provider-url=http://TEST_MACHINE_IP:4001
1919
device-registration-duration=P1M
2020
#endpoint=opc.tcp://TEST_MACHINE_IP:4334/UA/EnergyMESServer
2121
endpoint=opc.tcp://TEST_MACHINE_IP:5001/UA/CarServer
22-
log-level=DEBUG
22+
log-level=INFO
2323
#DATATYPE MAPPING OPCUA --> NGSI
2424
OPC-datatype-Number=Number
2525
OPC-datatype-Decimal128=Number
@@ -39,6 +39,9 @@ maxNotificationsPerPublish=100
3939
publishingEnabled=true
4040
priority=10
4141

42+
#SubscriptionsStrategy
43+
uniqueSubscription=false
44+
4245
#MONITORING PARAMETERS
4346
samplingInterval=1
4447
queueSize=10000

iot_agent_modules/run/findType.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module.exports = {
99
return device.active[i].type;
1010
}
1111
}
12-
console.log('ritorno null???');
1312
return null;
1413
}
1514
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"url": "https://github.com/Engineering-Research-and-Development/iotagent-opcua/issues"
2525
},
2626
"engines": {
27-
"node": ">=8.0.0"
27+
"node": ">=12.0.0"
2828
},
2929
"scripts": {
3030
"clean": "rm -rf package-lock.json && rm -rf node_modules && rm -rf coverage",

0 commit comments

Comments
 (0)