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

             Summary: camel-zookeeper: use a singleton test-infra service
                 Key: CAMEL-28078
                 URL: https://issues.apache.org/jira/browse/CAMEL-28078
             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-zookeeper}} (rank 3 in the priority order).

h3. Analysis for this module
* Container/service starts today: 13 classes ({{ZooKeeperITSupport}} has 12 
subclasses + {{ZooKeeperClusterViewLeadershipLostIT}})
* Average start time: about 4s (14.5s once for {{zookeeper:latest}})
* Estimated saving by sharing one instance: about 50s

h3. What to change
In {{ZooKeeperITSupport}} replace {{ZooKeeperServiceFactory.createService()}} 
by {{createSingletonService()}} (exists in 
{{test-infra/camel-test-infra-zookeeper}}).

h3. Check that a fresh container is not required
{{ZooKeeperClusterViewLeadershipLostIT}} pauses/unpauses the container through 
the Docker client: it *requires a fresh container* and must keep its own 
{{createService()}} (its container would be frozen for every other test of the 
JVM otherwise). Cluster/leader election tests 
({{ZooKeeperClusterServiceRestartTest}} and the cluster ITs) depend on the 
znodes of the previous tests: use unique base paths/namespaces per test. Note 
that one local log uses the image {{zookeeper:latest}} while the others use 
{{mirror.gcr.io/zookeeper:3.9.5}}: check that only the pinned image is used.

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