Configurations of historyTimeToLive not work in testing

The Camunda engine required Enforce History Time To Live from 7.20. However, it seems the feature does not work in testing.

Here is the XML configuration file:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">

                <property name="jdbcUrl" value="jdbc:h2:mem:test" />
                <property name="jdbcDriver" value="org.h2.Driver" />
                <property name="jdbcUsername" value="sa" />
                <property name="jdbcPassword" value="" />

        <!-- job executor configurations -->
        <property name="jobExecutorActivate" value="false" />

        <property name="history" value="full" />
        <property name="historyTimeToLive" value="P365D" />
        <property name="enforceHistoryTimeToLive" value="true"/>

        <property name="processEnginePlugins">
            <list>
                <bean class="org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin" />
                <bean class="org.camunda.spin.plugin.impl.SpinProcessEnginePlugin" />
            </list>
        </property>
    </bean>

</beans>

And I try to deploy using @Deployment annotation and test a BPMN file, the historyTimeToLive configuration of which is null. The test runs as the same correct result as it just in 7.19, and there just shows some warning messages:

10:57:34.533 [main] WARN org.camunda.bpm.engine.cfg -- ENGINE-12016 definitionKey: BusinessKeyProcess; You are using the default TTL (Time To Live) of 180 days (six months); the history clean-up feature will delete your data after six months. We recommend adjusting the TTL configuration property aligned with your specific requirements.

Meanwhile, if testing the same BPMN in Spring Boot container, an error occurs and indicates that the istoryTimeToLive cannot be null:

Caused by: org.camunda.bpm.engine.ParseException: ENGINE-09005 Could not parse BPMN process. Errors: 
* History Time To Live cannot be null: History Time To Live cannot be null

I’m not sure whether it is an expected behaviour in testing, just like some other best practices in testing such as disable job executor.

I finally found the following facts after some studies, and hope it can help the one who is confused by the TTL.

  1. In the current Modeler (ver 5.17.0), every process definition has a default TTL which value is 180 (days). If it is not changed, there will be a wrong message when deploying it:
WARN  org.camunda.bpm.engine.cfg - ENGINE-12016 definitionKey: XXXXXXX; You are using the default TTL (Time To Live) of 180 days (six months); the history clean-up feature will delete your data after six months. We recommend adjusting the TTL configuration property aligned with your specific requirements.
  1. If the TTL value is null, the deployment behaviour is according to the following two configuration properties:
  • historyTimeToLive: If the property is provided, the process definition with null TTL will use the property value as its TTL after deployment.
  • enforceHistoryTimeToLive: If the property is set to be false, the process engine will not check whether the TTL is null or not, and will save TTL as it is even it is null.

Therefore, the historyTimeToLive property has a high priority than the enforceHistoryTimeToLive, which means if the former one is provided the TTL will always have a value that makes it never be null.