Skip to content

Improve test database path isolation in ClpMetadataDbSetUp to avoid conflicts #25333

@coderabbitai

Description

@coderabbitai

Description

The ClpMetadataDbSetUp test utility class currently uses hardcoded paths under /tmp/%s for test databases, which can potentially cause conflicts with local files or concurrent test runs.

Problem

In presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpMetadataDbSetUp.java, the database path is constructed as:

public static final String metadataDbUrlTemplate = 
        "jdbc:h2:file:/tmp/%s;MODE=MySQL;DATABASE_TO_UPPER=FALSE";

This can lead to:

  • Conflicts with existing local files
  • Issues with concurrent test executions
  • Unpredictable test behavior in CI/CD environments

Proposed Solution

Use a random UUID for better isolation, for example:

  • Change the path pattern to /tmp/clp-connector-{UUID}
  • Generate the UUID once per test session to maintain consistency across related tests
  • Provide a method to retrieve this path for use in subsequent unit tests

Reference

This issue was identified and discussed in PR #15:

As mentioned in the discussion, this will be addressed in a future update to keep minimal changes in the current PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions