CPT 8.9 Ensuring Test Data is Cleaned Up

Hi, I’ve been creating automated process using CPT for Camunda 8.9 with so far next to no issues but now am having some. For context of the local setup is:

  • Local c8run (8.9.1) when running the tests locally
  • Real workers and stubbing the services rather than mocking the job workers entirely

I’m now noticing that tests in two of my test files are seemingly randomly failing

  • I thought potentially it may be some race conditions / async behaviour that causes them to sometimes pass and sometimes fail (which may still be the case)

  • But from some of the common failures and logs it seems like a lot of the issues may stem from test data not being deleted properly between tests e.g., a mocked service in one test returning the result that would apply in another test

  • 2026-05-28T11:56:49.210+01:00  WARN 23436 --- [challenges-service] [           main] .t.a.CamundaProcessTestExecutionListener : Failed to delete the runtime data, skipping. Check the runtime for details. Note that a dirty runtime may cause failures in other test cases.
    
  • This is usually accompanied by:

  • java.lang.RuntimeException: Request failed. [code: 409, message: {"message":"Cannot apply configuration change. Another configuration change [ClusterConfiguration[version=2344, members={0=MemberState[version=4687, lastUpdated=2026-05-28T10:56:48.920052300Z, state=ACTIVE, partitions={1=PartitionState[state=BOOTSTRAPPING, priority=1, config=DynamicPartitionConfig[exporting=ExportingConfig[state=EXPORTING, exporters={rdbms=ExporterState[metadataVersion=0, state=ENABLED, initializedFrom=Optional.empty]}]]]}]}, lastChange=Optional[CompletedChange[id=2342, status=COMPLETED, startedAt=2026-05-28T10:56:45.596377600Z, completedAt=2026-05-28T10:56:46.565395400Z]], pendingChanges=Optional[ClusterChangePlan[id=2344, version=4, status=IN_PROGRESS, startedAt=2026-05-28T10:56:48.791721600Z, completedOperations=[CompletedOperation[operation=PartitionLeaveOperation[memberId=0, partitionId=1, minimumAllowedReplicas=0], completedAt=2026-05-28T10:56:48.905350100Z], CompletedOperation[operation=DeleteHistoryOperation[memberId=0], completedAt=2026-05-28T10:56:48.913147200Z], CompletedOperation[operation=UpdateIncarnationNumberOperation[memberId=0], completedAt=2026-05-28T10:56:48.916651700Z]], pendingOperations=[PartitionBootstrapOperation[memberId=0, partitionId=1, priority=1, config=Optional[DynamicPartitionConfig[exporting=ExportingConfig[state=EXPORTING, exporters={rdbms=ExporterState[metadataVersion=0, state=ENABLED, initializedFrom=Optional.empty]}]]], initializeFromSnapshot=false]]]], routingState=Optional[RoutingState[version=1, requestHandling=AllPartitions[partitionCount=1], messageCorrelation=HashMod[partitionCount=1]]], clusterId=Optional[70f54761-1645-45d4-a271-2b3e162be349], incarnationNumber=1172]] is in progress."}]
    

My questions are:

  • Is there a way to ensure the cleanup retries the data cleanup until successful? I.e., that the cleanup isn’t skipped just because it failed - I’m unsure why this would be an option (or at least the default option) considering the likelihood of cascading test failures due to failed cleanup
  • Is there a checklist of test aspects to ensure (as much as possible) that the data cleanup will be successful?
    • E.g., ensuring the test is not ending on a job, ensuring process instance is completed / cancelled, etc.
    • E.g., some other config unrelated to process instance state?
  • Is this potentially just a limitation of local c8run and isn’t a realistic problem when considering automated testing as part of CI/CD?

The cleanup failures you’re experiencing are likely related to the management API port (9600) not being properly accessible or configuration changes being in progress during cleanup. I found the following relevant resources:

Does this help? If not, can anyone from the community jump in? :waving_hand:


:light_bulb: Hints: Use the Ask AI feature in Camunda’s documentation to chat with AI and get fast help. Report bugs and features in Camuda’s GitHub issue tracker. Trust the process. :robot:

  • I’ve read the lifecycle documentation before - it seems to suggest that the state of the process at the end of the test doesn’t matter (e.g., on a timer, on a service task) and won’t affect cleanup
  • I’m using the default c8run setup with the controlled clock enabled
  • Outside of some over asserting I think I’m generally following the best practices
  • I’m not mocking the job workers, just stubbing the service, to ensure the inputs are correct
  • The last link only mentions that cleanup isn’t handled in SaaS, which I’m not using - the c8run instance is set as self-managed

To give further context, it seems even when all my tests pass, the data cleanup sometimes fails to occur, so the failures may not be related to data clean up after all (or at least not all of the issues).

The failures may be more related to the tests themselves and any async interactions

@markm thank you for raising this issue and sharing all the details. :+1:

I’m not aware of a data deletion issue with a local C8 Run. This is not expected. We should analyze the behavior. Please create an issue.

We should analyze whether the issue is independent of the data deletion. Can you create an issue and share some code to reproduce the behavior?

Things to try out:

  • Using the default Testcontainer runtime instead of the local C8 Run
  • Switch from REST to gRPC for the Camunda client in the config