Getting ThinkingSphinx to run in RSpec

I’m working on setting up CircleCI for a Rails 5.1 / Ruby 2.3.1 application. We are looking to use Circle primarily to run our specs.

This application uses ThinkingSphinx for search, and we have some specs that rely on search to pass. ThinkingSphinx is configured for RSpec using the guide in their docs:

https://freelancing-gods.com/thinking-sphinx/v4/testing.html

We’re using SQL-backed indices.

The first spec that uses sphinx passes on Circle, but all subsequent specs fail. Outside of Circle, everything passes.

Does anyone have advice about how to get Sphinx-related specs to run on CircleCI?

Rspec version - 3.8.2
Thinking Sphinx version - 3.2.0

In my config.yml file, I download sphinx:

      - run:
          name: Install sphinx dependencies
          command: sudo apt-get install sphinxsearch

And later on, run my specs using:

      - run:
          name: run tests
          command: |
            mkdir /tmp/test-results
            TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

            bundle exec rspec --format progress $TEST_FILES

As an update, I discovered the error I’m getting with Thinking Sphinx is:

ERROR: index 'refinery_products_product_core': sql_fetch_row: Out of sort memory, consider increasing server sort buffer size.

One suggestion from the Thinking Sphinx maintainer was to adjust the settings in the /etc/mysql/my.cnf file, but I’m not sure how to access or update that file in the CircleCI realm.

You should be able to edit the file /etc/mysql/my.cnf using sed or similar in situ. Or maybe there is a separate config file for Sphinx (the one you have indicated appears to be for MySQL).

The other thing to try is to switch to the Machine executor, instead of the Docker executor. That does not allow the use of Docker secondary servers, but you get a VM with 8G instead of a container with 4G. I prefer Docker, but sometimes switching to a VM can be a useful quick fix.