Skip to content

Commit

Permalink
remove not necesary test + activate logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcger committed Sep 13, 2024
1 parent 3610dee commit 09b7a7f
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 104 deletions.
122 changes: 61 additions & 61 deletions .buildkite/pipelines/pull_request/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,69 +54,69 @@ steps:
timeout_in_minutes: 10
env:
JEST_UNIT_SCRIPT: '.buildkite/scripts/steps/test/jest.sh'
JEST_INTEGRATION_SCRIPT: '.buildkite/scripts/steps/test/jest_integration.sh'
FTR_CONFIGS_SCRIPT: '.buildkite/scripts/steps/test/ftr_configs.sh'
# JEST_INTEGRATION_SCRIPT: '.buildkite/scripts/steps/test/jest_integration.sh'
# FTR_CONFIGS_SCRIPT: '.buildkite/scripts/steps/test/ftr_configs.sh'
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/lint.sh
label: 'Linting'
agents:
machineType: n2-standard-8
preemptible: true
key: linting
timeout_in_minutes: 60
retry:
automatic:
- exit_status: '-1'
limit: 3

- command: .buildkite/scripts/steps/check_types.sh
label: 'Check Types'
agents:
machineType: n2-standard-4
preemptible: true
key: check_types
timeout_in_minutes: 70
retry:
automatic:
- exit_status: '-1'
limit: 3

- command: .buildkite/scripts/steps/lint_with_types.sh
label: 'Linting (with types)'
agents:
machineType: n2-standard-16
preemptible: true
key: linting_with_types
timeout_in_minutes: 90
retry:
automatic:
- exit_status: '-1'
limit: 3

- command: .buildkite/scripts/steps/checks.sh
label: 'Checks'
key: checks
agents:
machineType: n2-standard-2
preemptible: true
timeout_in_minutes: 60
retry:
automatic:
- exit_status: '-1'
limit: 3

- command: .buildkite/scripts/steps/api_docs/build_api_docs.sh
label: 'Build API Docs'
agents:
machineType: n2-standard-4
preemptible: true
key: build_api_docs
timeout_in_minutes: 90
retry:
automatic:
- exit_status: '-1'
limit: 3
# - command: .buildkite/scripts/steps/lint.sh
# label: 'Linting'
# agents:
# machineType: n2-standard-8
# preemptible: true
# key: linting
# timeout_in_minutes: 60
# retry:
# automatic:
# - exit_status: '-1'
# limit: 3
#
# - command: .buildkite/scripts/steps/check_types.sh
# label: 'Check Types'
# agents:
# machineType: n2-standard-4
# preemptible: true
# key: check_types
# timeout_in_minutes: 70
# retry:
# automatic:
# - exit_status: '-1'
# limit: 3
#
# - command: .buildkite/scripts/steps/lint_with_types.sh
# label: 'Linting (with types)'
# agents:
# machineType: n2-standard-16
# preemptible: true
# key: linting_with_types
# timeout_in_minutes: 90
# retry:
# automatic:
# - exit_status: '-1'
# limit: 3
#
# - command: .buildkite/scripts/steps/checks.sh
# label: 'Checks'
# key: checks
# agents:
# machineType: n2-standard-2
# preemptible: true
# timeout_in_minutes: 60
# retry:
# automatic:
# - exit_status: '-1'
# limit: 3
#
# - command: .buildkite/scripts/steps/api_docs/build_api_docs.sh
# label: 'Build API Docs'
# agents:
# machineType: n2-standard-4
# preemptible: true
# key: build_api_docs
# timeout_in_minutes: 90
# retry:
# automatic:
# - exit_status: '-1'
# limit: 3
80 changes: 40 additions & 40 deletions .buildkite/scripts/steps/test/jest_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,51 +53,51 @@ echo "
of noise on CI without any percevable benefit, so they have been disabled. If you want to log
output in your test temporarily, you can modify 'packages/kbn-test/src/jest/setup/disable_console_logs.js'
"
$config="x-pack/plugins/cases/jest.config.js"
# while read -r config; do
echo "--- $ node scripts/jest --config $config"

# --trace-warnings to debug
# Node.js process-warning detected:
# Warning: Closing file descriptor 24 on garbage collection
cmd="NODE_OPTIONS=\"--max-old-space-size=12288 --trace-warnings\" node ./scripts/jest --config=\"$config\" $parallelism --coverage=false --passWithNoTests"
echo "actual full command is:"
echo "$cmd"
echo ""

while read -r config; do
echo "--- $ node scripts/jest --config $config"

# --trace-warnings to debug
# Node.js process-warning detected:
# Warning: Closing file descriptor 24 on garbage collection
cmd="NODE_OPTIONS=\"--max-old-space-size=12288 --trace-warnings\" node ./scripts/jest --config=\"$config\" $parallelism --coverage=false --passWithNoTests"
echo "actual full command is:"
echo "$cmd"
echo ""

start=$(date +%s)

# prevent non-zero exit code from breaking the loop
set +e;
eval "$cmd"
lastCode=$?
set -e;

timeSec=$(($(date +%s)-start))
if [[ $timeSec -gt 60 ]]; then
min=$((timeSec/60))
sec=$((timeSec-(min*60)))
duration="${min}m ${sec}s"
else
duration="${timeSec}s"
fi
start=$(date +%s)

results+=("- $config
duration: ${duration}
result: ${lastCode}")
# prevent non-zero exit code from breaking the loop
set +e
eval "$cmd"
lastCode=$?
set -e

if [ $lastCode -ne 0 ]; then
exitCode=10
echo "Jest exited with code $lastCode"
echo "^^^ +++"
timeSec=$(($(date +%s) - start))
if [[ $timeSec -gt 60 ]]; then
min=$((timeSec / 60))
sec=$((timeSec - (min * 60)))
duration="${min}m ${sec}s"
else
duration="${timeSec}s"
fi

if [[ "$failedConfigs" ]]; then
failedConfigs="${failedConfigs}"$'\n'"$config"
else
failedConfigs="$config"
fi
results+=("- $config
duration: ${duration}
result: ${lastCode}")

if [ $lastCode -ne 0 ]; then
exitCode=10
echo "Jest exited with code $lastCode"
echo "^^^ +++"

if [[ "$failedConfigs" ]]; then
failedConfigs="${failedConfigs}"$'\n'"$config"
else
failedConfigs="$config"
fi
done <<< "$configs"
fi
# done <<< "$configs"

if [[ "$failedConfigs" ]]; then
buildkite-agent meta-data set "$FAILED_CONFIGS_KEY" "$failedConfigs"
Expand Down
26 changes: 26 additions & 0 deletions custom-jest-environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

const JSDOMEnvironment = require('jest-environment-jsdom');
const { screen } = require('@testing-library/react');

class CustomEnvironment extends JSDOMEnvironment {
async handleTestEvent(event, state) {
if (event.name === 'test_fn_failure') {
const error = event.test.errors[0];
if (error && error.message && error.message.includes('Timed out')) {
console.log('Timeout error detected. Current screen state:');
screen.debug();
}
}
await super.handleTestEvent(event, state);
}
}

module.exports = CustomEnvironment;
6 changes: 3 additions & 3 deletions packages/kbn-test/src/jest/setup/disable_console_logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
*/

// on CI these logs just muddy up the console and produce a ton of unnecessary noise
console.log = () => {};
console.error = () => {};
console.warn = () => {};
// console.log = () => {};
// console.error = () => {};
// console.warn = () => {};
1 change: 1 addition & 0 deletions x-pack/plugins/cases/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ module.exports = {
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/x-pack/plugins/cases',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/cases/{common,public,server}/**/*.{ts,tsx}'],
testEnvironment: '<rootDir>/custom-jest-environment.js',
};

0 comments on commit 09b7a7f

Please sign in to comment.