Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gurevichdmitry committed May 26, 2024
1 parent 96034e1 commit 7b915ed
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 57 deletions.
File renamed without changes.
30 changes: 10 additions & 20 deletions .github/actions/kibana-ftr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ This GitHub Action runs Kibana tests using the Functional Test Runner ([FTR](htt
| `test_kibana_url` | URL for the Kibana instance to test | true | |
| `test_es_url` | URL for the Elasticsearch instance to test | true | |
| `es_version` | Version of Elasticsearch to test against | true | |
| `ref_commit_sha` | Kibana PR commit sha | false | `main` |
| `test_browser_headless` | Whether to run tests in headless mode | false | `1` |
| `test_cloud` | Whether to enable cloud testing | false | `1` |
| `es_security_enabled` | Whether Elasticsearch security is enabled | false | `1` |
| `node_version_file` | Path to the Node.js version file | false | `package.json` |
| `config` | Path to the test configuration file | false | `x-pack/test/cloud_security_posture_functional/config.cloud.ts` |
| `kibana_ref` | Kibana PR commit sha | false | `main` |

## Usage

Expand All @@ -24,7 +19,7 @@ name: Kibana UI Tests
on:
workflow_dispatch:
inputs:
ref_commit_sha:
kibana_ref:
type: string
description: |
Kibana PR commit sha
Expand All @@ -40,15 +35,10 @@ jobs:
- name: Run Kibana Tests Action
uses: ./.github/actions/kibana-ftr
with:
ref_commit_sha: ${{ github.event.inputs.ref_commit_sha || 'main' }}
test_kibana_url: ${{ secrets.TEST_KIBANA_URL }} # required
test_es_url: ${{ secrets.TEST_ES_URL }} # required
es_version: 8.15.0-SNAPSHOT # required
test_browser_headless: '1'
test_cloud: '1'
es_security_enabled: '1'
node_version_file: 'package.json'
config: 'x-pack/test/cloud_security_posture_functional/config.cloud.ts'
kibana_ref: ${{ github.event.inputs.kibana_ref || 'main' }}
test_kibana_url: ${{ secrets.TEST_KIBANA_URL }}
test_es_url: ${{ secrets.TEST_ES_URL }}
es_version: ${{ env.ES_VERSION }}
```
## Details
Expand All @@ -59,18 +49,18 @@ This action performs the following steps:
- Sets the global variable `KIBANA_DIR` to `kibana`.

2. **Checkout Kibana Repository**:
- Uses the `actions/checkout@v4` action to check out the Kibana repository at the specified `ref_commit_sha` or `main` to the `kibana` directory.
- Uses the `actions/checkout@v4` action to check out the Kibana repository at the specified `kibana_ref` or `main` to the `kibana` directory.

3. **Setup Node**:
- Uses the `actions/setup-node@v4` action to set up the Node.js environment based on the specified `node_version_file`.
- Uses the `actions/setup-node@v4` action to set up the Node.js environment based on the `package.json`.

4. **Bootstrap Kibana**:
- Runs the `yarn kbn bootstrap` command in the `kibana` directory to bootstrap the Kibana environment.

5. **Run FTR**:
- Runs the Functional Test Runner (FTR) with the specified configuration and environment variables.
- Runs the Functional Test Runner (FTR) using the `x-pack/test/cloud_security_posture_functional/config.cloud.ts` configuration and the necessary environment variables.

## Notes

- Ensure that the `test_kibana_url` and `test_es_url` inputs are provided and valid. More information about these variables can be found [here](https://www.elastic.co/guide/en/kibana/current/development-tests.html#_running_functional_tests).
- The `ref_commit_sha` input can be omitted to default to the `main` branch.
- The `kibana_ref` input can be omitted to default to the `main` branch.
35 changes: 8 additions & 27 deletions .github/actions/kibana-ftr/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,10 @@ inputs:
es_version:
description: 'Version of Elasticsearch to test against'
required: true
ref_commit_sha:
kibana_ref:
description: 'Kibana PR commit sha'
required: false
default: 'main'
test_browser_headless:
description: 'Whether to run tests in headless mode'
required: false
default: '1'
test_cloud:
description: 'Whether to enable cloud testing'
required: false
default: '1'
es_security_enabled:
description: 'Whether Elasticsearch security is enabled'
required: false
default: '1'
node_version_file:
description: 'Path to the Node.js version file'
required: false
default: 'package.json'
config:
description: 'Path to the test configuration file'
required: false
default: 'x-pack/test/cloud_security_posture_functional/config.cloud.ts'

runs:
using: 'composite'
Expand All @@ -49,14 +29,14 @@ runs:
uses: actions/checkout@v4
with:
repository: elastic/kibana
ref: ${{ inputs.ref_commit_sha }}
ref: ${{ inputs.kibana_ref }}
fetch-depth: 1
path: ${{ steps.globals.outputs.KIBANA_DIR }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ${{ steps.globals.outputs.KIBANA_DIR }}/${{ inputs.node_version_file }}
node-version-file: ${{ steps.globals.outputs.KIBANA_DIR }}/package.json

- name: Bootstrap Kibana
shell: bash
Expand All @@ -69,11 +49,12 @@ runs:
shell: bash
working-directory: ${{ steps.globals.outputs.KIBANA_DIR }}
env:
TEST_BROWSER_HEADLESS: ${{ inputs.test_browser_headless }}
TEST_KIBANA_URL: ${{ inputs.test_kibana_url }}
TEST_ES_URL: ${{ inputs.test_es_url }}
TEST_CLOUD: ${{ inputs.test_cloud }}
ES_SECURITY_ENABLED: ${{ inputs.es_security_enabled }}
ES_VERSION: ${{ inputs.es_version }}
TEST_CLOUD: '1'
ES_SECURITY_ENABLED: '1'
TEST_BROWSER_HEADLESS: '1'
TEST_CONFIG: 'x-pack/test/cloud_security_posture_functional/config.cloud.ts'
run: |
node scripts/functional_test_runner --config ${{ inputs.config }} --es-version ${{ env.ES_VERSION }}
node scripts/functional_test_runner --config "$TEST_CONFIG" --es-version "$ES_VERSION"
9 changes: 4 additions & 5 deletions .github/workflows/test-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ on:
description: "Run UI sanity tests after provision"
default: false
type: boolean
ref_commit_sha:
kibana_ref:
description: "Kibana branch, tag, or commit SHA to check out the UI sanity tests from"
required: false
default: "main"
Expand Down Expand Up @@ -83,7 +83,7 @@ on:
description: "Run UI sanity tests after provision"
default: false
type: boolean
ref_commit_sha:
kibana_ref:
description: "Kibana branch, tag, or commit SHA to check out the UI sanity tests from"
required: false
default: "main"
Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
- name: Set Environment Output
id: env-output
run: ../../.ci/scripts/set_environment_output.sh
run: ../../.ci/scripts/set_cloud_env_params.sh

- name: Upload tf state
id: upload-state
Expand Down Expand Up @@ -436,8 +436,7 @@ jobs:
test_kibana_url: ${{ env.TEST_KIBANA_URL }}
test_es_url: ${{ env.TEST_ES_URL }}
es_version: ${{ env.STACK_VERSION }}
ref_commit_sha: ${{ inputs.ref_commit_sha }}
config: 'x-pack/test/cloud_security_posture_functional/config.cloud.ts'
kibana_ref: ${{ inputs.kibana_ref }}

- name: Cleanup Environment
if: ${{ !cancelled() && inputs.cleanup-env == true }}
Expand Down
13 changes: 8 additions & 5 deletions dev-docs/Cloud-Env-Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ Follow these steps to run the workflow:

- **`run-sanity-tests`** (**optional**): Set to `true` to run sanity tests after the environment is set up. Default: `false`

- **`run-ui-sanity-tests`** (**optional**): Set to `true` to run Kibana UI sanity tests after the environment is set up. Default: `false`
- **`run-ui-sanity-tests`** (**optional**): Set to `true` to run [Kibana UI sanity tests](/.github/actions/kibana-ftr/README.md) after the environment is set up. Default: `false`

- **`ref_commit_sha`** (**optional**): Specifies the Kibana branch, tag, or commit SHA to check out for the UI sanity tests, which will be executed after the environment is set up. This should correspond to the version of the `elk-stack-version` provisioned by this workflow. Note that for the current version in development, use Kibana's `main` branch. Default: `main`
- **`kibana_ref`** (**optional**): Specifies the Kibana branch, tag, or commit SHA to check out for the UI sanity tests, which will be executed after the environment is set up. This should correspond to the version of the `elk-stack-version` provisioned by this workflow. For the current version in development, use Kibana's `main` branch. Default: `main`. Examples of different inputs:
- Specifying Branch: `main`
- Specifying Tag: `v8.13.4`
- Specifying Commit SHA: `c776cf650e962f04330789a9f113bd4bbd6d7c61`

- **`cleanup-env`** (**optional**): Set to `true` if you want the resources to automatically be cleaned up after
provisioning - useful if you don't want to test the env manually after deployment.
Expand All @@ -61,7 +64,7 @@ Follow these steps to run the workflow:

![Optional Parameters](https://github.com/elastic/cloudbeat/assets/99176494/c3259dd8-0e63-429b-9738-e1374eb8309b)

5. Click the `Run workflow` button to start.
1. Click the `Run workflow` button to start.

![Run Workflow](https://github.com/oren-zohar/cloudbeat/assets/85433724/7b05bf58-cc0b-4ec9-8e49-55d117673df8)

Expand Down Expand Up @@ -164,14 +167,14 @@ Follow these steps to run the workflow:

- `prefix` (required): The prefix used to identify the environments to be deleted.

<img width="411" alt="Enter Inputs" src="https://github.com/elastic/cloudbeat/assets/99176494/04973b00-5411-4ace-ab3a-534371877c91">
<img width="411" alt="Enter Inputs" src="https://github.com/elastic/cloudbeat/assets/99176494/04973b00-5411-4ace-ab3a-534371877c91" />

4. Optionally, modify other input value if required:

- `ignore-prefix` (optional): The prefix used to identify environments that should be excluded from deletion.
- `ec-api-key` (required): Use your own [Elastic Cloud](https://cloud.elastic.co/home) API key if you want to delete environments from your Elastic Cloud account.

<img width="411" alt="Optional Inputs" src="https://github.com/elastic/cloudbeat/assets/99176494/aa89ad4e-fd32-461d-ab2d-3fee28094a9d">
<img width="411" alt="Optional Inputs" src="https://github.com/elastic/cloudbeat/assets/99176494/aa89ad4e-fd32-461d-ab2d-3fee28094a9d" />

5. Click the `Run workflow` button to start.

Expand Down

0 comments on commit 7b915ed

Please sign in to comment.