Skip to content

Commit

Permalink
mark slow array tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Jun 10, 2024
1 parent 9279a81 commit 9a70800
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 11 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ ignore_missing_imports = true
[tool.pytest.ini_options]
markers = [
"integration",
"speed"
"speed",
"cockroach_array_slow"
]

[tool.coverage.run]
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-cockroach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
61 changes: 52 additions & 9 deletions tests/columns/test_array.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import datetime
from unittest import TestCase

import pytest

from piccolo.columns.column_types import (
Array,
BigInt,
Expand All @@ -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

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 9a70800

Please sign in to comment.