Merge pull request #387 from mozilla/add-airflow-task-id-metric
Add Airflow task ID metric to burnham CLI 🚀
This commit is contained in:
Коммит
25c2129f00
|
@ -16,15 +16,16 @@ All available CLI options for burnham are defined in [src/burnham/cli.py][cli.py
|
|||
|
||||
Copied here for your convenience. 📋
|
||||
|
||||
| Short name | Long name | Environment variable | Type | Description |
|
||||
| ---------- | --------------------- | ---------------------- | ----- | --------------------------------------------------------------------------------------------- |
|
||||
| | `--help` | | | Print the help message |
|
||||
| `-v` | `--version` | | | Print the app's version number to the console |
|
||||
| `-r` | `--test-run` | `BURNHAM_TEST_RUN` | `str` | ID of the current test run |
|
||||
| `-n` | `--test-name` | `BURNHAM_TEST_NAME` | `str` | Name of the current test |
|
||||
| `-p` | `--platform` | `BURNHAM_PLATFORM_URL` | `str` | Data Platform URL |
|
||||
| `-s` | `--spore-drive` | `BURNHAM_SPORE_DRIVE` | `str` | Interface for the spore-drive technology. Accepted values: `["tardigrade", "tardigrade-dna"]` |
|
||||
| `--t` | `--enable-telemetry` | `BURNHAM_TELEMETRY` | | Enable telemetry submission with Glean |
|
||||
| `-T` | `--disable-telemetry` | `BURNHAM_TELEMETRY` | | Disable telemetry submission with Glean |
|
||||
| Short name | Long name | Environment variable | Type | Description |
|
||||
| ---------- | --------------------- | ------------------------- | ----- | --------------------------------------------------------------------------------------------- |
|
||||
| | `--help` | | | Print the help message |
|
||||
| `-v` | `--version` | | | Print the app's version number to the console |
|
||||
| `-r` | `--test-run` | `BURNHAM_TEST_RUN` | `str` | ID of the current test run |
|
||||
| `-n` | `--test-name` | `BURNHAM_TEST_NAME` | `str` | Name of the current test |
|
||||
| `-a` | `--airflow_task_id` | `BURNHAM_AIRFLOW_TASK_ID` | `str` | ID of the Airflow task that runs the client |
|
||||
| `-p` | `--platform` | `BURNHAM_PLATFORM_URL` | `str` | Data Platform URL |
|
||||
| `-s` | `--spore-drive` | `BURNHAM_SPORE_DRIVE` | `str` | Interface for the spore-drive technology. Accepted values: `["tardigrade", "tardigrade-dna"]` |
|
||||
| `-t` | `--enable-telemetry` | `BURNHAM_TELEMETRY` | | Enable telemetry submission with Glean |
|
||||
| `-T` | `--disable-telemetry` | `BURNHAM_TELEMETRY` | | Disable telemetry submission with Glean |
|
||||
|
||||
[cli.py]: ../src/burnham/cli.py
|
||||
|
|
|
@ -69,6 +69,14 @@ class MissionParamType(click.ParamType):
|
|||
required=True,
|
||||
envvar="BURNHAM_TEST_NAME",
|
||||
)
|
||||
@click.option(
|
||||
"-a",
|
||||
"--airflow-task-id",
|
||||
help="ID of the Airflow task that runs the client",
|
||||
type=str,
|
||||
required=True,
|
||||
envvar="BURNHAM_AIRFLOW_TASK_ID",
|
||||
)
|
||||
@click.option(
|
||||
"-p",
|
||||
"--platform",
|
||||
|
@ -105,6 +113,7 @@ def burnham(
|
|||
verbose: bool,
|
||||
test_run: str,
|
||||
test_name: str,
|
||||
airflow_task_id: str,
|
||||
enable_telemetry: bool,
|
||||
platform: str,
|
||||
spore_drive: str,
|
||||
|
@ -134,6 +143,7 @@ def burnham(
|
|||
|
||||
metrics.test.run.set(test_run)
|
||||
metrics.test.name.set(test_name)
|
||||
metrics.test.airflow_task_id.set(airflow_task_id)
|
||||
|
||||
space_ship = Discovery(
|
||||
warp_drive=WarpDrive(),
|
||||
|
|
|
@ -48,6 +48,27 @@ test:
|
|||
- raphael@mozilla.com
|
||||
expires: never
|
||||
|
||||
airflow_task_id:
|
||||
type: string
|
||||
description: >
|
||||
ID of the Airflow task that runs the client
|
||||
metadata:
|
||||
tags:
|
||||
- automation
|
||||
lifetime: application
|
||||
send_in_pings:
|
||||
- discovery
|
||||
- space-ship-ready
|
||||
- starbase46
|
||||
- deletion-request
|
||||
bugs:
|
||||
- https://github.com/mozilla/burnham/issues/381
|
||||
data_reviews:
|
||||
- https://github.com/mozilla/burnham/pull/387
|
||||
notification_emails:
|
||||
- raphael@mozilla.com
|
||||
expires: never
|
||||
|
||||
technology:
|
||||
space_travel:
|
||||
type: labeled_counter
|
||||
|
|
|
@ -11,6 +11,7 @@ from typing import Any, Callable
|
|||
import pytest
|
||||
from click.testing import CliRunner, Result
|
||||
|
||||
from burnham import metrics
|
||||
from burnham.cli import burnham
|
||||
|
||||
|
||||
|
@ -66,6 +67,7 @@ def test_cli(
|
|||
result = run_cli(
|
||||
f"--test-run={uuid.uuid4()}",
|
||||
"--test-name=test_cli",
|
||||
"--airflow-task-id=client1",
|
||||
"--platform=localhost:0",
|
||||
"--spore-drive=tardigrade-dna",
|
||||
*missions,
|
||||
|
@ -96,6 +98,7 @@ def test_cli_verbosity(
|
|||
result = run_cli(
|
||||
f"--test-run={uuid.uuid4()}",
|
||||
"--test-name=test_cli",
|
||||
"--airflow-task-id=client2",
|
||||
"--platform=localhost:0",
|
||||
"--verbose",
|
||||
*missions,
|
||||
|
@ -121,6 +124,7 @@ def test_cli_unknown_mission_identifier(
|
|||
result = run_cli(
|
||||
f"--test-run={uuid.uuid4()}",
|
||||
"--test-name=test_cli",
|
||||
"--airflow-task-id=client3",
|
||||
"--platform=localhost:0",
|
||||
"--spore-drive=tardigrade-dna",
|
||||
*missions,
|
||||
|
@ -153,6 +157,7 @@ def test_cli_restore_test_run_and_test_name(
|
|||
result = run_cli(
|
||||
f"--test-run={uuid.uuid4()}",
|
||||
"--test-name=test_cli",
|
||||
"--airflow-task-id=client4",
|
||||
"--platform=localhost:0",
|
||||
"--spore-drive=tardigrade-dna",
|
||||
*missions,
|
||||
|
@ -163,3 +168,40 @@ def test_cli_restore_test_run_and_test_name(
|
|||
assert monkeypatch_set_upload_enabled.values == [False, True]
|
||||
assert monkeypatch_space_ship_ready.counter == 1
|
||||
assert monkeypatch_discovery.counter == 4
|
||||
|
||||
|
||||
def test_cli_metrics(
|
||||
monkeypatch_space_ship_ready,
|
||||
monkeypatch_discovery,
|
||||
monkeypatch_starbase46,
|
||||
run_cli: Callable,
|
||||
) -> None:
|
||||
"""Test that the CLI app sets Glean metrics as expected."""
|
||||
|
||||
missions = [
|
||||
"MISSION A: ONE WARP",
|
||||
"MISSION G: FIVE WARPS, FOUR JUMPS",
|
||||
]
|
||||
|
||||
test_run = uuid.uuid4()
|
||||
test_name = "test_cli"
|
||||
airflow_task_id = "client5"
|
||||
|
||||
result = run_cli(
|
||||
f"--test-run={test_run}",
|
||||
f"--test-name={test_name}",
|
||||
f"--airflow-task-id={airflow_task_id}",
|
||||
"--platform=localhost:0",
|
||||
"--spore-drive=tardigrade-dna",
|
||||
*missions,
|
||||
)
|
||||
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert metrics.test.run.test_get_value() == test_run
|
||||
assert metrics.test.name.test_get_value() == test_name
|
||||
assert metrics.test.airflow_task_id.test_get_value() == airflow_task_id
|
||||
|
||||
assert monkeypatch_space_ship_ready.counter == 1
|
||||
assert monkeypatch_discovery.counter == 2
|
||||
assert monkeypatch_starbase46.counter == 0
|
||||
|
|
Загрузка…
Ссылка в новой задаче