|
| 1 | + |
| 2 | +>>> [CLI] pipelines test --help |
| 3 | +Run the tests of a pipeline in a test-only update. |
| 4 | + |
| 5 | +This command is experimental. Set DATABRICKS_CLI_PIPELINES_TEST=true to enable it. |
| 6 | + |
| 7 | +KEY is the unique name of the pipeline, as defined in its YAML file. |
| 8 | +It is required when test selections are given. If there is only one pipeline |
| 9 | +in the project and no arguments are given, it is selected automatically. |
| 10 | +Outside a project, identify the pipeline with --pipeline-id; all positional |
| 11 | +arguments are then test selections. |
| 12 | + |
| 13 | +TEST_SELECTION is a test directory, file, or pytest test ID, for example |
| 14 | +tests/test_orders.py::test_backfill. In a project, a relative path is a local |
| 15 | +path, relative to the working directory, and is converted to its deployed |
| 16 | +workspace path. With --pipeline-id, a relative path is relative to the |
| 17 | +pipeline's root_path. Paths that start with / are workspace paths. Without a |
| 18 | +selection, all of the pipeline's tests run. |
| 19 | + |
| 20 | +Each --pytest-arg passes one argument to pytest, in the order given. Only -k |
| 21 | +and -m are supported, each followed by its value in the next --pytest-arg, for |
| 22 | +example: |
| 23 | + |
| 24 | + databricks pipelines test my_pipeline --pytest-arg=-k --pytest-arg='orders and not slow' |
| 25 | + |
| 26 | +The command waits for the results. It exits with code 0 only if at least one |
| 27 | +test was collected and none failed or errored, so a run whose tests were all |
| 28 | +skipped succeeds; otherwise it exits with code 1. --no-wait returns after the |
| 29 | +update starts. |
| 30 | + |
| 31 | +--timeout and Ctrl+C stop waiting but not the update; pass its ID to --resume |
| 32 | +to read the results later. To stop the update, run 'pipelines stop'. |
| 33 | + |
| 34 | +--junit-xml writes one entry per test with its outcome and duration. An |
| 35 | +incomplete run, a run without tests, or a timeout adds a failing entry that |
| 36 | +names the cause. The report replaces the file on every exit except a flag that |
| 37 | +cannot be parsed. With workspace.sync_mode immutable, test names keep the path |
| 38 | +of the deployed snapshot, which changes with each deployment. |
| 39 | + |
| 40 | +Usage: |
| 41 | + databricks pipelines test [flags] [KEY] [TEST_SELECTION...] |
| 42 | + |
| 43 | +Pipeline Test Flags: |
| 44 | + --junit-xml string Write the results as a JUnit XML report to this file, replacing it. |
| 45 | + --no-wait Don't wait for the tests to complete. |
| 46 | + --pipeline-id string ID of the pipeline to test, instead of a KEY. |
| 47 | + --pytest-arg stringArray Argument to pass to pytest (repeatable). Only -k and -m are supported. |
| 48 | + --resume string Read the results of an existing test update instead of starting one. |
| 49 | + --timeout duration Stop waiting for results after this duration, for example 30m. The update keeps running. |
| 50 | + |
| 51 | +Flags: |
| 52 | + -h, --help help for test |
| 53 | + |
| 54 | +Global Flags: |
| 55 | + --debug enable debug logging |
| 56 | + -o, --output type output type: text or json (default text) |
| 57 | + -p, --profile string ~/.databrickscfg profile |
| 58 | + -t, --target string bundle target to use (if applicable) |
| 59 | + --var strings set values for variables defined in project config. Example: --var="foo=bar" |
| 60 | + |
| 61 | +=== The command is experimental and off by default |
| 62 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 |
| 63 | +Error: pipelines test is experimental. Set DATABRICKS_CLI_PIPELINES_TEST=true to enable it |
| 64 | + |
| 65 | +=== With the command off, an older report is still replaced |
| 66 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --junit-xml out.gate-off.xml |
| 67 | +Error: pipelines test is experimental. Set DATABRICKS_CLI_PIPELINES_TEST=true to enable it |
| 68 | + |
| 69 | +=== pytest arguments must be passed with --pytest-arg |
| 70 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 -k orders |
| 71 | +Error: -k is a pytest argument: pass pytest arguments with --pytest-arg, for example --pytest-arg=-k --pytest-arg='orders and not slow' |
| 72 | + |
| 73 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 -- -k orders |
| 74 | +Error: the -- separator is not supported: pass pytest arguments with --pytest-arg, for example --pytest-arg=-k --pytest-arg='orders and not slow' |
| 75 | + |
| 76 | +=== Invalid --pytest-arg values fail before any request |
| 77 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --pytest-arg=-x |
| 78 | +Error: unsupported pytest argument "-x": only -k and -m are supported |
| 79 | + |
| 80 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --pytest-arg= |
| 81 | +Error: --pytest-arg requires a non-empty value |
| 82 | + |
| 83 | +=== The pipeline ID must be a pipeline ID |
| 84 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 |
| 85 | +Error: --pipeline-id "1234" is not a pipeline ID |
| 86 | + |
| 87 | +=== JSON output is not supported |
| 88 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 -o json |
| 89 | +Error: --output json is not supported by pipelines test |
| 90 | + |
| 91 | +=== Incompatible run-control flags |
| 92 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 tests --resume 5678 |
| 93 | +Error: --resume cannot be used with test selections |
| 94 | + |
| 95 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --resume 5678 --pytest-arg=-m --pytest-arg=smoke |
| 96 | +Error: --resume cannot be used with --pytest-arg |
| 97 | + |
| 98 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --resume 5678 --no-wait |
| 99 | +Error: --resume cannot be used with --no-wait |
| 100 | + |
| 101 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --no-wait --timeout 10m |
| 102 | +Error: --timeout cannot be used with --no-wait |
| 103 | + |
| 104 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --resume 5678' OR '1'='1 |
| 105 | +Error: --resume "5678' OR '1'='1" is not an update ID; pass the update ID that pipelines test printed |
| 106 | + |
| 107 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --resume |
| 108 | +Error: --resume "" is not an update ID; pass the update ID that pipelines test printed |
| 109 | + |
| 110 | +=== --junit-xml needs the results |
| 111 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --no-wait --junit-xml out.no-wait.xml |
| 112 | +Error: --junit-xml cannot be used with --no-wait because no results are available when the command returns |
| 113 | + |
| 114 | +=== An invalid flag replaces an older report |
| 115 | +>>> musterr [CLI] pipelines test --pipeline-id 1234 --pytest-arg=-x --junit-xml out.flag-error.xml |
| 116 | +Error: unsupported pytest argument "-x": only -k and -m are supported |
0 commit comments