-
Notifications
You must be signed in to change notification settings - Fork 91
Fix #966 - Remove Legacy NGSI-v1 from codebase #995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove `config.isCurrentNGSI()` clauses from plugins - Remove NGSI-v1 Templates - Remove V1 options from service - Delete NGSI-V1 classes - Delete NGSI-V1 tests - Convert Keystone and Registry tests to NGSI-v2
|
Related #966 |
|
@AlvaroVega @fgalan - this is now ready for review. The remaining reduction of 1.5% code coverage may still be NGSI-v1 lava code somewhere or it may be that some additional test cases need to be added (particularly around plugins). Either way I wouldn't feel comfortable modifying the code further as part of this PR. |
|
We are going to start testing on this. To that end, the following (temporal) PRs has been created:
While unit tests have gone fine in the IOTA Manager PR, they are failing in IOTA-UL and IOTA-JSON. Looking at the results, it seems it is not the usual glitch in some AMQP tests, but a massive fail. At least 75 tests are failing in the IOTA-UL case and 80 in the IOTA-JSON case. Maybe I'm doing something wrong... @jason-fox could you have a look, please? |
@jason-fox Just to clarify, the idea is to add more test on a separate PR to increase the code coverage that 1.5% or leave it like this? |
|
@mapedraza - leave or add as a subsequent PR. All I've done is delete the NGSI-v1 tests and copied over the obvious tests for non NGSI functionality to use NGSI-v2 requests and responses. I am uncertain where the remaining drop of 1.5% lies - I'm guessing various plugins need to have some NGSI-v1 cleaning to remove dead code, but it could be a coveralls accounting error. Either way not part of this PR anyway. |
The failing tests are provisioned using NGSI-v1. For example Has a mock which assumes that the IoT Agent upserts a provisioned device using the deprecated So a 50% failure rate in the Unit Tests is a good thing. 😄 |
|
It should be the case that if the NGSI-v1 tests are deleted for IOTA-JSON and IOT-UL there should not be a significant reduction of coverage. If coverage is reduced then some of the NGSI-v1 tests will need to be converted to NGSI-v2. |
|
Example run for IOTA-JSON with no NGSI-v1 tests : https://github.com/jason-fox/iotagent-json/runs/2041091462?check_suite_focus=true Deleting all non NGSI-v2 tests. Code coverage drops from 80% to 67% https://coveralls.io/github/telefonicaid/iotagent-json?branch=master Some functions such as MQTT Bindings and Config Service are currently extensively tested using NGSI-v1 only using the following tests: |
|
Take into account that PR #1034 adds some files related with NGSIv1:
These ones should be removed in this PR upon conflict resolution when updated with master. |
# Conflicts: # lib/plugins/multiEntity.js
|
@mapedraza - I don't think there is an equivalent NGSI-v2 request to replicate the missing test in queryDeviceInformationInCb-test.js - With v2, if i make the GET request The missing All the other tests are complete and the reduction remains at 0.7% - I guess much of this is obscure NGSI-v1 edge cases I wouldn't want to look at. |
Maybe a warning in the code should be included about this. I mean something like this: |
In the case it can help, this is the current (at b1758c3) breakdown (https://coveralls.io/builds/42573501): |
|
I'm fairly positive that the following should work: entities-NGSI-v2.js } else if (response && body && response.statusCode === 404) {
logger.info(
context,
'Received the following response from the CB:\n\n%s\n\n',
JSON.stringify(body, null, 4)
);
logger.error(context, 'Operation ' + operationName + ' error connecting to the Context Broker: %j', body);
-
- const errorField = NGSIUtils.getErrorField(body);
- if (response.statusCode && response.statusCode === 404 && errorField !== undefined) {
+ if ( NGSIUtils.getErrorField(body) !== undefined) {
callback(new errors.DeviceNotFound(entityName));
- } else if (errorField.code && errorField.code === '404') {
- callback(new errors.AttributeNotFound());
} else {
callback(new errors.EntityGenericError(entityName, typeInformation.type, body));
}
entities-NGSI-LD.js } else if (response && body && response.statusCode === 404) {
logger.info(context, 'Received the following response from the CB:\n\n%s\n\n', bodyAsString);
logger.error(context, 'Operation ' + operationName + ' error connecting to the Context Broker: %j', body);
- const errorField = NGSIUtils.getErrorField(body);
- if (
- response.statusCode &&
- response.statusCode === 404 &&
- errorField.details.includes(typeInformation.type)
- ) {
+ if ( NGSIUtils.getErrorField(body) !== undefined) {
callback(new errors.DeviceNotFound(entityName));
- } else if (errorField.code && errorField.code === '404') {
- callback(new errors.AttributeNotFound());
} else {
callback(new errors.EntityGenericError(entityName, typeInformation.type, body));
}
Making this change will not break the tests. Should I add it? |
|
Basically saying:
|
Maybe after these changes the NGSIUtils.getErrorField() function can be removed? It seems a remanent usage in lib/services/devices/registrationUtils.js stills, but maybe that part can be simplified. |
|
|
We (@AlvaroVega @mapedraza @fgalan ) agree in doing your suggested changes, along with the removal/refactoring in Thanks! |
Removal of getErrorField.
|
Fixed 2304aae - coverage drop now 0.5% or less. I'm assuming the remaining drop is some NGSI-v1 stuff in the IoTManger and middlewares dealing with attributes. |
Looking to the modifications in b1758c3...2304aae, I see getErrorField() has been removed along with two of its usages, in generateNGSI2OperationHandler() and generateNGSILDOperationHandler(). With regards to the third one I see at master within createRegistrationHandler() (https://github.com/telefonicaid/iotagent-node-lib/blob/master/lib/services/devices/registrationUtils.js#L57) I see you have removed the whole createRegistrationHandler() so that's fine :) |
|
The one in |
|
Great, all tests seems to be ported to V2. Now it is just pending a couple of pending reviews (related with nomenclature stuff):
After that, I think it is almost ready to merge |
|
Fixed 3be10f7 |
mapedraza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
The PR is in a good shape to start conducting e2e testing with IOTAs (+ Manager) generated from the following branches:
In the meanwhile, this PR would need a CHANGES_NEXT_RELEASE entry. Suggestion: |
|
Fixed 4a9fd4c |
|
Good news. The CI e2e pass with the NGSIv1-removed versions went OK last night :) So I think only this small issue is pending to do the merge: telefonicaid/sigfox-iotagent#111 (comment) |
fgalan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. There is still some drop in coverage (around -0.7%) but it's acceptable (taking into account we come from a higher drop)
This PR will now be merged, followed by all the related ones in the IOTAs repositories. Thanks @jason-fox for this huge amount of work and also thanks to @mapedraza for his review work!

config.isCurrentNGSI()clauses from plugins