Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Elastic-wide Buildkite system #157220

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
de06768
WIP prep things to test elastic buildkite system and without secrets
brianseeders May 9, 2023
3de1e4d
Make vars exist but be empty
brianseeders May 9, 2023
330d282
Merge branch 'main' into elastic-buildkite
brianseeders May 10, 2023
c7840a8
Switch to n1s for now
brianseeders May 10, 2023
9522199
Merge branch 'elastic-buildkite' of github.com:brianseeders/kibana in…
brianseeders May 10, 2023
c4e641d
Output pipeline instead of upload
brianseeders May 12, 2023
ce1b10c
Comment out function
brianseeders May 12, 2023
2ac3ae1
A few more fixes
brianseeders May 12, 2023
7eb7d59
Bring back the secrets
brianseeders May 16, 2023
6f38f25
Fix paths
brianseeders May 16, 2023
429de22
Fix path
brianseeders May 16, 2023
a054936
Bring back all the FTR configs
brianseeders May 16, 2023
be5b909
Use util
brianseeders May 16, 2023
6286c7b
Fix dynamic agents
brianseeders May 16, 2023
8f3ee19
n1 -> n2
brianseeders May 17, 2023
569eed2
Merge remote-tracking branch 'upstream/main' into elastic-buildkite
brianseeders May 17, 2023
3211a97
Fix commented out yaml
brianseeders May 17, 2023
1b90f0f
Merge remote-tracking branch 'upstream/main' into elastic-buildkite
brianseeders May 17, 2023
617876d
Add umask debug step
brianseeders May 17, 2023
93b7042
Test commit
brianseeders May 17, 2023
86c80c8
test commit
brianseeders May 18, 2023
d097492
test commit
brianseeders May 18, 2023
34b75cd
test commit
brianseeders May 18, 2023
cf0f362
Move to new image family
brianseeders May 22, 2023
5b8664e
Remove umask step
brianseeders May 22, 2023
646ef40
Remove commented out section
brianseeders May 22, 2023
81f9f54
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 22, 2023
bafe1ed
Test new git config
brianseeders May 22, 2023
22f8c55
Merge branch 'elastic-buildkite' of github.com:brianseeders/kibana in…
brianseeders May 22, 2023
e48c314
Private repo instead
brianseeders May 22, 2023
1dc30e8
Make agents spot instances
brianseeders May 24, 2023
d54eb13
Merge remote-tracking branch 'upstream/main' into elastic-buildkite
brianseeders May 24, 2023
433517b
Update a few missed agent configs
brianseeders May 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .buildkite/pipeline-utils/buildkite/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ export interface BuildkiteStep {
label: string;
parallelism?: number;
agents: {
queue: string;
queue?: string;
provider?: string;
image?: string;
imageProject?: string;
machineType?: string;
minCpuPlatform?: string;
preemptible?: boolean;
};
timeout_in_minutes?: number;
key?: string;
Expand Down
21 changes: 17 additions & 4 deletions .buildkite/pipeline-utils/ci-stats/pick_test_group_run_order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@ export async function pickTestGroupRunOrder() {
timeout_in_minutes: 120,
key: 'jest',
agents: {
queue: 'n2-4-spot',
provider: 'gcp',
image: 'family/kibana-ubuntu-2004',
imageProject: 'elastic-images-qa',
machineType: 'n2-standard-4',
preemptible: true,
},
retry: {
automatic: [
Expand All @@ -424,7 +428,11 @@ export async function pickTestGroupRunOrder() {
timeout_in_minutes: 120,
key: 'jest-integration',
agents: {
queue: 'n2-4-spot',
provider: 'gcp',
image: 'family/kibana-ubuntu-2004',
imageProject: 'elastic-images-qa',
machineType: 'n2-standard-4',
preemptible: true,
},
retry: {
automatic: [
Expand Down Expand Up @@ -455,12 +463,17 @@ export async function pickTestGroupRunOrder() {
: -1
)
.map(
({ title, key, queue = defaultQueue }): BuildkiteStep => ({
// ({ title, key, queue = defaultQueue }): BuildkiteStep => ({
({ title, key }): BuildkiteStep => ({
label: title,
command: getRequiredEnv('FTR_CONFIGS_SCRIPT'),
timeout_in_minutes: 90,
agents: {
queue,
provider: 'gcp',
image: 'family/kibana-ubuntu-2004',
imageProject: 'elastic-images-qa',
machineType: 'n2-standard-4',
preemptible: true,
},
env: {
FTR_CONFIG_GROUP_KEY: key,
Expand Down
58 changes: 49 additions & 9 deletions .buildkite/pipelines/pull_request/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@ steps:
label: Pre-Build
timeout_in_minutes: 10
agents:
queue: kibana-default
provider: gcp
preemptible: true
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-2

- wait

- command: .buildkite/scripts/steps/build_kibana.sh
label: Build Kibana Distribution and Plugins
agents:
queue: n2-16-spot
provider: gcp
preemptible: true
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-16
buildDirectory: /dev/shm/bk
key: build
if: "build.env('KIBANA_BUILD_ID') == null || build.env('KIBANA_BUILD_ID') == ''"
timeout_in_minutes: 60
Expand All @@ -22,7 +31,11 @@ steps:
- command: .buildkite/scripts/steps/build_api_docs.sh
label: 'Build API Docs'
agents:
queue: n2-4-spot
provider: gcp
preemptible: true
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-4
key: build_api_docs
timeout_in_minutes: 60
retry:
Expand All @@ -33,7 +46,11 @@ steps:
- command: .buildkite/scripts/steps/ci_stats_ready.sh
label: Mark CI Stats as ready
agents:
queue: kibana-default
provider: gcp
preemptible: true
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-2
timeout_in_minutes: 10
depends_on:
- build
Expand All @@ -46,7 +63,11 @@ steps:
- command: .buildkite/scripts/steps/test/pick_test_group_run_order.sh
label: 'Pick Test Group Run Order'
agents:
queue: kibana-default
provider: gcp
preemptible: true
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-2
env:
JEST_UNIT_SCRIPT: '.buildkite/scripts/steps/test/jest.sh'
JEST_INTEGRATION_SCRIPT: '.buildkite/scripts/steps/test/jest_integration.sh'
Expand All @@ -59,7 +80,11 @@ steps:
- command: .buildkite/scripts/steps/lint.sh
label: 'Linting'
agents:
queue: n2-8-spot
provider: gcp
preemptible: true
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-8
key: linting
timeout_in_minutes: 60
retry:
Expand All @@ -70,7 +95,12 @@ steps:
- command: .buildkite/scripts/steps/lint_with_types.sh
label: 'Linting (with types)'
agents:
queue: n2-16-spot
provider: gcp
preemptible: true
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-16
buildDirectory: /dev/shm/bk
key: linting_with_types
timeout_in_minutes: 90
retry:
Expand All @@ -81,7 +111,12 @@ steps:
- command: .buildkite/scripts/steps/checks.sh
label: 'Checks'
agents:
queue: n2-2-spot
provider: gcp
preemptible: true
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-2
buildDirectory: /dev/shm/bk
timeout_in_minutes: 60
retry:
automatic:
Expand All @@ -91,7 +126,12 @@ steps:
- command: .buildkite/scripts/steps/check_types.sh
label: 'Check Types'
agents:
queue: n2-16-spot
provider: gcp
preemptible: true
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-16
buildDirectory: /dev/shm/bk
timeout_in_minutes: 60
retry:
automatic:
Expand Down
6 changes: 5 additions & 1 deletion .buildkite/pipelines/pull_request/post_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ steps:
- command: .buildkite/scripts/lifecycle/post_build.sh
label: Post-Build
agents:
queue: kibana-default
provider: gcp
image: family/kibana-ubuntu-2004
imageProject: elastic-images-qa
machineType: n2-standard-2
preemptible: true
12 changes: 12 additions & 0 deletions .buildkite/scripts/common/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,15 @@ npm_install_global() {
download_artifact() {
retry 3 1 timeout 3m buildkite-agent artifact download "$@"
}

vault_get() {
path=$1
field=$2

fullPath="secret/ci/elastic-kibana/migrated/$path"
if [[ "$VAULT_ADDR" == *"secrets.elastic.co"* ]]; then
fullPath="secret/kibana-issues/dev/$path"
fi

retry 5 5 vault read -field="$field" "$fullPath"
}
4 changes: 2 additions & 2 deletions .buildkite/scripts/lifecycle/pre_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ if [[ "${GITHUB_BUILD_COMMIT_STATUS_ENABLED:-}" != "true" ]]; then
"$(dirname "${0}")/commit_status_start.sh"
fi

export CI_STATS_TOKEN="$(retry 5 5 vault read -field=api_token secret/kibana-issues/dev/kibana_ci_stats)"
export CI_STATS_HOST="$(retry 5 5 vault read -field=api_host secret/kibana-issues/dev/kibana_ci_stats)"
export CI_STATS_TOKEN="$(vault_get kibana_ci_stats api_token)"
export CI_STATS_HOST="$(vault_get kibana_ci_stats api_host)"

ts-node "$(dirname "${0}")/ci_stats_start.ts"

Expand Down
38 changes: 19 additions & 19 deletions .buildkite/scripts/lifecycle/pre_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo '--- Setup environment vars'
source .buildkite/scripts/common/env.sh
source .buildkite/scripts/common/setup_node.sh

BUILDKITE_TOKEN="$(retry 5 5 vault read -field=buildkite_token_all_jobs secret/kibana-issues/dev/buildkite-ci)"
BUILDKITE_TOKEN="$(vault_get buildkite-ci buildkite_token_all_jobs)"
export BUILDKITE_TOKEN

echo '--- Install/build buildkite dependencies'
Expand Down Expand Up @@ -81,10 +81,10 @@ EOF
if [[ "$CI_STATS_BUILD_ID" ]]; then
echo "CI Stats Build ID: $CI_STATS_BUILD_ID"

CI_STATS_TOKEN="$(retry 5 5 vault read -field=api_token secret/kibana-issues/dev/kibana_ci_stats)"
CI_STATS_TOKEN="$(vault_get kibana_ci_stats api_token)"
export CI_STATS_TOKEN

CI_STATS_HOST="$(retry 5 5 vault read -field=api_host secret/kibana-issues/dev/kibana_ci_stats)"
CI_STATS_HOST="$(vault_get kibana_ci_stats api_host)"
export CI_STATS_HOST

KIBANA_CI_STATS_CONFIG=$(jq -n \
Expand All @@ -97,57 +97,57 @@ EOF
fi
}

GITHUB_TOKEN=$(retry 5 5 vault read -field=github_token secret/kibana-issues/dev/kibanamachine)
GITHUB_TOKEN=$(vault_get kibanamachine github_token)
export GITHUB_TOKEN

KIBANA_CI_GITHUB_TOKEN=$(retry 5 5 vault read -field=github_token secret/kibana-issues/dev/kibana-ci-github)
KIBANA_CI_GITHUB_TOKEN=$(vault_get kibana-ci-github github_token)
export KIBANA_CI_GITHUB_TOKEN

KIBANA_CI_REPORTER_KEY=$(retry 5 5 vault read -field=value secret/kibana-issues/dev/kibanamachine-reporter)
KIBANA_CI_REPORTER_KEY=$(vault_get kibanamachine-reporter value)
export KIBANA_CI_REPORTER_KEY

KIBANA_DOCKER_USERNAME="$(retry 5 5 vault read -field=username secret/kibana-issues/dev/container-registry)"
KIBANA_DOCKER_USERNAME="$(vault_get container-registry username)"
export KIBANA_DOCKER_USERNAME

KIBANA_DOCKER_PASSWORD="$(retry 5 5 vault read -field=password secret/kibana-issues/dev/container-registry)"
KIBANA_DOCKER_PASSWORD="$(vault_get container-registry password)"
export KIBANA_DOCKER_PASSWORD

EC_API_KEY="$(retry 5 5 vault read -field=pr_deploy_api_key secret/kibana-issues/dev/kibana-ci-cloud-deploy)"
EC_API_KEY="$(vault_get kibana-ci-cloud-deploy pr_deploy_api_key)"
export EC_API_KEY

SYNTHETICS_SERVICE_USERNAME="$(retry 5 5 vault read -field=username secret/kibana-issues/dev/kibana-ci-synthetics-credentials)"
SYNTHETICS_SERVICE_USERNAME="$(vault_get kibana-ci-synthetics-credentials username)"
export SYNTHETICS_SERVICE_USERNAME

SYNTHETICS_SERVICE_PASSWORD="$(retry 5 5 vault read -field=password secret/kibana-issues/dev/kibana-ci-synthetics-credentials)"
SYNTHETICS_SERVICE_PASSWORD="$(vault_get kibana-ci-synthetics-credentials password)"
export SYNTHETICS_SERVICE_PASSWORD

SYNTHETICS_SERVICE_MANIFEST="$(retry 5 5 vault read -field=manifest secret/kibana-issues/dev/kibana-ci-synthetics-credentials)"
SYNTHETICS_SERVICE_MANIFEST="$(vault_get kibana-ci-synthetics-credentials manifest)"
export SYNTHETICS_SERVICE_MANIFEST

SYNTHETICS_REMOTE_KIBANA_USERNAME="$(retry 5 5 vault read -field=username secret/kibana-issues/dev/kibana-ci-synthetics-remote-credentials)"
SYNTHETICS_REMOTE_KIBANA_USERNAME="$(vault_get kibana-ci-synthetics-remote-credentials username)"
export SYNTHETICS_REMOTE_KIBANA_USERNAME

SYNTHETICS_REMOTE_KIBANA_PASSWORD="$(retry 5 5 vault read -field=password secret/kibana-issues/dev/kibana-ci-synthetics-remote-credentials)"
SYNTHETICS_REMOTE_KIBANA_PASSWORD="$(vault_get kibana-ci-synthetics-remote-credentials password)"
export SYNTHETICS_REMOTE_KIBANA_PASSWORD

SYNTHETICS_REMOTE_KIBANA_URL=${SYNTHETICS_REMOTE_KIBANA_URL-"$(retry 5 5 vault read -field=url secret/kibana-issues/dev/kibana-ci-synthetics-remote-credentials)"}
SYNTHETICS_REMOTE_KIBANA_URL=${SYNTHETICS_REMOTE_KIBANA_URL-"$(vault_get kibana-ci-synthetics-remote-credentials url)"}
export SYNTHETICS_REMOTE_KIBANA_URL

# Setup Failed Test Reporter Elasticsearch credentials
{
TEST_FAILURES_ES_CLOUD_ID=$(retry 5 5 vault read -field=cloud_id secret/kibana-issues/dev/failed_tests_reporter_es)
TEST_FAILURES_ES_CLOUD_ID=$(vault_get failed_tests_reporter_es cloud_id)
export TEST_FAILURES_ES_CLOUD_ID

TEST_FAILURES_ES_USERNAME=$(retry 5 5 vault read -field=username secret/kibana-issues/dev/failed_tests_reporter_es)
TEST_FAILURES_ES_USERNAME=$(vault_get failed_tests_reporter_es username)
export TEST_FAILURES_ES_USERNAME

TEST_FAILURES_ES_PASSWORD=$(retry 5 5 vault read -field=password secret/kibana-issues/dev/failed_tests_reporter_es)
TEST_FAILURES_ES_PASSWORD=$(vault_get failed_tests_reporter_es password)
export TEST_FAILURES_ES_PASSWORD
}

BAZEL_LOCAL_DEV_CACHE_CREDENTIALS_FILE="$HOME/.kibana-ci-bazel-remote-cache-local-dev.json"
export BAZEL_LOCAL_DEV_CACHE_CREDENTIALS_FILE
retry 5 5 vault read -field=service_account_json secret/kibana-issues/dev/kibana-ci-bazel-remote-cache-local-dev > "$BAZEL_LOCAL_DEV_CACHE_CREDENTIALS_FILE"
vault_get kibana-ci-bazel-remote-cache-local-dev service_account_json > "$BAZEL_LOCAL_DEV_CACHE_CREDENTIALS_FILE"

PIPELINE_PRE_COMMAND=${PIPELINE_PRE_COMMAND:-".buildkite/scripts/lifecycle/pipelines/$BUILDKITE_PIPELINE_SLUG/pre_command.sh"}
if [[ -f "$PIPELINE_PRE_COMMAND" ]]; then
Expand Down
20 changes: 10 additions & 10 deletions .buildkite/scripts/pipelines/pull_request/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ const getPipeline = (filename: string, removeSteps = true) => {
return removeSteps ? str.replace(/^steps:/, '') : str;
};

const uploadPipeline = (pipelineContent: string | object) => {
const str =
typeof pipelineContent === 'string' ? pipelineContent : JSON.stringify(pipelineContent);

execSync('buildkite-agent pipeline upload', {
input: str,
stdio: ['pipe', 'inherit', 'inherit'],
});
};
// const uploadPipeline = (pipelineContent: string | object) => {
// const str =
// typeof pipelineContent === 'string' ? pipelineContent : JSON.stringify(pipelineContent);

// execSync('buildkite-agent pipeline upload', {
// input: str,
// stdio: ['pipe', 'inherit', 'inherit'],
// });
// };

(async () => {
try {
Expand Down Expand Up @@ -189,7 +189,7 @@ const uploadPipeline = (pipelineContent: string | object) => {

pipeline.push(getPipeline('.buildkite/pipelines/pull_request/post_build.yml'));

uploadPipeline(pipeline.join('\n'));
console.log(pipeline.join('\n'));
} catch (ex) {
console.error('PR pipeline generation error', ex.message);
process.exit(1);
Expand Down