feat(simulator): add SQL execution support with MySQL and PostgreSQL#375
feat(simulator): add SQL execution support with MySQL and PostgreSQL#375chhil wants to merge 2 commits into
Conversation
Implements optional pre/post-SQL execution in test cases with configurable error handling. Changes: - Add preSQL and postSQL fields to TestCase with getters/setters - Add continueOnSqlError option to control SQL failure behavior (default: continue) - Add SQLFailureException for strict SQL error handling - Add executeSQL() method to TestRunner using Hibernate Work interface - Parse pre-sql/post-sql XML elements in test suite configuration - Support continue-on-sql-error attribute on test elements - Execute SQL before request (preSQL) and after response (postSQL) - Support semicolon-separated multiple SQL statements - Log SELECT results and affected row counts - Add MySQL test support via Testcontainers (db-mysql, testcontainers.mysql) - Add commons-codec runtime dependency for testcontainers tar operations Documentation: - Complete SQL execution support documentation with examples - Execution order: init, pre-sql, request/response, post, post-sql - When to use SQL execution (balance setup, limits, state reset) - Database configuration and db.properties examples - init script scoping with suite-level and test-level differences - Database dependencies (PostgreSQL, MySQL, H2) for Gradle - Supported databases with behavioral differences Tests: - 36 tests covering SQL functionality, backward compatibility, and error handling - Tests run against both PostgreSQL (default) and MySQL via property test.clientsim_db_driver - Driver-aware DDL syntax ensures cross-database compatibility Fixes: - doc/build.gradle and doc/buildSrc/build.gradle - Java compatibility fixes for Gradle 9.x
|
Thanks for this contribution. SQL setup/cleanup around Client Simulator tests is a very useful addition and will come in handy for stateful simulator scenarios, especially balance setup, limits, and deterministic cleanup between cases. I think this needs a small rework before merge:
Verification I ran:
|
Fix a bug in fire-and-forget path where SQL failure result code was overwritten by unconditional OK. Tighten SQL error breaks in runSuite to always exit the repetition loop when continue-on-sql-error=no. Clean up Javadoc across SQLFailureException, TestCase, and TestRunner: remove orphaned </p> tags, align asterisks, normalize indentation, and update preSQL→pre-SQL in lifecycle docs. Add TestRunnerSQLIntegrationTest covering SQL XML parsing, strict vs lenient error modes, multi-statement execution, and table cleanup.
Implements optional pre/post-SQL execution in test cases with configurable error handling.
Summary
preSQLandpostSQLfields toTestCasewith getters/setterscontinueOnSqlErroroption to control SQL failure behavior (default: continue)SQLFailureExceptionfor strict SQL error handlingexecuteSQL()method toTestRunnerusing Hibernate Work interfacepre-sql/post-sqlXML elements in test suite configurationcontinue-on-sql-errorattribute on test elementspreSQL) and after response (postSQL)Documentation
init,pre-sql, request/response,post,post-sqldb.propertiesexamplesinitscript scoping with suite-level and test-level differencesTests
test.clientsim_db_driverBehavior
continue-on-sql-error="no"to fail test on SQL errorAssisted-by
Qwen36