Skip to content

Conversation

@kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

…ok in parallel tests (elastic#247219)

## Summary
Adds a new ESLint rule
`scout_require_global_setup_hook_in_parallel_tests` that ensures
`parallel_tests` directories contain a `global.setup.ts` file that calls
`globalSetupHook`. Without this hook, ES security indexes are not
pre-generated and tests become flaky.

## What it does
The rule performs two checks:
1. Every `parallel_tests` directory must contain a `global.setup.ts`
file
2. The `global.setup.ts` file must call `globalSetupHook`

**Invalid:**
```ts
// ❌ Missing global.setup.ts file in parallel_tests directory
test/scout/ui/parallel_tests/
  └── my_test.spec.ts  // Error: directory must contain global.setup.ts

// ❌ globalSetupHook imported but not called
// test/scout/ui/parallel_tests/global.setup.ts
import { globalSetupHook } from '@kbn/scout-security';

export const setup = async () => {};  // Error: must call globalSetupHook
```

**Valid:**
```ts
// ✅ global.setup.ts with globalSetupHook call
// test/scout/ui/parallel_tests/global.setup.ts
import { globalSetupHook } from '@kbn/scout-security';

globalSetupHook('Ingest archives', async ({ esArchiver }) => {});

// ✅ Missing global.setup.ts in non-parallel tests directory (no error)
test/scout/ui/tests/
  └── my_test.spec.ts  // OK: rule only applies to parallel_tests
```

## Features
- Validates that `parallel_tests` directories contain a
`global.setup.ts` file
- Validates that `global.setup.ts` calls `globalSetupHook` function
- Reports only once per directory (not for every file in the directory)
- Does not affect files outside `parallel_tests` directories

## Changes
- Added rule implementation with filesystem check for `global.setup.ts`
existence
- Added test suite covering valid and invalid cases
- Registered rule in plugin and enabled as error for Scout test files

(cherry picked from commit fb35695)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Dec 23, 2025
@kibanamachine kibanamachine enabled auto-merge (squash) December 23, 2025 17:46
@elasticmachine
Copy link
Contributor

elasticmachine commented Dec 23, 2025

💔 Build Failed

Failed CI Steps

History

cc @steliosmavro

@steliosmavro
Copy link
Contributor

Has been overwritten by new PR (and backported), so this current backport is no longer needed.

auto-merge was automatically disabled January 10, 2026 14:02

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants