From 2417c3e1b05463f81a907fc5d00bc519d060ad06 Mon Sep 17 00:00:00 2001 From: Or Ouziel Date: Thu, 1 Dec 2022 17:18:48 +0200 Subject: [PATCH 1/3] update readme --- .../plugins/cloud_security_posture/README.md | 73 ++++--------------- 1 file changed, 14 insertions(+), 59 deletions(-) diff --git a/x-pack/plugins/cloud_security_posture/README.md b/x-pack/plugins/cloud_security_posture/README.md index 86f8a44a2e944..c1bfcc45610ec 100755 --- a/x-pack/plugins/cloud_security_posture/README.md +++ b/x-pack/plugins/cloud_security_posture/README.md @@ -4,81 +4,36 @@ Cloud Posture automates the identification and remediation of risks across cloud --- -## Table of contents - -- [Development](#development) - - [Local checks before creating a PR](#local-checks-before-creating-a-pr) - - [Install pre-commit hooks (optional)](#install-pre-commit-hooks-optional) - - [Running unit tests](#running-unit-tests) - - [Running integration tests](#running-integration-tests) - ---- - ## Development -See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions -setting up your development environment. +read [Kibana Contributing Guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for more details -### Local checks before creating a PR +## Testing -Kibana has a pretty long CI process. -Therefore, we suggest running the following commands locally before creating a PR: +read [Kibana Testing Guide](https://www.elastic.co/guide/en/kibana/current/development-tests.html) for more details -1. Typescript check: `node scripts/type_check.js --project=x-pack/plugins/cloud_security_posture/tsconfig.json` -2. Linter check: `yarn lint:es x-pack/plugins/cloud_security_posture` -3. Unit tests: `yarn jest --config x-pack/plugins/cloud_security_posture/jest.config.js` - -### Install pre-commit hooks (optional) - -We -use [pre-commit](https://docs.elastic.dev/kibana-dev-docs/getting-started/setup-dev-env#install-pre-commit-hook-optional) -to run linters and tests before each commit. To install the pre-commit hooks, run the following command from the root of -the repository: +Run **Unit Tests**: ```bash -node scripts/register_git_hook +yarn test:jest --config x-pack/plugins/cloud_security_posture/jest.config.js ``` -### Running unit tests - -Our [unit tests](https://docs.elastic.dev/kibana-dev-docs/tutorials/testing-plugins#unit-testing) are written -using [jest](https://jestjs.io/) framework. - -As a convention, we use the `.test.ts` suffix for all our tests. +> **Note** +> for a coverage report, add the `--coverage` flag, and run `open target/kibana-coverage/jest/x-pack/plugins/cloud_security_posture/index.html` -You can run all cloud security posture tests with the following command: +Run **API Integration**: ```bash -yarn jest --config x-pack/plugins/cloud_security_posture/jest.config.js +yarn test:ftr --config x-pack/test/api_integration/config.ts ``` -To run a specific test, you can use the `--testNamePattern` flag: +Run **Functional UI Tests**: ```bash -yarn jest --config x-pack/plugins/cloud_security_posture/jest.config.js --testNamePattern=FilePattern -t MyTest +yarn test:ftr --config x-pack/test/cloud_security_posture_functional/config.ts ``` -### Running integration tests - -The cloud security posture plugin has -also [integration tests](https://docs.elastic.dev/kibana-dev-docs/tutorials/testing-plugins#integration-tests) that run -against a real Elasticsearch and Kibana instances. -We use these tests to verify that the plugin works as expected when running in a real environment. -In order to run the integration tests, you need to have a running Elasticsearch and Kibana instances with the -integration test configuration. - -You can run Kibana and Elastic with the integration test configuration by running the following command from the root of -the Kibana repository: - -```bash -node scripts/functional_tests_server.js --config x-pack/test/api_integration/config.ts -``` - -** You should wait until the server is ready to accept connections before running the integration tests. - -Then, in a separate terminal, you can run the integration test. -In order to do so, run the following command: +
-``` bash -node scripts/functional_test_runner.js --config x-pack/test/api_integration/config.ts --include=test_file_path -``` \ No newline at end of file +> **Note** +> in development, run them separately with `ftr:runner` and `yarn ftr:server` From 2ec6b283998cc76127530abc3b40dacc548fd6e0 Mon Sep 17 00:00:00 2001 From: Or Ouziel Date: Thu, 1 Dec 2022 19:39:18 +0200 Subject: [PATCH 2/3] update readme --- x-pack/plugins/cloud_security_posture/README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/cloud_security_posture/README.md b/x-pack/plugins/cloud_security_posture/README.md index c1bfcc45610ec..5d60ee678760b 100755 --- a/x-pack/plugins/cloud_security_posture/README.md +++ b/x-pack/plugins/cloud_security_posture/README.md @@ -12,6 +12,18 @@ read [Kibana Contributing Guide](https://github.com/elastic/kibana/blob/main/CON read [Kibana Testing Guide](https://www.elastic.co/guide/en/kibana/current/development-tests.html) for more details +Run **TypeScript**: + +```bash +node scripts/type_check.js --project=x-pack/plugins/cloud_security_posture/tsconfig.json +``` + +Run **ESLint**: + +```bash +yarn lint:es +``` + Run **Unit Tests**: ```bash @@ -36,4 +48,4 @@ yarn test:ftr --config x-pack/test/cloud_security_posture_functional/config.ts
> **Note** -> in development, run them separately with `ftr:runner` and `yarn ftr:server` +> in development, run them separately with `ftr:runner` and `ftr:server` From e9a27c16558d80fb5a191484b69fd70ac5e6f984 Mon Sep 17 00:00:00 2001 From: Or Ouziel Date: Mon, 19 Dec 2022 11:05:47 +0200 Subject: [PATCH 3/3] Update README.md --- x-pack/plugins/cloud_security_posture/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/cloud_security_posture/README.md b/x-pack/plugins/cloud_security_posture/README.md index 5d60ee678760b..7a4646d08ba07 100755 --- a/x-pack/plugins/cloud_security_posture/README.md +++ b/x-pack/plugins/cloud_security_posture/README.md @@ -21,7 +21,7 @@ node scripts/type_check.js --project=x-pack/plugins/cloud_security_posture/tscon Run **ESLint**: ```bash -yarn lint:es +yarn lint:es x-pack/plugins/cloud_security_posture ``` Run **Unit Tests**: