Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Implemented
-
None
Description
ContainerLayoutVersion is used in several classes to parameterize test methods.
Example usage:
@ParameterizedTest @MethodSource("layoutVersion") public void closeContainerWithPipeline(ContainerLayoutVersion layout)
where the source method is defined as:
private static Iterable<Object[]> layoutVersion() { return ContainerLayoutTestInfo.containerLayoutParameters(); }
All usages (found so far):
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerDataYaml.java hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerDeletionChoosingPolicy.java hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerSet.java hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestHddsDispatcher.java hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerCommandHandler.java hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueContainerMarkUnhealthy.java hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandler.java hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/read/TestChunkInputStream.java hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/read/TestKeyInputStream.java
The goal of this task is to reduce code duplication by defining a composite annotation.
Using the custom annotation we can:
- replace repeated @ParameterizedTest and @MethodSource
- delete the local method used as source in the test class (layoutVersion() in the example above)
Please see similar annotation defined for ContainerTestVersionInfo in HDDS-9932:
/** * Composite annotation for tests parameterized with {@link ContainerTestVersionInfo}. */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @ParameterizedTest @MethodSource("org.apache.hadoop.ozone.container.keyvalue.ContainerTestVersionInfo#getLayoutList") public @interface ContainerTest { // composite annotation }
and its usage:
@ContainerTestVersionInfo.ContainerTest public void testCreateContainer(ContainerTestVersionInfo versionInfo) throws Exception {
Attachments
Issue Links
- links to