diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/__snapshots__/instance_details.spec.snap b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/__snapshots__/instance_details.spec.snap deleted file mode 100644 index 2ec70b7491543..0000000000000 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/__snapshots__/instance_details.spec.snap +++ /dev/null @@ -1,59 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`APM API tests service_overview/instance_details.spec.ts basic no archive Instance details when data is loaded fetch instance details return the correct data 1`] = ` -Object { - "agent": Object { - "name": "java", - }, - "container": Object { - "id": "123", - }, - "host": Object { - "name": "multiple-env-service-production", - }, - "kubernetes": Object { - "container": Object {}, - "deployment": Object {}, - "pod": Object { - "uid": "234", - }, - "replicaset": Object {}, - }, - "service": Object { - "environment": "production", - "name": "service1", - "node": Object { - "name": "multiple-env-service-production", - }, - }, -} -`; - -exports[`Serverless Observability - Deployment-agnostic api integration tests APM service_overview Service Overview Instance details when data is loaded fetch instance details return the correct data 1`] = ` -Object { - "agent": Object { - "name": "java", - }, - "container": Object { - "id": "123", - }, - "host": Object { - "name": "multiple-env-service-production", - }, - "kubernetes": Object { - "container": Object {}, - "deployment": Object {}, - "pod": Object { - "uid": "234", - }, - "replicaset": Object {}, - }, - "service": Object { - "environment": "production", - "name": "service1", - "node": Object { - "name": "multiple-env-service-production", - }, - }, -} -`; diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/__snapshots__/instances_detailed_statistics.spec.snap b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/__snapshots__/instances_detailed_statistics.spec.snap deleted file mode 100644 index a5444cc6a6e32..0000000000000 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/__snapshots__/instances_detailed_statistics.spec.snap +++ /dev/null @@ -1,1317 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`APM API tests service_overview/instances_detailed_statistics.spec.ts basic apm_8.0.0 Service overview instances detailed statistics when data is loaded fetching data with comparison returns the right data for current and previous periods 5`] = ` -Object { - "currentPeriod": Object { - "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad": Object { - "cpuUsage": Array [ - Object { - "x": 1627974300000, - "y": 0.0015, - }, - Object { - "x": 1627974360000, - "y": 0.001, - }, - Object { - "x": 1627974420000, - "y": 0.0025, - }, - Object { - "x": 1627974480000, - "y": 0.0015, - }, - Object { - "x": 1627974540000, - "y": 0.0015, - }, - Object { - "x": 1627974600000, - "y": 0.0015, - }, - Object { - "x": 1627974660000, - "y": 0.0015, - }, - Object { - "x": 1627974720000, - "y": 0.002, - }, - Object { - "x": 1627974780000, - "y": 0.0015, - }, - Object { - "x": 1627974840000, - "y": 0.002, - }, - Object { - "x": 1627974900000, - "y": 0.0025, - }, - Object { - "x": 1627974960000, - "y": 0.001, - }, - Object { - "x": 1627975020000, - "y": 0.002, - }, - Object { - "x": 1627975080000, - "y": 0.002, - }, - Object { - "x": 1627975140000, - "y": 0.0025, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "errorRate": Array [ - Object { - "x": 1627974300000, - "y": 0, - }, - Object { - "x": 1627974360000, - "y": null, - }, - Object { - "x": 1627974420000, - "y": 0, - }, - Object { - "x": 1627974480000, - "y": 0, - }, - Object { - "x": 1627974540000, - "y": 0, - }, - Object { - "x": 1627974600000, - "y": 0.125, - }, - Object { - "x": 1627974660000, - "y": 0.6, - }, - Object { - "x": 1627974720000, - "y": 0.2, - }, - Object { - "x": 1627974780000, - "y": 0, - }, - Object { - "x": 1627974840000, - "y": 0, - }, - Object { - "x": 1627974900000, - "y": 0.0666666666666667, - }, - Object { - "x": 1627974960000, - "y": 0, - }, - Object { - "x": 1627975020000, - "y": 0, - }, - Object { - "x": 1627975080000, - "y": 0, - }, - Object { - "x": 1627975140000, - "y": 0.181818181818182, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "latency": Array [ - Object { - "x": 1627974300000, - "y": 34887.8888888889, - }, - Object { - "x": 1627974360000, - "y": null, - }, - Object { - "x": 1627974420000, - "y": 4983, - }, - Object { - "x": 1627974480000, - "y": 41285.4, - }, - Object { - "x": 1627974540000, - "y": 13820.3333333333, - }, - Object { - "x": 1627974600000, - "y": 13782, - }, - Object { - "x": 1627974660000, - "y": 13392.6, - }, - Object { - "x": 1627974720000, - "y": 6991, - }, - Object { - "x": 1627974780000, - "y": 6885.85714285714, - }, - Object { - "x": 1627974840000, - "y": 7935, - }, - Object { - "x": 1627974900000, - "y": 10828.3333333333, - }, - Object { - "x": 1627974960000, - "y": 6079, - }, - Object { - "x": 1627975020000, - "y": 5217, - }, - Object { - "x": 1627975080000, - "y": 8477.76923076923, - }, - Object { - "x": 1627975140000, - "y": 5937.18181818182, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "memoryUsage": Array [ - Object { - "x": 1627974300000, - "y": 0.786640167236328, - }, - Object { - "x": 1627974360000, - "y": 0.786666870117188, - }, - Object { - "x": 1627974420000, - "y": 0.786960601806641, - }, - Object { - "x": 1627974480000, - "y": 0.787132263183594, - }, - Object { - "x": 1627974540000, - "y": 0.787441253662109, - }, - Object { - "x": 1627974600000, - "y": 0.787555694580078, - }, - Object { - "x": 1627974660000, - "y": 0.788524627685547, - }, - Object { - "x": 1627974720000, - "y": 0.788822174072266, - }, - Object { - "x": 1627974780000, - "y": 0.789054870605469, - }, - Object { - "x": 1627974840000, - "y": 0.78936767578125, - }, - Object { - "x": 1627974900000, - "y": 0.789985656738281, - }, - Object { - "x": 1627974960000, - "y": 0.790130615234375, - }, - Object { - "x": 1627975020000, - "y": 0.790508270263672, - }, - Object { - "x": 1627975080000, - "y": 0.791069030761719, - }, - Object { - "x": 1627975140000, - "y": 0.791587829589844, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "serviceNodeName": "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad", - "throughput": Array [ - Object { - "x": 1627974300000, - "y": 9, - }, - Object { - "x": 1627974360000, - "y": 0, - }, - Object { - "x": 1627974420000, - "y": 4, - }, - Object { - "x": 1627974480000, - "y": 5, - }, - Object { - "x": 1627974540000, - "y": 6, - }, - Object { - "x": 1627974600000, - "y": 8, - }, - Object { - "x": 1627974660000, - "y": 5, - }, - Object { - "x": 1627974720000, - "y": 5, - }, - Object { - "x": 1627974780000, - "y": 7, - }, - Object { - "x": 1627974840000, - "y": 2, - }, - Object { - "x": 1627974900000, - "y": 15, - }, - Object { - "x": 1627974960000, - "y": 3, - }, - Object { - "x": 1627975020000, - "y": 8, - }, - Object { - "x": 1627975080000, - "y": 13, - }, - Object { - "x": 1627975140000, - "y": 11, - }, - Object { - "x": 1627975200000, - "y": 0, - }, - ], - }, - }, - "previousPeriod": Object { - "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad": Object { - "cpuUsage": Array [ - Object { - "x": 1627974300000, - "y": 0.0015, - }, - Object { - "x": 1627974360000, - "y": 0.002, - }, - Object { - "x": 1627974420000, - "y": 0.0025, - }, - Object { - "x": 1627974480000, - "y": 0.0015, - }, - Object { - "x": 1627974540000, - "y": 0.002, - }, - Object { - "x": 1627974600000, - "y": 0.002, - }, - Object { - "x": 1627974660000, - "y": 0.002, - }, - Object { - "x": 1627974720000, - "y": 0.002, - }, - Object { - "x": 1627974780000, - "y": 0.002, - }, - Object { - "x": 1627974840000, - "y": 0.0045, - }, - Object { - "x": 1627974900000, - "y": 0.0025, - }, - Object { - "x": 1627974960000, - "y": 0.0025, - }, - Object { - "x": 1627975020000, - "y": 0.002, - }, - Object { - "x": 1627975080000, - "y": 0.002, - }, - Object { - "x": 1627975140000, - "y": 0.0025, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "errorRate": Array [ - Object { - "x": 1627974300000, - "y": 0, - }, - Object { - "x": 1627974360000, - "y": 0, - }, - Object { - "x": 1627974420000, - "y": 0.333333333333333, - }, - Object { - "x": 1627974480000, - "y": 0.181818181818182, - }, - Object { - "x": 1627974540000, - "y": 0, - }, - Object { - "x": 1627974600000, - "y": 0, - }, - Object { - "x": 1627974660000, - "y": 0.166666666666667, - }, - Object { - "x": 1627974720000, - "y": 0.181818181818182, - }, - Object { - "x": 1627974780000, - "y": 0, - }, - Object { - "x": 1627974840000, - "y": 0, - }, - Object { - "x": 1627974900000, - "y": 0.0833333333333333, - }, - Object { - "x": 1627974960000, - "y": 0.0769230769230769, - }, - Object { - "x": 1627975020000, - "y": 0, - }, - Object { - "x": 1627975080000, - "y": 0.1, - }, - Object { - "x": 1627975140000, - "y": 0.153846153846154, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "latency": Array [ - Object { - "x": 1627974300000, - "y": 11839, - }, - Object { - "x": 1627974360000, - "y": 7407, - }, - Object { - "x": 1627974420000, - "y": 1925569.66666667, - }, - Object { - "x": 1627974480000, - "y": 9017.18181818182, - }, - Object { - "x": 1627974540000, - "y": 63575, - }, - Object { - "x": 1627974600000, - "y": 7577.66666666667, - }, - Object { - "x": 1627974660000, - "y": 6844.33333333333, - }, - Object { - "x": 1627974720000, - "y": 503471, - }, - Object { - "x": 1627974780000, - "y": 6247.8, - }, - Object { - "x": 1627974840000, - "y": 1137247, - }, - Object { - "x": 1627974900000, - "y": 27951.6666666667, - }, - Object { - "x": 1627974960000, - "y": 10248.8461538462, - }, - Object { - "x": 1627975020000, - "y": 13529, - }, - Object { - "x": 1627975080000, - "y": 6691247.8, - }, - Object { - "x": 1627975140000, - "y": 12098.6923076923, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "memoryUsage": Array [ - Object { - "x": 1627974300000, - "y": 0.780715942382813, - }, - Object { - "x": 1627974360000, - "y": 0.780921936035156, - }, - Object { - "x": 1627974420000, - "y": 0.781166076660156, - }, - Object { - "x": 1627974480000, - "y": 0.781524658203125, - }, - Object { - "x": 1627974540000, - "y": 0.781723022460938, - }, - Object { - "x": 1627974600000, - "y": 0.782463073730469, - }, - Object { - "x": 1627974660000, - "y": 0.782634735107422, - }, - Object { - "x": 1627974720000, - "y": 0.782939910888672, - }, - Object { - "x": 1627974780000, - "y": 0.783458709716797, - }, - Object { - "x": 1627974840000, - "y": 0.783935546875, - }, - Object { - "x": 1627974900000, - "y": 0.784690856933594, - }, - Object { - "x": 1627974960000, - "y": 0.785182952880859, - }, - Object { - "x": 1627975020000, - "y": 0.785446166992188, - }, - Object { - "x": 1627975080000, - "y": 0.786224365234375, - }, - Object { - "x": 1627975140000, - "y": 0.786415100097656, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "serviceNodeName": "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad", - "throughput": Array [ - Object { - "x": 1627974300000, - "y": 4, - }, - Object { - "x": 1627974360000, - "y": 2, - }, - Object { - "x": 1627974420000, - "y": 3, - }, - Object { - "x": 1627974480000, - "y": 11, - }, - Object { - "x": 1627974540000, - "y": 4, - }, - Object { - "x": 1627974600000, - "y": 6, - }, - Object { - "x": 1627974660000, - "y": 6, - }, - Object { - "x": 1627974720000, - "y": 11, - }, - Object { - "x": 1627974780000, - "y": 10, - }, - Object { - "x": 1627974840000, - "y": 10, - }, - Object { - "x": 1627974900000, - "y": 12, - }, - Object { - "x": 1627974960000, - "y": 13, - }, - Object { - "x": 1627975020000, - "y": 8, - }, - Object { - "x": 1627975080000, - "y": 10, - }, - Object { - "x": 1627975140000, - "y": 13, - }, - Object { - "x": 1627975200000, - "y": 0, - }, - ], - }, - }, -} -`; - -exports[`APM API tests service_overview/instances_detailed_statistics.spec.ts basic apm_8.0.0 Service overview instances detailed statistics when data is loaded fetching data without comparison returns the right data 3`] = ` -Object { - "currentPeriod": Object { - "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad": Object { - "cpuUsage": Array [ - Object { - "x": 1627973400000, - "y": 0.0015, - }, - Object { - "x": 1627973460000, - "y": 0.002, - }, - Object { - "x": 1627973520000, - "y": 0.0025, - }, - Object { - "x": 1627973580000, - "y": 0.0015, - }, - Object { - "x": 1627973640000, - "y": 0.002, - }, - Object { - "x": 1627973700000, - "y": 0.002, - }, - Object { - "x": 1627973760000, - "y": 0.002, - }, - Object { - "x": 1627973820000, - "y": 0.002, - }, - Object { - "x": 1627973880000, - "y": 0.002, - }, - Object { - "x": 1627973940000, - "y": 0.0045, - }, - Object { - "x": 1627974000000, - "y": 0.0025, - }, - Object { - "x": 1627974060000, - "y": 0.0025, - }, - Object { - "x": 1627974120000, - "y": 0.002, - }, - Object { - "x": 1627974180000, - "y": 0.002, - }, - Object { - "x": 1627974240000, - "y": 0.0025, - }, - Object { - "x": 1627974300000, - "y": 0.0015, - }, - Object { - "x": 1627974360000, - "y": 0.001, - }, - Object { - "x": 1627974420000, - "y": 0.0025, - }, - Object { - "x": 1627974480000, - "y": 0.0015, - }, - Object { - "x": 1627974540000, - "y": 0.0015, - }, - Object { - "x": 1627974600000, - "y": 0.0015, - }, - Object { - "x": 1627974660000, - "y": 0.0015, - }, - Object { - "x": 1627974720000, - "y": 0.002, - }, - Object { - "x": 1627974780000, - "y": 0.0015, - }, - Object { - "x": 1627974840000, - "y": 0.002, - }, - Object { - "x": 1627974900000, - "y": 0.0025, - }, - Object { - "x": 1627974960000, - "y": 0.001, - }, - Object { - "x": 1627975020000, - "y": 0.002, - }, - Object { - "x": 1627975080000, - "y": 0.002, - }, - Object { - "x": 1627975140000, - "y": 0.0025, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "errorRate": Array [ - Object { - "x": 1627973400000, - "y": 0, - }, - Object { - "x": 1627973460000, - "y": 0, - }, - Object { - "x": 1627973520000, - "y": 0.333333333333333, - }, - Object { - "x": 1627973580000, - "y": 0.181818181818182, - }, - Object { - "x": 1627973640000, - "y": 0, - }, - Object { - "x": 1627973700000, - "y": 0, - }, - Object { - "x": 1627973760000, - "y": 0.166666666666667, - }, - Object { - "x": 1627973820000, - "y": 0.181818181818182, - }, - Object { - "x": 1627973880000, - "y": 0, - }, - Object { - "x": 1627973940000, - "y": 0, - }, - Object { - "x": 1627974000000, - "y": 0.0833333333333333, - }, - Object { - "x": 1627974060000, - "y": 0.0769230769230769, - }, - Object { - "x": 1627974120000, - "y": 0, - }, - Object { - "x": 1627974180000, - "y": 0.1, - }, - Object { - "x": 1627974240000, - "y": 0.153846153846154, - }, - Object { - "x": 1627974300000, - "y": 0, - }, - Object { - "x": 1627974360000, - "y": null, - }, - Object { - "x": 1627974420000, - "y": 0, - }, - Object { - "x": 1627974480000, - "y": 0, - }, - Object { - "x": 1627974540000, - "y": 0, - }, - Object { - "x": 1627974600000, - "y": 0.125, - }, - Object { - "x": 1627974660000, - "y": 0.6, - }, - Object { - "x": 1627974720000, - "y": 0.2, - }, - Object { - "x": 1627974780000, - "y": 0, - }, - Object { - "x": 1627974840000, - "y": 0, - }, - Object { - "x": 1627974900000, - "y": 0.0666666666666667, - }, - Object { - "x": 1627974960000, - "y": 0, - }, - Object { - "x": 1627975020000, - "y": 0, - }, - Object { - "x": 1627975080000, - "y": 0, - }, - Object { - "x": 1627975140000, - "y": 0.181818181818182, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "latency": Array [ - Object { - "x": 1627973400000, - "y": 11839, - }, - Object { - "x": 1627973460000, - "y": 7407, - }, - Object { - "x": 1627973520000, - "y": 1925569.66666667, - }, - Object { - "x": 1627973580000, - "y": 9017.18181818182, - }, - Object { - "x": 1627973640000, - "y": 63575, - }, - Object { - "x": 1627973700000, - "y": 7577.66666666667, - }, - Object { - "x": 1627973760000, - "y": 6844.33333333333, - }, - Object { - "x": 1627973820000, - "y": 503471, - }, - Object { - "x": 1627973880000, - "y": 6247.8, - }, - Object { - "x": 1627973940000, - "y": 1137247, - }, - Object { - "x": 1627974000000, - "y": 27951.6666666667, - }, - Object { - "x": 1627974060000, - "y": 10248.8461538462, - }, - Object { - "x": 1627974120000, - "y": 13529, - }, - Object { - "x": 1627974180000, - "y": 6691247.8, - }, - Object { - "x": 1627974240000, - "y": 12098.6923076923, - }, - Object { - "x": 1627974300000, - "y": 34887.8888888889, - }, - Object { - "x": 1627974360000, - "y": null, - }, - Object { - "x": 1627974420000, - "y": 4983, - }, - Object { - "x": 1627974480000, - "y": 41285.4, - }, - Object { - "x": 1627974540000, - "y": 13820.3333333333, - }, - Object { - "x": 1627974600000, - "y": 13782, - }, - Object { - "x": 1627974660000, - "y": 13392.6, - }, - Object { - "x": 1627974720000, - "y": 6991, - }, - Object { - "x": 1627974780000, - "y": 6885.85714285714, - }, - Object { - "x": 1627974840000, - "y": 7935, - }, - Object { - "x": 1627974900000, - "y": 10828.3333333333, - }, - Object { - "x": 1627974960000, - "y": 6079, - }, - Object { - "x": 1627975020000, - "y": 5217, - }, - Object { - "x": 1627975080000, - "y": 8477.76923076923, - }, - Object { - "x": 1627975140000, - "y": 5937.18181818182, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "memoryUsage": Array [ - Object { - "x": 1627973400000, - "y": 0.780715942382813, - }, - Object { - "x": 1627973460000, - "y": 0.780921936035156, - }, - Object { - "x": 1627973520000, - "y": 0.781166076660156, - }, - Object { - "x": 1627973580000, - "y": 0.781524658203125, - }, - Object { - "x": 1627973640000, - "y": 0.781723022460938, - }, - Object { - "x": 1627973700000, - "y": 0.782463073730469, - }, - Object { - "x": 1627973760000, - "y": 0.782634735107422, - }, - Object { - "x": 1627973820000, - "y": 0.782939910888672, - }, - Object { - "x": 1627973880000, - "y": 0.783458709716797, - }, - Object { - "x": 1627973940000, - "y": 0.783935546875, - }, - Object { - "x": 1627974000000, - "y": 0.784690856933594, - }, - Object { - "x": 1627974060000, - "y": 0.785182952880859, - }, - Object { - "x": 1627974120000, - "y": 0.785446166992188, - }, - Object { - "x": 1627974180000, - "y": 0.786224365234375, - }, - Object { - "x": 1627974240000, - "y": 0.786415100097656, - }, - Object { - "x": 1627974300000, - "y": 0.786640167236328, - }, - Object { - "x": 1627974360000, - "y": 0.786666870117188, - }, - Object { - "x": 1627974420000, - "y": 0.786960601806641, - }, - Object { - "x": 1627974480000, - "y": 0.787132263183594, - }, - Object { - "x": 1627974540000, - "y": 0.787441253662109, - }, - Object { - "x": 1627974600000, - "y": 0.787555694580078, - }, - Object { - "x": 1627974660000, - "y": 0.788524627685547, - }, - Object { - "x": 1627974720000, - "y": 0.788822174072266, - }, - Object { - "x": 1627974780000, - "y": 0.789054870605469, - }, - Object { - "x": 1627974840000, - "y": 0.78936767578125, - }, - Object { - "x": 1627974900000, - "y": 0.789985656738281, - }, - Object { - "x": 1627974960000, - "y": 0.790130615234375, - }, - Object { - "x": 1627975020000, - "y": 0.790508270263672, - }, - Object { - "x": 1627975080000, - "y": 0.791069030761719, - }, - Object { - "x": 1627975140000, - "y": 0.791587829589844, - }, - Object { - "x": 1627975200000, - "y": null, - }, - ], - "serviceNodeName": "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad", - "throughput": Array [ - Object { - "x": 1627973400000, - "y": 4, - }, - Object { - "x": 1627973460000, - "y": 2, - }, - Object { - "x": 1627973520000, - "y": 3, - }, - Object { - "x": 1627973580000, - "y": 11, - }, - Object { - "x": 1627973640000, - "y": 4, - }, - Object { - "x": 1627973700000, - "y": 6, - }, - Object { - "x": 1627973760000, - "y": 6, - }, - Object { - "x": 1627973820000, - "y": 11, - }, - Object { - "x": 1627973880000, - "y": 10, - }, - Object { - "x": 1627973940000, - "y": 10, - }, - Object { - "x": 1627974000000, - "y": 12, - }, - Object { - "x": 1627974060000, - "y": 13, - }, - Object { - "x": 1627974120000, - "y": 8, - }, - Object { - "x": 1627974180000, - "y": 10, - }, - Object { - "x": 1627974240000, - "y": 13, - }, - Object { - "x": 1627974300000, - "y": 9, - }, - Object { - "x": 1627974360000, - "y": 0, - }, - Object { - "x": 1627974420000, - "y": 4, - }, - Object { - "x": 1627974480000, - "y": 5, - }, - Object { - "x": 1627974540000, - "y": 6, - }, - Object { - "x": 1627974600000, - "y": 8, - }, - Object { - "x": 1627974660000, - "y": 5, - }, - Object { - "x": 1627974720000, - "y": 5, - }, - Object { - "x": 1627974780000, - "y": 7, - }, - Object { - "x": 1627974840000, - "y": 2, - }, - Object { - "x": 1627974900000, - "y": 15, - }, - Object { - "x": 1627974960000, - "y": 3, - }, - Object { - "x": 1627975020000, - "y": 8, - }, - Object { - "x": 1627975080000, - "y": 13, - }, - Object { - "x": 1627975140000, - "y": 11, - }, - Object { - "x": 1627975200000, - "y": 0, - }, - ], - }, - }, - "previousPeriod": Object {}, -} -`; diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/dependencies/index.spec.ts b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/dependencies/index.spec.ts index c9c36d27ca70f..12acce1e1c3fd 100644 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/dependencies/index.spec.ts +++ b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/dependencies/index.spec.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { last, omit, pick, sortBy } from 'lodash'; +import { last, pick } from 'lodash'; import { ValuesType } from 'utility-types'; import { Node, NodeType } from '@kbn/apm-plugin/common/connections'; import { @@ -297,229 +297,8 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon }); }); - // UNSUPPORTED - describe.skip('when data is loaded', () => { - let response: { - status: number; - body: APIReturnType<'GET /internal/apm/services/{serviceName}/dependencies'>; - }; - - before(async () => { - response = await apmApiClient.readUser({ - endpoint: `GET /internal/apm/services/{serviceName}/dependencies`, - params: { - path: { serviceName: 'opbeans-python' }, - query: { - start, - end, - numBuckets: 20, - environment: ENVIRONMENT_ALL.value, - }, - }, - }); - }); - - it('returns a successful response', () => { - expect(response.status).to.be(200); - }); - - it('returns at least one item', () => { - expect(response.body.serviceDependencies.length).to.be.greaterThan(0); - - expectSnapshot(response.body.serviceDependencies.length).toMatchInline(`4`); - - const { currentStats, ...firstItem } = sortBy( - response.body.serviceDependencies, - 'currentStats.impact' - ).reverse()[0]; - - expectSnapshot(firstItem.location).toMatchInline(` - Object { - "agentName": "dotnet", - "dependencyName": "opbeans:3000", - "environment": "production", - "id": "5948c153c2d8989f92a9c75ef45bb845f53e200d", - "serviceName": "opbeans-dotnet", - "type": "service", - } - `); - - expectSnapshot( - omit(currentStats, [ - 'errorRate.timeseries', - 'throughput.timeseries', - 'latency.timeseries', - 'totalTime.timeseries', - ]) - ).toMatchInline(` - Object { - "errorRate": Object { - "value": 0.163636363636364, - }, - "impact": 100, - "latency": Object { - "value": 1117085.74545455, - }, - "throughput": Object { - "value": 1.83333333333333, - }, - "totalTime": Object { - "value": 61439716, - }, - } - `); - }); - - it('returns the right names', () => { - const names = response.body.serviceDependencies.map((item) => getName(item.location)); - expectSnapshot(names.sort()).toMatchInline(` - Array [ - "elasticsearch", - "opbeans-dotnet", - "postgresql", - "redis", - ] - `); - }); - - it('returns the right service names', () => { - const serviceNames = response.body.serviceDependencies - .map((item) => - item.location.type === NodeType.service ? getName(item.location) : undefined - ) - .filter(Boolean); - - expectSnapshot(serviceNames.sort()).toMatchInline(` - Array [ - "opbeans-dotnet", - ] - `); - }); - - it('returns the right latency values', () => { - const latencyValues = sortBy( - response.body.serviceDependencies.map((item) => ({ - name: getName(item.location), - latency: item.currentStats.latency.value, - })), - 'name' - ); - - expectSnapshot(latencyValues).toMatchInline(` - Array [ - Object { - "latency": 9496.32291666667, - "name": "elasticsearch", - }, - Object { - "latency": 1117085.74545455, - "name": "opbeans-dotnet", - }, - Object { - "latency": 27826.9968314322, - "name": "postgresql", - }, - Object { - "latency": 1468.27242524917, - "name": "redis", - }, - ] - `); - }); - - it('returns the right throughput values', () => { - const throughputValues = sortBy( - response.body.serviceDependencies.map((item) => ({ - name: getName(item.location), - throughput: item.currentStats.throughput.value, - })), - 'name' - ); - - expectSnapshot(throughputValues).toMatchInline(` - Array [ - Object { - "name": "elasticsearch", - "throughput": 3.2, - }, - Object { - "name": "opbeans-dotnet", - "throughput": 1.83333333333333, - }, - Object { - "name": "postgresql", - "throughput": 52.6, - }, - Object { - "name": "redis", - "throughput": 40.1333333333333, - }, - ] - `); - }); - - it('returns the right impact values', () => { - const impactValues = sortBy( - response.body.serviceDependencies.map((item) => ({ - name: getName(item.location), - impact: item.currentStats.impact, - })), - 'name' - ); - - expectSnapshot(impactValues).toMatchInline(` - Array [ - Object { - "impact": 0, - "name": "elasticsearch", - }, - Object { - "impact": 100, - "name": "opbeans-dotnet", - }, - Object { - "impact": 71.0403531954737, - "name": "postgresql", - }, - Object { - "impact": 1.41447268043525, - "name": "redis", - }, - ] - `); - }); - - it('returns the right totalTime values', () => { - const totalTimeValues = sortBy( - response.body.serviceDependencies.map((item) => ({ - name: getName(item.location), - totalTime: item.currentStats.totalTime.value, - })), - 'name' - ); - - expectSnapshot(totalTimeValues).toMatchInline(` - Array [ - Object { - "name": "elasticsearch", - "totalTime": 911647, - }, - Object { - "name": "opbeans-dotnet", - "totalTime": 61439716, - }, - Object { - "name": "postgresql", - "totalTime": 43911001, - }, - Object { - "name": "redis", - "totalTime": 1767800, - }, - ] - `); - }); - }); + // UNSUPPORTED TEST CASES - when data is loaded + // TODO: These tests should be migrated to use synthtrace }); }); } diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/instance_details.spec.ts b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/instance_details.spec.ts index c18b945a7eab1..d7eee00a48d53 100644 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/instance_details.spec.ts +++ b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/instance_details.spec.ts @@ -128,8 +128,33 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon expect(response.body).to.not.eql({}); }); - it.skip('return the correct data', () => { - expectSnapshot(omit(response.body, '@timestamp')).toMatch(); + it('return the correct data', () => { + expect(omit(response.body, '@timestamp')).to.eql({ + agent: { + name: "java", + }, + container: { + id: "123", + }, + host: { + name: "multiple-env-service-production", + }, + kubernetes: { + container: {}, + deployment: {}, + pod: { + uid: "234", + }, + replicaset: {}, + }, + service: { + environment: "production", + name: "service1", + node: { + name: "multiple-env-service-production", + } + } + }); }); }); }); diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/instances_detailed_statistics.spec.ts b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/instances_detailed_statistics.spec.ts index 63249363c5187..e4ff1609baec4 100644 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/instances_detailed_statistics.spec.ts +++ b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/service_overview/instances_detailed_statistics.spec.ts @@ -6,11 +6,7 @@ */ import expect from '@kbn/expect'; -import moment from 'moment'; -import { Coordinate } from '@kbn/apm-plugin/typings/timeseries'; import { LatencyAggregationType } from '@kbn/apm-plugin/common/latency_aggregation_types'; -import { isFiniteNumber } from '@kbn/apm-plugin/common/utils/is_finite_number'; -import { APIReturnType } from '@kbn/apm-plugin/public/services/rest/create_call_apm_api'; import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context'; import { getServiceNodeIds } from './get_service_node_ids'; @@ -24,11 +20,6 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon end: '2021-08-03T07:20:15.910Z', }; - interface Response { - status: number; - body: APIReturnType<'GET /internal/apm/services/{serviceName}/service_overview_instances/detailed_statistics'>; - } - describe('Service Overview', () => { describe('Instances detailed statistics', () => { describe('when data is not loaded', () => { @@ -58,151 +49,8 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon }); }); - // UNSUPPORTED - describe.skip('when data is loaded', () => { - describe('fetching data without comparison', () => { - let response: Response; - let serviceNodeIds: string[]; - - beforeEach(async () => { - serviceNodeIds = await getServiceNodeIds({ - apmApiClient, - start, - end, - }); - - response = await apmApiClient.readUser({ - endpoint: - 'GET /internal/apm/services/{serviceName}/service_overview_instances/detailed_statistics', - params: { - path: { serviceName }, - query: { - latencyAggregationType: LatencyAggregationType.avg, - start, - end, - numBuckets: 20, - transactionType: 'request', - serviceNodeIds: JSON.stringify(serviceNodeIds), - environment: 'ENVIRONMENT_ALL', - kuery: '', - }, - }, - }); - }); - - it('returns a service node item', () => { - expect(Object.values(response.body.currentPeriod).length).to.be.greaterThan(0); - expect(Object.values(response.body.previousPeriod)).to.eql(0); - }); - - it('returns statistics for each service node', async () => { - const item = response.body.currentPeriod[serviceNodeIds[0]]; - - expect(item?.cpuUsage?.some((point) => isFiniteNumber(point.y))).to.be(true); - expect(item?.memoryUsage?.some((point) => isFiniteNumber(point.y))).to.be(true); - expect(item?.errorRate?.some((point) => isFiniteNumber(point.y))).to.be(true); - expect(item?.throughput?.some((point) => isFiniteNumber(point.y))).to.be(true); - expect(item?.latency?.some((point) => isFiniteNumber(point.y))).to.be(true); - }); - - it('returns the right data', () => { - expectSnapshot(Object.values(response.body.currentPeriod).length).toMatchInline(`1`); - - expectSnapshot(Object.keys(response.body.currentPeriod)).toMatchInline(` - Array [ - "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad", - ] - `); - - expectSnapshot(response.body).toMatch(); - }); - }); - - describe('fetching data with comparison', () => { - let response: Response; - let serviceNodeIds: string[]; - - beforeEach(async () => { - serviceNodeIds = await getServiceNodeIds({ - apmApiClient, - start, - end, - }); - response = await apmApiClient.readUser({ - endpoint: - 'GET /internal/apm/services/{serviceName}/service_overview_instances/detailed_statistics', - params: { - path: { serviceName }, - query: { - latencyAggregationType: LatencyAggregationType.avg, - numBuckets: 20, - transactionType: 'request', - serviceNodeIds: JSON.stringify(serviceNodeIds), - start: moment(end).subtract(15, 'minutes').toISOString(), - end, - offset: '15m', - environment: 'ENVIRONMENT_ALL', - kuery: '', - }, - }, - }); - }); - - it('returns a service node item for current and previous periods', () => { - expect(Object.values(response.body.currentPeriod).length).to.be.greaterThan(0); - expect(Object.values(response.body.previousPeriod).length).to.be.greaterThan(0); - }); - - it('returns statistics for current and previous periods', () => { - const currentPeriodItem = response.body.currentPeriod[serviceNodeIds[0]]; - - function hasValidYCoordinate(point: Coordinate) { - return isFiniteNumber(point.y); - } - - expect(currentPeriodItem?.cpuUsage?.some(hasValidYCoordinate)).to.be(true); - expect(currentPeriodItem?.memoryUsage?.some(hasValidYCoordinate)).to.be(true); - expect(currentPeriodItem?.errorRate?.some(hasValidYCoordinate)).to.be(true); - expect(currentPeriodItem?.throughput?.some(hasValidYCoordinate)).to.be(true); - expect(currentPeriodItem?.latency?.some(hasValidYCoordinate)).to.be(true); - - const previousPeriodItem = response.body.previousPeriod[serviceNodeIds[0]]; - - expect(previousPeriodItem?.cpuUsage?.some(hasValidYCoordinate)).to.be(true); - expect(previousPeriodItem?.memoryUsage?.some(hasValidYCoordinate)).to.be(true); - expect(previousPeriodItem?.errorRate?.some(hasValidYCoordinate)).to.be(true); - expect(previousPeriodItem?.throughput?.some(hasValidYCoordinate)).to.be(true); - expect(previousPeriodItem?.latency?.some(hasValidYCoordinate)).to.be(true); - }); - - it('returns the right data for current and previous periods', () => { - expectSnapshot(Object.values(response.body.currentPeriod).length).toMatchInline(`1`); - expectSnapshot(Object.values(response.body.previousPeriod).length).toMatchInline(`1`); - - expectSnapshot(Object.keys(response.body.currentPeriod)).toMatchInline(` - Array [ - "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad", - ] - `); - expectSnapshot(Object.keys(response.body.previousPeriod)).toMatchInline(` - Array [ - "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad", - ] - `); - - expectSnapshot(response.body).toMatch(); - }); - - it('matches x-axis on current period and previous period', () => { - const currentLatencyItems = response.body.currentPeriod[serviceNodeIds[0]]?.latency; - const previousLatencyItems = response.body.previousPeriod[serviceNodeIds[0]]?.latency; - - expect(currentLatencyItems?.map(({ x }) => x)).to.be.eql( - previousLatencyItems?.map(({ x }) => x) - ); - }); - }); - }); + // UNSUPPORTED TEST CASES - when data is loaded + // TODO: These tests should be migrated to use synthtrace }); }); } diff --git a/x-pack/test/apm_api_integration/tests/service_overview/dependencies/index.spec.ts b/x-pack/test/apm_api_integration/tests/service_overview/dependencies/index.spec.ts new file mode 100644 index 0000000000000..c2c56e8148ede --- /dev/null +++ b/x-pack/test/apm_api_integration/tests/service_overview/dependencies/index.spec.ts @@ -0,0 +1,254 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { omit, sortBy } from 'lodash'; +import { Node, NodeType } from '@kbn/apm-plugin/common/connections'; +import { ENVIRONMENT_ALL } from '@kbn/apm-plugin/common/environment_filter_values'; +import { APIReturnType } from '@kbn/apm-plugin/public/services/rest/create_call_apm_api'; +import archives from '../../../common/fixtures/es_archiver/archives_metadata'; +import { FtrProviderContext } from '../../../common/ftr_provider_context'; + +export default function ApiTest({ getService }: FtrProviderContext) { + const registry = getService('registry'); + const apmApiClient = getService('apmApiClient'); + const es = getService('es'); + + const archiveName = 'apm_8.0.0'; + const { start, end } = archives[archiveName]; + + function getName(node: Node) { + return node.type === NodeType.service ? node.serviceName : node.dependencyName; + } + + registry.when( + 'Service overview dependencies when data is loaded', + { config: 'basic', archives: [archiveName] }, + () => { + let response: { + status: number; + body: APIReturnType<'GET /internal/apm/services/{serviceName}/dependencies'>; + }; + + before(async () => { + response = await apmApiClient.readUser({ + endpoint: `GET /internal/apm/services/{serviceName}/dependencies`, + params: { + path: { serviceName: 'opbeans-python' }, + query: { + start, + end, + numBuckets: 20, + environment: ENVIRONMENT_ALL.value, + }, + }, + }); + }); + + it('returns a successful response', () => { + expect(response.status).to.be(200); + }); + + it('returns at least one item', () => { + expect(response.body.serviceDependencies.length).to.be.greaterThan(0); + + expectSnapshot(response.body.serviceDependencies.length).toMatchInline(`4`); + + const { currentStats, ...firstItem } = sortBy( + response.body.serviceDependencies, + 'currentStats.impact' + ).reverse()[0]; + + expectSnapshot(firstItem.location).toMatchInline(` + Object { + "agentName": "dotnet", + "dependencyName": "opbeans:3000", + "environment": "production", + "id": "5948c153c2d8989f92a9c75ef45bb845f53e200d", + "serviceName": "opbeans-dotnet", + "type": "service", + } + `); + + expectSnapshot( + omit(currentStats, [ + 'errorRate.timeseries', + 'throughput.timeseries', + 'latency.timeseries', + 'totalTime.timeseries', + ]) + ).toMatchInline(` + Object { + "errorRate": Object { + "value": 0.163636363636364, + }, + "impact": 100, + "latency": Object { + "value": 1117085.74545455, + }, + "throughput": Object { + "value": 1.83333333333333, + }, + "totalTime": Object { + "value": 61439716, + }, + } + `); + }); + + it('returns the right names', () => { + const names = response.body.serviceDependencies.map((item) => getName(item.location)); + expectSnapshot(names.sort()).toMatchInline(` + Array [ + "elasticsearch", + "opbeans-dotnet", + "postgresql", + "redis", + ] + `); + }); + + it('returns the right service names', () => { + const serviceNames = response.body.serviceDependencies + .map((item) => + item.location.type === NodeType.service ? getName(item.location) : undefined + ) + .filter(Boolean); + + expectSnapshot(serviceNames.sort()).toMatchInline(` + Array [ + "opbeans-dotnet", + ] + `); + }); + + it('returns the right latency values', () => { + const latencyValues = sortBy( + response.body.serviceDependencies.map((item) => ({ + name: getName(item.location), + latency: item.currentStats.latency.value, + })), + 'name' + ); + + expectSnapshot(latencyValues).toMatchInline(` + Array [ + Object { + "latency": 9496.32291666667, + "name": "elasticsearch", + }, + Object { + "latency": 1117085.74545455, + "name": "opbeans-dotnet", + }, + Object { + "latency": 27826.9968314322, + "name": "postgresql", + }, + Object { + "latency": 1468.27242524917, + "name": "redis", + }, + ] + `); + }); + + it('returns the right throughput values', () => { + const throughputValues = sortBy( + response.body.serviceDependencies.map((item) => ({ + name: getName(item.location), + throughput: item.currentStats.throughput.value, + })), + 'name' + ); + + expectSnapshot(throughputValues).toMatchInline(` + Array [ + Object { + "name": "elasticsearch", + "throughput": 3.2, + }, + Object { + "name": "opbeans-dotnet", + "throughput": 1.83333333333333, + }, + Object { + "name": "postgresql", + "throughput": 52.6, + }, + Object { + "name": "redis", + "throughput": 40.1333333333333, + }, + ] + `); + }); + + it('returns the right impact values', () => { + const impactValues = sortBy( + response.body.serviceDependencies.map((item) => ({ + name: getName(item.location), + impact: item.currentStats.impact, + })), + 'name' + ); + + expectSnapshot(impactValues).toMatchInline(` + Array [ + Object { + "impact": 0, + "name": "elasticsearch", + }, + Object { + "impact": 100, + "name": "opbeans-dotnet", + }, + Object { + "impact": 71.0403531954737, + "name": "postgresql", + }, + Object { + "impact": 1.41447268043525, + "name": "redis", + }, + ] + `); + }); + + it('returns the right totalTime values', () => { + const totalTimeValues = sortBy( + response.body.serviceDependencies.map((item) => ({ + name: getName(item.location), + totalTime: item.currentStats.totalTime.value, + })), + 'name' + ); + + expectSnapshot(totalTimeValues).toMatchInline(` + Array [ + Object { + "name": "elasticsearch", + "totalTime": 911647, + }, + Object { + "name": "opbeans-dotnet", + "totalTime": 61439716, + }, + Object { + "name": "postgresql", + "totalTime": 43911001, + }, + Object { + "name": "redis", + "totalTime": 1767800, + }, + ] + `); + }); + } + ); +} diff --git a/x-pack/test/apm_api_integration/tests/service_overview/get_service_node_ids.ts b/x-pack/test/apm_api_integration/tests/service_overview/get_service_node_ids.ts new file mode 100644 index 0000000000000..ad3e872bcc879 --- /dev/null +++ b/x-pack/test/apm_api_integration/tests/service_overview/get_service_node_ids.ts @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { take } from 'lodash'; +import { LatencyAggregationType } from '@kbn/apm-plugin/common/latency_aggregation_types'; +import { ApmServices } from '../../common/config'; + +export async function getServiceNodeIds({ + apmApiClient, + start, + end, + serviceName = 'opbeans-java', + count = 1, +}: { + apmApiClient: Awaited<ReturnType<ApmServices['apmApiClient']>>; + start: string; + end: string; + serviceName?: string; + count?: number; +}) { + const { body } = await apmApiClient.readUser({ + endpoint: `GET /internal/apm/services/{serviceName}/service_overview_instances/main_statistics`, + params: { + path: { serviceName }, + query: { + latencyAggregationType: LatencyAggregationType.avg, + start, + end, + transactionType: 'request', + environment: 'ENVIRONMENT_ALL', + kuery: '', + sortField: 'throughput', + sortDirection: 'desc', + }, + }, + }); + + return take(body.currentPeriod.map((item) => item.serviceNodeName).sort(), count); +} diff --git a/x-pack/test/apm_api_integration/tests/service_overview/instances_detailed_statistics.spec.ts b/x-pack/test/apm_api_integration/tests/service_overview/instances_detailed_statistics.spec.ts new file mode 100644 index 0000000000000..00cc149c86b6d --- /dev/null +++ b/x-pack/test/apm_api_integration/tests/service_overview/instances_detailed_statistics.spec.ts @@ -0,0 +1,179 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import moment from 'moment'; +import { Coordinate } from '@kbn/apm-plugin/typings/timeseries'; +import { LatencyAggregationType } from '@kbn/apm-plugin/common/latency_aggregation_types'; +import { isFiniteNumber } from '@kbn/apm-plugin/common/utils/is_finite_number'; +import { APIReturnType } from '@kbn/apm-plugin/public/services/rest/create_call_apm_api'; +import { FtrProviderContext } from '../../common/ftr_provider_context'; +import archives from '../../common/fixtures/es_archiver/archives_metadata'; +import { getServiceNodeIds } from './get_service_node_ids'; + +export default function ApiTest({ getService }: FtrProviderContext) { + const registry = getService('registry'); + const apmApiClient = getService('apmApiClient'); + + const serviceName = 'opbeans-java'; + const archiveName = 'apm_8.0.0'; + const { start, end } = archives[archiveName]; + + interface Response { + status: number; + body: APIReturnType<'GET /internal/apm/services/{serviceName}/service_overview_instances/detailed_statistics'>; + } + + registry.when( + 'Service overview instances detailed statistics when data is loaded', + { config: 'basic', archives: [archiveName] }, + () => { + describe('fetching data without comparison', () => { + let response: Response; + let serviceNodeIds: string[]; + + beforeEach(async () => { + serviceNodeIds = await getServiceNodeIds({ + apmApiClient, + start, + end, + }); + + response = await apmApiClient.readUser({ + endpoint: + 'GET /internal/apm/services/{serviceName}/service_overview_instances/detailed_statistics', + params: { + path: { serviceName }, + query: { + latencyAggregationType: LatencyAggregationType.avg, + start, + end, + numBuckets: 20, + transactionType: 'request', + serviceNodeIds: JSON.stringify(serviceNodeIds), + environment: 'ENVIRONMENT_ALL', + kuery: '', + }, + }, + }); + }); + + it('returns a service node item', () => { + expect(Object.values(response.body.currentPeriod).length).to.be.greaterThan(0); + expect(Object.values(response.body.previousPeriod)).to.eql(0); + }); + + it('returns statistics for each service node', async () => { + const item = response.body.currentPeriod[serviceNodeIds[0]]; + + expect(item?.cpuUsage?.some((point) => isFiniteNumber(point.y))).to.be(true); + expect(item?.memoryUsage?.some((point) => isFiniteNumber(point.y))).to.be(true); + expect(item?.errorRate?.some((point) => isFiniteNumber(point.y))).to.be(true); + expect(item?.throughput?.some((point) => isFiniteNumber(point.y))).to.be(true); + expect(item?.latency?.some((point) => isFiniteNumber(point.y))).to.be(true); + }); + + it('returns the right data', () => { + expectSnapshot(Object.values(response.body.currentPeriod).length).toMatchInline(`1`); + + expectSnapshot(Object.keys(response.body.currentPeriod)).toMatchInline(` + Array [ + "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad", + ] + `); + + expectSnapshot(response.body).toMatch(); + }); + }); + + describe('fetching data with comparison', () => { + let response: Response; + let serviceNodeIds: string[]; + + beforeEach(async () => { + serviceNodeIds = await getServiceNodeIds({ + apmApiClient, + start, + end, + }); + response = await apmApiClient.readUser({ + endpoint: + 'GET /internal/apm/services/{serviceName}/service_overview_instances/detailed_statistics', + params: { + path: { serviceName }, + query: { + latencyAggregationType: LatencyAggregationType.avg, + numBuckets: 20, + transactionType: 'request', + serviceNodeIds: JSON.stringify(serviceNodeIds), + start: moment(end).subtract(15, 'minutes').toISOString(), + end, + offset: '15m', + environment: 'ENVIRONMENT_ALL', + kuery: '', + }, + }, + }); + }); + + it('returns a service node item for current and previous periods', () => { + expect(Object.values(response.body.currentPeriod).length).to.be.greaterThan(0); + expect(Object.values(response.body.previousPeriod).length).to.be.greaterThan(0); + }); + + it('returns statistics for current and previous periods', () => { + const currentPeriodItem = response.body.currentPeriod[serviceNodeIds[0]]; + + function hasValidYCoordinate(point: Coordinate) { + return isFiniteNumber(point.y); + } + + expect(currentPeriodItem?.cpuUsage?.some(hasValidYCoordinate)).to.be(true); + expect(currentPeriodItem?.memoryUsage?.some(hasValidYCoordinate)).to.be(true); + expect(currentPeriodItem?.errorRate?.some(hasValidYCoordinate)).to.be(true); + expect(currentPeriodItem?.throughput?.some(hasValidYCoordinate)).to.be(true); + expect(currentPeriodItem?.latency?.some(hasValidYCoordinate)).to.be(true); + + const previousPeriodItem = response.body.previousPeriod[serviceNodeIds[0]]; + + expect(previousPeriodItem?.cpuUsage?.some(hasValidYCoordinate)).to.be(true); + expect(previousPeriodItem?.memoryUsage?.some(hasValidYCoordinate)).to.be(true); + expect(previousPeriodItem?.errorRate?.some(hasValidYCoordinate)).to.be(true); + expect(previousPeriodItem?.throughput?.some(hasValidYCoordinate)).to.be(true); + expect(previousPeriodItem?.latency?.some(hasValidYCoordinate)).to.be(true); + }); + + it('returns the right data for current and previous periods', () => { + expectSnapshot(Object.values(response.body.currentPeriod).length).toMatchInline(`1`); + expectSnapshot(Object.values(response.body.previousPeriod).length).toMatchInline(`1`); + + expectSnapshot(Object.keys(response.body.currentPeriod)).toMatchInline(` + Array [ + "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad", + ] + `); + expectSnapshot(Object.keys(response.body.previousPeriod)).toMatchInline(` + Array [ + "31651f3c624b81c55dd4633df0b5b9f9ab06b151121b0404ae796632cd1f87ad", + ] + `); + + expectSnapshot(response.body).toMatch(); + }); + + it('matches x-axis on current period and previous period', () => { + const currentLatencyItems = response.body.currentPeriod[serviceNodeIds[0]]?.latency; + const previousLatencyItems = response.body.previousPeriod[serviceNodeIds[0]]?.latency; + + expect(currentLatencyItems?.map(({ x }) => x)).to.be.eql( + previousLatencyItems?.map(({ x }) => x) + ); + }); + }); + } + ); +}