From 9a708001029ae098f250b334b73020bfc015e9a7 Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Mon, 10 Jun 2024 17:53:20 +0100 Subject: [PATCH] mark slow array tests --- pyproject.toml | 3 +- scripts/test-cockroach.sh | 2 +- tests/columns/test_array.py | 61 +++++++++++++++++++++++++++++++------ 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ec6a0655e..eed50963a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,8 @@ ignore_missing_imports = true [tool.pytest.ini_options] markers = [ "integration", - "speed" + "speed", + "cockroach_array_slow" ] [tool.coverage.run] diff --git a/scripts/test-cockroach.sh b/scripts/test-cockroach.sh index 1c944aeae..9c8d23ca8 100755 --- a/scripts/test-cockroach.sh +++ b/scripts/test-cockroach.sh @@ -10,5 +10,5 @@ python3 -m pytest \ --cov-report=xml \ --cov-report=html \ --cov-fail-under=80 \ - -m "not integration" \ + -m "not integration and not cockroach_array_slow" \ -s $@ diff --git a/tests/columns/test_array.py b/tests/columns/test_array.py index 7da4dadfb..0b96e176c 100644 --- a/tests/columns/test_array.py +++ b/tests/columns/test_array.py @@ -1,6 +1,8 @@ import datetime from unittest import TestCase +import pytest + from piccolo.columns.column_types import ( Array, BigInt, @@ -10,6 +12,7 @@ Timestamp, Timestamptz, ) +from piccolo.querystring import QueryString from piccolo.table import Table from tests.base import engines_only, engines_skip, sqlite_only @@ -40,11 +43,18 @@ def setUp(self): def tearDown(self): MyTable.alter().drop_table().run_sync() + @pytest.mark.cockroach_array_slow def test_storage(self): """ Make sure data can be stored and retrieved. - 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + In CockroachDB <= v22.2.0 we had this error: + + * https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + + In newer CockroachDB versions, it runs but is very slow: + + * https://github.com/piccolo-orm/piccolo/issues/1005 """ # noqa: E501 MyTable(value=[1, 2, 3]).save().run_sync() @@ -54,11 +64,18 @@ def test_storage(self): self.assertEqual(row.value, [1, 2, 3]) @engines_skip("sqlite") + @pytest.mark.cockroach_array_slow def test_index(self): """ Indexes should allow individual array elements to be queried. - 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + In CockroachDB <= v22.2.0 we had this error: + + * https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + + In newer CockroachDB versions, it runs but is very slow: + + * https://github.com/piccolo-orm/piccolo/issues/1005 """ # noqa: E501 MyTable(value=[1, 2, 3]).save().run_sync() @@ -68,65 +85,91 @@ def test_index(self): ) @engines_skip("sqlite") + @pytest.mark.cockroach_array_slow def test_all(self): """ Make sure rows can be retrieved where all items in an array match a given value. - 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + In CockroachDB <= v22.2.0 we had this error: + + * https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + + In newer CockroachDB versions, it runs but is very slow: + + * https://github.com/piccolo-orm/piccolo/issues/1005 """ # noqa: E501 MyTable(value=[1, 1, 1]).save().run_sync() + # We have to explicitly specify the type, so CockroachDB works. self.assertEqual( MyTable.select(MyTable.value) - .where(MyTable.value.all(1)) + .where(MyTable.value.all(QueryString("{}::INTEGER", 1))) .first() .run_sync(), {"value": [1, 1, 1]}, ) + # We have to explicitly specify the type, so CockroachDB works. self.assertEqual( MyTable.select(MyTable.value) - .where(MyTable.value.all(0)) + .where(MyTable.value.all(QueryString("{}::INTEGER", 0))) .first() .run_sync(), None, ) @engines_skip("sqlite") + @pytest.mark.cockroach_array_slow def test_any(self): """ Make sure rows can be retrieved where any items in an array match a given value. - 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + In CockroachDB <= v22.2.0 we had this error: + + * https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + + In newer CockroachDB versions, it runs but is very slow: + + * https://github.com/piccolo-orm/piccolo/issues/1005 """ # noqa: E501 + MyTable(value=[1, 2, 3]).save().run_sync() + # We have to explicitly specify the type, so CockroachDB works. self.assertEqual( MyTable.select(MyTable.value) - .where(MyTable.value.any(1)) + .where(MyTable.value.any(QueryString("{}::INTEGER", 1))) .first() .run_sync(), {"value": [1, 2, 3]}, ) + # We have to explicitly specify the type, so CockroachDB works. self.assertEqual( MyTable.select(MyTable.value) - .where(MyTable.value.any(0)) + .where(MyTable.value.any(QueryString("{}::INTEGER", 0))) .first() .run_sync(), None, ) @engines_skip("sqlite") + @pytest.mark.cockroach_array_slow def test_cat(self): """ Make sure values can be appended to an array. - 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + In CockroachDB <= v22.2.0 we had this error: + + * https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg + + In newer CockroachDB versions, it runs but is very slow: + + * https://github.com/piccolo-orm/piccolo/issues/1005 """ # noqa: E501 MyTable(value=[1, 1, 1]).save().run_sync()