Skip to content

Commit

Permalink
[CI] Add pipeline task queue framework and merge workers into one (el…
Browse files Browse the repository at this point in the history
  • Loading branch information
brianseeders committed Aug 14, 2020
1 parent 811b006 commit 7799d38
Show file tree
Hide file tree
Showing 54 changed files with 902 additions and 114 deletions.
38 changes: 38 additions & 0 deletions .ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# NOTE: This Dockerfile is ONLY used to run certain tasks in CI. It is not used to run Kibana or as a distributable.
# If you're looking for the Kibana Docker image distributable, please see: src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.ts

ARG NODE_VERSION=10.21.0

FROM node:${NODE_VERSION} AS base

RUN apt-get update && \
apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget openjdk-8-jre && \
rm -rf /var/lib/apt/lists/*

RUN curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y rsync jq bsdtar google-chrome-stable \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN LATEST_VAULT_RELEASE=$(curl -s https://api.github.com/repos/hashicorp/vault/tags | jq --raw-output .[0].name[1:]) \
&& curl -L https://releases.hashicorp.com/vault/${LATEST_VAULT_RELEASE}/vault_${LATEST_VAULT_RELEASE}_linux_amd64.zip -o vault.zip \
&& unzip vault.zip \
&& rm vault.zip \
&& chmod +x vault \
&& mv vault /usr/local/bin/vault

RUN groupadd -r kibana && useradd -r -g kibana kibana && mkdir /home/kibana && chown kibana:kibana /home/kibana

COPY ./bash_standard_lib.sh /usr/local/bin/bash_standard_lib.sh
RUN chmod +x /usr/local/bin/bash_standard_lib.sh

COPY ./runbld /usr/local/bin/runbld
RUN chmod +x /usr/local/bin/runbld

USER kibana
2 changes: 1 addition & 1 deletion .ci/runbld_no_junit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
profiles:
- ".*": # Match any job
tests:
junit-filename-pattern: "8d8bd494-d909-4e67-a052-7e8b5aaeb5e4" # A bogus path that should never exist
junit-filename-pattern: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ package-lock.json
npm-debug.log*
.tern-project
.ci/pipeline-library/build/
.ci/runbld
.ci/bash_standard_lib.sh
.gradle
4 changes: 4 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ kibanaPipeline(timeoutMinutes: 155, checkPrChanges: true, setCommitStatus: true)
ciStats.trackBuild {
catchError {
retryable.enable()
<<<<<<< HEAD
parallel([
'kibana-intake-agent': workers.intake('kibana-intake', './test/scripts/jenkins_unit.sh'),
'x-pack-intake-agent': workers.intake('x-pack-intake', './test/scripts/jenkins_xpack.sh'),
Expand All @@ -35,6 +36,9 @@ kibanaPipeline(timeoutMinutes: 155, checkPrChanges: true, setCommitStatus: true)
'xpack-ciGroup6': kibanaPipeline.xpackCiGroupProcess(6),
]),
])
=======
kibanaPipeline.allCiTasks()
>>>>>>> 0ca8e99a9f... [CI] Add pipeline task queue framework and merge workers into one (#71268)
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/dev/ci_setup/checkout_sibling_es.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ function checkout_sibling {
targetDir=$2
useExistingParamName=$3
useExisting="$(eval "echo "\$$useExistingParamName"")"
repoAddress="https://github.com/"

if [ -z ${useExisting:+x} ]; then
if [ -d "$targetDir" ]; then
echo "I expected a clean workspace but an '${project}' sibling directory already exists in [$PARENT_DIR]!"
echo "I expected a clean workspace but an '${project}' sibling directory already exists in [$WORKSPACE]!"
echo
echo "Either define '${useExistingParamName}' or remove the existing '${project}' sibling."
exit 1
Expand All @@ -21,8 +22,9 @@ function checkout_sibling {
cloneBranch=""

function clone_target_is_valid {

echo " -> checking for '${cloneBranch}' branch at ${cloneAuthor}/${project}"
if [[ -n "$(git ls-remote --heads "git@github.com:${cloneAuthor}/${project}.git" ${cloneBranch} 2>/dev/null)" ]]; then
if [[ -n "$(git ls-remote --heads "${repoAddress}${cloneAuthor}/${project}.git" ${cloneBranch} 2>/dev/null)" ]]; then
return 0
else
return 1
Expand Down Expand Up @@ -71,7 +73,7 @@ function checkout_sibling {
fi

echo " -> checking out '${cloneBranch}' branch from ${cloneAuthor}/${project}..."
git clone -b "$cloneBranch" "git@github.com:${cloneAuthor}/${project}.git" "$targetDir" --depth=1
git clone -b "$cloneBranch" "${repoAddress}${cloneAuthor}/${project}.git" "$targetDir" --depth=1
echo " -> checked out ${project} revision: $(git -C "${targetDir}" rev-parse HEAD)"
echo
}
Expand All @@ -87,12 +89,12 @@ function checkout_sibling {
fi
}

checkout_sibling "elasticsearch" "${PARENT_DIR}/elasticsearch" "USE_EXISTING_ES"
checkout_sibling "elasticsearch" "${WORKSPACE}/elasticsearch" "USE_EXISTING_ES"
export TEST_ES_FROM=${TEST_ES_FROM:-snapshot}

# Set the JAVA_HOME based on the Java property file in the ES repo
# This assumes the naming convention used on CI (ex: ~/.java/java10)
ES_DIR="$PARENT_DIR/elasticsearch"
ES_DIR="$WORKSPACE/elasticsearch"
ES_JAVA_PROP_PATH=$ES_DIR/.ci/java-versions.properties


Expand Down
4 changes: 3 additions & 1 deletion src/dev/ci_setup/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export PARENT_DIR="$parentDir"
kbnBranch="$(jq -r .branch "$KIBANA_DIR/package.json")"
export KIBANA_PKG_BRANCH="$kbnBranch"

export WORKSPACE="${WORKSPACE:-$PARENT_DIR}"

###
### download node
###
Expand Down Expand Up @@ -150,7 +152,7 @@ export -f checks-reporter-with-killswitch

source "$KIBANA_DIR/src/dev/ci_setup/load_env_keys.sh"

ES_DIR="$PARENT_DIR/elasticsearch"
ES_DIR="$WORKSPACE/elasticsearch"
ES_JAVA_PROP_PATH=$ES_DIR/.ci/java-versions.properties

if [[ -d "$ES_DIR" && -f "$ES_JAVA_PROP_PATH" ]]; then
Expand Down
6 changes: 3 additions & 3 deletions tasks/test_jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ const { resolve } = require('path');
module.exports = function (grunt) {
grunt.registerTask('test:jest', function () {
const done = this.async();
runJest(resolve(__dirname, '../scripts/jest.js')).then(done, done);
runJest(resolve(__dirname, '../scripts/jest.js'), ['--maxWorkers=10']).then(done, done);
});

grunt.registerTask('test:jest_integration', function () {
const done = this.async();
runJest(resolve(__dirname, '../scripts/jest_integration.js')).then(done, done);
});

function runJest(jestScript) {
function runJest(jestScript, args = []) {
const serverCmd = {
cmd: 'node',
args: [jestScript, '--no-cache', '--ci'],
args: [jestScript, '--no-cache', '--ci', ...args],
opts: { stdio: 'inherit' }
};

Expand Down
5 changes: 5 additions & 0 deletions test/scripts/checks/doc_api_changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:checkDocApiChanges
5 changes: 5 additions & 0 deletions test/scripts/checks/file_casing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:checkFileCasing
5 changes: 5 additions & 0 deletions test/scripts/checks/i18n.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:i18nCheck
5 changes: 5 additions & 0 deletions test/scripts/checks/licenses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:licenses
5 changes: 5 additions & 0 deletions test/scripts/checks/lock_file_symlinks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:checkLockfileSymlinks
5 changes: 5 additions & 0 deletions test/scripts/checks/telemetry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:telemetryCheck
5 changes: 5 additions & 0 deletions test/scripts/checks/test_hardening.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:test_hardening
5 changes: 5 additions & 0 deletions test/scripts/checks/test_projects.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:test_projects
5 changes: 5 additions & 0 deletions test/scripts/checks/ts_projects.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:checkTsProjects
5 changes: 5 additions & 0 deletions test/scripts/checks/type_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:typeCheck
5 changes: 5 additions & 0 deletions test/scripts/checks/verify_dependency_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:verifyDependencyVersions
5 changes: 5 additions & 0 deletions test/scripts/checks/verify_notice.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

yarn run grunt run:verifyNotice
9 changes: 9 additions & 0 deletions test/scripts/jenkins_accessibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

source test/scripts/jenkins_test_setup_oss.sh

checks-reporter-with-killswitch "Kibana accessibility tests" \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_INSTALL_DIR" \
--config test/accessibility/config.ts;
9 changes: 9 additions & 0 deletions test/scripts/jenkins_build_kbn_sample_panel_action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

cd test/plugin_functional/plugins/kbn_sample_panel_action;
if [[ ! -d "target" ]]; then
checks-reporter-with-killswitch "Build kbn_sample_panel_action" yarn build;
fi
cd -;
12 changes: 10 additions & 2 deletions test/scripts/jenkins_build_kibana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

source src/dev/ci_setup/setup_env.sh

# doesn't persist, also set in kibanaPipeline.groovy
export KBN_NP_PLUGINS_BUILT=true

echo " -> Ensuring all functional tests are in a ciGroup"
yarn run grunt functionalTests:ensureAllTestsInCiGroup;

echo " -> building and extracting OSS Kibana distributable for use in functional tests"
node scripts/build --debug --oss
# Do not build kibana for code coverage run
if [[ -z "$CODE_COVERAGE" ]] ; then
echo " -> building and extracting OSS Kibana distributable for use in functional tests"
node scripts/build --debug --oss

mkdir -p "$WORKSPACE/kibana-build-oss"
cp -pR build/oss/kibana-*-SNAPSHOT-linux-x86_64/. $WORKSPACE/kibana-build-oss/
fi
12 changes: 12 additions & 0 deletions test/scripts/jenkins_build_plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

echo " -> building kibana platform plugins"
node scripts/build_kibana_platform_plugins \
--oss \
--filter '!alertingExample' \
--scan-dir "$KIBANA_DIR/test/plugin_functional/plugins" \
--scan-dir "$KIBANA_DIR/test/interpreter_functional/plugins" \
--workers 6 \
--verbose
15 changes: 0 additions & 15 deletions test/scripts/jenkins_ci_group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,4 @@

source test/scripts/jenkins_test_setup.sh

if [[ -z "$IS_PIPELINE_JOB" ]] ; then
yarn run grunt functionalTests:ensureAllTestsInCiGroup;
node scripts/build --debug --oss;
else
installDir="$(realpath $PARENT_DIR/kibana/build/oss/kibana-*-SNAPSHOT-linux-x86_64)"
destDir=${installDir}-${PARALLEL_PIPELINE_WORKER_INDEX}
cp -R "$installDir" "$destDir"

export KIBANA_INSTALL_DIR="$destDir"
fi

yarn run grunt "run:functionalTests_ciGroup${CI_GROUP}";

if [ "$CI_GROUP" == "1" ]; then
yarn run grunt run:pluginFunctionalTestsRelease;
fi
10 changes: 10 additions & 0 deletions test/scripts/jenkins_firefox_smoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

source test/scripts/jenkins_test_setup_oss.sh

checks-reporter-with-killswitch "Firefox smoke test" \
node scripts/functional_tests \
--bail --debug \
--kibana-install-dir "$KIBANA_INSTALL_DIR" \
--include-tag "includeFirefox" \
--config test/functional/config.firefox.js;
5 changes: 5 additions & 0 deletions test/scripts/jenkins_plugin_functional.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source test/scripts/jenkins_test_setup_oss.sh

yarn run grunt run:pluginFunctionalTestsRelease;
15 changes: 15 additions & 0 deletions test/scripts/jenkins_security_solution_cypress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

source test/scripts/jenkins_test_setup_xpack.sh

echo " -> Running security solution cypress tests"
cd "$XPACK_DIR"

checks-reporter-with-killswitch "Security solution Cypress Tests" \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_INSTALL_DIR" \
--config test/security_solution_cypress/config.ts

echo ""
echo ""
32 changes: 32 additions & 0 deletions test/scripts/jenkins_setup_parallel_workspace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -e

CURRENT_DIR=$(pwd)

# Copy everything except node_modules into the current workspace
rsync -a ${WORKSPACE}/kibana/* . --exclude node_modules
rsync -a ${WORKSPACE}/kibana/.??* .

# Symlink all non-root, non-fixture node_modules into our new workspace
cd ${WORKSPACE}/kibana
find . -type d -name node_modules -not -path '*__fixtures__*' -not -path './node_modules*' -prune -print0 | xargs -0I % ln -s "${WORKSPACE}/kibana/%" "${CURRENT_DIR}/%"
find . -type d -wholename '*__fixtures__*node_modules' -not -path './node_modules*' -prune -print0 | xargs -0I % cp -R "${WORKSPACE}/kibana/%" "${CURRENT_DIR}/%"
cd "${CURRENT_DIR}"

# Symlink all of the individual root-level node_modules into the node_modules/ directory
mkdir -p node_modules
ln -s ${WORKSPACE}/kibana/node_modules/* node_modules/
ln -s ${WORKSPACE}/kibana/node_modules/.??* node_modules/

# Copy a few node_modules instead of symlinking them. They don't work correctly if symlinked
unlink node_modules/@kbn
unlink node_modules/css-loader
unlink node_modules/style-loader

# packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts will fail if this is a symlink
unlink node_modules/val-loader

cp -R ${WORKSPACE}/kibana/node_modules/@kbn node_modules/
cp -R ${WORKSPACE}/kibana/node_modules/css-loader node_modules/
cp -R ${WORKSPACE}/kibana/node_modules/style-loader node_modules/
cp -R ${WORKSPACE}/kibana/node_modules/val-loader node_modules/
8 changes: 6 additions & 2 deletions test/scripts/jenkins_test_setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ trap 'post_work' EXIT

export TEST_BROWSER_HEADLESS=1

if [[ -n "$IS_PIPELINE_JOB" ]] ; then
source src/dev/ci_setup/setup_env.sh
source src/dev/ci_setup/setup_env.sh

# For parallel workspaces, we should copy the .es directory from the root, because it should already have downloaded snapshots in it
# This isn't part of jenkins_setup_parallel_workspace.sh just because not all tasks require ES
if [[ ! -d .es && -d "$WORKSPACE/kibana/.es" ]]; then
cp -R $WORKSPACE/kibana/.es ./
fi
Loading

0 comments on commit 7799d38

Please sign in to comment.