[kbn-test] extract ES logs only for svl (#202927)

## Summary

PR fixes the issue reported by @dolaru when running stateful FTR
environment without docker setup locally:

```
 info [es] killing node
 info [es] stopping node scout
 info [es] no debug files found, assuming es did not write any
 info [es] cleanup complete
ERROR UNHANDLED ERROR
ERROR Error: Command failed with exit code 1: docker ps -a --format {{.Names}}
      error during connect: Get "http://docker.example.com/v1.47/containers/json?all=1": command [ssh -o ConnectTimeout=30 -T -l dolaru -- debian-12-vm docker system dial-stdio] has exited with exit status 255, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=ssh: Could not resolve hostname dolaru-m2-mbp-debian.local: nodename nor servname provided, or not known
          at makeError (/Users/dolaru/workspace/kibana/node_modules/execa/lib/error.js:60:11)
          at handlePromise (/Users/dolaru/workspace/kibana/node_modules/execa/index.js:118:26)
          at processTicksAndRejections (node:internal/process/task_queues:95:5)
          at extractAndArchiveLogs (extract_and_archive_logs.ts:34:41)
          at run_elasticsearch.ts:86:5
```

Since we don't need it for stateful ES instance, I added condition.
kbn-scout had the same issue, so I exported `cleanupElasticsearch` from
`kbn-test` to avoid code duplication
This commit is contained in:
Dzmitry Lemechko 2024-12-05 00:19:41 +01:00 committed by GitHub
parent c8866e4ce3
commit cdb5a2dca2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 8 deletions

View file

@ -12,8 +12,8 @@ import { resolve } from 'path';
import type { ToolingLog } from '@kbn/tooling-log';
import { REPO_ROOT } from '@kbn/repo-info';
import type { ArtifactLicense, ServerlessProjectType } from '@kbn/es';
import { isServerlessProjectType, extractAndArchiveLogs } from '@kbn/es/src/utils';
import { createTestEsCluster, esTestConfig } from '@kbn/test';
import { isServerlessProjectType } from '@kbn/es/src/utils';
import { createTestEsCluster, esTestConfig, cleanupElasticsearch } from '@kbn/test';
import { Config } from '../config';
interface RunElasticsearchOptions {
@ -82,8 +82,7 @@ export async function runElasticsearch(
config,
});
return async () => {
await node.cleanup();
await extractAndArchiveLogs({ outputFolder: logsDir, log });
await cleanupElasticsearch(node, config.serverless, logsDir, log);
};
}

View file

@ -22,6 +22,7 @@ export {
remapPluginPaths,
getKibanaCliArg,
getKibanaCliLoggers,
cleanupElasticsearch,
} from './src/functional_tests/lib';
export { initLogsDir } from './src/functional_tests/lib';

View file

@ -8,7 +8,7 @@
*/
export { runKibanaServer } from './run_kibana_server';
export { runElasticsearch } from './run_elasticsearch';
export { runElasticsearch, cleanupElasticsearch } from './run_elasticsearch';
export * from './run_ftr';
export {
parseRawFlags,

View file

@ -16,7 +16,7 @@ import { REPO_ROOT } from '@kbn/repo-info';
import type { ArtifactLicense, ServerlessProjectType } from '@kbn/es';
import { isServerlessProjectType, extractAndArchiveLogs } from '@kbn/es/src/utils';
import type { Config } from '../../functional_test_runner';
import { createTestEsCluster, esTestConfig } from '../../es';
import { ICluster, createTestEsCluster, esTestConfig } from '../../es';
interface RunElasticsearchOptions {
log: ToolingLog;
@ -77,6 +77,19 @@ function getEsConfig({
};
}
export async function cleanupElasticsearch(
node: ICluster,
isServerless: boolean,
logsDir: string | undefined,
log: ToolingLog
): Promise<void> {
await node.cleanup();
if (isServerless) {
await extractAndArchiveLogs({ outputFolder: logsDir, log });
}
}
export async function runElasticsearch(
options: RunElasticsearchOptions
): Promise<() => Promise<void>> {
@ -91,8 +104,7 @@ export async function runElasticsearch(
config,
});
return async () => {
await node.cleanup();
await extractAndArchiveLogs({ outputFolder: logsDir, log });
await cleanupElasticsearch(node, config.serverless, logsDir, log);
};
}