diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 69068809..f2349633 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ env: jobs: test: - name: Python ${{ matrix.python-version }} - ${{ matrix.connection }} [redis-stack ${{matrix.redis-stack-version}}] + name: Python ${{ matrix.python-version }} - ${{ matrix.connection }} [redis ${{ matrix.redis-version }}] runs-on: ubuntu-latest strategy: @@ -26,13 +26,7 @@ jobs: matrix: python-version: [3.9, '3.10', 3.11, 3.12, 3.13] connection: ['hiredis', 'plain'] - redis-stack-version: ['6.2.6-v9', 'latest', 'edge'] - - services: - redis: - image: redis/redis-stack-server:${{matrix.redis-stack-version}} - ports: - - 6379:6379 + redis-version: ['6.2.6-v9', 'latest', '8.0-M03'] steps: - name: Check out repository @@ -58,9 +52,13 @@ jobs: run: | poetry add hiredis - - name: Set Redis version + - name: Set Redis image name run: | - echo "REDIS_VERSION=${{ matrix.redis-stack-version }}" >> $GITHUB_ENV + if [[ "${{ matrix.redis-version }}" == "8.0-M03" ]]; then + echo "REDIS_IMAGE=redis:${{ matrix.redis-version }}" >> $GITHUB_ENV + else + echo "REDIS_IMAGE=redis/redis-stack-server:${{ matrix.redis-version }}" >> $GITHUB_ENV + fi - name: Authenticate to Google Cloud uses: google-github-actions/auth@v1 @@ -68,7 +66,7 @@ jobs: credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} - name: Run tests - if: matrix.connection == 'plain' && matrix.redis-stack-version == 'latest' + if: matrix.connection == 'plain' && matrix.redis-version == 'latest' env: OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} GCP_LOCATION: ${{ secrets.GCP_LOCATION }} @@ -86,12 +84,12 @@ jobs: make test-all - name: Run tests - if: matrix.connection != 'plain' || matrix.redis-stack-version != 'latest' + if: matrix.connection != 'plain' || matrix.redis-version != 'latest' run: | make test - name: Run notebooks - if: matrix.connection == 'plain' && matrix.redis-stack-version == 'latest' + if: matrix.connection == 'plain' && matrix.redis-version == 'latest' env: OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} GCP_LOCATION: ${{ secrets.GCP_LOCATION }} @@ -106,6 +104,7 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | + docker run -d --name redis -p 6379:6379 redis/redis-stack-server:latest make test-notebooks docs: diff --git a/tests/conftest.py b/tests/conftest.py index de41b4b2..9ed97bd5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -25,7 +25,7 @@ def redis_container(request): # Set the Compose project name so containers do not clash across workers os.environ["COMPOSE_PROJECT_NAME"] = f"redis_test_{worker_id}" - os.environ.setdefault("REDIS_VERSION", "edge") + os.environ.setdefault("REDIS_IMAGE", "redis/redis-stack-server:latest") compose = DockerCompose( context="tests", diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index e8648df8..1441e30e 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.9" services: redis: - image: "redis/redis-stack:${REDIS_VERSION}" + image: "${REDIS_IMAGE}" ports: - "6379" environment: diff --git a/tests/integration/test_llmcache.py b/tests/integration/test_llmcache.py index 6c045b2b..380a00b8 100644 --- a/tests/integration/test_llmcache.py +++ b/tests/integration/test_llmcache.py @@ -770,7 +770,7 @@ def test_complex_filters(cache_with_filters): assert len(results) == 1 -def test_index_updating(redis_url): +def test_cache_index_overwrite(redis_url): cache_no_tags = SemanticCache( name="test_cache", redis_url=redis_url, @@ -785,15 +785,22 @@ def test_index_updating(redis_url): # filterable_fields not defined in schema, so no tags will match tag_filter = Tag("some_tag") == "abc" - response = cache_no_tags.check( - prompt="this prompt has a tag", - filter_expression=tag_filter, - ) + try: + response = cache_no_tags.check( + prompt="this prompt has a tag", + filter_expression=tag_filter, + ) + except Exception as e: + # This will fail in Redis 8+ on query dialect 2 + if "Unknown field" in str(e): + response = [] + else: + raise + assert response == [] with pytest.raises((RedisModuleVersionError, ValueError)): - - cache_with_tags = SemanticCache( + SemanticCache( name="test_cache", redis_url=redis_url, filterable_fields=[{"name": "some_tag", "type": "tag"}],