changeset 146:e3ef516af2f4

Specify system and JVM IDs when sending kill-vm command Corrected kill-vm URL to use kill_vm action name and removed unnecessary receiver payload parameter. Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-August/024409.html
author Andrew Azores <aazores@redhat.com>
date Wed, 02 Aug 2017 09:24:15 -0400
parents d84aa90787cc
children 7c160e4e81a1
files src/app/components/jvm-info/kill-vm.service.js src/app/components/jvm-info/kill-vm.service.spec.js src/app/shared/services/command-channel.service.js src/app/shared/services/command-channel.service.spec.js
diffstat 4 files changed, 10 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/components/jvm-info/kill-vm.service.js	Tue Aug 01 15:40:08 2017 -0400
+++ b/src/app/components/jvm-info/kill-vm.service.js	Wed Aug 02 09:24:15 2017 -0400
@@ -41,13 +41,13 @@
       'commands',
       'v1',
       'actions',
-      'kill-vm',
+      'kill_vm',
       'systems',
-      'foo',
+      systemId,
       'agents',
-      'testAgent',
+      'testAgent', // TODO: replace with agentId once agent registers itself with correct id
       'jvms',
-      'abc',
+      jvmId,
       'sequence',
       this.commandChannel.sequence
     );
@@ -55,11 +55,7 @@
 
   killVm (systemId, agentId, jvmId, jvmPid) {
     return this.q((resolve, reject) => {
-      this.commandChannel.sendMessage(
-        this.getPath(systemId, agentId, jvmId),
-        'com.redhat.thermostat.killvm.agent.internal.KillVmReceiver',
-        { 'vm-pid': jvmPid }
-      ).then(
+      this.commandChannel.sendMessage(this.getPath(systemId, agentId, jvmId), { 'vm-pid': jvmPid }).then(
         success => {
           resolve({
             status: success.payload.respType.value === this.commandChannel.responseCodes.OK.value,
--- a/src/app/components/jvm-info/kill-vm.service.spec.js	Tue Aug 01 15:40:08 2017 -0400
+++ b/src/app/components/jvm-info/kill-vm.service.spec.js	Wed Aug 02 09:24:15 2017 -0400
@@ -71,9 +71,8 @@
 
   describe('CommandChannel delegation', () => {
     it('should delegate', () => {
-      svc.killVm('foo', 'bar', 'baz');
-      commandChannel.sendMessage.should.be.calledWith(sinon.match(svc.getPath('foo', 'bar', 'baz')),
-        'com.redhat.thermostat.killvm.agent.internal.KillVmReceiver');
+      svc.killVm('foo', 'bar', 'baz', 9999);
+      commandChannel.sendMessage.should.be.calledWith(sinon.match(svc.getPath('foo', 'bar', 'baz')), sinon.match({ 'vm-pid': 9999 }));
       scope.$apply();
     });
 
--- a/src/app/shared/services/command-channel.service.js	Tue Aug 01 15:40:08 2017 -0400
+++ b/src/app/shared/services/command-channel.service.js	Wed Aug 02 09:24:15 2017 -0400
@@ -83,7 +83,7 @@
     return val;
   }
 
-  sendMessage (connectPath, receiver, payload = {}) {
+  sendMessage (connectPath, payload = {}) {
     let defer = this.q.defer();
     let socket = this.socketFactory.createSocket(urlJoin(this.commandChannelUrl, connectPath));
     if (!socket) {
@@ -92,7 +92,6 @@
     }
 
     socket.addEventListener('open', open => {
-      payload.receiver = receiver;
       socket.send(JSON.stringify({
         type: CLIENT_REQUEST_TYPE,
         payload: payload
--- a/src/app/shared/services/command-channel.service.spec.js	Tue Aug 01 15:40:08 2017 -0400
+++ b/src/app/shared/services/command-channel.service.spec.js	Wed Aug 02 09:24:15 2017 -0400
@@ -98,13 +98,13 @@
     });
 
     it('should send message when socket is ready', () => {
-      svc.sendMessage('foo', 'bar');
+      svc.sendMessage('foo');
       webSocketFactory.addEventListener.should.be.calledWith('open', sinon.match.func);
       webSocketFactory.addEventListener.withArgs('open').args[0][1]();
       webSocketFactory.send.should.be.calledOnce();
       webSocketFactory.send.should.be.calledWith(JSON.stringify({
         type: 2,
-        payload: { receiver: 'bar' }
+        payload: {}
       }));
     });
 
@@ -167,19 +167,6 @@
       scope.$apply();
     });
 
-    it('should append receiver to payload if specified', () => {
-      svc.sendMessage('foo', 'bar', { prop: 5 });
-      webSocketFactory.addEventListener.should.be.calledWith('open', sinon.match.func);
-      webSocketFactory.addEventListener.withArgs('open').args[0][1]();
-      webSocketFactory.send.should.be.calledOnce();
-      webSocketFactory.send.should.be.calledWith(JSON.stringify({
-        type: 2,
-        payload: {
-          prop: 5,
-          receiver: 'bar'
-        }
-      }));
-    });
   });
 
   describe('auth credentials', () => {