Skip to content

Conversation

dpsutton
Copy link
Contributor

@dpsutton dpsutton commented Aug 19, 2025

ignoring some tests

with ignored '{:vars ["metabase.util.queue-test/bounded-transfer-queue-test" "metabase.util.queue-test/take-batch-test"]}' we run 4 tests

clj -X:dev:test :only metabase.util.queue-test :ignored '{:vars ["metabase.util.queue-test/bounded-transfer-queue-test" "metabase.util.queue-test/take-batch-test"]}'
ignoring var: metabase.util.queue-test/bounded-transfer-queue-test
ignoring var: metabase.util.queue-test/take-batch-test
Running tests with options {:mode :cli/local, :namespace-pattern #"^(?:(?:metabase.*)|(?:hooks\..*))", :exclude-directories [".clj-kondo/src" "classes" "dev" "enterprise/backend/src" "local" "resources" "resources-ee" "src" "target" "test_config" "test_resources"], :test-warn-time 3000, :exclude-tags [:metabot-v3/e2e], :only metabase.util.queue-test, :ignored {:vars #{"metabase.util.queue-test/bounded-transfer-queue-test" "metabase.util.queue-test/take-batch-test"}}}
Running tests in metabase.util.queue-test
Finding tests took 7.4 s.
Running 4 tests
Running before-run hooks...

vs without this:

❯ clj -X:dev:test :only metabase.util.queue-test
Running tests with options {:mode :cli/local, :namespace-pattern #"^(?:(?:metabase.*)|(?:hooks\..*))", :exclude-directories [".clj-kondo/src" "classes" "dev" "enterprise/backend/src" "local" "resources" "resources-ee" "src" "target" "test_config" "test_resources"], :test-warn-time 3000, :exclude-tags [:metabot-v3/e2e], :only metabase.util.queue-test}
Running tests in metabase.util.queue-test
Finding tests took 6.8 s.
Running 6 tests
Running before-run hooks...

LONG TEST in metabase.util.queue-test/take-batch-test
Test took 4.721 seconds seconds to run

LONG TEST in metabase.util.queue-test/bounded-transfer-queue-test
Test took 7.015 seconds seconds to run

6/6   100% [==================================================]  ETA: 00:00

Ran 6 tests in 11.882 seconds
53 assertions, 0 failures, 0 errors.
{:test 6, :pass 53, :fail 0, :error 0, :type :summary, :duration 11881.563167, :single-threaded 6}
Ran 0 tests in parallel, 6 single-threaded.
Finding and running tests took 18.7 s.
All tests passed.

We can annotate existing tests, but it is helpful to be able to ignore from the CLI. This will give us the ability to quickly suppress known, flaky tests in all of CI without having to change source, land PRs, etc.

API in CI

clj -X:dev:test :only metabase.util.queue-test :ignored "$(cat /tmp/test-config.json| jq '.ignored' | jet -i json -o edn --keywordize)"

Ran 4 tests in 0.118 seconds
{:test 4, :pass 42, :fail 0, :error 0, :type :summary, :duration 118.443792, :single-threaded 4}
Ran 0 tests in parallel, 4 single-threaded.
Finding and running tests took 7.1 s.
All tests passed.
Running after-run hooks...

❯ cat /tmp/test-config.json
{"ignored":{"vars":["metabase.util.queue-test/bounded-transfer-queue-test","metabase.util.queue-test/take-batch-test"]}}%

alternatively, perhaps easier to pass a filename of either json or edn and let the runner convert from json into clojure data structures. doing this all on the CLI isn't crazy but it's not super elegant

```
clj -X:dev:test :only metabase.util.queue-test :ignored '{:vars ["metabase.util.queue-test/bounded-transfer-queue-test" "metabase.util.queue-test/take-batch-test"]}'
ignoring var: metabase.util.queue-test/bounded-transfer-queue-test
ignoring var: metabase.util.queue-test/take-batch-test
Running tests with options {:mode :cli/local, :namespace-pattern #"^(?:(?:metabase.*)|(?:hooks\..*))", :exclude-directories [".clj-kondo/src" "classes" "dev" "enterprise/backend/src" "local" "resources" "resources-ee" "src" "target" "test_config" "test_resources"], :test-warn-time 3000, :exclude-tags [:metabot-v3/e2e], :only metabase.util.queue-test, :ignored {:vars #{"metabase.util.queue-test/bounded-transfer-queue-test" "metabase.util.queue-test/take-batch-test"}}}
Running tests in metabase.util.queue-test
Finding tests took 7.4 s.
Running 4 tests
Running before-run hooks...
```

vs without this:

```
❯ clj -X:dev:test :only metabase.util.queue-test
Running tests with options {:mode :cli/local, :namespace-pattern #"^(?:(?:metabase.*)|(?:hooks\..*))", :exclude-directories [".clj-kondo/src" "classes" "dev" "enterprise/backend/src" "local" "resources" "resources-ee" "src" "target" "test_config" "test_resources"], :test-warn-time 3000, :exclude-tags [:metabot-v3/e2e], :only metabase.util.queue-test}
Running tests in metabase.util.queue-test
Finding tests took 6.8 s.
Running 6 tests
Running before-run hooks...

LONG TEST in metabase.util.queue-test/take-batch-test
Test took 4.721 seconds seconds to run

LONG TEST in metabase.util.queue-test/bounded-transfer-queue-test
Test took 7.015 seconds seconds to run

6/6   100% [==================================================]  ETA: 00:00

Ran 6 tests in 11.882 seconds
53 assertions, 0 failures, 0 errors.
{:test 6, :pass 53, :fail 0, :error 0, :type :summary, :duration 11881.563167, :single-threaded 6}
Ran 0 tests in parallel, 6 single-threaded.
Finding and running tests took 18.7 s.
All tests passed.
```

We can annotate existing tests, but it is helpful to be able to ignore
from the CLI. This will give us the ability to quickly suppress known,
flaky tests in all of CI without having to change source, land PRs, etc.
@dpsutton dpsutton requested a review from camsaul as a code owner August 19, 2025 23:14
Copy link

@escherize escherize left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Don't have to do it in this PR but we should add docs for this

@@ -28,6 +33,22 @@
(is (seq tests))
(is (every? var? tests))
(is (contains? (set tests) (resolve 'mb.hawk.core-test/find-tests-test)))))
(testing "ignore var options"
;; note this is a set here. but that gets normalized and the cli can pass a sequence

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of passing a seq of ignored vars in the test, since it mirrors the usual usage more closely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i want it to be the same, but the entrypoint here means it would convert this to a set many times rather than just once. I normalize the options at the beginning of the find-tests bit, but this multi-method (defmethod find-tests clojure.lang.Symbol gets called once for each symbol; so if a vector comes in i have to turn it into a set each time and that is just very wasteful.

@dpsutton dpsutton merged commit 8813c2b into main Aug 21, 2025
2 checks passed
@dpsutton dpsutton deleted the ignore-vars branch August 21, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants