From 581589f708886a5877ad9c26ef0daeeaa5c949e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Mon, 18 Dec 2023 16:21:07 +0100 Subject: [PATCH] Remove legacy unit test --- .../__snapshots__/queries.test.ts.snap | 314 ------------------ .../server/routes/services/queries.test.ts | 90 ----- 2 files changed, 404 deletions(-) delete mode 100644 x-pack/plugins/apm/server/routes/services/__snapshots__/queries.test.ts.snap delete mode 100644 x-pack/plugins/apm/server/routes/services/queries.test.ts diff --git a/x-pack/plugins/apm/server/routes/services/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/services/__snapshots__/queries.test.ts.snap deleted file mode 100644 index 9625af3c5f4b86..00000000000000 --- a/x-pack/plugins/apm/server/routes/services/__snapshots__/queries.test.ts.snap +++ /dev/null @@ -1,314 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`services queries fetches the agent status 1`] = ` -Object { - "apm": Object { - "events": Array [ - "error", - "metric", - "transaction", - ], - }, - "body": Object { - "query": undefined, - "size": 0, - "terminate_after": 1, - "track_total_hits": 1, - }, -} -`; - -exports[`services queries fetches the service agent name 1`] = ` -Object { - "apm": Object { - "events": Array [ - "error", - "transaction", - "metric", - ], - }, - "body": Object { - "_source": Array [ - "agent.name", - "service.runtime.name", - "cloud.provider", - "cloud.service.name", - ], - "query": Object { - "bool": Object { - "filter": Array [ - Object { - "term": Object { - "service.name": "foo", - }, - }, - Object { - "range": Object { - "@timestamp": Object { - "format": "epoch_millis", - "gte": 0, - "lte": 50000, - }, - }, - }, - Object { - "exists": Object { - "field": "agent.name", - }, - }, - ], - "should": Array [ - Object { - "exists": Object { - "field": "service.runtime.name", - }, - }, - Object { - "exists": Object { - "field": "cloud.provider", - }, - }, - Object { - "exists": Object { - "field": "cloud.service.name", - }, - }, - ], - }, - }, - "size": 1, - "sort": Object { - "_score": Object { - "order": "desc", - }, - }, - "track_total_hits": 1, - }, - "terminate_after": 1, -} -`; - -exports[`services queries fetches the service items 1`] = ` -Array [ - Object { - "apm": Object { - "sources": Array [ - Object { - "documentType": "transactionEvent", - "rollupInterval": "none", - }, - ], - }, - "body": Object { - "aggs": Object { - "sample": Object { - "aggs": Object { - "overflowCount": Object { - "sum": Object { - "field": "service_transaction.aggregation.overflow_count", - }, - }, - "services": Object { - "aggs": Object { - "transactionType": Object { - "aggs": Object { - "avg_duration": Object { - "avg": Object { - "field": "transaction.duration.us", - }, - }, - "environments": Object { - "terms": Object { - "field": "service.environment", - }, - }, - "sample": Object { - "top_metrics": Object { - "metrics": Array [ - Object { - "field": "agent.name", - }, - ], - "sort": Object { - "@timestamp": "desc", - }, - }, - }, - "successful": Object { - "filter": Object { - "bool": Object { - "filter": Array [ - Object { - "terms": Object { - "event.outcome": Array [ - "success", - ], - }, - }, - ], - }, - }, - }, - "successful_or_failed": Object { - "filter": Object { - "bool": Object { - "filter": Array [ - Object { - "terms": Object { - "event.outcome": Array [ - "failure", - "success", - ], - }, - }, - ], - }, - }, - }, - }, - "terms": Object { - "field": "transaction.type", - }, - }, - }, - "terms": Object { - "field": "service.name", - "size": 1000, - }, - }, - }, - "random_sampler": Object { - "probability": 1, - "seed": 0, - }, - }, - }, - "query": Object { - "bool": Object { - "filter": Array [ - Object { - "range": Object { - "@timestamp": Object { - "format": "epoch_millis", - "gte": 0, - "lte": 50000, - }, - }, - }, - ], - }, - }, - "size": 0, - "track_total_hits": false, - }, - }, - Object { - "apm": Object { - "events": Array [ - "metric", - "error", - ], - }, - "body": Object { - "aggs": Object { - "sample": Object { - "aggs": Object { - "services": Object { - "aggs": Object { - "environments": Object { - "terms": Object { - "field": "service.environment", - }, - }, - "latest": Object { - "top_metrics": Object { - "metrics": Array [ - Object { - "field": "agent.name", - }, - ], - "sort": Object { - "@timestamp": "desc", - }, - }, - }, - }, - "terms": Object { - "field": "service.name", - "size": 1000, - }, - }, - }, - "random_sampler": Object { - "probability": 1, - "seed": 0, - }, - }, - }, - "query": Object { - "bool": Object { - "filter": Array [ - Object { - "range": Object { - "@timestamp": Object { - "format": "epoch_millis", - "gte": 0, - "lte": 50000, - }, - }, - }, - ], - }, - }, - "size": 0, - "track_total_hits": false, - }, - }, - undefined, -] -`; - -exports[`services queries fetches the service transaction types 1`] = ` -Object { - "apm": Object { - "sources": Array [ - Object { - "documentType": "transactionMetric", - "rollupInterval": "1m", - }, - ], - }, - "body": Object { - "aggs": Object { - "types": Object { - "terms": Object { - "field": "transaction.type", - "size": 100, - }, - }, - }, - "query": Object { - "bool": Object { - "filter": Array [ - Object { - "term": Object { - "service.name": "foo", - }, - }, - Object { - "range": Object { - "@timestamp": Object { - "format": "epoch_millis", - "gte": 0, - "lte": 50000, - }, - }, - }, - ], - }, - }, - "size": 0, - "track_total_hits": false, - }, -} -`; diff --git a/x-pack/plugins/apm/server/routes/services/queries.test.ts b/x-pack/plugins/apm/server/routes/services/queries.test.ts deleted file mode 100644 index 7d45899aa84c0e..00000000000000 --- a/x-pack/plugins/apm/server/routes/services/queries.test.ts +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 { ApmDocumentType } from '../../../common/document_type'; -import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values'; -import { RollupInterval } from '../../../common/rollup'; -import { - inspectSearchParams, - SearchParamsMock, -} from '../../utils/test_helpers'; -import { hasHistoricalAgentData } from '../historical_data/has_historical_agent_data'; -import { getServicesItems } from './get_services/get_services_items'; -import { getServiceAgent } from './get_service_agent'; -import { getServiceTransactionTypes } from './get_service_transaction_types'; - -describe('services queries', () => { - let mock: SearchParamsMock; - - afterEach(() => { - mock.teardown(); - }); - - it('fetches the service agent name', async () => { - mock = await inspectSearchParams(({ mockApmEventClient }) => - getServiceAgent({ - serviceName: 'foo', - apmEventClient: mockApmEventClient, - start: 0, - end: 50000, - }) - ); - - expect(mock.params).toMatchSnapshot(); - }); - - it('fetches the service transaction types', async () => { - mock = await inspectSearchParams(({ mockApmEventClient }) => - getServiceTransactionTypes({ - serviceName: 'foo', - apmEventClient: mockApmEventClient, - start: 0, - end: 50000, - documentType: ApmDocumentType.TransactionMetric, - rollupInterval: RollupInterval.OneMinute, - }) - ); - - expect(mock.params).toMatchSnapshot(); - }); - - it('fetches the service items', async () => { - mock = await inspectSearchParams( - ({ mockApmEventClient, mockApmAlertsClient }) => - getServicesItems({ - mlClient: undefined, - apmEventClient: mockApmEventClient, - documentType: ApmDocumentType.TransactionEvent, - rollupInterval: RollupInterval.None, - logger: {} as any, - environment: ENVIRONMENT_ALL.value, - kuery: '', - start: 0, - end: 50000, - serviceGroup: null, - randomSampler: { - probability: 1, - seed: 0, - }, - apmAlertsClient: mockApmAlertsClient, - useDurationSummary: false, - }) - ); - - const allParams = mock.spy.mock.calls.map((call) => call[1]); - - expect(allParams).toMatchSnapshot(); - }); - - it('fetches the agent status', async () => { - mock = await inspectSearchParams(({ mockApmEventClient }) => - hasHistoricalAgentData(mockApmEventClient) - ); - - expect(mock.params).toMatchSnapshot(); - }); -});