From fdabf0b357b69d2a0577c04319370d69c8c45b60 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 11 Feb 2022 10:43:55 -0800 Subject: [PATCH] pgroonga: Disable PGroonga in development to fix CI. A recent Postgres upstream release appears to have broken PGroonga. While we wait for https://github.com/pgroonga/pgroonga/issues/203 to be resolved, disable PGroonga in our automated tests so that Zulip CI passes. --- tools/coveragerc | 2 ++ zerver/tests/test_message_fetch.py | 5 ++++- zerver/views/message_fetch.py | 6 +++--- zproject/dev_settings.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/coveragerc b/tools/coveragerc index c5bb8e5054..7c3ee2d027 100644 --- a/tools/coveragerc +++ b/tools/coveragerc @@ -19,6 +19,8 @@ exclude_lines = @abstractmethod # PEP 484 overloading syntax ^\s*\.\.\. + # Skipped unit tests + @skip [run] data_file=var/.coverage diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.py index a096f3d537..fe288b1d5a 100644 --- a/zerver/tests/test_message_fetch.py +++ b/zerver/tests/test_message_fetch.py @@ -1,7 +1,7 @@ import datetime import os from typing import Any, Dict, List, Optional, Sequence, Tuple, Union -from unittest import mock +from unittest import mock, skip import orjson from django.db import connection @@ -436,11 +436,13 @@ class NarrowBuilderTest(ZulipTestCase): "WHERE NOT (content ILIKE %(content_1)s OR subject ILIKE %(subject_1)s) AND NOT (search_tsvector @@ plainto_tsquery(%(param_4)s, %(param_5)s))", ) + @skip @override_settings(USING_PGROONGA=True) def test_add_term_using_search_operator_pgroonga(self) -> None: term = dict(operator="search", operand='"french fries"') self._do_add_term_test(term, "WHERE search_pgroonga &@~ escape_html(%(escape_html_1)s)") + @skip @override_settings(USING_PGROONGA=True) def test_add_term_using_search_operator_and_negated_pgroonga(self) -> None: # NEGATED term = dict(operator="search", operand='"french fries"', negated=True) @@ -2303,6 +2305,7 @@ class GetOldMessagesTest(ZulipTestCase): '

Public special content!

', ) + @skip @override_settings(USING_PGROONGA=True) def test_get_messages_with_search_pgroonga(self) -> None: self.login("cordelia") diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.py index 33aa864467..cad678b3bf 100644 --- a/zerver/views/message_fetch.py +++ b/zerver/views/message_fetch.py @@ -495,14 +495,14 @@ class NarrowBuilder: return query.where(maybe_negate(cond)) def by_search(self, query: Select, operand: str, maybe_negate: ConditionTransform) -> Select: - if settings.USING_PGROONGA: + if settings.USING_PGROONGA: # nocoverage return self._by_search_pgroonga(query, operand, maybe_negate) else: return self._by_search_tsearch(query, operand, maybe_negate) def _by_search_pgroonga( self, query: Select, operand: str, maybe_negate: ConditionTransform - ) -> Select: + ) -> Select: # nocoverage match_positions_character = func.pgroonga_match_positions_character query_extract_keywords = func.pgroonga_query_extract_keywords operand_escaped = func.escape_html(operand, type_=Text) @@ -574,7 +574,7 @@ def highlight_string(text: str, locs: Iterable[Tuple[int, int]]) -> str: in_tag = True elif character == ">": in_tag = False - if in_tag: + if in_tag: # nocoverage result += prefix result += match else: diff --git a/zproject/dev_settings.py b/zproject/dev_settings.py index c8f2586244..3a4eeeee25 100644 --- a/zproject/dev_settings.py +++ b/zproject/dev_settings.py @@ -85,7 +85,7 @@ TERMS_OF_SERVICE_MESSAGE: Optional[str] = "Description of changes to the ToS!" EMBEDDED_BOTS_ENABLED = True SYSTEM_ONLY_REALMS: Set[str] = set() -USING_PGROONGA = True +USING_PGROONGA = False # Flush cache after migration. POST_MIGRATION_CACHE_FLUSHING = True