66
77import expect from '@kbn/expect' ;
88import url from 'url' ;
9- import { sortBy , pick , last } from 'lodash' ;
9+ import { sortBy , pick , last , omit } from 'lodash' ;
1010import { ValuesType } from 'utility-types' ;
1111import { registry } from '../../../common/registry' ;
1212import { Maybe } from '../../../../../plugins/apm/typings/common' ;
@@ -306,7 +306,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
306306 before ( async ( ) => {
307307 response = await supertest . get (
308308 url . format ( {
309- pathname : `/api/apm/services/opbeans-java /dependencies` ,
309+ pathname : `/api/apm/services/opbeans-python /dependencies` ,
310310 query : {
311311 start,
312312 end,
@@ -323,14 +323,41 @@ export default function ApiTest({ getService }: FtrProviderContext) {
323323
324324 it ( 'returns at least one item' , ( ) => {
325325 expect ( response . body . length ) . to . be . greaterThan ( 0 ) ;
326+
327+ expectSnapshot (
328+ omit ( response . body [ 0 ] , [
329+ 'errorRate.timeseries' ,
330+ 'throughput.timeseries' ,
331+ 'latency.timeseries' ,
332+ ] )
333+ ) . toMatchInline ( `
334+ Object {
335+ "errorRate": Object {
336+ "value": 0,
337+ },
338+ "impact": 1.97910470896139,
339+ "latency": Object {
340+ "value": 1043.99015586546,
341+ },
342+ "name": "redis",
343+ "spanSubtype": "redis",
344+ "spanType": "db",
345+ "throughput": Object {
346+ "value": 40.6333333333333,
347+ },
348+ "type": "external",
349+ }
350+ ` ) ;
326351 } ) ;
327352
328353 it ( 'returns the right names' , ( ) => {
329354 const names = response . body . map ( ( item ) => item . name ) ;
330355 expectSnapshot ( names . sort ( ) ) . toMatchInline ( `
331356 Array [
332- "opbeans-go",
357+ "elasticsearch",
358+ "opbeans-java",
333359 "postgresql",
360+ "redis",
334361 ]
335362 ` ) ;
336363 } ) ;
@@ -342,7 +369,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
342369
343370 expectSnapshot ( serviceNames . sort ( ) ) . toMatchInline ( `
344371 Array [
345- "opbeans-go ",
372+ "opbeans-java ",
346373 ]
347374 ` ) ;
348375 } ) ;
@@ -356,32 +383,89 @@ export default function ApiTest({ getService }: FtrProviderContext) {
356383 expectSnapshot ( latencyValues ) . toMatchInline ( `
357384 Array [
358385 Object {
359- "latency": 38506.4285714286,
360- "name": "opbeans-go",
386+ "latency": 2568.40816326531,
387+ "name": "elasticsearch",
388+ },
389+ Object {
390+ "latency": 25593.875,
391+ "name": "opbeans-java",
361392 },
362393 Object {
363- "latency": 5908.77272727273 ,
394+ "latency": 28885.3293963255 ,
364395 "name": "postgresql",
365396 },
397+ Object {
398+ "latency": 1043.99015586546,
399+ "name": "redis",
400+ },
366401 ]
367402 ` ) ;
368403 } ) ;
369404
370405 it ( 'returns the right throughput values' , ( ) => {
371406 const throughputValues = sortBy (
372- response . body . map ( ( item ) => ( { name : item . name , latency : item . throughput . value } ) ) ,
407+ response . body . map ( ( item ) => ( { name : item . name , throughput : item . throughput . value } ) ) ,
373408 'name'
374409 ) ;
375410
376411 expectSnapshot ( throughputValues ) . toMatchInline ( `
377412 Array [
378413 Object {
379- "latency": 0.466666666666667,
380- "name": "opbeans-go",
414+ "name": "elasticsearch",
415+ "throughput": 13.0666666666667,
416+ },
417+ Object {
418+ "name": "opbeans-java",
419+ "throughput": 0.533333333333333,
381420 },
382421 Object {
383- "latency": 3.66666666666667,
384422 "name": "postgresql",
423+ "throughput": 50.8,
424+ },
425+ Object {
426+ "name": "redis",
427+ "throughput": 40.6333333333333,
428+ },
429+ ]
430+ ` ) ;
431+ } ) ;
432+
433+ it ( 'returns the right impact values' , ( ) => {
434+ const impactValues = sortBy (
435+ response . body . map ( ( item ) => ( {
436+ name : item . name ,
437+ impact : item . impact ,
438+ latency : item . latency . value ,
439+ throughput : item . throughput . value ,
440+ } ) ) ,
441+ 'name'
442+ ) ;
443+
444+ expectSnapshot ( impactValues ) . toMatchInline ( `
445+ Array [
446+ Object {
447+ "impact": 1.36961744704522,
448+ "latency": 2568.40816326531,
449+ "name": "elasticsearch",
450+ "throughput": 13.0666666666667,
451+ },
452+ Object {
453+ "impact": 0,
454+ "latency": 25593.875,
455+ "name": "opbeans-java",
456+ "throughput": 0.533333333333333,
457+ },
458+ Object {
459+ "impact": 100,
460+ "latency": 28885.3293963255,
461+ "name": "postgresql",
462+ "throughput": 50.8,
463+ },
464+ Object {
465+ "impact": 1.97910470896139,
466+ "latency": 1043.99015586546,
467+ "name": "redis",
468+ "throughput": 40.6333333333333,
385469 },
386470 ]
387471 ` ) ;
0 commit comments