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

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

h3. Analysis for this module
* Container/service starts today: 6
* Average start time: 3.6s
* Estimated saving by sharing one instance: about 18s

h3. What to change
Replace {{AWSServiceFactory.createIAMService()}} by a singleton. 
{{AWSServiceFactory}} has no {{createSingletonIAMService()}} yet: add it in 
{{test-infra/camel-test-infra-aws-v2}} next to the existing singletons (S3, 
SQS, DynamoDB, EventBridge, Kinesis, Transcribe), following the pattern of 
{{RedisServiceFactory}}/{{SingletonService}}. The service is the {{floci}} 
emulator container.

h3. Check that a fresh container is not required
Tests of AWS emulator services share the account/region state: use unique names 
for the resources they create (user, group and role names; tests that list 
users/groups must not expect an exact count) and check that no test assumes the 
service is empty.

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