-
Notifications
You must be signed in to change notification settings - Fork 30
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
Remove obsolete v1 tests #248
Conversation
- These tests are duplicated by equivalent v2 tests
Maybe this PR shoud use |
Eventually it will, but some of the unit-tests which are still v1, which haven't got v2 duplicates will need to updated to use first. This series of PR is just reducing the target area by deleting obvious duplicates first. |
GitHub Actions is reporting this fail in tests:
Sometimes we have glitches due to timeout expiration in tests, but not sure if this is the case. I have re-run GitActions several times and it seems it always fail the same way. Currently master is fine: I'll relaunch test in master. Let's see how it goes... |
The run in master has failed: However, not the same way... much more test are failing in master:
Not sure what could be happening (maybe some recent changes in iotagent-node-lib that have impacted someway in this agent?) but until this can be analyzed in master I think it is not good idea to merge this PR... it would increase entropy in the code. |
@mapedraza @fgalan - given the recent activity on other PRs, I think this may be ready too. It is a simple deletion. I don't know why the one test is timing out, but it is better than existing |
describe( | ||
'When a device sends a registration request for a provisioned device without type configuration' + | ||
' and without an explicit LWM2M Mapping', | ||
function(done) { | ||
const registration = { | ||
url: 'http://localhost:' + config.ngsi.server.port + '/iot/devices', | ||
method: 'POST', | ||
json: utils.readExampleFile('./test/provisionExamples/provisionMinimumDevice.json'), | ||
headers: { | ||
'fiware-service': 'smartgondor', | ||
'fiware-servicepath': '/gardens' | ||
} | ||
}; | ||
|
||
beforeEach(function(done) { | ||
async.series( | ||
[ | ||
apply(lwm2mClient.registry.create, '/3303/0'), | ||
apply(lwm2mClient.registry.create, '/3304/0'), | ||
apply(lwm2mClient.registry.setResource, '/3303/0', '0', '19'), | ||
apply(lwm2mClient.registry.setResource, '/3304/0', '0', '85'), | ||
apply(request, registration), | ||
apply(lwm2mClient.register, clientConfig.host, clientConfig.port, '/', 'ws1') | ||
], | ||
function(error) { | ||
done(); | ||
} | ||
); | ||
}); | ||
|
||
it('should use the OMA Registry mapping to create the NGSI attributes', function(done) { | ||
const ngsiQuery = { | ||
url: | ||
'http://' + | ||
config.ngsi.contextBroker.host + | ||
':' + | ||
config.ngsi.contextBroker.port + | ||
'/v1/queryContext', | ||
method: 'POST', | ||
json: { | ||
entities: [ | ||
{ | ||
type: 'WeatherStation', | ||
isPattern: 'false', | ||
id: 'Weather1' | ||
} | ||
], | ||
attributes: ['Temperature Sensor#0'] | ||
}, | ||
headers: { | ||
'fiware-service': 'smartgondor', | ||
'fiware-servicepath': '/gardens' | ||
} | ||
}; | ||
|
||
request(ngsiQuery, function(error, response, body) { | ||
should.not.exist(error); | ||
should.not.exist(body.orionError); | ||
response.statusCode.should.equal(200); | ||
|
||
should.exist(body.contextResponses); | ||
should.exist(body.contextResponses[0]); | ||
should.exist(body.contextResponses[0].contextElement); | ||
should.exist(body.contextResponses[0].contextElement.attributes[0]); | ||
should.exist(body.contextResponses[0].contextElement.attributes[0].value); | ||
body.contextResponses[0].contextElement.attributes[0].value.should.equal('19'); | ||
|
||
done(); | ||
}); | ||
}); | ||
it('should support the unregistered attributes with a register in OMA Registry'); | ||
} | ||
); |
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.
This describe is not present on v2 test
describe('When a preprovisioned device sends a registration request to the the IoT Agent', function(done) { | ||
const options = { | ||
url: 'http://localhost:' + config.ngsi.server.port + '/iot/devices', | ||
method: 'POST', | ||
json: utils.readExampleFile('./test/provisionExamples/preprovisionDevice.json'), | ||
headers: { | ||
'fiware-service': 'smartgondor', | ||
'fiware-servicepath': '/gardens' | ||
} | ||
}; | ||
|
||
beforeEach(function(done) { | ||
request(options, function(error, response, body) { | ||
async.series( | ||
[ | ||
apply(lwm2mClient.registry.create, '/5000/0'), | ||
async.apply(lwm2mClient.registry.setResource, '/5000/0', '2', '89'), | ||
async.apply(lwm2mClient.registry.setResource, '/5000/0', '2', '19') | ||
], | ||
done | ||
); | ||
}); | ||
}); | ||
|
||
it('should return the registration information', function(done) { | ||
lwm2mClient.register(clientConfig.host, clientConfig.port, '/rd', 'PreprovisionedLight1', function( | ||
error, | ||
result | ||
) { | ||
should.not.exist(error); | ||
should.exist(result); | ||
should.exist(result.serverInfo); | ||
should.exist(result.location); | ||
|
||
done(); | ||
}); | ||
}); | ||
it('should register its passive attributes in the Context Broker as a Context Provider', function(done) { | ||
lwm2mClient.register(clientConfig.host, clientConfig.port, '/rd', 'PreprovisionedLight1', function( | ||
error, | ||
result | ||
) { | ||
ngsiClient.discover('ThePreprovisionedLight', 'APreprovisionedDevice', undefined, function( | ||
error, | ||
response, | ||
body | ||
) { | ||
should.not.exist(error); | ||
should.exist(body); | ||
should.not.exist(body.errorCode); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should subscribe to its active attributes', function(done) { | ||
lwm2mClient.register(clientConfig.host, clientConfig.port, '/rd', 'PreprovisionedLight1', function( | ||
error, | ||
result | ||
) { | ||
setTimeout(function() { | ||
ngsiClient.query('ThePreprovisionedLight', 'APreprovisionedDevice', ['pressure'], function( | ||
error, | ||
response, | ||
body | ||
) { | ||
should.not.exist(error); | ||
should.exist(body); | ||
should.not.exist(body.errorCode); | ||
body.contextResponses[0].contextElement.attributes[0].value.should.match(/19|89/); | ||
|
||
done(); | ||
}); | ||
}, 500); | ||
}); | ||
}); | ||
}); |
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.
This describe is not present on v2 test
it('should observe internal attributes', function(done) { | ||
lwm2mClient.register(clientConfig.host, clientConfig.port, '/rd', 'ws1', function(error, result) { | ||
should.not.exist(error); | ||
should.exist(result); | ||
should.exist(result.serverInfo); | ||
should.exist(result.location); | ||
setTimeout(function() { | ||
async.series( | ||
[ | ||
async.apply(lwm2mClient.registry.setResource, '/3303/0', '0', '89'), | ||
async.nextTick, | ||
async.apply(lwm2mClient.registry.setResource, '/3303/0', '0', '33'), | ||
async.nextTick, | ||
async.apply(lwm2mClient.registry.setResource, '/3303/0', '0', '19'), | ||
async.nextTick | ||
], | ||
function(error) { | ||
setTimeout(function() { | ||
ngsiClient.query('weather1', 'weatherStation', ['Temperature Sensor'], function( | ||
error, | ||
response, | ||
body | ||
) { | ||
should.not.exist(error); | ||
should.exist(body); | ||
should.not.exist(body.errorCode); | ||
body.contextResponses[0].contextElement.attributes[0].value.should.equal('19'); | ||
done(); | ||
}); | ||
}, 500); | ||
} | ||
); | ||
}, 1000); | ||
}); |
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.
This it case is not present in v2 test
apply(lwm2mClient.registry.create, '/3303/0'), | ||
async.apply(lwm2mClient.registry.setResource, '/3303/0', '0', '19') | ||
], | ||
done | ||
); | ||
}); | ||
|
||
it('should return the appropiate error', function(done) { | ||
const deviceInfo = { | ||
_id: '5a5dfe44f3dffc5e233d27d3', | ||
id: 79, | ||
type: 'Device', | ||
name: 'ws1', | ||
lifetime: '85671', | ||
path: '/rd/rd', | ||
port: 35239, | ||
address: '127.0.0.1', | ||
creationDate: '2018-01-16T13:29:40.972Z' | ||
}; | ||
|
||
updateRegistration.handler(deviceInfo, null, function(error) { | ||
should.exist(error); | ||
error.name.should.equal('DEVICE_NOT_FOUND'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe( | ||
'When a preprovisioned device registers to the the IoT Agent with an active attribute ' + | ||
'without internal mapping, but present in the OMA registry', | ||
function(done) { | ||
const options = { | ||
url: 'http://localhost:' + config.ngsi.server.port + '/iot/devices', | ||
method: 'POST', | ||
json: utils.readExampleFile('./test/provisionExamples/preprovisionDeviceOMANoInternalMapping.json'), | ||
headers: { | ||
'fiware-service': 'smartgondor', | ||
'fiware-servicepath': '/gardens' | ||
} | ||
}; | ||
|
||
beforeEach(function(done) { | ||
request(options, function(error, response, body) { | ||
async.series( | ||
[ | ||
apply(lwm2mClient.registry.create, '/3303/0'), | ||
async.apply(lwm2mClient.registry.setResource, '/3303/0', '0', '19') | ||
], | ||
done | ||
); | ||
}); | ||
}); | ||
|
||
it('should handle device update queries and restart observations', function(done) { | ||
lwm2mClient.register(clientConfig.host, clientConfig.port, '/rd', 'ws1', function(error, result) { | ||
should.not.exist(error); | ||
should.exist(result); | ||
should.exist(result.serverInfo); | ||
should.exist(result.location); | ||
lwm2mClient.update(result, function(error, result) { | ||
should.not.exist(error); | ||
should.exist(result); | ||
should.exist(result.serverInfo); | ||
should.exist(result.location); | ||
setTimeout(function() { | ||
async.series( | ||
[ | ||
async.apply(lwm2mClient.registry.setResource, '/3303/0', '0', '44'), | ||
async.nextTick, | ||
async.apply(lwm2mClient.registry.setResource, '/3303/0', '0', '22'), | ||
async.nextTick, | ||
async.apply(lwm2mClient.registry.setResource, '/3303/0', '0', '00'), | ||
async.nextTick | ||
], | ||
function(error) { | ||
setTimeout(function() { | ||
ngsiClient.query('weather1', 'weatherStation', ['Temperature Sensor'], function( | ||
error, | ||
response, | ||
body | ||
) { | ||
should.not.exist(error); | ||
should.exist(body); | ||
should.not.exist(body.errorCode); | ||
body.contextResponses[0].contextElement.attributes[0].value.should.equal( | ||
'00' | ||
); | ||
done(); | ||
}); | ||
}, 500); | ||
} | ||
); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
} | ||
); | ||
}); |
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.
this test does not have an equivalent in ngsiv2
Gaps detected by @mapedraza moved to issue #252 |
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
In order to merge telefonicaid/iotagent-node-lib#995 I want to get the unit-tests running without relying on NGSI-v1. This PR just deletes tests which are already duplicated in the NGSI-v2 test suite. Any drop in coverage should be within acceptable limits.