1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-23 19:53:47 +00:00

Updated Self-Update Test, to uninstall service after finishing test

This commit is contained in:
Bryan Roe
2022-06-27 20:01:35 -07:00
parent b6349db37e
commit 9a0a4dede4

View File

@@ -142,7 +142,7 @@ server.on('upgrade', function (msg, sck, head)
}); });
global._client.on('end', function () global._client.on('end', function ()
{ {
console.log('Agent Disconnected...'); if (updateState < 99) { console.log('Agent Disconnected...'); }
}); });
global._client.command = function command(j) global._client.command = function command(j)
{ {
@@ -356,12 +356,22 @@ server.on('upgrade', function (msg, sck, head)
}.bind(this), delay); }.bind(this), delay);
} }
else
{
updateState = 99;
console.log('==> End of Test');
var params = ['--meshServiceName=TestAgent'];
var paramsString = JSON.stringify(params);
require('agent-installer').fullUninstall(paramsString);
console.setDestination(console.Destinations.STDOUT);
}
break; break;
case MeshCommand_CoreModuleHash: case MeshCommand_CoreModuleHash:
var hash = buffer.slice(4).toString('hex'); var hash = buffer.slice(4).toString('hex');
console.log('CoreModuleHash[' + hash.length + ']=' + hash); if (updateState < 99) { console.log('CoreModuleHash[' + hash.length + ']=' + hash); }
if (process.argv.getParameter('NoInstall') == null) if (process.argv.getParameter('NoInstall') == null && updateState<99)
{ {
console.log('Service PID: ' + getPID()); console.log('Service PID: ' + getPID());
} }
@@ -378,6 +388,9 @@ server.on('upgrade', function (msg, sck, head)
this.write(b); this.write(b);
this.command({ url: 'https://127.0.0.1:9250/update', action: 'agentupdate', hash: getSHA384FileHash(getCurrentUpdatePath()).toString('hex'), sessionid: 'none' }); this.command({ url: 'https://127.0.0.1:9250/update', action: 'agentupdate', hash: getSHA384FileHash(getCurrentUpdatePath()).toString('hex'), sessionid: 'none' });
break; break;
case 99:
// No-Op because we are done
break;
default: default:
console.log('Agent Update State: ' + updateState); console.log('Agent Update State: ' + updateState);
break; break;