Skip to content

Commit

Permalink
Merge branch 'main' into 181542-dataset-quality-dataset-is-not-marked…
Browse files Browse the repository at this point in the history
…-as-part-of-the-integration
  • Loading branch information
mohamedhamed-ahmed authored Apr 28, 2024
2 parents 7c14347 + 50f4911 commit a8fd686
Show file tree
Hide file tree
Showing 1,579 changed files with 12,286 additions and 10,919 deletions.
38 changes: 38 additions & 0 deletions .buildkite/pipeline-resource-definitions/kibana-fips-daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: bk-kibana-fips-daily
description: Run Kibana FIPS smoke tests
links:
- title: Pipeline link
url: https://buildkite.com/elastic/kibana-fips
spec:
type: buildkite-pipeline
owner: group:kibana-operations
system: buildkite
implementation:
apiVersion: buildkite.elastic.dev/v1
kind: Pipeline
metadata:
name: kibana / fips
description: Run Kibana FIPS smoke tests
spec:
env:
SLACK_NOTIFICATIONS_CHANNEL: "#kibana-operations-alerts"
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
repository: elastic/kibana
branch_configuration: main
default_branch: main
pipeline_file: ".buildkite/pipelines/fips.yml"
provider_settings:
trigger_mode: none
schedules:
daily:
branch: main
cronline: 0 9 * * * America/New_York
teams:
kibana-operations:
access_level: MANAGE_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 @@ -12,6 +12,7 @@ spec:
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-es-serverless-snapshots.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-es-snapshots.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-esql-grammar-sync.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-fips-daily.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-flaky.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-fleet-packages-daily.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-migration-staging.yml
Expand Down
32 changes: 32 additions & 0 deletions .buildkite/pipelines/fips.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
env:
DISABLE_CI_STATS_SHIPPING: "true"
steps:
- command: .buildkite/scripts/steps/build_kibana.sh
label: Build Kibana Distribution and Plugins
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
provider: gcp
machineType: n2-standard-16
preemptible: true
key: build
if: "build.env('KIBANA_BUILD_ID') == null || build.env('KIBANA_BUILD_ID') == ''"
timeout_in_minutes: 60
retry:
automatic:
- exit_status: "-1"
limit: 3

- wait

- command: TEST_PACKAGE=fips .buildkite/scripts/steps/package_testing/test.sh
label: "Smoke testing for FIPS"
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
provider: gcp
enableNestedVirtualization: true
localSsds: 1
localSsdInterface: nvme
machineType: n2-standard-4
timeout_in_minutes: 600
36 changes: 18 additions & 18 deletions .buildkite/pipelines/security_solution/api_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ steps:
- group: 'Execute Tests'
key: test_execution
steps:
- label: Running exception_workflows:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_workflows:qa:serverless
key: exception_workflows:qa:serverless
- label: Running exception_workflows:essentials:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_workflows:essentials:qa:serverless
key: exception_workflows:essentials:qa:serverless
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
Expand All @@ -32,9 +32,9 @@ steps:
- exit_status: '*'
limit: 2

- label: Running exception_operators_date_numeric_types:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_date_numeric_types:qa:serverless
key: exception_operators_date_numeric_types:qa:serverless
- label: Running exception_operators_date_numeric_types:essentials:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_date_numeric_types:essentials:qa:serverless
key: exception_operators_date_numeric_types:essentials:qa:serverless
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
Expand All @@ -47,9 +47,9 @@ steps:
- exit_status: '*'
limit: 2

- label: Running exception_operators_keyword:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_keyword:qa:serverless
key: exception_operators_keyword:qa:serverless
- label: Running exception_operators_keyword:essentials:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_keyword:essentials:qa:serverless
key: exception_operators_keyword:essentials:qa:serverless
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
Expand All @@ -62,9 +62,9 @@ steps:
- exit_status: '*'
limit: 2

- label: Running exception_operators_ips:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_ips:qa:serverless
key: exception_operators_ips:qa:serverless
- label: Running exception_operators_ips:essentials:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_ips:essentials:qa:serverless
key: exception_operators_ips:essentials:qa:serverless
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
Expand All @@ -77,9 +77,9 @@ steps:
- exit_status: '*'
limit: 2

- label: Running exception_operators_long:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_long:qa:serverless
key: exception_operators_long:qa:serverless
- label: Running exception_operators_long:essentials:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_long:essentials:qa:serverless
key: exception_operators_long:essentials:qa:serverless
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
Expand All @@ -92,9 +92,9 @@ steps:
- exit_status: '1'
limit: 2

- label: Running exception_operators_text:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_text:qa:serverless
key: exception_operators_text:qa:serverless
- label: Running exception_operators_text:essentials:qa:serverless
command: .buildkite/scripts/pipelines/security_solution_quality_gate/api_integration/api-integration-tests.sh exception_operators_text:essentials:qa:serverless
key: exception_operators_text:essentials:qa:serverless
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ steps:
- exit_status: "*"
limit: 1

- command: "echo 'Running the defend worklows tests in this step"
- command: .buildkite/scripts/pipelines/security_solution_quality_gate/edr_workflows/mki_security_solution_defend_workflows.sh cypress:dw:qa:serverless:run
label: 'Serverless MKI QA Defend Workflows Cypress Tests on Serverless'
key: test_defend_workflows
label: "Serverless MKI QA Defend Workflows - Security Solution Cypress Tests"
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
provider: gcp
enableNestedVirtualization: true
localSsds: 1
localSsdInterface: nvme
machineType: n2-standard-4
timeout_in_minutes: 300
parallelism: 6
retry:
automatic:
- exit_status: '*'
limit: 1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ set +e

# Generate a random 5-digit number
random_number=$((10000 + $RANDOM % 90000))
PROXY_URL="https://cloud-handler-test-r344edqiza-uc.a.run.app"
# Check the healthcheck of the proxy service
response=$(curl -s -o /dev/null -w "%{http_code}" "$PROXY_URL/healthcheck")
echo "Proxy Healthcheck Response code: $response"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -euo pipefail

if [ -z "$1" ]
then
echo "No target script from the package.json file, is supplied"
exit 1
fi


source .buildkite/scripts/common/util.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
.buildkite/scripts/bootstrap.sh

export JOB=kibana-defend-workflows-serverless-cypress

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

source .buildkite/scripts/pipelines/security_solution_quality_gate/prepare_vault_entries.sh

cd x-pack/plugins/security_solution
set +e

export BK_ANALYTICS_API_KEY=$(vault_get security-solution-quality-gate serverless-cypress-defend-workflows)

echo "--- Running the tests for target $1"
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn $1; status=$?; yarn junit:merge || :; exit $status
33 changes: 33 additions & 0 deletions .buildkite/scripts/steps/api_docs/publish_api_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -euo pipefail

echo "--- Publish API Docs"

buildkite-agent artifact download "api_docs_changes.diff" .

if [[ -s "api_docs_changes.diff" ]]; then
echo "Changes detected in API Docs"
git apply api_docs_changes.diff
rm api_docs_changes.diff
else
echo "No changes detected in API Docs"
exit 0
fi

git config --global user.name kibanamachine
git config --global user.email '[email protected]'

branch="api_docs_$(date +%F_%H-%M-%S)"
git checkout -b "$branch"
git add ./*.docnav.json
git add api_docs
git commit -m "[api-docs] Daily api_docs build"

git push origin "$branch"

prUrl=$(gh pr create --repo elastic/kibana --base main --head "$branch" --title "[api-docs] $(date +%F) Daily api_docs build" --body "Generated by $BUILDKITE_BUILD_URL" --label "release_note:skip" --label "docs")
echo "Opened PR: $prUrl"
gh pr merge --repo elastic/kibana --auto --squash "$prUrl"

GH_TOKEN="$KIBANA_CI_GITHUB_TOKEN" gh pr review --repo elastic/kibana --approve -b "Automated review from $BUILDKITE_BUILD_URL" "$prUrl"
13 changes: 3 additions & 10 deletions .buildkite/scripts/steps/artifacts/docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,9 @@ gsutil -m cp -r "$CDN_ASSETS_FOLDER/*" "gs://$GCS_SA_CDN_BUCKET/$GIT_ABBREV_COMM
gcloud auth revoke "$GCS_SA_CDN_EMAIL"

echo "--- Validate CDN assets"
(
shopt -s globstar
cd $CDN_ASSETS_FOLDER
for CDN_ASSET in **/*; do
if [[ -f "$CDN_ASSET" ]]; then
echo -n "Testing $CDN_ASSET..."
curl --retry 10 --retry-max-time 600 --connect-timeout 120 --max-time 120 -I --write-out '%{http_code}\n' --fail --silent --output /dev/null "$GCS_SA_CDN_URL/$CDN_ASSET"
fi
done
)
ts-node "$(git rev-parse --show-toplevel)/.buildkite/scripts/steps/artifacts/validate_cdn_assets.ts" \
"$GCS_SA_CDN_URL" \
"$CDN_ASSETS_FOLDER"

echo "--- Upload archives"
buildkite-agent artifact upload "kibana-$BASE_VERSION-linux-x86_64.tar.gz"
Expand Down
96 changes: 96 additions & 0 deletions .buildkite/scripts/steps/artifacts/validate_cdn_assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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.
*/

import * as glob from 'glob';
import axios from 'axios';

const CDN_URL_PREFIX = process.argv[2];
const CDN_ASSETS_FOLDER = process.argv[3];

async function main() {
const allAssets = glob.sync('**/*', { cwd: CDN_ASSETS_FOLDER, nodir: true });
const totalAssetCount = allAssets.length;
let assetsProcessed = 0;
let assetsFound = 0;

const batchSize = 50;

console.log(`Starting CDN asset validation for ${totalAssetCount} assets...`);

while (assetsProcessed < totalAssetCount) {
const batch = allAssets.slice(assetsProcessed, assetsProcessed + batchSize);
const results = await Promise.all(batch.map((url) => headAssetUrlWithRetry(url)));
assetsProcessed += results.length;
results.forEach((result) => {
if (result.status === 200) {
console.log(`Testing ${result.assetPath}...${result.status}`);
assetsFound++;
} else {
console.error(`Testing ${result.assetPath}...${result.status} (${result.testUrl})`);
}
});
}

return {
totalAssetCount,
assetsProcessed,
assetsFound,
assetsNotFound: totalAssetCount - assetsFound,
};
}

async function headAssetUrl(assetPath: string) {
const testUrl = `${CDN_URL_PREFIX}/${assetPath}`;
const response = await axios.head(testUrl, {
timeout: 1000,
});
return {
status: response.status,
testUrl,
assetPath,
};
}

async function headAssetUrlWithRetry(
assetPath: string,
retries = 5
): Promise<{
status: number;
testUrl: string;
assetPath: string;
}> {
const result = await headAssetUrl(assetPath);
if (result.status === 200) {
return result;
} else if (retries > 0) {
console.log(`Retrying ${assetPath}...(retries left: ${retries})`);
await new Promise((resolve) => setTimeout(resolve, 1000));
return headAssetUrlWithRetry(assetPath, retries - 1);
} else {
return {
status: result.status || 0,
testUrl: result.testUrl,
assetPath,
};
}
}

main()
.then(({ totalAssetCount, assetsNotFound }) => {
if (assetsNotFound) {
console.error(`Couldn't find ${assetsNotFound} assets on CDN.`);
process.exit(1);
} else {
console.log(`All ${totalAssetCount} found on CDN.`);
process.exit(0);
}
})
.catch((error) => {
console.error(error.message);
process.exit(1);
});
Empty file modified .buildkite/scripts/steps/fips/build.sh
100644 → 100755
Empty file.
Loading

0 comments on commit a8fd686

Please sign in to comment.