Skip to content

Commit fcb6092

Browse files
author
redyyang
committed
fix(admin): check shared opengauss initialization seeds.
1 parent 3f88df5 commit fcb6092

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎.github/scripts/check-agent-gateway-migrations.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def check(root):
7676
"""Verify all supported upgrade dialects, regardless of working directory."""
7777
for dialect in DIALECTS:
7878
filename = "create-table.sql" if dialect in ("og", "pg") else "schema.sql"
79-
schema = root / "db" / "init" / dialect / filename
79+
schema_dialect = "pg" if dialect == "og" else dialect
80+
schema = root / "db" / "init" / schema_dialect / filename
8081
migration = root / "db" / "upgrade" / f"2.7.1-upgrade-2.7.2-{dialect}.sql"
8182
try:
8283
count = check_pair(schema.read_text(encoding="utf-8"), migration.read_text(encoding="utf-8"))

‎.github/scripts/test-agent-gateway-migrations.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import importlib.util
1919
from pathlib import Path
2020
import sys
21+
import tempfile
2122
import unittest
23+
from unittest.mock import patch
2224

2325
sys.dont_write_bytecode = True
2426

@@ -37,6 +39,22 @@ def setUp(self):
3739
def test_all_dialects_match(self):
3840
CHECK.check(ROOT)
3941

42+
def test_opengauss_uses_shared_schema_and_its_own_upgrade(self):
43+
with tempfile.TemporaryDirectory() as directory:
44+
root = Path(directory)
45+
schema = root / "db/init/pg/create-table.sql"
46+
migration = root / "db/upgrade/2.7.1-upgrade-2.7.2-og.sql"
47+
schema.parent.mkdir(parents=True)
48+
migration.parent.mkdir(parents=True)
49+
schema.write_text((ROOT / "db/init/pg/create-table.sql").read_text(encoding="utf-8"), encoding="utf-8")
50+
released_upgrade = (ROOT / "db/upgrade/2.7.1-upgrade-2.7.2-og.sql").read_text(encoding="utf-8")
51+
migration.write_text(released_upgrade, encoding="utf-8")
52+
with patch.object(CHECK, "DIALECTS", ("og",)):
53+
CHECK.check(root)
54+
migration.write_text(released_upgrade.replace("plugin:agentGatewayRule:delete", "plugin:agentGatewayRule:edit"), encoding="utf-8")
55+
with self.assertRaisesRegex(ValueError, "og: fresh-install/upgrade mismatch"):
56+
CHECK.check(root)
57+
4058
def test_missing_each_required_record_is_detected(self):
4159
for table, ids in CHECK.EXPECTED.items():
4260
for row_id in ids:

0 commit comments

Comments
 (0)