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

ThinkingSphinx::Test.clean raises error Errno::ENOTEMPTY: Directory not empty when deleting indices location #1259

Open
pdany1116 opened this issue Apr 1, 2024 · 1 comment

Comments

@pdany1116
Copy link

Hello, our tests fail randomly at clean up phase for ThinkingSphinx. It seems it can not delete the indices directory (db/sphinx/test).

image

Here is our test setup for ThinkingSphinx in Minitest:
sphinx_helper.rb

# frozen_string_literal: true

module SphinxHelper
  extend ActiveSupport::Concern
  include Minitest::Hooks

  included do
    after(:all) do
      ThinkingSphinx::Test.stop
    end

    setup do
      S3Stub.stub_all
      ThinkingSphinx::Test.start_with_autostop
    end

    teardown do
      ThinkingSphinx::Test.clear
    end

    around do |&block|
      DatabaseCleaner.strategy = DatabaseCleaner::ActiveRecord::Deletion.new(
        except: %w[roles]
      )
      DatabaseCleaner.cleaning(&block)
    end
  end

  def index_sphinx(indices = nil)
    indices ? ThinkingSphinx::Test.index(indices) : ThinkingSphinx::Test.index

    sleep 0.01 until SphinxHelper.index_finished?
  end

  def self.index_finished?
    Dir[Rails.root.join(ThinkingSphinx::Test.config.indices_location, '*.{new,tmp}*')].empty?
  end
end

test_helper.rb

# ...
ThinkingSphinx::Test.init
ThinkingSphinx::Test.config
# ...

In test we just include SphinxHelper module and use index_sphinx method after creating the test data with Faker.


Is it safe to remove manually the indices directory? For example:

    # ...
    teardown do
      FileUtils.rm_rf('db/sphinx/test')
      ThinkingSphinx::Test.clear
    end
    # ...

Gems:
Ruby 3.0.6
Rails 7.0.8.1
ThinkingSphinx 5.5.1

@pat
Copy link
Owner

pat commented Jul 7, 2024

A very belated response, but: I've just released v5.6.0 which uses rm_rf instead of just rm_r. Hopefully this resolves the issue for you! Do let me know if that's not the case though.

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

2 participants