Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor queue rspec runner #56

Merged
merged 14 commits into from
Feb 23, 2024
Merged

Refactor queue rspec runner #56

merged 14 commits into from
Feb 23, 2024

Conversation

ArturT
Copy link
Member

@ArturT ArturT commented Jan 19, 2024

story

https://trello.com/c/BcBhX2MW

related

How to mock the Queue API responses in the knapsack_pro gem

You can add the following code to the source code of the Knapsack Pro gem to mock the Queue API responses.
KnapsackPro/knapsack_pro-ruby@348f563

# lib/knapsack_pro/queue_allocator.rb

    def test_file_paths(can_initialize_queue, executed_test_files)
      if ENV['MOCK_QUEUE_API_RESPONSE'] == 'true'
        @@index ||= 0
        batches = [
          ['spec/features/calculator_spec.rb[1:2:1]', 'spec/controllers/articles_controller_spec.rb'],
          ['spec/collection_spec.rb'],
          ['spec/features/calculator_spec.rb[1:1:1]'],
          ['spec/bar_spec.rb'],
          [], # the last Queue API response is always an empty list of test files
        ]

        # example of an empty batch for a late CI node
        #batches = [
          #[]
        #]
        tests = batches[@@index] || []
        @@index += 1
        puts '='*50
        puts 'Tests (mocked API response):'
        puts tests.inspect
        puts '='*50
        return tests
      end

      return [] if @fallback_activated
...

@ArturT ArturT added the WIP Work in progress label Jan 19, 2024
@@ -27,6 +27,13 @@ BRANCH_NAME=fake-branch
#export KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true
#export KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN="spec/**{,/*/**}/*_spec.rb"

# In order to mock the Queue API responses, you need to change source code of the knapsack_pro gem:
Copy link
Member Author

Choose a reason for hiding this comment

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

The purpose of this file was to help developer (me) to play with the knapsack_pro gem and a Rails app at the same time, so that I could see what will happen on the output, I could use a debugger etc.

We have isolated integration tests in PR KnapsackPro/knapsack_pro-ruby#237
The isolated integration tests are already covering all edge cases (except real API calls).

This bin script is in bin/edge_cases directory. It is not executed as part of bin/knapsack_pro_all bin script (see).

@ArturT ArturT removed the WIP Work in progress label Feb 5, 2024
@ArturT ArturT requested a review from 3v0k4 February 5, 2024 22:29
Copy link
Contributor

@3v0k4 3v0k4 left a comment

Choose a reason for hiding this comment

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

I don't have much to say about this, but I hope that going forward we'll wipe this repo 🙂

spec/support/config/rspec_retry.rb Outdated Show resolved Hide resolved
@ArturT
Copy link
Member Author

ArturT commented Feb 8, 2024

I don't have much to say about this, but I hope that going forward we'll wipe this repo 🙂

We are moving in this direction but I think we still need it so that we could easily test a Rails app + Knapsack Pro integration on various CI providers.

ArturT and others added 2 commits February 8, 2024 13:29
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
@ArturT ArturT merged commit 8f95bc3 into master Feb 23, 2024
7 checks passed
@ArturT ArturT deleted the refactor-queue-rspec-runner branch February 23, 2024 11:54
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