Aurélien Pupier created CAMEL-28090:
---------------------------------------

             Summary: camel-azure-servicebus: use a singleton test-infra service
                 Key: CAMEL-28090
                 URL: https://issues.apache.org/jira/browse/CAMEL-28090
             Project: Camel
          Issue Type: Sub-task
          Components: tests, test-infra
            Reporter: Aurélien Pupier


Sub-task of CAMEL-28075: use a singleton test-infra service in 
{{camel-azure-servicebus}} (rank 15 in the priority order).

h3. Analysis for this module
* Container/service starts today: 3 classes (through 
{{BaseServiceBusTestSupport}})
* Average start time: about 4s ({{floci-az}}), but one local log shows a first 
start that failed after about 2 minutes and was retried
* Estimated saving by sharing one instance: about 8s, more if the failed first 
start is recurrent

h3. What to change
{{BaseServiceBusTestSupport}} calls 
{{AzureServiceBusServiceFactory.createService()}}: use 
{{createSingletonService()}}, which exists in 
{{test-infra/camel-test-infra-azure-servicebus}}. Also have a look at why the 
container startup failed in the local log {{target/camel-servicebus-test.log}} 
(startup timeout of the {{floci-az}} image), because a singleton would make a 
recurrent failure impact the whole module.

h3. Check that a fresh container is not required
Use unique queue/topic/subscription names per test and make sure the messages 
of a test are not consumed by another one.

h3. Stability first
Moving a test class to a singleton service must *not* make the build less 
stable. Before switching a class:
* check that the test does not require a fresh container: it must not stop, 
shut down, pause, restart or reconfigure the service (or its container) and 
must not depend on an empty initial state;
* make the data it creates unique per test (queue/topic/bucket/secret/parameter 
names, consumer groups, ...) so that tests sharing the same instance, in the 
same JVM, do not interfere, including when test classes run concurrently;
* leave tests that really need a fresh instance on {{createService()}} (and 
document why in a comment);
* run the module several times (for example with 
{{-Dcamel.failsafe.forkCount=N}} and, where supported, 
{{-Dcamel.surefire.parallel=true}}) and compare the duration and the failure 
rate with the current ones before opening the PR.

_AI-generated by IBM Bob on behalf of apupier._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to