Skip to content

Commit

Permalink
Merge branch 'sessions/error-format' of github.com:lizozom/kibana int…
Browse files Browse the repository at this point in the history
…o sessions/error-format
  • Loading branch information
Liza K committed Jan 28, 2021
2 parents 434fc62 + 1435ec1 commit 7c94fe0
Show file tree
Hide file tree
Showing 24 changed files with 135 additions and 55 deletions.
1 change: 1 addition & 0 deletions .ci/es-snapshots/Jenkinsfile_verify_es
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ kibanaPipeline(timeoutMinutes: 150) {
withEnv(["ES_SNAPSHOT_MANIFEST=${SNAPSHOT_MANIFEST}"]) {
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'),
'kibana-oss-agent': workers.functional('kibana-oss-tests', { kibanaPipeline.buildOss() }, [
'oss-ciGroup1': kibanaPipeline.ossCiGroupProcess(1),
'oss-ciGroup2': kibanaPipeline.ossCiGroupProcess(2),
Expand Down
1 change: 1 addition & 0 deletions .ci/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

JOB:
- kibana-intake
- x-pack-intake
- kibana-firefoxSmoke
- kibana-ciGroup1
- kibana-ciGroup2
Expand Down
10 changes: 8 additions & 2 deletions .ci/teamcity/default/jest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash

# This file is temporary and can be removed once #85850 has been
# merged and the changes included in open PR's (~3 days after merging)
set -euo pipefail

source "$(dirname "${0}")/../util.sh"

export JOB=kibana-default-jest

checks-reporter-with-killswitch "Jest Unit Tests" \
node scripts/jest x-pack --ci --verbose --maxWorkers=5
7 changes: 2 additions & 5 deletions .ci/teamcity/oss/jest.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/bin/bash

# This file is temporary and can be removed once #85850 has been
# merged and the changes included in open PR's (~3 days after merging)

set -euo pipefail

source "$(dirname "${0}")/../util.sh"

export JOB=kibana-oss-jest

checks-reporter-with-killswitch "Jest Unit Tests" \
node scripts/jest --ci --maxWorkers=5 --verbose
checks-reporter-with-killswitch "OSS Jest Unit Tests" \
node scripts/jest --config jest.config.oss.js --ci --verbose --maxWorkers=5
10 changes: 0 additions & 10 deletions .ci/teamcity/tests/jest.sh

This file was deleted.

15 changes: 7 additions & 8 deletions .teamcity/src/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,20 @@ fun BuildType.kibanaAgent(size: Int) {
}

val testArtifactRules = """
target/junit/**/*
target/kibana-*
target/kibana-coverage/**/*
target/kibana-security-solution/**/*.png
target/test-metrics/*
target/kibana-security-solution/**/*.png
target/junit/**/*
target/test-suites-ci-plan.json
test/**/screenshots/diff/*.png
test/**/screenshots/failure/*.png
test/**/screenshots/session/*.png
test/**/screenshots/failure/*.png
test/**/screenshots/diff/*.png
test/functional/failure_debug/html/*.html
x-pack/test/**/screenshots/diff/*.png
x-pack/test/**/screenshots/failure/*.png
x-pack/test/**/screenshots/session/*.png
x-pack/test/functional/apps/reporting/reports/session/*.pdf
x-pack/test/**/screenshots/failure/*.png
x-pack/test/**/screenshots/diff/*.png
x-pack/test/functional/failure_debug/html/*.html
x-pack/test/functional/apps/reporting/reports/session/*.pdf
""".trimIndent()

fun BuildType.addTestSettings() {
Expand Down
2 changes: 1 addition & 1 deletion .teamcity/src/builds/test/AllTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ object AllTests : BuildType({
description = "All Non-Functional Tests"
type = Type.COMPOSITE

dependsOn(QuickTests, Jest, JestIntegration, OssApiServerIntegration)
dependsOn(QuickTests, Jest, XPackJest, JestIntegration, OssApiServerIntegration)
})
2 changes: 1 addition & 1 deletion .teamcity/src/builds/test/Jest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object Jest : BuildType({
kibanaAgent(8)

steps {
runbld("Jest Unit", "./.ci/teamcity/tests/jest.sh")
runbld("Jest Unit", "./.ci/teamcity/oss/jest.sh")
}

addTestSettings()
Expand Down
19 changes: 19 additions & 0 deletions .teamcity/src/builds/test/XPackJest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package builds.test

import addTestSettings
import jetbrains.buildServer.configs.kotlin.v2019_2.BuildType
import kibanaAgent
import runbld

object XPackJest : BuildType({
name = "X-Pack Jest Unit"
description = "Executes X-Pack Jest Unit Tests"

kibanaAgent(16)

steps {
runbld("X-Pack Jest Unit", "./.ci/teamcity/default/jest.sh")
}

addTestSettings()
})
1 change: 1 addition & 0 deletions .teamcity/src/projects/Kibana.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fun Kibana(config: KibanaConfiguration = KibanaConfiguration()) : Project {
name = "Jest"

buildType(Jest)
buildType(XPackJest)
buildType(JestIntegration)
}

Expand Down
5 changes: 1 addition & 4 deletions jest.config.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ module.exports = {
testPathIgnorePatterns: preset.testPathIgnorePatterns.filter(
(pattern) => !pattern.includes('integration_tests')
),
setupFilesAfterEnv: ['<rootDir>/packages/kbn-test/target/jest/setup/after_env.integration.js'],
reporters: [
'default',
[
'<rootDir>/packages/kbn-test/target/jest/junit_reporter',
{ reportName: 'Jest Integration Tests' },
],
],
coverageReporters: !!process.env.CI
? [['json', { file: 'jest-integration.json' }]]
: ['html', 'text'],
setupFilesAfterEnv: ['<rootDir>/packages/kbn-test/target/jest/setup/after_env.integration.js'],
};
10 changes: 1 addition & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
*/

module.exports = {
preset: '@kbn/test',
rootDir: '.',
projects: [
'<rootDir>/packages/*/jest.config.js',
'<rootDir>/src/*/jest.config.js',
'<rootDir>/src/legacy/*/jest.config.js',
'<rootDir>/src/plugins/*/jest.config.js',
'<rootDir>/test/*/jest.config.js',
'<rootDir>/x-pack/plugins/*/jest.config.js',
],
projects: [...require('./jest.config.oss').projects, ...require('./x-pack/jest.config').projects],
};
19 changes: 19 additions & 0 deletions jest.config.oss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '.',
projects: [
'<rootDir>/packages/*/jest.config.js',
'<rootDir>/src/*/jest.config.js',
'<rootDir>/src/legacy/*/jest.config.js',
'<rootDir>/src/plugins/*/jest.config.js',
'<rootDir>/test/*/jest.config.js',
],
};
2 changes: 1 addition & 1 deletion packages/kbn-test/jest-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
coveragePathIgnorePatterns: ['/node_modules/', '.*\\.d\\.ts'],

// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: !!process.env.CI ? [['json', { file: 'jest.json' }]] : ['html', 'text'],
coverageReporters: !!process.env.CODE_COVERAGE ? ['json'] : ['html', 'text'],

// An array of file extensions your modules use
moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'],
Expand Down
2 changes: 1 addition & 1 deletion src/dev/code_coverage/shell_scripts/extract_archives.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ EXTRACT_DIR=/tmp/extracted_coverage
mkdir -p $EXTRACT_DIR

echo "### Extracting downloaded artifacts"
for x in kibana-intake kibana-oss-tests kibana-xpack-tests; do
for x in kibana-intake x-pack-intake kibana-oss-tests kibana-xpack-tests; do
tar -xzf $DOWNLOAD_DIR/coverage/${x}/kibana-coverage.tar.gz -C $EXTRACT_DIR || echo "### Error 'tarring': ${x}"
done

17 changes: 14 additions & 3 deletions test/scripts/jenkins_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

source test/scripts/jenkins_test_setup.sh

rename_coverage_file() {
test -f target/kibana-coverage/jest/coverage-final.json \
&& mv target/kibana-coverage/jest/coverage-final.json \
target/kibana-coverage/jest/$1-coverage-final.json
}

if [[ -z "$CODE_COVERAGE" ]] ; then
# Lint
./test/scripts/lint/eslint.sh
Expand All @@ -28,8 +34,13 @@ if [[ -z "$CODE_COVERAGE" ]] ; then
./test/scripts/checks/test_hardening.sh
else
echo " -> Running jest tests with coverage"
node scripts/jest --ci --verbose --maxWorkers=6 --coverage || true;

node scripts/jest --ci --verbose --coverage --config jest.config.oss.js || true;
rename_coverage_file "oss"
echo ""
echo ""
echo " -> Running jest integration tests with coverage"
node scripts/jest_integration --ci --verbose --coverage || true;
node --max-old-space-size=8192 scripts/jest_integration --ci --verbose --coverage || true;
rename_coverage_file "oss-integration"
echo ""
echo ""
fi
23 changes: 23 additions & 0 deletions test/scripts/jenkins_xpack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

source test/scripts/jenkins_test_setup.sh

if [[ -z "$CODE_COVERAGE" ]] ; then
echo " -> Running jest tests"

./test/scripts/test/xpack_jest_unit.sh
else
echo " -> Build runtime for canvas"
# build runtime for canvas
echo "NODE_ENV=$NODE_ENV"
node ./x-pack/plugins/canvas/scripts/shareable_runtime
echo " -> Running jest tests with coverage"
cd x-pack
node --max-old-space-size=6144 scripts/jest --ci --verbose --maxWorkers=5 --coverage --config jest.config.js || true;
# rename file in order to be unique one
test -f ../target/kibana-coverage/jest/coverage-final.json \
&& mv ../target/kibana-coverage/jest/coverage-final.json \
../target/kibana-coverage/jest/xpack-coverage-final.json
echo ""
echo ""
fi
2 changes: 1 addition & 1 deletion test/scripts/test/jest_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source src/dev/ci_setup/setup_env.sh

checks-reporter-with-killswitch "Jest Integration Tests" \
node scripts/jest_integration --ci --verbose --coverage
node scripts/jest_integration --ci --verbose
2 changes: 1 addition & 1 deletion test/scripts/test/jest_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source src/dev/ci_setup/setup_env.sh

checks-reporter-with-killswitch "Jest Unit Tests" \
node scripts/jest --ci --verbose --maxWorkers=6 --coverage
node scripts/jest --config jest.config.oss.js --ci --verbose --maxWorkers=5
6 changes: 6 additions & 0 deletions test/scripts/test/xpack_jest_unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

checks-reporter-with-killswitch "X-Pack Jest" \
node scripts/jest x-pack --ci --verbose --maxWorkers=5
7 changes: 7 additions & 0 deletions vars/kibanaCoverage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ def ingest(jobName, buildNumber, buildUrl, timestamp, previousSha, teamAssignmen
def runTests() {
parallel([
'kibana-intake-agent': workers.intake('kibana-intake', './test/scripts/jenkins_unit.sh'),
'x-pack-intake-agent': {
withEnv([
'NODE_ENV=test' // Needed for jest tests only
]) {
workers.intake('x-pack-intake', './test/scripts/jenkins_xpack.sh')()
}
},
'kibana-oss-agent' : workers.functional(
'kibana-oss-tests',
{ kibanaPipeline.buildOss() },
Expand Down
15 changes: 7 additions & 8 deletions vars/kibanaPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,20 @@ def uploadCoverageArtifacts(prefix, pattern) {
def withGcsArtifactUpload(workerName, closure) {
def uploadPrefix = "kibana-ci-artifacts/jobs/${env.JOB_NAME}/${BUILD_NUMBER}/${workerName}"
def ARTIFACT_PATTERNS = [
'target/junit/**/*',
'target/kibana-*',
'target/kibana-coverage/**/*',
'target/kibana-security-solution/**/*.png',
'target/test-metrics/*',
'target/kibana-security-solution/**/*.png',
'target/junit/**/*',
'target/test-suites-ci-plan.json',
'test/**/screenshots/diff/*.png',
'test/**/screenshots/failure/*.png',
'test/**/screenshots/session/*.png',
'test/**/screenshots/failure/*.png',
'test/**/screenshots/diff/*.png',
'test/functional/failure_debug/html/*.html',
'x-pack/test/**/screenshots/diff/*.png',
'x-pack/test/**/screenshots/failure/*.png',
'x-pack/test/**/screenshots/session/*.png',
'x-pack/test/functional/apps/reporting/reports/session/*.pdf',
'x-pack/test/**/screenshots/failure/*.png',
'x-pack/test/**/screenshots/diff/*.png',
'x-pack/test/functional/failure_debug/html/*.html',
'x-pack/test/functional/apps/reporting/reports/session/*.pdf',
]

withEnv([
Expand Down
1 change: 1 addition & 0 deletions vars/tasks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test() {

kibanaPipeline.scriptTask('Jest Unit Tests', 'test/scripts/test/jest_unit.sh'),
kibanaPipeline.scriptTask('API Integration Tests', 'test/scripts/test/api_integration.sh'),
kibanaPipeline.scriptTask('X-Pack Jest Unit Tests', 'test/scripts/test/xpack_jest_unit.sh'),
])
}

Expand Down
11 changes: 11 additions & 0 deletions x-pack/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '..',
projects: ['<rootDir>/x-pack/plugins/*/jest.config.js'],
};

0 comments on commit 7c94fe0

Please sign in to comment.