Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into eui-v91.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Dec 15, 2023
2 parents c85649b + 1ec887e commit 0330646
Show file tree
Hide file tree
Showing 1,396 changed files with 39,328 additions and 20,571 deletions.
18 changes: 14 additions & 4 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ enabled:
- x-pack/test/cloud_security_posture_api/config.ts
- x-pack/test/dataset_quality_api_integration/basic/config.ts
- x-pack/test/detection_engine_api_integration/basic/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/group1/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/group10/config.ts
- x-pack/test/disable_ems/config.ts
- x-pack/test/encrypted_saved_objects_api_integration/config.ts
- x-pack/test/examples/config.ts
Expand Down Expand Up @@ -499,5 +497,17 @@ enabled:
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/exception_lists_items/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/lists_items/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/lists_items/configs/ess.config.ts


- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_delete/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_delete/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_update/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_update/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_patch/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_patch/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_import_export/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_import_export/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_management/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_management/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_read/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_read/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_bulk_actions/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_bulk_actions/configs/serverless.config.ts
5 changes: 5 additions & 0 deletions .buildkite/pipelines/quality-gates/pipeline.kibana-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#
# Docs: https://docs.elastic.dev/serverless/qualitygates

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

env:
TEAM_CHANNEL: "#kibana-mission-control"
ENVIRONMENT: ${ENVIRONMENT?}
Expand Down
97 changes: 86 additions & 11 deletions .buildkite/pipelines/security_solution/api_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ steps:
key: exception_operators_date_numeric_types:qa:serverless
agents:
queue: n2-4-spot
timeout_in_minutes: 120
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
Expand All @@ -31,7 +31,7 @@ steps:
automatic:
- exit_status: '*'
limit: 2

- label: Running exception_operators_ips:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh exception_operators_ips:qa:serverless
key: exception_operators_ips:qa:serverless
Expand All @@ -53,7 +53,6 @@ steps:
automatic:
- exit_status: '1'
limit: 2


- label: Running exception_operators_text:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh exception_operators_text:qa:serverless
Expand All @@ -76,7 +75,7 @@ steps:
automatic:
- exit_status: '1'
limit: 2

- label: Running actions:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh actions:qa:serverless
key: actions:qa:serverless
Expand All @@ -97,7 +96,7 @@ steps:
retry:
automatic:
- exit_status: '1'
limit: 2
limit: 2

- label: Running prebuilt_rules_management:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh prebuilt_rules_management:qa:serverless
Expand All @@ -119,7 +118,7 @@ steps:
retry:
automatic:
- exit_status: '1'
limit: 2
limit: 2

- label: Running prebuilt_rules_large_prebuilt_rules_package:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh prebuilt_rules_large_prebuilt_rules_package:qa:serverless
Expand All @@ -130,7 +129,7 @@ steps:
retry:
automatic:
- exit_status: '1'
limit: 2
limit: 2

- label: Running prebuilt_rules_update_prebuilt_rules_package:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh prebuilt_rules_update_prebuilt_rules_package:qa:serverless
Expand All @@ -152,8 +151,8 @@ steps:
retry:
automatic:
- exit_status: '1'
limit: 2
limit: 2

- label: Running user_roles:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh user_roles:qa:serverless
key: user_roles:qa:serverless
Expand All @@ -163,7 +162,7 @@ steps:
retry:
automatic:
- exit_status: '1'
limit: 2
limit: 2

- label: Running telemetry:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh telemetry:qa:serverless
Expand All @@ -175,4 +174,80 @@ steps:
automatic:
- exit_status: '1'
limit: 2


- label: Running rule_delete:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh rule_delete:qa:serverless
key: rule_delete:qa:serverless
agents:
queue: n2-4-spot
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '1'
limit: 2

- label: Running rule_update:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh rule_update:qa:serverless
key: rule_update:qa:serverless
agents:
queue: n2-4-spot
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '1'
limit: 2

- label: Running rule_patch:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh rule_patch:qa:serverless
key: rule_patch:qa:serverless
agents:
queue: n2-4-spot
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '1'
limit: 2

- label: Running rule_import_export:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh rule_import_export:qa:serverless
key: rule_import_export:qa:serverless
agents:
queue: n2-4-spot
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '1'
limit: 2

- label: Running rule_management:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh rule_management:qa:serverless
key: rule_management:qa:serverless
agents:
queue: n2-4-spot
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '1'
limit: 2

- label: Running rule_bulk_actions:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh rule_bulk_actions:qa:serverless
key: rule_bulk_actions:qa:serverless
agents:
queue: n2-4-spot
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '1'
limit: 2

- label: Running rule_read:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api-integration-tests.sh rule_read:qa:serverless
key: rule_read:qa:serverless
agents:
queue: n2-4-spot
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '1'
limit: 2
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export JOB=kibana-security-solution-chrome

buildkite-agent meta-data set "${BUILDKITE_JOB_ID}_is_test_execution_step" "true"

mkdir .ftr
retry 5 5 vault kv get -format=json -field=data secret/kibana-issues/dev/security-quality-gate/role-users > .ftr/role_users.json

cd x-pack/test/security_solution_cypress
set +e

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getSelectedCommitHash,
getCommitByHash,
makeCommitInfoHtml,
getRecentCommits,
} from './info_sections/commit_info';
import {
getArtifactBuild,
Expand Down Expand Up @@ -45,7 +46,8 @@ async function main() {
const buildkiteBuild = await getOnMergePRBuild(selectedSha);
const nextBuildContainingCommit = await getQAFBuildContainingCommit(
selectedSha,
selectedCommitInfo.date!
selectedCommitInfo.date!,
await getRecentCommits(50)
);
const artifactBuild = await getArtifactBuild(selectedSha);
addBuildkiteInfoSection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ fi

echo "--- Creating deploy tag $DEPLOY_TAG at $KIBANA_COMMIT_SHA"

echo "Fetching user identity from GitHub..."
IDENTITY_JSON=$(ts-node .buildkite/scripts/serverless/create_deploy_tag/get_github_identity.ts)

# Set git identity to whomever triggered the buildkite job
git config user.email "$BUILDKITE_BUILD_CREATOR_EMAIL"
git config user.name "$BUILDKITE_BUILD_CREATOR"
git config user.email "${BUILDKITE_BUILD_CREATOR_EMAIL:-$(echo ${IDENTITY_JSON} | jq .email)}"
git config user.name "${BUILDKITE_BUILD_CREATOR:-$(echo ${IDENTITY_JSON} | jq .name)}"

# Create a tag for the deploy
git tag -a "$DEPLOY_TAG" "$KIBANA_COMMIT_SHA" \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.
*/

// Query the GitHub API for the user's GitHub identity
import { octokit } from './shared';

const getGitHubIdentity = async (): Promise<{
login: string;
name: string | null;
email: string | null;
}> => {
const { data } = await octokit.users.getAuthenticated();

return {
login: data.login,
name: data.name,
email: data.email,
};
};

async function main() {
try {
const identity = await getGitHubIdentity();

if (!identity.name) {
identity.name = identity.login;
}

if (!identity.email) {
identity.email = `${identity.login}@elastic.co`;
}

return identity;
} catch (error) {
console.error(error);

return {
login: 'unknown-user',
name: 'Unknown User',
email: '[email protected]',
};
}
}

if (require.main === module) {
main().then((identity) => {
console.log(JSON.stringify(identity));
});
} else {
module.exports = main;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Side Public License, v 1.
*/

import { components } from '@octokit/openapi-types';
import { buildkite, buildkiteBuildStateToEmoji, CommitWithStatuses, octokit } from '../shared';
import { buildkite, buildkiteBuildStateToEmoji, CommitWithStatuses } from '../shared';
import { GitCommitExtract } from './commit_info';
import { Build } from '#pipeline-utils/buildkite';

const QA_FTR_TEST_SLUG = 'appex-qa-serverless-kibana-ftr-tests';
Expand Down Expand Up @@ -70,27 +70,30 @@ export async function getArtifactBuild(commitSha: string): Promise<BuildkiteBuil

export async function getQAFBuildContainingCommit(
commitSha: string,
date: string
date: string,
recentGitCommits: GitCommitExtract[]
): Promise<BuildkiteBuildExtract | null> {
// List of commits
const commitShaList = await getCommitListCached();

// List of QAF builds
const qafBuilds = await buildkite.getBuildsAfterDate(QA_FTR_TEST_SLUG, date, 30);
qafBuilds.reverse();

// Find the first build that contains this commit
const build = qafBuilds.find((kbBuild) => {
// Check if build.commit is after commitSha?
const kibanaCommitSha = tryGetKibanaBuildHashFromQAFBuild(kbBuild);
const buildkiteBuildShaIndex = commitShaList.findIndex((c) => c.sha === kibanaCommitSha);
const commitShaIndex = commitShaList.findIndex((c) => c.sha === commitSha);

return (
commitShaIndex !== -1 &&
buildkiteBuildShaIndex !== -1 &&
buildkiteBuildShaIndex < commitShaIndex
);
});
const build = qafBuilds
// Only search across scheduled builds, triggered builds might run with different commits
.filter((e) => e.source === 'schedule')
.find((kbBuild) => {
const commitShaIndex = recentGitCommits.findIndex((c) => c.sha === commitSha);

const kibanaCommitOfFTR = tryGetKibanaBuildHashFromQAFBuild(kbBuild);
const buildkiteBuildShaIndex = recentGitCommits.findIndex((c) => c.sha === kibanaCommitOfFTR);

// Check if build.commit is after commitSha?
return (
commitShaIndex !== -1 &&
buildkiteBuildShaIndex !== -1 &&
buildkiteBuildShaIndex <= commitShaIndex
);
});

if (!build) {
return null;
Expand Down Expand Up @@ -121,25 +124,6 @@ function tryGetKibanaBuildHashFromQAFBuild(build: Build) {
}
}

let _commitListCache: Array<components['schemas']['commit']> | null = null;
async function getCommitListCached() {
if (!_commitListCache) {
const resp = await octokit.request<'GET /repos/{owner}/{repo}/commits'>(
'GET /repos/{owner}/{repo}/commits',
{
owner: 'elastic',
repo: 'kibana',
headers: {
accept: 'application/vnd.github.v3+json',
'X-GitHub-Api-Version': '2022-11-28',
},
}
);
_commitListCache = resp.data;
}
return _commitListCache;
}

function makeBuildInfoSnippetHtml(name: string, build: BuildkiteBuildExtract | null) {
if (!build) {
return `[❓] ${name} - no build found`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async function enrichWithStatuses(commits: GitCommitExtract[]): Promise<CommitWi
};
}

const nextFTRBuild = await getQAFBuildContainingCommit(commit.sha, commit.date);
const nextFTRBuild = await getQAFBuildContainingCommit(commit.sha, commit.date, commits);
const artifactBuild = await getArtifactBuild(commit.sha);

return {
Expand Down
Loading

0 comments on commit 0330646

Please sign in to comment.