add to documentation cookbook for testing (#3544)

This commit is contained in:
Leli 2023-01-30 18:52:41 +01:00 коммит произвёл GitHub
Родитель a0a4e08a83
Коммит 17c4fb35b1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -73,8 +73,9 @@ SELECT
## How to Configure a Generated Test
1. Make a directory for test resources named `tests/{dataset}/{table}/{test_name}/`,
e.g. `tests/telemetry_derived/clients_last_seen_raw_v1/test_single_day`
Queries are tested by running the `query.sql` with test-input tables and comparing the result to an expected table.
1. Make a directory for test resources named `tests/sql/{project}/{dataset}/{table}/{test_name}/`,
e.g. `tests/sql/moz-fx-data-shared-prod/telemetry_derived/clients_last_seen_raw_v1/test_single_day`
- `table` must match a directory named like `{dataset}/{table}`, e.g.
`telemetry_derived/clients_last_seen_v1`
- `test_name` should start with `test_`, e.g. `test_single_day`
@ -83,6 +84,8 @@ SELECT
1. Add `.yaml` files for input tables, e.g. `clients_daily_v6.yaml`
- Include the dataset prefix if it's set in the tested query,
e.g. `analysis.clients_last_seen_v1.yaml`
- Include the project prefix if it's set in the tested query,
e.g. `moz-fx-other-data.new_dataset.table_1.yaml`
- This will result in the dataset prefix being removed from the query,
e.g. `query = query.replace("analysis.clients_last_seen_v1", "clients_last_seen_v1")`
1. Add `.sql` files for input view queries, e.g. `main_summary_v4.sql`
@ -97,9 +100,12 @@ SELECT
using `.isoformat()`
- Columns named `generated_time` are removed from the result before
comparing to `expect` because they should not be static
- `NULL` values should be omitted in `expect.yaml`. If a column is expected to be `NULL` don't add it to `expect.yaml`.
(Be careful with spreading previous rows (`-<<: *base`) here)
1. Optionally add `.schema.json` files for input table schemas to the table directory, e.g.
`tests/telemetry_derived/clients_last_seen_raw_v1/clients_daily_v6.schema.json`.
`tests/sql/moz-fx-data-shared-prod/telemetry_derived/clients_last_seen_raw_v1/clients_daily_v6.schema.json`.
These tables will be available for every test in the suite.
The `schema.json` file need to match the table name in the `query.sql` file. If it has project and dataset listed there, the schema file also needs project and dataset.
1. Optionally add `query_params.yaml` to define query parameters
- `query_params` must be a list