Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket
W-16941297
Description
Attempting to add a test piggybacking on existing SG timeout test and a flow demonstrating use of
mule-integration-tests/integration/src/test/resources/lazy-routes.xml
Lines 16 to 24 in b0be565
Alternatives considered
Derby Database
Tried using the existing derby database config, and use derby db in embedded mode. However, the derby db doesn't have a SLEEP equivalent function.
There's a potential solution where a Java method that invokes Thread.sleep() could be registered as a UDF (User Defined Function) but that requires a restart and also the classpath property modification. After a successful registration, there is a way to run the sql from java code as below:
where org.example.derby.SleepExample.sleep is the java method that calls Thread.sleep.
Although in theory it looks very procedural but it may not work for the integration tests because there's seems to be a restart step for an embedded db that runs during the lifetime of the tests. After numerous tries, it felt very uneasy to go down this route.
H2 Database
Having H2 database for a test requires adding dependency in the pom for example:
Using the Embedded H2 Database
DB Config in the mule flow
Make sure to configure the flow with the following db config
H2_Database_Config
and use it in thedb:select
DB Alias for SLEEP
This is needed because like Derby DB, the H2 DB also doesn't have an inbuilt SLEEP function.
Followed by the
flowRunner
invocation of the test flow that's reproduces the scenarioAn oversimplified version.
Verification step
TBD - working on this, a rough idea is to use an
error-handler
in the flow and then execute sqlThis is somewhat equivalent to running this in mysql