Skip to content

Conversation

@Pahari47
Copy link

@Pahari47 Pahari47 commented Jan 7, 2026

Closes #11651

Implements integration test infrastructure for Solr as requested. This allows running tests against a real Solr Docker container to verify search behavior like rankings, sort orderings, and other Solr configuration.

Technical

Files Created:
openlibrary/tests/solr/integration/__init__.py - Package initialization [empty as all structure]
openlibrary/tests/solr/integration/conftest.py - Pytest fixtures for Solr container management

  1. Session-scoped solr_container fixture that starts a fresh Solr 9.9.0 Docker container
  2. Uses port 8984 to avoid conflicts with main Solr
  3. Automatic cleanup of containers after tests
  4. Uses the project's existing Solr config

openlibrary/tests/solr/integration/helpers.py - Utility functions for tests

  1. create_test_author() - Creates test author dicts
  2. insert_authors_to_solr() - Inserts authors into Solr using AuthorSolrBuilder
  3. cleanup_authors_from_solr() - Removes test data from Solr
  4. wait_for_solr_commit() - Waits for Solr commits to complete

openlibrary/tests/solr/integration/test_author_search.py - First test case
test_author_search_sort_by_name - Currently skipped test that documents the incorrect behavior of the sort=name option

Key Implementation Details:

  1. Uses Docker directly via subprocess (no additional dependencies)
  2. Container starts with same Solr config as compose.yaml
  3. Tests can insert deterministic test data and verify search results
  4. Designed for future expansion with more test cases

Testing

you can run all test. also can run specific integration test

pytest openlibrary/tests/solr/integration/ -v

Expected output: 1 skipped (the author search test is intentionally skipped)

Note:

The test_author_search_sort_by_name test is intentionally skipped with @pytest.mark.skip. It documents the current incorrect behavior of the name sort option. Once the underlying issue is fixed, the skip can be removed and the test should pass.

Stakeholders

@cdrini

@github-actions github-actions bot added the Priority: 2 Important, as time permits. [managed] label Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 2 Important, as time permits. [managed]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create integration tests for solr

2 participants