mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[ska] relocate x-pack/test/osquery_cypress (#225104)
## Summary Part of https://github.com/elastic/kibana-team/issues/1503 This PR is mostly about moving osquery cypress dir with security-solution imports ``` x-pack/test/osquery_cypress ``` After: ``` x-pack/solutions/security/test/osquery_cypress ``` --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
afb9a927bc
commit
fbddd79f24
21 changed files with 106 additions and 17 deletions
|
@ -5,11 +5,11 @@ disabled:
|
|||
- x-pack/test/security_solution_api_integration/config/serverless/config.base.edr_workflows.ts
|
||||
- x-pack/test/security_solution_api_integration/config/serverless/config.base.ai4dsoc.ts
|
||||
- x-pack/test/defend_workflows_cypress/serverless_config.base.ts
|
||||
- x-pack/test/osquery_cypress/serverless_config.base.ts
|
||||
- x-pack/solutions/security/test/osquery_cypress/serverless_config.base.ts
|
||||
|
||||
# Cypress configs, for now these are still run manually
|
||||
- x-pack/test/defend_workflows_cypress/serverless_config.ts
|
||||
- x-pack/test/osquery_cypress/serverless_cli_config.ts
|
||||
- x-pack/solutions/security/test/osquery_cypress/serverless_cli_config.ts
|
||||
- x-pack/test/security_solution_cypress/serverless_config.ts
|
||||
- x-pack/test/security_solution_cypress/ai4dsoc_serverless_config.ts
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ disabled:
|
|||
# Cypress configs, for now these are still run manually
|
||||
- x-pack/test/defend_workflows_cypress/cli_config.ts
|
||||
- x-pack/test/defend_workflows_cypress/config.ts
|
||||
- x-pack/test/osquery_cypress/cli_config.ts
|
||||
- x-pack/test/osquery_cypress/config.ts
|
||||
- x-pack/test/osquery_cypress/visual_config.ts
|
||||
- x-pack/solutions/security/test/osquery_cypress/cli_config.ts
|
||||
- x-pack/solutions/security/test/osquery_cypress/config.ts
|
||||
- x-pack/solutions/security/test/osquery_cypress/visual_config.ts
|
||||
- x-pack/test/security_solution_cypress/cli_config.ts
|
||||
- x-pack/test/security_solution_cypress/config.ts
|
||||
|
||||
|
|
|
@ -414,7 +414,7 @@ const getPipeline = (filename: string, removeSteps = true) => {
|
|||
if (
|
||||
((await doAnyChangesMatch([
|
||||
/^x-pack\/platform\/plugins\/shared\/osquery/,
|
||||
/^x-pack\/test\/osquery_cypress/,
|
||||
/^x-pack\/solutions\/security\/test\/osquery_cypress/,
|
||||
/^x-pack\/solutions\/security\/plugins\/security_solution/,
|
||||
])) ||
|
||||
GITHUB_PR_LABELS.includes('ci:all-cypress-suites')) &&
|
||||
|
|
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
|
@ -2687,7 +2687,7 @@ x-pack/test/security_solution_api_integration/test_suites/genai @elastic/securit
|
|||
x-pack/platform/test/automatic_import_api_integration @elastic/security-scalability
|
||||
|
||||
# Security Defend Workflows - OSQuery Ownership
|
||||
/x-pack/test/osquery_cypress @elastic/security-defend-workflows
|
||||
/x-pack/solutions/security/test/osquery_cypress @elastic/security-defend-workflows
|
||||
/x-pack/plugins/osquery @elastic/security-defend-workflows
|
||||
/x-pack/solutions/security/plugins/security_solution/common/api/detection_engine/model/rule_response_actions @elastic/security-defend-workflows
|
||||
/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_response_actions @elastic/security-defend-workflows
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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".
|
||||
*/
|
||||
import type { ToolingLog } from '@kbn/tooling-log';
|
||||
import chalk from 'chalk';
|
||||
import type { RuntimeServices } from './stack_services';
|
||||
import { createRuntimeServices } from './stack_services';
|
||||
|
||||
/**
|
||||
* Returns a logger that intercepts calls to the ToolingLog instance methods passed in input
|
||||
* and prefix it with the provided value. Useful in order to track log entries, especially when
|
||||
* logging output from multiple sources is concurrently being output to the same source
|
||||
* (ex. CI jobs and output to stdout).
|
||||
*
|
||||
* @param prefix
|
||||
* @param log
|
||||
*
|
||||
* @example
|
||||
* const logger = new ToolingLog();
|
||||
* const prefixedLogger = prefixedOutputLogger('my_log', logger);
|
||||
*
|
||||
* prefixedLogger.info('log something'); // => info [my_log] log something
|
||||
*/
|
||||
export const prefixedOutputLogger = (prefix: string, log: ToolingLog): ToolingLog => {
|
||||
const styledPrefix = `[${chalk.grey(prefix)}]`;
|
||||
const logIt = (type: keyof ToolingLog, ...args: any) => {
|
||||
return log[type](styledPrefix, ...args);
|
||||
};
|
||||
|
||||
const logger: Partial<ToolingLog> = {
|
||||
info: logIt.bind(null, 'info'),
|
||||
debug: logIt.bind(null, 'debug'),
|
||||
verbose: logIt.bind(null, 'verbose'),
|
||||
success: logIt.bind(null, 'success'),
|
||||
warning: logIt.bind(null, 'warning'),
|
||||
write: logIt.bind(null, 'write'),
|
||||
};
|
||||
|
||||
const proxy = new Proxy(log, {
|
||||
get(target: ToolingLog, prop: keyof ToolingLog, receiver: any): any {
|
||||
if (prop in logger) {
|
||||
return logger[prop];
|
||||
}
|
||||
|
||||
return log[prop];
|
||||
},
|
||||
});
|
||||
|
||||
return proxy;
|
||||
};
|
||||
|
||||
const RUNTIME_SERVICES_CACHE = new WeakMap<Cypress.PluginConfigOptions, RuntimeServices>();
|
||||
|
||||
export const setupStackServicesUsingCypressConfig = async (config: Cypress.PluginConfigOptions) => {
|
||||
if (RUNTIME_SERVICES_CACHE.has(config)) {
|
||||
return RUNTIME_SERVICES_CACHE.get(config)!;
|
||||
}
|
||||
|
||||
const isServerless = config.env.IS_SERVERLESS;
|
||||
const isCloudServerless = config.env.CLOUD_SERVERLESS;
|
||||
|
||||
const stackServices = await createRuntimeServices({
|
||||
kibanaUrl: config.env.KIBANA_URL,
|
||||
elasticsearchUrl: config.env.ELASTICSEARCH_URL,
|
||||
fleetServerUrl: config.env.FLEET_SERVER_URL,
|
||||
username: config.env.KIBANA_USERNAME,
|
||||
password: config.env.KIBANA_PASSWORD,
|
||||
esUsername: config.env.ELASTICSEARCH_USERNAME,
|
||||
esPassword: config.env.ELASTICSEARCH_PASSWORD,
|
||||
asSuperuser: !isCloudServerless,
|
||||
useCertForSsl: !isCloudServerless && isServerless,
|
||||
}).then(({ log, ...others }) => {
|
||||
return {
|
||||
...others,
|
||||
log: prefixedOutputLogger('cy.dfw', log),
|
||||
};
|
||||
});
|
||||
|
||||
RUNTIME_SERVICES_CACHE.set(config, stackServices);
|
||||
|
||||
return stackServices;
|
||||
};
|
|
@ -20,7 +20,7 @@ A headless browser is a browser simulation program that does not have a user int
|
|||
|
||||
#### FTR (CI)
|
||||
|
||||
This is the configuration used by CI. It uses the FTR to spawn both a Kibana instance (http://localhost:5620) and an Elasticsearch instance (http://localhost:9220) with a preloaded minimum set of data (see preceding "Test data" section), and then executes cypress against this stack. You can find this configuration in `x-pack/test/osquery_cypress`
|
||||
This is the configuration used by CI. It uses the FTR to spawn both a Kibana instance (http://localhost:5620) and an Elasticsearch instance (http://localhost:9220) with a preloaded minimum set of data (see preceding "Test data" section), and then executes cypress against this stack. You can find this configuration in `x-pack/solutions/security/test/osquery_cypress`
|
||||
|
||||
### Test Execution: Examples
|
||||
|
||||
|
@ -101,13 +101,13 @@ We use es_archiver to manage the data that our Cypress tests need.
|
|||
3. When you are sure that you have all the data you need run the following command from: `x-pack/platform/plugins/shared/osquery`
|
||||
|
||||
```sh
|
||||
node ../../../../../scripts/es_archiver save <nameOfTheFolderWhereDataIsSaved> <indexPatternsToBeSaved> --dir ../../test/osquery_cypress/es_archives --config ../../../test/functional/config.base.js --es-url http://<elasticsearchUsername>:<elasticsearchPassword>@<elasticsearchHost>:<elasticsearchPort>
|
||||
node ../../../../../scripts/es_archiver save <nameOfTheFolderWhereDataIsSaved> <indexPatternsToBeSaved> --dir ../../solutions/security/test/osquery_cypress/es_archives --config ../../../test/functional/config.base.js --es-url http://<elasticsearchUsername>:<elasticsearchPassword>@<elasticsearchHost>:<elasticsearchPort>
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
node ../../../../../scripts/es_archiver save custom_rules ".kibana",".siem-signal*" --dir ../../test/osquery_cypress/es_archives --config ../../../test/functional/config.base.js --es-url http://elastic:changeme@localhost:9220
|
||||
node ../../../../../scripts/es_archiver save custom_rules ".kibana",".siem-signal*" --dir ../../solutions/security/test/osquery_cypress/es_archives --config ../../../test/functional/config.base.js --es-url http://elastic:changeme@localhost:9220
|
||||
```
|
||||
|
||||
Note that the command will create the folder if it does not exist.
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
"scripts": {
|
||||
"cypress:burn": "yarn cypress:run --env burn=2 --headed",
|
||||
"cypress:changed-specs-only": "yarn cypress:run --changed-specs-only --env burn=2",
|
||||
"cypress": "node ../../../../solutions/security/plugins/security_solution/scripts/start_cypress_parallel --config-file ../../../x-pack/platform/plugins/shared/osquery/cypress/cypress.config.ts --ftr-config-file ../../../../../x-pack/test/osquery_cypress/cli_config",
|
||||
"cypress": "node ../../../../solutions/security/plugins/security_solution/scripts/start_cypress_parallel --config-file ../../../x-pack/platform/plugins/shared/osquery/cypress/cypress.config.ts --ftr-config-file ../../../../../x-pack/solutions/security/test/osquery_cypress/cli_config",
|
||||
"cypress:open": "yarn cypress open",
|
||||
"cypress:run": "yarn cypress run",
|
||||
"cypress:serverless": "node ../../../../solutions/security/plugins/security_solution/scripts/start_cypress_parallel --config-file ../../../x-pack/platform/plugins/shared/osquery/cypress/serverless_cypress.config.ts --ftr-config-file ../../../../../x-pack/test/osquery_cypress/serverless_cli_config",
|
||||
"cypress:serverless": "node ../../../../solutions/security/plugins/security_solution/scripts/start_cypress_parallel --config-file ../../../x-pack/platform/plugins/shared/osquery/cypress/serverless_cypress.config.ts --ftr-config-file ../../../../../x-pack/solutions/security/test/osquery_cypress/serverless_cli_config",
|
||||
"cypress:serverless:open": "yarn cypress:serverless open",
|
||||
"cypress:serverless:run": "yarn cypress:serverless run",
|
||||
"cypress:qa:serverless": "node ../../../../solutions/security/plugins/security_solution/scripts/start_cypress_parallel_serverless --config-file ../../../x-pack/platform/plugins/shared/osquery/cypress/serverless_cypress_qa.config.ts --onBeforeHook ../../../../test/osquery_cypress/runner_qa.ts",
|
||||
"cypress:qa:serverless": "node ../../../../solutions/security/plugins/security_solution/scripts/start_cypress_parallel_serverless --config-file ../../../x-pack/platform/plugins/shared/osquery/cypress/serverless_cypress_qa.config.ts --onBeforeHook ../../../../solutions/security/test/osquery_cypress/runner_qa.ts",
|
||||
"cypress:qa:serverless:run": "yarn cypress:qa:serverless run",
|
||||
"nyc": "../../../../../node_modules/.bin/nyc report --reporter=text-summary",
|
||||
"junit:merge": "../../../../../node_modules/.bin/mochawesome-merge ../../../../../target/kibana-osquery/cypress/results/mochawesome*.json > ../../../../../target/kibana-osquery/cypress/results/output.json && ../../../../../node_modules/.bin/marge ../../../../../target/kibana-osquery/cypress/results/output.json --reportDir ../../../../../target/kibana-osquery/cypress/results && yarn junit:transform && mkdir -p ../../../../../target/junit && cp ../../../../../target/kibana-osquery/cypress/results/*.xml ../../../../../target/junit/",
|
||||
|
|
|
@ -14,7 +14,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
|||
require.resolve('@kbn/test-suites-src/common/config')
|
||||
);
|
||||
const xpackFunctionalTestsConfig = await readConfigFile(
|
||||
require.resolve('../functional/config.base.js')
|
||||
require.resolve('@kbn/test-suites-xpack-platform/functional/config.base')
|
||||
);
|
||||
|
||||
return {
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { prefixedOutputLogger } from '@kbn/security-solution-plugin/scripts/endpoint/common/utils';
|
||||
import { createToolingLogger } from '@kbn/security-solution-plugin/common/endpoint/data_loaders/utils';
|
||||
import { setupStackServicesUsingCypressConfig } from '@kbn/security-solution-plugin/public/management/cypress/support/common';
|
||||
import { setupStackServicesUsingCypressConfig } from '@kbn/cypress-test-helper/src/services/common';
|
||||
import { maybeCreateDockerNetwork, verifyDockerInstalled } from '@kbn/es';
|
||||
import { AgentManager } from './agent';
|
||||
import { createAgentPolicy } from './utils';
|
|
@ -9,7 +9,6 @@ import axios from 'axios';
|
|||
import semver from 'semver';
|
||||
import { map } from 'lodash';
|
||||
import { PackagePolicy, CreatePackagePolicyResponse, API_VERSIONS } from '@kbn/fleet-plugin/common';
|
||||
// @ts-expect-error we have to check types with "allowJs: false" for now, causing this import to fail
|
||||
import { kibanaPackageJson } from '@kbn/repo-info';
|
||||
import { KbnClient } from '@kbn/test';
|
||||
import {
|
|
@ -43,5 +43,9 @@
|
|||
"@kbn/stack-connectors-plugin",
|
||||
"@kbn/security-plugin",
|
||||
"@kbn/security-plugin-types-common",
|
||||
"@kbn/es",
|
||||
"@kbn/cypress-test-helper",
|
||||
"@kbn/fleet-plugin",
|
||||
"@kbn/repo-info",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -140,7 +140,6 @@
|
|||
"@kbn/securitysolution-endpoint-exceptions-common",
|
||||
"@kbn/osquery-plugin",
|
||||
"@kbn/cases-api-integration-test-plugin",
|
||||
"@kbn/security-solution-plugin/public/management/cypress",
|
||||
"@kbn/mock-idp-utils",
|
||||
"@kbn/saved-objects-management-plugin",
|
||||
"@kbn/alerting-types",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue