Skip to content

Commit

Permalink
[Infra] API tests deployment agnostic (#198257)
Browse files Browse the repository at this point in the history
closes [#198015](#198015)

## Summary

Migrate most of the infra APIs integration tests to the
deployment-agnostic approach.

>[!important]
> - Metrics UI related tests were note migrated because the feature is
not enabled on serverless.
> - `Host with active alerts` test was not migrated because
`es_archiver` fails to load the alerts data. This is because on
serverless, the alerts indices are created as managed data streams and
that causes the `es_archiver` to fail. We should probably try use
synthtrace.

 - [x] Tested against MKI
 - [x] Tested against stateful

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
3 people authored Nov 5, 2024
1 parent 62d1670 commit 26f24c6
Show file tree
Hide file tree
Showing 56 changed files with 1,114 additions and 27,667 deletions.
5 changes: 3 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ packages/kbn-zod-helpers @elastic/security-detection-rule-management
# The #CC# prefix delineates Code Coverage,
# used for the 'team' designator within Kibana Stats

/x-pack/test/api_integration/apis/metrics_ui @elastic/obs-ux-logs-team @elastic/obs-ux-infra_services-team
/x-pack/test/api_integration/apis/metrics_ui @elastic/obs-ux-infra_services-team
x-pack/test_serverless/api_integration/test_suites/common/platform_security @elastic/kibana-security

# Observability Entities Team (@elastic/obs-entities)
Expand Down Expand Up @@ -1157,7 +1157,7 @@ x-pack/test/observability_ai_assistant_api_integration @elastic/obs-ai-assistant
x-pack/test/observability_ai_assistant_functional @elastic/obs-ai-assistant
x-pack/test_serverless/**/test_suites/observability/ai_assistant @elastic/obs-ai-assistant

# Infra Monitoring
# Infra Obs
## This plugin mostly contains the codebase for the infra services, but also includes some code for the Logs UI app.
## To keep @elastic/obs-ux-logs-team as codeowner of the plugin manifest without requiring a review for all the other code changes
## the priority on codeownership will be as follow:
Expand Down Expand Up @@ -1188,6 +1188,7 @@ x-pack/test_serverless/**/test_suites/observability/ai_assistant @elastic/obs-ai
/x-pack/plugins/observability_solution/infra/server/services @elastic/obs-ux-infra_services-team
/x-pack/plugins/observability_solution/infra/server/usage @elastic/obs-ux-infra_services-team
/x-pack/plugins/observability_solution/infra/server/utils @elastic/obs-ux-infra_services-team
/x-pack/test/api_integration/deployment_agnostic/apis/observability/infra @elastic/obs-ux-logs-team

## Logs UI code exceptions -> @elastic/obs-ux-logs-team
/x-pack/test_serverless/functional/page_objects/svl_oblt_onboarding_stream_log_file.ts @elastic/obs-ux-logs-team
Expand Down
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 All @@ -39,7 +41,7 @@ export class ApmSynthtraceKibanaClient {

const response = await fetch(url, {
method: 'GET',
headers: kibanaHeaders(),
headers: this.headers,
agent: getFetchAgent(url),
});

Expand Down Expand Up @@ -79,7 +81,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 @@ -127,7 +129,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 26f24c6

Please sign in to comment.