feat(M09-D1): 完成商品目录与库存流水底座

This commit is contained in:
Codex
2026-08-11 03:51:18 +08:00
parent 2de796143f
commit 93af128002
37 changed files with 14683 additions and 58 deletions
+17 -3
View File
@@ -37,6 +37,8 @@ database="qipai_m01c_test_${run_id}"
username="qmb_$$_$(openssl rand -hex 4)"
password="$(openssl rand -hex 24)"
created=0
trust_function_creators_before="$(mysql --batch --skip-column-names -e 'SELECT @@GLOBAL.log_bin_trust_function_creators')"
trust_function_creators_changed=0
cleanup() {
if [[ "${created}" == "1" ]]; then
@@ -45,6 +47,11 @@ DROP DATABASE IF EXISTS \`${database}\`;
DROP USER IF EXISTS '${username}'@'127.0.0.1';
SQL
fi
if [[ "${trust_function_creators_changed}" == "1" ]]; then
mysql --batch --skip-column-names \
-e "SET GLOBAL log_bin_trust_function_creators = ${trust_function_creators_before}" >/dev/null
trust_function_creators_changed=0
fi
}
trap cleanup EXIT INT TERM
@@ -55,6 +62,11 @@ CREATE DATABASE \`${database}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
CREATE USER '${username}'@'127.0.0.1' IDENTIFIED BY '${password}';
GRANT ALL PRIVILEGES ON \`${database}\`.* TO '${username}'@'127.0.0.1';
SQL
if [[ "${trust_function_creators_before}" != "1" ]]; then
mysql --batch --skip-column-names \
-e 'SET GLOBAL log_bin_trust_function_creators = 1' >/dev/null
trust_function_creators_changed=1
fi
}
if [[ "${1:-}" == "--force-failure" ]]; then
@@ -65,6 +77,7 @@ fi
if [[ "${1:-}" == "--cleanup-probe" ]]; then
before_database_count="$(mysql --batch --skip-column-names -e "SELECT COUNT(*) FROM information_schema.SCHEMATA WHERE SCHEMA_NAME LIKE 'qipai_m01c_test_%'")"
before_user_count="$(mysql --batch --skip-column-names -e "SELECT COUNT(*) FROM mysql.user WHERE User LIKE 'qmb_%' AND Host = '127.0.0.1'")"
before_trust_function_creators="$(mysql --batch --skip-column-names -e 'SELECT @@GLOBAL.log_bin_trust_function_creators')"
set +e
bash "${BASH_SOURCE[0]}" --force-failure
probe_status=$?
@@ -75,7 +88,8 @@ if [[ "${1:-}" == "--cleanup-probe" ]]; then
}
after_database_count="$(mysql --batch --skip-column-names -e "SELECT COUNT(*) FROM information_schema.SCHEMATA WHERE SCHEMA_NAME LIKE 'qipai_m01c_test_%'")"
after_user_count="$(mysql --batch --skip-column-names -e "SELECT COUNT(*) FROM mysql.user WHERE User LIKE 'qmb_%' AND Host = '127.0.0.1'")"
if [[ "${before_database_count}" != "${after_database_count}" || "${before_user_count}" != "${after_user_count}" ]]; then
after_trust_function_creators="$(mysql --batch --skip-column-names -e 'SELECT @@GLOBAL.log_bin_trust_function_creators')"
if [[ "${before_database_count}" != "${after_database_count}" || "${before_user_count}" != "${after_user_count}" || "${before_trust_function_creators}" != "${after_trust_function_creators}" ]]; then
echo "FAIL: temporary MySQL resources survived an interrupted test." >&2
exit 1
fi
@@ -93,6 +107,6 @@ export QIPAI_MYSQL_USER="${username}"
export QIPAI_MYSQL_PASSWORD="${password}"
export QIPAI_MYSQL_CONNECTION_LIMIT=2
echo "INFO: MySQL ${mysql_version}; running M01-B through M09-C integration roundtrip in a temporary database."
echo "INFO: MySQL ${mysql_version}; running M01-B through M09-D1 integration roundtrip in a temporary database."
npm --prefix backend run test:mysql:migration
echo "PASS: M01-B through M09-C live MySQL integration roundtrip completed."
echo "PASS: M01-B through M09-D1 live MySQL integration roundtrip completed."