Uploaded image for project: 'Apache Ozone'
  1. Apache Ozone
  2. HDDS-9931 Improve unit/integration tests
  3. HDDS-9948

Compose annotation for tests parameterized with ContainerLayoutVersion

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Implemented
    • None
    • 2.0.0
    • test

    Description

      ContainerLayoutVersion is used in several classes to parameterize test methods.

      Example usage:

      where the source method is defined as:

      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:

      Attachments

        Issue Links

          Activity

            People

              wangzhaohui Zhaohui Wang
              adoroszlai Attila Doroszlai
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: