Skip to content

Commit

Permalink
Merge branch 'main' into de-8-12/fix-esql-test
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliidm authored Nov 14, 2023
2 parents e26f561 + e569a79 commit b29e529
Show file tree
Hide file tree
Showing 17 changed files with 496 additions and 46 deletions.
3 changes: 1 addition & 2 deletions .buildkite/pipelines/quality-gates/pipeline.tests-qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
steps:
- label: ":kibana: Kibana Serverless Tests for ${ENVIRONMENT}"
trigger: appex-qa-serverless-kibana-ftr-tests # https://buildkite.com/elastic/appex-qa-serverless-kibana-ftr-tests
soft_fail: true # Remove this before release or when tests stabilize
soft_fail: true # Remove when tests stabilize
build:
env:
ENVIRONMENT: ${ENVIRONMENT}
Expand All @@ -16,7 +16,6 @@ steps:
# TODO: Uncomment this code when the integration is ready.
# - label: ":pipeline::female-detective::seedling: Trigger Security Solution quality gate script"
# trigger: security-serverless-quality-gate # https://buildkite.com/elastic/security-serverless-quality-gate
# soft_fail: true # Remove this when tests are fixed
# build:
# env:
# ENVIRONMENT: ${ENVIRONMENT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ steps:

- label: ":kibana: Kibana Serverless Tests for ${ENVIRONMENT}"
trigger: appex-qa-serverless-kibana-ftr-tests # https://buildkite.com/elastic/appex-qa-serverless-kibana-ftr-tests
soft_fail: true # Remove this before release or when tests stabilize
soft_fail: true # Remove when tests stabilize
build:
env:
ENVIRONMENT: ${ENVIRONMENT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ClusterInfo {
cluster_name: string;
cluster_uuid: string;
cluster_version: string;
cluster_build_flavor: string;
cluster_build_flavor?: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export function registerAnalyticsContextProvider(
cluster_name: { type: 'keyword', _meta: { description: 'The Cluster Name' } },
cluster_uuid: { type: 'keyword', _meta: { description: 'The Cluster UUID' } },
cluster_version: { type: 'keyword', _meta: { description: 'The Cluster version' } },
cluster_build_flavor: { type: 'keyword', _meta: { description: 'The Cluster build flavor' } },
cluster_build_flavor: {
type: 'keyword',
_meta: { description: 'The Cluster build flavor', optional: true },
},
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

// @ts-expect-error not in the definition file
import HapiRequest from '@hapi/hapi/lib/request.js';
import { IncomingMessage } from 'http';
import { inspect } from 'util';

export const patchRequest = () => {
// HAPI request
HapiRequest.prototype.toString = function () {
return `[HAPI.Request method="${this.method}" url="${this.url}"]`;
};

HapiRequest.prototype.toJSON = function () {
return {
method: this.method,
url: String(this.url),
};
};

HapiRequest.prototype[inspect.custom] = function () {
return this.toJSON();
};

// http.IncomingMessage
const IncomingMessageProto = IncomingMessage.prototype;

IncomingMessageProto.toString = function () {
return `[http.IncomingMessage method="${this.method}" url="${this.url}" complete="${this.complete}" aborted="${this.aborted}"]`;
};

// @ts-expect-error missing definition
IncomingMessageProto.toJSON = function () {
return {
method: this.method,
url: this.url,
complete: this.complete,
aborted: this.aborted,
};
};

// @ts-expect-error missing definition
IncomingMessageProto[inspect.custom] = function () {
// @ts-expect-error missing definition
return this.toJSON();
};
};
28 changes: 28 additions & 0 deletions packages/core/http/core-http-router-server-internal/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { URL } from 'url';
import { v4 as uuidv4 } from 'uuid';
import { inspect } from 'util';
import type { Request, RouteOptions } from '@hapi/hapi';
import { fromEvent, NEVER } from 'rxjs';
import { shareReplay, first, filter } from 'rxjs/operators';
Expand Down Expand Up @@ -36,6 +37,10 @@ import {
import { RouteValidator } from './validator';
import { isSafeMethod } from './route';
import { KibanaSocket } from './socket';
import { patchRequest } from './patch_requests';

// patching at module load
patchRequest();

const requestSymbol = Symbol('request');

Expand Down Expand Up @@ -174,6 +179,29 @@ export class CoreKibanaRequest<
};
}

toString() {
return `[CoreKibanaRequest id="${this.id}" method="${this.route.method}" url="${this.url}" fake="${this.isFakeRequest}" system="${this.isSystemRequest}" api="${this.isInternalApiRequest}"]`;
}

toJSON() {
return {
id: this.id,
uuid: this.uuid,
url: `${this.url}`,
isFakeRequest: this.isFakeRequest,
isSystemRequest: this.isSystemRequest,
isInternalApiRequest: this.isInternalApiRequest,
auth: {
isAuthenticated: this.auth.isAuthenticated,
},
route: this.route,
};
}

[inspect.custom]() {
return this.toJSON();
}

private getEvents(request: RawRequest): KibanaRequestEvents {
if (isFakeRawRequest(request)) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { css } from '@emotion/react';

export const redirectAppLinksStyles = css({
display: 'inherit',
height: 'inherit',
width: 'inherit',
flex: '1',
flexFlow: 'column nowrap',
height: '100%',
width: '100%',
});
Loading

0 comments on commit b29e529

Please sign in to comment.