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

Support rails parallel testing #902

Open
quorak opened this issue Oct 21, 2023 · 1 comment
Open

Support rails parallel testing #902

quorak opened this issue Oct 21, 2023 · 1 comment

Comments

@quorak
Copy link

quorak commented Oct 21, 2023

Make index_name thread save to support parallel-test feature from rails

It looks like setting the index_name per test can lead to cross pollination of the index_name, leading to situation where
the index changes during test, because another elasticsearch test just started.

  • Are we sure, current implementation even can (and want) support highly concurrent test scenarios with different indexes?
  • Can you thin of another way of speedin gup tests?

I checked #342 but don't think naming will solve everything

@quorak
Copy link
Author

quorak commented Jun 14, 2024

I got it quite stable by using this approach:

    parallelize_setup do |worker|
      Chewy.settings[:prefix] = "chewy-test-parallel-#{worker}"
      SearchIndex.purge!
    end
    
    teardown do
      # Loop until the document count is zero
      loop do
        SearchIndex.purge
        sleep 1 # Sleep for 1 second before checking again
        document_count = SearchIndex.client.count(index: SearchIndex.index_name)['count']
        puts "Waiting for deletion... Current document count: #{document_count}"
        break if document_count == 0
      rescue Elasticsearch::Transport::Transport::Errors::ServiceUnavailable
        puts 'Waiting for sever available'
        sleep 3
      end
    end

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

No branches or pull requests

1 participant