KnapsackPro / knapsack_pro-ruby

Knapsack Pro gem splits tests across parallel CI nodes and makes sure that tests run in optimal time
https://knapsackpro.com
MIT License
131 stars 27 forks source link

After upgrading to minitest 5.22.0 I get error status even if all test pass #240

Closed davidwessman closed 7 months ago

davidwessman commented 7 months ago

Hello!

After upgrading to minitest 5.22.0 we are getting a failed status from bundle exec rake knapsack_pro:queue:minitest even if all test cases pass.

The failing jobs has the output Nothing ran for filter: and the passing jobs does not.

My guess is that this change for empty_run! will generate a warning where it previously did not: https://github.com/minitest/minitest/compare/v5.21.2...v5.22.0#diff-b43f1192f616004aa819abdb67ebe90528572c49ec805b9ad66ce45e1afce97bR177

ArturT commented 7 months ago

I reproduced the error.

Minitest shows the Nothing ran for filter: error and exits with 1 as exit code (error exit code) when test files returned from the Queue API include pending tests or an empty test file with no test cases.

I use the knapsack_pro gem 6.0.4.

I prepared PRs to reproduce the problem for our team:

The output:

➜  rails-app-with-knapsack_pro git:(debug-minitest-5.22.0) bin/knapsack_pro_queue_minitest
==================================================
Tests (mocked API response):
["test/minitest_spec_rails/shared_examples_test.rb"]
==================================================
D, [2024-02-06T19:06:10.015472 #90231] DEBUG -- : [knapsack_pro] Test suite time execution queue recording enabled.
Run options: --verbose --seed 50180

# Running:

Nothing ran for filter:
----------After Subset Queue Hook - run after subset of test suite----------==================================================
Tests (mocked API response):
["test/controllers/pending_controller_test.rb"]
==================================================
Run options: --verbose --seed 49280

# Running:

Nothing ran for filter:
----------After Subset Queue Hook - run after subset of test suite----------==================================================
Tests (mocked API response):
[]
==================================================
----------After Queue Hook - run after test suite----------W, [2024-02-06T19:06:10.056715 #90231]  WARN -- : [knapsack_pro] 2 test files were executed on this CI node but the recorded time was lost due to:
W, [2024-02-06T19:06:10.056732 #90231]  WARN -- : [knapsack_pro] 1. Please ensure you do not remove the contents of the .knapsack_pro directory between tests run.
W, [2024-02-06T19:06:10.056740 #90231]  WARN -- : [knapsack_pro] 2. Ensure you've added Knapsack::Adapters::RSpecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: https://knapsackpro.com/perma/ruby/installation-guide
W, [2024-02-06T19:06:10.056745 #90231]  WARN -- : [knapsack_pro] 3. Another potential reason for this warning is that all your tests are empty test files, pending tests, or they have syntax errors, and the time execution was not recorded for them.
D, [2024-02-06T19:06:10.143137 #90231] DEBUG -- : [knapsack_pro] POST http://api.knapsackpro.test:3000/v1/build_subsets
D, [2024-02-06T19:06:10.143159 #90231] DEBUG -- : [knapsack_pro] API request UUID: e055db31-5cde-4800-b6f5-1926cddbbcfd
D, [2024-02-06T19:06:10.143168 #90231] DEBUG -- : [knapsack_pro] API response:
D, [2024-02-06T19:06:10.143177 #90231] DEBUG -- : [knapsack_pro]
D, [2024-02-06T19:06:10.143190 #90231] DEBUG -- : [knapsack_pro] Saved time execution report on Knapsack Pro API server.
Coverage report generated for Unit Tests to /Users/artur/Documents/github/knapsack-pro/rails-app-with-knapsack_pro/coverage. 2 / 2 LOC (100.0%) covered.
SimpleCov failed with exit 1%
➜  rails-app-with-knapsack_pro git:(debug-minitest-5.22.0) echo $?
1

Internal story for reference: https://trello.com/c/hJVGPrmE


@davidwessman Could you use the old Minitest version until this is solved? Thanks.

ArturT commented 7 months ago

I reported an issue in Minitest:

ArturT commented 7 months ago

The problem exists also for Knapsack Pro Regular Mode. API returns a pending test then 1 is set as an exit code.

Failing CI build: https://app.circleci.com/pipelines/github/KnapsackPro/knapsack_pro-ruby/1229/workflows/e15db5b4-01b3-4468-a9c4-63a1ca8d05ef/jobs/7496

davidwessman commented 7 months ago

https://github.com/minitest/minitest/compare/v5.22.0...v5.22.1 They seem to have fixed it in 5.22.1!

davidwessman commented 7 months ago

Never mind, now I get no output of Nothing ran for filter:, but still get failure status

ArturT commented 7 months ago

The issue was partially solved. More details here: https://github.com/minitest/minitest/issues/985#issuecomment-1932480740

davidwessman commented 7 months ago

Works with 5.22.2 🚀

ArturT commented 7 months ago

I can confirm that the Minitest 5.22.2 version fixed the issue.