Skip to content

Commit

Permalink
[8.x] [Infra] API tests deployment agnostic (elastic#198257) (elastic…
Browse files Browse the repository at this point in the history
…#199597)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Infra] API tests deployment agnostic
(elastic#198257)](elastic#198257)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Carlos
Crespo","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-05T18:39:58Z","message":"[Infra]
API tests deployment agnostic (elastic#198257)\n\ncloses
[elastic#198015](https://github.com/elastic/kibana/issues/198015)\r\n\r\n##
Summary\r\n\r\nMigrate most of the infra APIs integration tests to
the\r\ndeployment-agnostic approach.\r\n\r\n>[!important]\r\n> - Metrics
UI related tests were note migrated because the feature is\r\nnot
enabled on serverless.\r\n> - `Host with active alerts` test was not
migrated because\r\n`es_archiver` fails to load the alerts data. This is
because on\r\nserverless, the alerts indices are created as managed data
streams and\r\nthat causes the `es_archiver` to fail. We should probably
try use\r\nsynthtrace.\r\n\r\n - [x] Tested against MKI\r\n - [x] Tested
against stateful\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"26f24c66b5843f5d2c4340dd442c4ddfd375793f","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services"],"number":198257,"url":"https://github.com/elastic/kibana/pull/198257","mergeCommit":{"message":"[Infra]
API tests deployment agnostic (elastic#198257)\n\ncloses
[elastic#198015](https://github.com/elastic/kibana/issues/198015)\r\n\r\n##
Summary\r\n\r\nMigrate most of the infra APIs integration tests to
the\r\ndeployment-agnostic approach.\r\n\r\n>[!important]\r\n> - Metrics
UI related tests were note migrated because the feature is\r\nnot
enabled on serverless.\r\n> - `Host with active alerts` test was not
migrated because\r\n`es_archiver` fails to load the alerts data. This is
because on\r\nserverless, the alerts indices are created as managed data
streams and\r\nthat causes the `es_archiver` to fail. We should probably
try use\r\nsynthtrace.\r\n\r\n - [x] Tested against MKI\r\n - [x] Tested
against stateful\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"26f24c66b5843f5d2c4340dd442c4ddfd375793f"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198257","number":198257,"mergeCommit":{"message":"[Infra]
API tests deployment agnostic (elastic#198257)\n\ncloses
[elastic#198015](https://github.com/elastic/kibana/issues/198015)\r\n\r\n##
Summary\r\n\r\nMigrate most of the infra APIs integration tests to
the\r\ndeployment-agnostic approach.\r\n\r\n>[!important]\r\n> - Metrics
UI related tests were note migrated because the feature is\r\nnot
enabled on serverless.\r\n> - `Host with active alerts` test was not
migrated because\r\n`es_archiver` fails to load the alerts data. This is
because on\r\nserverless, the alerts indices are created as managed data
streams and\r\nthat causes the `es_archiver` to fail. We should probably
try use\r\nsynthtrace.\r\n\r\n - [x] Tested against MKI\r\n - [x] Tested
against stateful\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"26f24c66b5843f5d2c4340dd442c4ddfd375793f"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
crespocarlos and kibanamachine authored Nov 11, 2024
1 parent 2aae3df commit 98a2427
Show file tree
Hide file tree
Showing 54 changed files with 1,116 additions and 27,665 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import { getFetchAgent } from '../../../cli/utils/ssl';
export class ApmSynthtraceKibanaClient {
private readonly logger: Logger;
private target: string;
private headers: Record<string, string>;

constructor(options: { logger: Logger; target: string }) {
constructor(options: { logger: Logger; target: string; headers?: Record<string, string> }) {
this.logger = options.logger;
this.target = options.target;
this.headers = { ...kibanaHeaders(), ...(options.headers ?? {}) };
}

getFleetApmPackagePath(packageVersion?: string): string {
Expand Down Expand Up @@ -63,7 +65,7 @@ export class ApmSynthtraceKibanaClient {
async () => {
const res = await fetch(url, {
method: 'POST',
headers: kibanaHeaders(),
headers: this.headers,
body: '{"force":true}',
agent: getFetchAgent(url),
});
Expand Down Expand Up @@ -111,7 +113,7 @@ export class ApmSynthtraceKibanaClient {
async () => {
const res = await fetch(url, {
method: 'DELETE',
headers: kibanaHeaders(),
headers: this.headers,
body: '{"force":true}',
agent: getFetchAgent(url),
});
Expand Down
3 changes: 3 additions & 0 deletions x-pack/test/api_integration/apis/logs_ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ export default function ({ loadTestFile }: FtrProviderContext) {
describe('Logs UI routes', () => {
loadTestFile(require.resolve('./log_views'));
loadTestFile(require.resolve('./log_threshold_alert'));
loadTestFile(require.resolve('./log_entry_highlights'));
loadTestFile(require.resolve('./log_summary'));
loadTestFile(require.resolve('./log_analysis_validation_log_entry_datasets'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
RatioCriteria,
RuleParams,
} from '@kbn/infra-plugin/common/alerting/logs/log_threshold/types';
import { DATES } from '../metrics_ui/constants';
import { DATES } from './utils/constants';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
Expand Down
24 changes: 24 additions & 0 deletions x-pack/test/api_integration/apis/logs_ui/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.
*/

export const DATES = {
'alert-test-data': {
gauge: {
min: 1609459200000, // '2022-01-01T00:00:00Z'
max: 1609462800000, // '2021-01-01T01:00:00Z',
midpoint: 1609461000000, // '2021-01-01T00:30:00Z'
},
rate: {
min: 1609545600000, // '2021-01-02T00:00:00Z'
max: 1609545900000, // '2021-01-02T00:05:00Z'
},
},
ten_thousand_plus: {
min: 1634604480001, // 2021-10-19T00:48:00.001Z
max: 1634604839997, // 2021-10-19T00:53:59.997Z
},
};
87 changes: 0 additions & 87 deletions x-pack/test/api_integration/apis/metrics_ui/helpers.ts

This file was deleted.

61 changes: 0 additions & 61 deletions x-pack/test/api_integration/apis/metrics_ui/http_source.ts

This file was deleted.

15 changes: 15 additions & 0 deletions x-pack/test/api_integration/apis/metrics_ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 type { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('MetricsUI Endpoints', () => {
loadTestFile(require.resolve('./metrics_explorer'));
loadTestFile(require.resolve('./metric_threshold_alert'));
});
}
Loading

0 comments on commit 98a2427

Please sign in to comment.