Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-3110

Add ability to skip tests based on available database options

    XMLWordPrintable

Details

    Description

      Depending on the Oracle database edition deployed, some tests could fail due to certain database options not being enabled or available on those editions of the database. One specific example is "Partitioning" which requires each Oracle Enterprise Edition or to have the partitioning module installed separately.

      For these use cases, it would be useful to introduce a marker annotation called RequireDatabaseOption where the value is the option that's required, e.g. "Partitioning". The supplemental JUnit rule would use TestHelper.testConnection() to run a query against the database and return whether the given option is enabled/available.

      final RequireDatabaseOption option = hasAnnotation(description, RequireDatabaseOption.class);
              if (option != null) {
                  try (OracleConnection connection = TestHelper.testConnection()) {
                      final String value = connection.queryAndMap("SELECT VALUE FROM V$OPTION WHERE PARAMETER = '" + option.value() + "'",
                                                                  (rs) -> {
                                                                      if (rs.next()) {
                                                                          return rs.getString(1);
                                                                      }
                                                                      return null;
                                                                  });
                      if (value == null || value.equalsIgnoreCase("FALSE")) {
                          return emptyStatement("Database option '" + option.value() + "' not available", description);
                      }
                      return base;
                  }
                  catch (SQLException e) {
                      throw new RuntimeException("Failed to resolve database option " + option.value(), e);
                  }
              }
      

      When running tests specifically for Oracle 11 or Oracle 18 (which is only available at XE), this would allow tests to pass by skipping tests that require these options that aren't available in that database edition.

      Attachments

        Activity

          People

            ccranfor@redhat.com Chris Cranford
            ccranfor@redhat.com Chris Cranford
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: