Mercurial > hg > thermostat-ng > web-client
changeset 122:7f7956d7b541
Update jvm-gc mock endpoint to imitate web-gateway response
Reviewed-by: aazores, jkang
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-July/024067.html
author | Alex Macdonald <almacdon@redhat.com> |
---|---|
date | Wed, 12 Jul 2017 10:00:35 -0400 |
parents | bfe06b87ea58 |
children | f1079500a01f |
files | mock-api/endpoints/jvm-gc.endpoint.js src/app/components/jvm-info/jvm-gc/jvm-gc.controller.js src/app/components/jvm-info/jvm-gc/jvm-gc.controller.spec.js |
diffstat | 3 files changed, 49 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/mock-api/endpoints/jvm-gc.endpoint.js Wed Jul 12 09:53:26 2017 -0400 +++ b/mock-api/endpoints/jvm-gc.endpoint.js Wed Jul 12 10:00:35 2017 -0400 @@ -27,11 +27,12 @@ accumulatedMicros = 1000; } var data = { + agentId: 'foo-agentId', + jvmId: jvmId, + timeStamp: { $numberLong: (Date.now() - i).toString() }, collectorName: 'fooCollector', - timeStamp: Date.now() - i, - wallTimeInMicros: accumulatedMicros, - jvmId: jvmId, - agentId: 'foo-agentId' + runCount: { $numberLong: '0' }, + wallTimeInMicros: { $numberLong: accumulatedMicros.toString() } }; response.push(data); }
--- a/src/app/components/jvm-info/jvm-gc/jvm-gc.controller.js Wed Jul 12 09:53:26 2017 -0400 +++ b/src/app/components/jvm-info/jvm-gc/jvm-gc.controller.js Wed Jul 12 10:00:35 2017 -0400 @@ -30,17 +30,15 @@ import service from './jvm-gc.service.js'; class JvmGcController { - constructor (jvmId, $scope, $interval, jvmGcService, metricToBigIntFilter, - bigIntToStringFilter, stringToNumberFilter, unixToDateFilter) { + constructor (jvmId, $scope, $interval, jvmGcService, + metricToNumberFilter, unixToDateFilter) { 'ngInject'; this.jvmId = jvmId; this.scope = $scope; this.interval = $interval; this.jvmGcService = jvmGcService; - this.metricToBigInt = metricToBigIntFilter; - this.bigIntToString = bigIntToStringFilter; - this.stringToNumber = stringToNumberFilter; + this.metricToNumberFilter = metricToNumberFilter; this.unixToDate = unixToDateFilter; this.scope.refreshRate = '1000'; @@ -174,8 +172,8 @@ for (let i = resp.data.response.length - 1; i >= 0; i--) { let data = resp.data.response[i]; let collectorName = data.collectorName; - let timestamp = data.timeStamp; - let micros = data.wallTimeInMicros; + let timestamp = this.metricToNumberFilter(data.timeStamp); + let micros = this.metricToNumberFilter(data.wallTimeInMicros); seenCollectors.add(collectorName); this.makeConfig(collectorName, micros);
--- a/src/app/components/jvm-info/jvm-gc/jvm-gc.controller.spec.js Wed Jul 12 09:53:26 2017 -0400 +++ b/src/app/components/jvm-info/jvm-gc/jvm-gc.controller.spec.js Wed Jul 12 10:00:35 2017 -0400 @@ -86,8 +86,8 @@ response: [ { collectorName: 'fooCollector', - timeStamp: 100, - wallTimeInMicros: 50 + timeStamp: { $numberLong: '100' }, + wallTimeInMicros: { $numberLong: '50' } } ] } @@ -263,14 +263,14 @@ ctrl.collectors.should.deepEqual([]); ctrl.chartConfigs.should.deepEqual({}); ctrl.collectorData.has('fooCollector').should.be.false(); - let timestamp = Date.now(); + let timestamp = Date.now().toString(); ctrl.processData({ data: { response: [ { collectorName: 'fooCollector', - timeStamp: timestamp, - wallTimeInMicros: 50 + timeStamp: { $numberLong: timestamp }, + wallTimeInMicros: { $numberLong: '50' } } ] } @@ -278,26 +278,27 @@ ctrl.collectorData.has('fooCollector').should.be.true(); ctrl.collectorData.get('fooCollector').should.be.an.Array(); ctrl.collectorData.get('fooCollector').length.should.equal(1); - ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: timestamp, micros: 50 }); + ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: parseInt(timestamp), micros: 50 }); }); it('should process multiple service results', () => { ctrl.collectors.should.deepEqual([]); ctrl.chartConfigs.should.deepEqual({}); ctrl.collectorData.has('fooCollector').should.be.false(); - let timestamp = Date.now(); + let timestampA = Date.now().toString(); + let timestampB = (Date.now() - 10).toString(); ctrl.processData({ data: { response: [ { collectorName: 'fooCollector', - timeStamp: timestamp, - wallTimeInMicros: 50 + timeStamp: { $numberLong: timestampA }, + wallTimeInMicros: { $numberLong: '50' } }, { collectorName: 'fooCollector', - timeStamp: timestamp - 10, - wallTimeInMicros: 25 + timeStamp: { $numberLong: timestampB }, + wallTimeInMicros: { $numberLong: '25' } } ] } @@ -305,20 +306,20 @@ ctrl.collectorData.has('fooCollector').should.be.true(); ctrl.collectorData.get('fooCollector').should.be.an.Array(); ctrl.collectorData.get('fooCollector').length.should.equal(2); - ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: (timestamp - 10), micros: 25 }); - ctrl.collectorData.get('fooCollector')[1].should.deepEqual({ timestamp: timestamp, micros: 50 }); + ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: parseInt(timestampB), micros: 25 }); + ctrl.collectorData.get('fooCollector')[1].should.deepEqual({ timestamp: parseInt(timestampA), micros: 50 }); }); it('should append new data', () => { - let timestampA = Date.now(); - let timestampB = Date.now() + 5000; + let timestampA = Date.now().toString(); + let timestampB = (Date.now() + 5000).toString(); ctrl.processData({ data: { response: [ { collectorName: 'fooCollector', - timeStamp: timestampA, - wallTimeInMicros: 50 + timeStamp: { $numberLong: timestampA }, + wallTimeInMicros: { $numberLong: '50' } } ] } @@ -328,8 +329,8 @@ response: [ { collectorName: 'fooCollector', - timeStamp: timestampB, - wallTimeInMicros: 100 + timeStamp: { $numberLong: timestampB }, + wallTimeInMicros: { $numberLong: '100' } } ] } @@ -337,19 +338,20 @@ ctrl.collectorData.has('fooCollector').should.be.true(); ctrl.collectorData.get('fooCollector').should.be.an.Array(); ctrl.collectorData.get('fooCollector').length.should.equal(2); - ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: timestampA, micros: 50 }); - ctrl.collectorData.get('fooCollector')[1].should.deepEqual({ timestamp: timestampB, micros: 100 }); + ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: parseInt(timestampA), micros: 50 }); + ctrl.collectorData.get('fooCollector')[1].should.deepEqual({ timestamp: parseInt(timestampB), micros: 100 }); }); it('should append a sample with duplicate elapsed time if no sample received for a collector', () => { - let timestamp = Date.now(); + let timestampA = Date.now().toString(); + let timestampB = (Date.now() + 10).toString(); ctrl.processData({ data: { response: [ { collectorName: 'fooCollector', - timeStamp: timestamp, - wallTimeInMicros: 100 + timeStamp: { $numberLong: timestampA }, + wallTimeInMicros: { $numberLong: '100' } } ] } @@ -359,46 +361,46 @@ response: [ { collectorName: 'barCollector', - timeStamp: timestamp + 10, - wallTimeInMicros: 200 + timeStamp: { $numberLong: timestampB }, + wallTimeInMicros: { $numberLong: '200' } } ] } }); ctrl.collectorData.get('fooCollector').length.should.equal(2); - ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: timestamp, micros: 100 }); - ctrl.collectorData.get('fooCollector')[1].should.deepEqual({ timestamp: timestamp + 10, micros: 100 }); + ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: parseInt(timestampA), micros: 100 }); + ctrl.collectorData.get('fooCollector')[1].should.deepEqual({ timestamp: parseInt(timestampB), micros: 100 }); ctrl.collectorData.get('barCollector').length.should.equal(1); - ctrl.collectorData.get('barCollector')[0].should.deepEqual({ timestamp: timestamp + 10, micros: 200 }); + ctrl.collectorData.get('barCollector')[0].should.deepEqual({ timestamp: parseInt(timestampB), micros: 200 }); }); it('should ignore duplicate timestamps', () => { - let timestamp = Date.now(); + let timestamp = Date.now().toString(); ctrl.processData({ data: { response: [ { collectorName: 'fooCollector', - timeStamp: timestamp, - wallTimeInMicros: 200 + timeStamp: { $numberLong: timestamp }, + wallTimeInMicros: { $numberLong: 200 } }, { collectorName: 'fooCollector', - timeStamp: timestamp, - wallTimeInMicros: 100 + timeStamp: { $numberLong: timestamp }, + wallTimeInMicros: { $numberLong: 100 } }, { collectorName: 'fooCollector', - timeStamp: timestamp, - wallTimeInMicros: 100 + timeStamp: { $numberLong: timestamp }, + wallTimeInMicros: { $numberLong: 100 } } ] } }); ctrl.collectorData.get('fooCollector').length.should.equal(1); // note: response is processed in reverse order, so 100 is seen first - ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: timestamp, micros: 100 }); + ctrl.collectorData.get('fooCollector')[0].should.deepEqual({ timestamp: parseInt(timestamp), micros: 100 }); }); });