Support pgvector in CI for different pg versions (#5660)

This commit is contained in:
Fantix King 2023-07-15 02:16:08 +09:00 committed by GitHub
parent 865f77b4a6
commit e8a1093245
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 3 deletions

View file

@ -46,7 +46,7 @@ jobs:
remote-compiler: ''
services:
postgres:
image: postgres:${{ matrix.postgres-version }}-alpine
image: fantix/pgvector:${{ matrix.postgres-version }}
env:
POSTGRES_PASSWORD: postgres
options: >-

View file

@ -335,7 +335,7 @@ jobs:
remote-compiler: ''
services:
postgres:
image: postgres:${{ matrix.postgres-version }}-alpine
image: fantix/pgvector:${{ matrix.postgres-version }}
env:
POSTGRES_PASSWORD: postgres
options: >-

View file

@ -640,7 +640,11 @@ class ClusterTestCase(BaseHTTPTestCase):
)
cls.has_create_database = cls.cluster.has_create_database()
cls.has_create_role = cls.cluster.has_create_role()
cls.is_superuser = cls.has_create_database and cls.has_create_role
cls.backend_dsn = os.environ.get('EDGEDB_TEST_BACKEND_DSN')
if getattr(cls, 'BACKEND_SUPERUSER', False):
if not cls.is_superuser:
raise unittest.SkipTest('skipped due to lack of superuser')
@classmethod
async def tearDownSingleDB(cls):
@ -1155,6 +1159,11 @@ class DatabaseTestCase(ClusterTestCase, ConnectedTestCaseMixin):
if cls.INTERNAL_TESTMODE:
script += '\nCONFIGURE SESSION SET __internal_testmode := true;'
if getattr(cls, 'BACKEND_SUPERUSER', False):
is_superuser = getattr(cls, 'is_superuser', True)
if not is_superuser:
raise unittest.SkipTest('skipped due to lack of superuser')
schema = []
# Incude the extensions before adding schemas.
for ext in cls.EXTENSIONS:
@ -1704,7 +1713,11 @@ def get_test_cases_setup(
if not hasattr(case, 'get_setup_script'):
continue
setup_script = case.get_setup_script()
try:
setup_script = case.get_setup_script()
except unittest.SkipTest:
continue
if not setup_script:
continue

View file

@ -924,6 +924,10 @@ class ParallelTextTestRunner:
if not cluster.has_create_database():
return []
if not cluster.has_create_role():
for case in cases:
case.is_superuser = False
stats = await tb.setup_test_cases(
cases,
conn,

View file

@ -57,6 +57,7 @@ class DumpTestCaseMixin:
class TestDumpV4(tb.StableDumpTestCase, DumpTestCaseMixin):
EXTENSIONS = ["pgvector"]
BACKEND_SUPERUSER = True
SCHEMA_DEFAULT = os.path.join(os.path.dirname(__file__), 'schemas',
'dump_v4_default.esdl')

View file

@ -11935,6 +11935,8 @@ class TestEdgeQLDataMigrationNonisolated(EdgeQLDataMigrationTestCase):
async def test_edgeql_migration_extension_01(self):
# Test migrations getting from an array in integers to vector and then
# revert to an array of floats.
if not self.is_superuser:
self.skipTest('the backend is not running with superuser')
await self.migrate('''
module default {

View file

@ -27,6 +27,7 @@ from edb.tools import test
class TestEdgeQLVector(tb.QueryTestCase):
EXTENSIONS = ['pgvector']
BACKEND_SUPERUSER = True
SCHEMA = os.path.join(os.path.dirname(__file__), 'schemas',
'pgvector.esdl')