Skip to content

Commit

Permalink
Merge branch 'main' into #3689
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Jul 2, 2024
2 parents 36be3a3 + 307c03e commit afdaef0
Show file tree
Hide file tree
Showing 213 changed files with 13,732 additions and 2,961 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: kibana-tests-emergency-pipeline
description: Definition of the kibana pipeline
links:
- title: Pipeline
url: https://buildkite.com/elastic/kibana-tests-emergency
spec:
type: buildkite-pipeline
owner: group:kibana-tech-leads
system: buildkite
implementation:
apiVersion: buildkite.elastic.dev/v1
kind: Pipeline
metadata:
name: kibana-tests-emergency
description: Pipeline that tests the service integration in various environments
spec:
repository: elastic/kibana
pipeline_file: ./.buildkite/pipelines/quality-gates/emergency/pipeline.emergency.kibana-tests.yaml
provider_settings:
trigger_mode: none
teams:
kibana-operations:
access_level: MANAGE_BUILD_AND_READ
kibana-release-operators:
access_level: BUILD_AND_READ
cloud-tooling:
access_level: BUILD_AND_READ
everyone:
access_level: READ_ONLY
1 change: 1 addition & 0 deletions .buildkite/pipeline-resource-definitions/locations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-performance-data-set-extraction-daily.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-pr.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-purge-cloud-deployments.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-serverless-quality-gates-emergency.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-serverless-release-testing.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-serverless-release.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/scalability_testing-daily.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This pipeline serves as the entry point for your service's quality gates definitions. When
# properly configured, it will be invoked automatically as part of the automated
# promotion process once a new version was rolled out in one of the various cloud stages.
#
# The updated environment is provided via ENVIRONMENT variable. The seedling
# step will branch and execute pipeline snippets at the following location:
# pipeline.tests-qa.yaml
# pipeline.tests-staging.yaml
# pipeline.tests-production.yaml
#
# Docs: https://docs.elastic.dev/serverless/qualitygates

agents:
cpu: 2
ephemeralStorage: "20G"
memory: "8G"

env:
SKIP_NODE_SETUP: true
TEAM_CHANNEL: "#kibana-mission-control"
ENVIRONMENT: ${ENVIRONMENT?}

steps:
- label: ":pipeline::grey_question::seedling: Trigger Kibana Tests for ${ENVIRONMENT}"
env:
QG_PIPELINE_LOCATION: ".buildkite/pipelines/quality-gates/emergency"
command: "make -C /agent run-environment-tests" # will trigger https://buildkite.com/elastic/kibana-tests-emergency
agents:
image: "docker.elastic.co/ci-agent-images/quality-gate-seedling:0.0.4"

notify:
- slack: "${TEAM_CHANNEL?}"
if: build.branch == "main" && build.state == "failed"
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# These pipeline steps constitute the quality gate for your service within the production environment.
# Incorporate any necessary additional logic to validate the service's integrity.
# A failure in this pipeline build will prevent further progression to the subsequent stage.

steps:
- label: ":kibana: SLO check"
trigger: "serverless-quality-gates" # https://buildkite.com/elastic/serverless-quality-gates
build:
message: "${BUILDKITE_MESSAGE} (triggered by pipeline.tests-production.yaml)"
env:
TARGET_ENV: production
CHECK_SLO: true
CHECK_SLO_TAG: kibana
CHECK_SLO_WAITING_PERIOD: 15m
CHECK_SLO_BURN_RATE_THRESHOLD: 0.1
soft_fail: true

- label: ":rocket: control-plane e2e tests"
if: build.env("ENVIRONMENT") == "production-canary"
trigger: "ess-k8s-production-e2e-tests" # https://buildkite.com/elastic/ess-k8s-production-e2e-tests
build:
env:
REGION_ID: aws-us-east-1
NAME_PREFIX: ci_test_kibana-promotion_
message: "${BUILDKITE_MESSAGE} (triggered by pipeline.tests-production.yaml)"

- label: ":cookie: 24h bake time before continuing promotion"
if: build.env("ENVIRONMENT") == "production-canary"
command: "sleep 86400"
soft_fail:
# A manual cancel of that step produces return code 255.
# We're treating this case as a soft fail to allow manual bake time skipping.
# To stop the promotion entirely, instead click the "Cancel" button at the top of the page
- exit_status: 255
agents:
# How long can this agent live for in minutes - 25 hours
instanceMaxAge: 1500
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These pipeline steps constitute the quality gate for your service within the QA environment.
# Incorporate any necessary additional logic to validate the service's integrity.
# A failure in this pipeline build will prevent further progression to the subsequent stage.

steps:
- label: ":rocket: control-plane e2e tests"
trigger: "ess-k8s-qa-e2e-tests-daily" # https://buildkite.com/elastic/ess-k8s-qa-e2e-tests-daily
build:
env:
REGION_ID: aws-eu-west-1
NAME_PREFIX: ci_test_kibana-promotion_
message: "${BUILDKITE_MESSAGE} (triggered by pipeline.tests-qa.yaml)"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# These pipeline steps constitute the quality gate for your service within the staging environment.
# Incorporate any necessary additional logic to validate the service's integrity.
# A failure in this pipeline build will prevent further progression to the subsequent stage.

steps:
- label: ":rocket: control-plane e2e tests"
trigger: "ess-k8s-staging-e2e-tests" # https://buildkite.com/elastic/ess-k8s-staging-e2e-tests
build:
env:
REGION_ID: aws-us-east-1
NAME_PREFIX: ci_test_kibana-promotion_
message: "${BUILDKITE_MESSAGE} (triggered by pipeline.tests-staging.yaml)"

- 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 when tests stabilize
build:
env:
ENVIRONMENT: ${ENVIRONMENT}
EC_ENV: staging
EC_REGION: aws-us-east-1
RETRY_TESTS_ON_FAIL: "true"
message: "${BUILDKITE_MESSAGE} (triggered by pipeline.tests-staging.yaml)"

- label: ":rocket: Fleet synthetic monitor to check the long standing project"
trigger: "serverless-quality-gates"
build:
message: "${BUILDKITE_MESSAGE} (triggered by pipeline.tests-staging.yaml)"
env:
TARGET_ENV: staging
CHECK_SYNTHETICS: true
CHECK_SYNTHETICS_TAG: "fleet"
CHECK_SYNTHETICS_MINIMUM_RUNS: 3
MAX_FAILURES: 2
CHECK_SYNTHETIC_MAX_POLL: 50
soft_fail: true

- wait: ~

- group: "Kibana Release Manager"
steps:
- label: ":judge::seedling: Trigger Manual Tests Phase"
command: "make -C /agent trigger-manual-verification-phase"
agents:
image: "docker.elastic.co/ci-agent-images/manual-verification-agent:0.0.6"
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ steps:
EC_REGION: aws-us-east-1
RETRY_TESTS_ON_FAIL: "true"
message: "${BUILDKITE_MESSAGE} (triggered by pipeline.tests-staging.yaml)"

- label: ":rocket: Fleet synthetic monitor to check the long standing project"
trigger: "serverless-quality-gates"
build:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,38 @@ if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) {
// make subsequent calls to failure() noop
failure = function () {};
var err = document.createElement('h1');
err.style['color'] = 'white';
err.style['font-family'] = 'monospace';
err.style['text-align'] = 'center';
err.style['background'] = '#F44336';
err.style['padding'] = '25px';
err.innerText = document.querySelector('[data-error-message]').dataset.errorMessage;
document.body.innerHTML = err.outerHTML;
var errorTitle = document.querySelector('[data-error-message-title]').dataset.errorMessageTitle;
var errorText = document.querySelector('[data-error-message-text]').dataset.errorMessageText;
var errorReload = document.querySelector('[data-error-message-reload]').dataset.errorMessageReload;
var err = document.createElement('div');
err.style.textAlign = 'center';
err.style.padding = '120px 20px';
err.style.fontFamily = 'Inter, BlinkMacSystemFont, Helvetica, Arial, sans-serif';
var errorTitleEl = document.createElement('h1');
errorTitleEl.innerText = errorTitle;
errorTitleEl.style.margin = '20px';
var errorTextEl = document.createElement('p');
errorTextEl.innerText = errorText;
errorTextEl.style.margin = '20px';
var errorReloadEl = document.createElement('button');
errorReloadEl.innerText = errorReload;
errorReloadEl.onclick = function () {
location.reload();
};
errorReloadEl.setAttribute('style',
'cursor: pointer; padding-inline: 12px; block-size: 40px; font-size: 1rem; line-height: 1.4286rem; border-radius: 6px; min-inline-size: 112px; color: rgb(255, 255, 255); background-color: rgb(0, 119, 204); outline-color: rgb(0, 0, 0); border:none'
);
err.appendChild(errorTitleEl);
err.appendChild(errorTextEl);
err.appendChild(errorReloadEl);
document.body.innerHTML = '';
document.body.appendChild(err);
}
var stylesheetTarget = document.querySelector('head meta[name="add-styles-here"]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ export const Template: FunctionComponent<Props> = ({
{logo}
<div
className="kbnWelcomeText"
data-error-message={i18n('core.ui.welcomeErrorMessage', {
data-error-message-title={i18n('core.ui.welcomeErrorMessageTitle', {
defaultMessage: 'Elastic did not load properly',
})}
data-error-message-text={i18n('core.ui.welcomeErrorMessageText', {
defaultMessage:
'Elastic did not load properly. Check the server output for more information.',
'Please reload this page. If the issue persists, check the browser console and server logs.',
})}
data-error-message-reload={i18n('core.ui.welcomeErrorReloadButton', {
defaultMessage: 'Reload',
})}
>
{i18n('core.ui.welcomeMessage', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { createMemoryHistory } from 'history';
import { renderHook, act } from '@testing-library/react-hooks';
import { renderHook, act, cleanup } from '@testing-library/react-hooks';

import { coreMock } from '@kbn/core/public/mocks';
import { CoreScopedHistory } from '@kbn/core/public';
Expand All @@ -23,6 +23,20 @@ const navigateToUrl = jest.fn().mockImplementation(async (url) => {
});

describe('useUnsavedChangesPrompt', () => {
let addSpy: jest.SpiedFunction<Window['addEventListener']>;
let removeSpy: jest.SpiedFunction<Window['removeEventListener']>;

beforeEach(() => {
addSpy = jest.spyOn(window, 'addEventListener');
removeSpy = jest.spyOn(window, 'removeEventListener');
});

afterEach(() => {
addSpy.mockRestore();
removeSpy.mockRestore();
jest.resetAllMocks();
});

it('should not block if not edited', () => {
renderHook(() =>
useUnsavedChangesPrompt({
Expand All @@ -39,6 +53,7 @@ describe('useUnsavedChangesPrompt', () => {
expect(history.location.pathname).toBe('/test');
expect(history.location.search).toBe('');
expect(coreStart.overlays.openConfirm).not.toBeCalled();
expect(addSpy).not.toBeCalledWith('beforeunload', expect.anything());
});

it('should block if edited', async () => {
Expand All @@ -61,5 +76,23 @@ describe('useUnsavedChangesPrompt', () => {

expect(navigateToUrl).toBeCalledWith('/mock/test', expect.anything());
expect(coreStart.overlays.openConfirm).toBeCalled();
expect(addSpy).toBeCalledWith('beforeunload', expect.anything());
});

it('beforeunload event should be cleaned up', async () => {
coreStart.overlays.openConfirm.mockResolvedValue(true);

renderHook(() =>
useUnsavedChangesPrompt({
hasUnsavedChanges: true,
http: coreStart.http,
openConfirm: coreStart.overlays.openConfirm,
history,
navigateToUrl,
})
);
cleanup();
expect(addSpy).toBeCalledWith('beforeunload', expect.anything());
expect(removeSpy).toBeCalledWith('beforeunload', expect.anything());
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ export const useUnsavedChangesPrompt = ({
confirmButtonText = DEFAULT_CONFIRM_BUTTON,
cancelButtonText = DEFAULT_CANCEL_BUTTON,
}: Props) => {
useEffect(() => {
if (hasUnsavedChanges) {
const handler = (event: BeforeUnloadEvent) => {
// These 2 lines of code are the recommendation from MDN for triggering a browser prompt for confirming
// whether or not a user wants to leave the current site.
event.preventDefault();
event.returnValue = '';
};
// Adding this handler will prompt users if they are navigating to a new page, outside of the Kibana SPA
window.addEventListener('beforeunload', handler);
return () => window.removeEventListener('beforeunload', handler);
}
}, [hasUnsavedChanges]);

useEffect(() => {
if (!hasUnsavedChanges) {
return;
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/cases/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ export const MAX_CUSTOM_FIELDS_PER_CASE = 10 as const;
export const MAX_CUSTOM_FIELD_KEY_LENGTH = 36 as const; // uuidv4 length
export const MAX_CUSTOM_FIELD_LABEL_LENGTH = 50 as const;
export const MAX_CUSTOM_FIELD_TEXT_VALUE_LENGTH = 160 as const;
export const MAX_TEMPLATE_KEY_LENGTH = 36 as const; // uuidv4 length
export const MAX_TEMPLATE_NAME_LENGTH = 50 as const;
export const MAX_TEMPLATE_DESCRIPTION_LENGTH = 1000 as const;
export const MAX_TEMPLATES_LENGTH = 10 as const;
export const MAX_TEMPLATE_TAG_LENGTH = 50 as const;
export const MAX_TAGS_PER_TEMPLATE = 10 as const;

/**
* Cases features
Expand Down
Loading

0 comments on commit afdaef0

Please sign in to comment.