-
Notifications
You must be signed in to change notification settings - Fork 1
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
Added test cases related to Firmware Upgrade plugin #55
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* This function is used to upgrade the firmware | ||
* @param name | ||
* @param location | ||
* @param type | ||
* @param progressinterval | ||
* @param hmac | ||
* @returns {Promise<T>} | ||
*/ | ||
export const firmwareUpgrade = function(name, location, type, progressinterval, hmac) { | ||
return this.$thunder.api.FirmwareControl.upgrade({ | ||
name: name, | ||
location: location, | ||
type: type, | ||
progressinterval: progressinterval, | ||
hmac: hmac, | ||
}) | ||
.then(result => result) | ||
.catch(err => err) | ||
} | ||
|
||
/** | ||
* This function is used to get the status of firmware upgrade | ||
* @returns {Promise<T>} | ||
*/ | ||
export const upgradeStatus = function() { | ||
return this.$thunder.api.FirmwareControl.status() | ||
.then(result => result) | ||
.catch(err => err) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { firmwareUpgrade, upgradeStatus } from '../../commonMethods/firmwarecontrol' | ||
import { pluginActivate, pluginDeactivate } from '../../commonMethods/controller' | ||
import constants from '../../commonMethods/constants' | ||
|
||
let listener | ||
|
||
export default { | ||
title: 'Firmware Upgrade - 001', | ||
description: 'Check the Upgrade of the device to the specified firmware', | ||
context: { | ||
state: 'completed', | ||
}, | ||
setup() { | ||
return this.$sequence([ | ||
() => pluginDeactivate.call(this, constants.firmwareUpgradePlugin), | ||
() => pluginActivate.call(this, constants.firmwareUpgradePlugin), | ||
() => { | ||
listener = this.$thunder.api.FirmwareControl.on( | ||
'upgradeprogress', | ||
data => { | ||
this.$data.write('upgradeStatus', data.status) | ||
}, | ||
e => { | ||
this.$log('Error subscribing to upgradeprogress: ', e) | ||
} | ||
) | ||
return true | ||
}, | ||
]) | ||
}, | ||
steps: [ | ||
{ | ||
description: 'Upgrade the firmware and check whether it is completed', | ||
sleep: 5, | ||
test() { | ||
//TODO - Update the test to enter the 'name', 'location', 'type', 'progressinterval', 'hmac' through User prompt | ||
return firmwareUpgrade.call(this, 'name', 'location', 'type', 'progressinterval', 'hmac') | ||
}, | ||
validate(res) { | ||
if (res == null) { | ||
return true | ||
} else { | ||
throw new Error(`FirmwareUpgrade is not invoked properly and the result is ${res}`) | ||
} | ||
}, | ||
}, | ||
{ | ||
description: 'Sleep until Completed event is detected', | ||
sleep() { | ||
// Purpose of this sleep is to wait until current step gets 'upgradeprogress' response from the listener | ||
return new Promise((resolve, reject) => { | ||
let attempts = 0 | ||
const interval = setInterval(() => { | ||
attempts++ | ||
if (this.$data.read('upgradeStatus') === this.$context.read('state')) { | ||
clearInterval(interval) | ||
setTimeout(resolve, 5000) //give it some time to load | ||
} else if (attempts > 100) { | ||
clearInterval(interval) | ||
reject('Upgrade Not completed') | ||
} | ||
}, 1000) | ||
}) | ||
}, | ||
}, | ||
{ | ||
description: 'Get Upgrade Status and validate the result', | ||
test() { | ||
return upgradeStatus.call(this) | ||
}, | ||
validate(res) { | ||
if (res == 'completed') { | ||
return true | ||
} else { | ||
throw new Error('Firmware upgrade not completed successfully') | ||
} | ||
}, | ||
}, | ||
], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { firmwareUpgrade } from '../../commonMethods/firmwarecontrol' | ||
import { pluginActivate, pluginDeactivate } from '../../commonMethods/controller' | ||
import constants from '../../commonMethods/constants' | ||
|
||
export default { | ||
title: 'Firmware Upgrade - 002', | ||
description: 'Check the upgrade Functionality when upgrade is already in progress', | ||
setup() { | ||
return this.$sequence([ | ||
() => pluginDeactivate.call(this, constants.firmwareUpgradePlugin), | ||
() => pluginActivate.call(this, constants.firmwareUpgradePlugin), | ||
]) | ||
}, | ||
steps: [ | ||
{ | ||
description: | ||
'Invoke Upgrade firmware when already firmware upgrade in progres and validate the result', | ||
sleep: 5, | ||
test() { | ||
//TODO - Update the test to enter the 'name', 'location', 'type', 'progressinterval', 'hmac' through User prompt | ||
firmwareUpgrade.call(this, 'name', 'location', 'type', 'progressinterval', 'hmac') | ||
return firmwareUpgrade.call(this, 'name', 'location', 'type', 'progressinterval', 'hmac') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest to use promise.all to run 2 promises in parallel, for reference: And same here, guess we wait until we can fill in something meaninful to avoid false negative results? |
||
}, | ||
validate(res) { | ||
if (res.code === 12 && res.message === 'ERROR_INPROGRESS') { | ||
return true | ||
} else { | ||
this.$log('Proper error message is not shown') | ||
return false | ||
} | ||
}, | ||
}, | ||
], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { firmwareUpgrade } from '../../commonMethods/firmwarecontrol' | ||
import { pluginActivate, pluginDeactivate } from '../../commonMethods/controller' | ||
import constants from '../../commonMethods/constants' | ||
|
||
export default { | ||
title: 'Firmware Upgrade - 002', | ||
description: 'Check the upgrade Functionality when upgrade is already in progress', | ||
context: { | ||
invalidURL: 'incorrectURL', | ||
}, | ||
setup() { | ||
return this.$sequence([ | ||
() => pluginDeactivate.call(this, constants.firmwareUpgradePlugin), | ||
() => pluginActivate.call(this, constants.firmwareUpgradePlugin), | ||
]) | ||
}, | ||
steps: [ | ||
{ | ||
description: | ||
'Invoke Upgrade firmware when already firmware upgrade in progres and validate the result', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to update description |
||
sleep: 5, | ||
test() { | ||
return firmwareUpgrade.call( | ||
this, | ||
'firmware_v.0', | ||
this.$context.read('invalidURL'), | ||
'CDL', | ||
'10', | ||
'hmac' | ||
) | ||
}, | ||
validate(res) { | ||
if (res.code === 15 && res.message === 'ERROR_INCORRECT_URL') { | ||
return true | ||
} else { | ||
this.$log('Proper error message is not shown') | ||
return false | ||
} | ||
}, | ||
}, | ||
], | ||
} |
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.
Do we want to merge this already or wait for an ability to fill this in with meaningful values?