Skip to content

Commit 557cdaa

Browse files
committed
Write a JUnit XML report from databricks pipelines test
1 parent 6cba663 commit 557cdaa

20 files changed

Lines changed: 560 additions & 28 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Add `--junit-xml` to `databricks pipelines test`, which writes the test results as a JUnit XML report. ([#7273](https://github.com/databricks/cli/pull/7273))

‎acceptance/pipelines/test/arguments/output.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ collected and none failed or errored. --no-wait returns after the update starts.
2626
--timeout and Ctrl+C stop waiting but not the update; pass its ID to --resume
2727
to read the results later. To stop the update, run 'pipelines stop'.
2828

29+
--junit-xml writes one entry per test with its outcome and duration. An
30+
incomplete run, a run without tests, or a timeout adds a failing entry that
31+
names the cause.
32+
2933
Usage:
3034
databricks pipelines test [PIPELINE_KEY] [TEST_SELECTION...] [flags] [--pytest-arg=ARG ...]
3135

3236
Pipeline Test Flags:
37+
--junit-xml string Write the results as a JUnit XML report to this file, replacing it.
3338
--no-wait Return after the test update starts, without waiting for results.
3439
--pipeline-id string ID of the pipeline to test, instead of a PIPELINE_KEY.
3540
--pytest-arg stringArray Argument to pass to pytest (repeatable). Only -k and -m are supported.
@@ -92,6 +97,9 @@ Error: --resume "5678' OR '1'='1" is not an update ID; pass the update ID that p
9297
>>> musterr [CLI] pipelines test --pipeline-id 1234 --resume
9398
Error: --resume "" is not an update ID; pass the update ID that pipelines test printed
9499

100+
>>> musterr [CLI] pipelines test --pipeline-id 1234 --no-wait --junit-xml report.xml
101+
Error: --junit-xml cannot be used with --no-wait because no results are available when the command returns
102+
95103
=== JSON output is not supported
96104
>>> musterr [CLI] pipelines test --pipeline-id 1234 -o json
97105
Error: --output json is not supported by pipelines test

‎acceptance/pipelines/test/arguments/script‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ trace musterr $CLI pipelines test --pipeline-id 1234 --resume 5678 --no-wait
2121
trace musterr $CLI pipelines test --pipeline-id 1234 --no-wait --timeout 10m
2222
trace musterr $CLI pipelines test --pipeline-id 1234 --resume "5678' OR '1'='1"
2323
trace musterr $CLI pipelines test --pipeline-id 1234 --resume ""
24+
trace musterr $CLI pipelines test --pipeline-id 1234 --no-wait --junit-xml report.xml
2425

2526
title "JSON output is not supported"
2627
trace musterr $CLI pipelines test --pipeline-id 1234 -o json
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="my_pipeline" tests="4" failures="1" errors="1" skipped="1">
4+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_orders" name="test_valid_order" time="1.000"></testcase>
5+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_orders" name="test_backfill_fails" time="1.000">
6+
<failure message="AssertionError: assert 100 == 150">AssertionError: assert 100 == 150</failure>
7+
</testcase>
8+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_orders" name="test_legacy_format_skipped" time="1.000">
9+
<skipped></skipped>
10+
</testcase>
11+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_orders" name="test_fixture_error" time="1.000">
12+
<error message="RuntimeError: fixture &#39;orders&#39; setup failed">RuntimeError: fixture &#39;orders&#39; setup failed</error>
13+
</testcase>
14+
</testsuite>
15+
</testsuites>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="my_pipeline" tests="4" failures="0" errors="3" skipped="0">
4+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_compute" name="test_small_order" time="1.000"></testcase>
5+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_compute" name="test_crash_on_large_order">
6+
<error message="no result received"></error>
7+
</testcase>
8+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_compute" name="test_last_order">
9+
<error message="no result received"></error>
10+
</testcase>
11+
<testcase name="update [UUID]">
12+
<error message="RUN INCOMPLETE: the update failed before all test results were received.">RUN INCOMPLETE: the update failed before all test results were received.&#xA;update [UUID] is FAILED: ComputeTerminatedException: Compute terminated unexpectedly.</error>
13+
</testcase>
14+
</testsuite>
15+
</testsuites>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="my_pipeline" tests="3" failures="1" errors="1" skipped="0">
4+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_late_failure" name="test_backfill_fails" time="1.000">
5+
<failure message="AssertionError: assert 100 == 150">AssertionError: assert 100 == 150</failure>
6+
</testcase>
7+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_late_failure" name="test_breaks_update_after_summary" time="1.000"></testcase>
8+
<testcase name="update [UUID]">
9+
<error message="update [UUID] is FAILED: ResultDeliveryException: Test results could not be verified.">update [UUID] is FAILED: ResultDeliveryException: Test results could not be verified.</error>
10+
</testcase>
11+
</testsuite>
12+
</testsuites>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="my_pipeline" tests="1" failures="0" errors="1" skipped="0">
4+
<testcase name="update [UUID]">
5+
<error message="No tests were collected.">No tests were collected.</error>
6+
</testcase>
7+
</testsuite>
8+
</testsuites>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="my_pipeline" tests="2" failures="0" errors="1" skipped="0">
4+
<testcase classname="Workspace.Users.[USERNAME]..bundle.test-pipeline-test-results.default.files.tests.test_delivery" name="test_breaks_update_after_summary" time="1.000"></testcase>
5+
<testcase name="update [UUID]">
6+
<error message="update [UUID] is FAILED: ResultDeliveryException: Test results could not be verified.">update [UUID] is FAILED: ResultDeliveryException: Test results could not be verified.</error>
7+
</testcase>
8+
</testsuite>
9+
</testsuites>

‎acceptance/pipelines/test/results/output.txt‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ tests/test_orders.py::test_valid_order PASSED (1.00s)
5959
}
6060

6161
=== Failed, errored, and skipped tests
62-
>>> musterr [CLI] pipelines test my_pipeline tests/test_orders.py
62+
>>> musterr [CLI] pipelines test my_pipeline tests/test_orders.py --junit-xml out.failures.xml
6363
Recommendation: This command runs the last deployed version of the code
6464

6565
If you've made local changes, run 'databricks pipelines deploy' first to ensure they are included.
@@ -80,9 +80,10 @@ tests/test_orders.py::test_fixture_error
8080
RuntimeError: fixture 'orders' setup failed
8181

8282
4 tests: 1 passed, 1 failed, 1 skipped, 1 error
83+
JUnit report: out.failures.xml
8384

8485
=== No tests collected
85-
>>> musterr [CLI] pipelines test my_pipeline tests/helpers.py
86+
>>> musterr [CLI] pipelines test my_pipeline tests/helpers.py --junit-xml out.no-tests.xml
8687
Recommendation: This command runs the last deployed version of the code
8788

8889
If you've made local changes, run 'databricks pipelines deploy' first to ensure they are included.
@@ -93,9 +94,10 @@ Waiting for compute...
9394
Running tests...
9495

9596
No tests were collected.
97+
JUnit report: out.no-tests.xml
9698

9799
=== The update fails after all tests passed
98-
>>> musterr [CLI] pipelines test my_pipeline tests/test_delivery.py
100+
>>> musterr [CLI] pipelines test my_pipeline tests/test_delivery.py --junit-xml out.update-failed.xml
99101
Recommendation: This command runs the last deployed version of the code
100102

101103
If you've made local changes, run 'databricks pipelines deploy' first to ensure they are included.
@@ -107,10 +109,11 @@ Running tests...
107109
tests/test_delivery.py::test_breaks_update_after_summary PASSED (1.00s)
108110

109111
1 test: 1 passed, 0 failed, 0 skipped, 0 errors
112+
JUnit report: out.update-failed.xml
110113
Error: update [UUID] is FAILED: ResultDeliveryException: Test results could not be verified.
111114

112115
=== The update fails with an error of its own after a test failed
113-
>>> musterr [CLI] pipelines test my_pipeline tests/test_late_failure.py
116+
>>> musterr [CLI] pipelines test my_pipeline tests/test_late_failure.py --junit-xml out.late-failure.xml
114117
Recommendation: This command runs the last deployed version of the code
115118

116119
If you've made local changes, run 'databricks pipelines deploy' first to ensure they are included.
@@ -127,10 +130,11 @@ tests/test_late_failure.py::test_backfill_fails
127130
AssertionError: assert 100 == 150
128131

129132
2 tests: 1 passed, 1 failed, 0 skipped, 0 errors
133+
JUnit report: out.late-failure.xml
130134
Error: update [UUID] is FAILED: ResultDeliveryException: Test results could not be verified.
131135

132136
=== Compute terminates before all results are received
133-
>>> musterr [CLI] pipelines test my_pipeline tests/test_compute.py
137+
>>> musterr [CLI] pipelines test my_pipeline tests/test_compute.py --junit-xml out.incomplete.xml
134138
Recommendation: This command runs the last deployed version of the code
135139

136140
If you've made local changes, run 'databricks pipelines deploy' first to ensure they are included.
@@ -143,4 +147,5 @@ tests/test_compute.py::test_small_order PASSED (1.00s)
143147

144148
RUN INCOMPLETE: the update failed before all test results were received.
145149
Results received: 1 passed.
150+
JUnit report: out.incomplete.xml
146151
Error: update [UUID] is FAILED: ComputeTerminatedException: Compute terminated unexpectedly.

‎acceptance/pipelines/test/results/script‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ trace $CLI pipelines test my_pipeline tests/test_orders.py::test_valid_order
66
trace print_requests.py --get //events
77

88
title "Failed, errored, and skipped tests"
9-
trace musterr $CLI pipelines test my_pipeline tests/test_orders.py
9+
trace musterr $CLI pipelines test my_pipeline tests/test_orders.py --junit-xml out.failures.xml
1010

1111
title "No tests collected"
12-
trace musterr $CLI pipelines test my_pipeline tests/helpers.py
12+
trace musterr $CLI pipelines test my_pipeline tests/helpers.py --junit-xml out.no-tests.xml
1313

1414
title "The update fails after all tests passed"
15-
trace musterr $CLI pipelines test my_pipeline tests/test_delivery.py
15+
trace musterr $CLI pipelines test my_pipeline tests/test_delivery.py --junit-xml out.update-failed.xml
1616

1717
title "The update fails with an error of its own after a test failed"
18-
trace musterr $CLI pipelines test my_pipeline tests/test_late_failure.py
18+
trace musterr $CLI pipelines test my_pipeline tests/test_late_failure.py --junit-xml out.late-failure.xml
1919

2020
title "Compute terminates before all results are received"
21-
trace musterr $CLI pipelines test my_pipeline tests/test_compute.py
21+
trace musterr $CLI pipelines test my_pipeline tests/test_compute.py --junit-xml out.incomplete.xml
2222
rm "$OUT_REQUESTS"

0 commit comments

Comments
 (0)