Description
Is your feature request related to a problem? Please describe.
During testing it may be necessary to disable the idempotency feature. Currently this can be achieved by setting the POWERTOOLS_IDEMPOTENCY_DISABLED
ENV variable to true
. The documentation suggests to either use the JUnit-Pioneer library to manipuplate the ENV variable during test or set the variable for all tests in the Maven or Gradle build.
However, when using Java 17+ it's no longer possible to use JUnit-Pioneer to set the ENV variable. The documentation of JUnit-Pioneer states:
The best way to prevent these warnings/errors, is to change the code under test, so this extension is no longer needed.
This only leaves the option to disable idempotency during build when using Maven or Gradle. However, when running test without a build tool (e.g. using IntelliJ) you have to manually configure ENV for each test you run. This also couples the test execution to the environment it's running in (Gradle, IDE etc.). In my opinion the test can no longer be 'self-containt'.
Describe the solution you'd like
Independent of the technical solution the documentation should be updated to reflect the fact, that JUnit-Pioneer cannot be used for Java 17+.
To actually disable the idempotency feature there should be another mechanism that does not rely on an ENV variable. I'm not sure what would best fit the best-practices of this library. I could imagine a Java system-property or a method in the software.amazon.lambda.powertools.idempotency.Idempotency
class.
Another alternative could be to extend the software.amazon.lambda.powertools.idempotency.Idempotency.Config
class to disable idempotency.
I would still keep the option to use an ENV variable for test scenarios outside a unit test.
Describe alternatives you've considered
As described above the only alternative I can see is to disable idempotency in the build tool/environment.
Additional context
./.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status