Skip to content

inverted condition in Wait.waitFor() #6050

@teamconfx

Description

@teamconfx

Describe the bug
The test ExternalCompactionProgressIT.testCompactionDurationContinuesAfterCoordinatorStop contains an inverted condition in Wait.waitFor() waits for compactions to be EMPTY instead of waiting for compactions to EXIST.

Versions (OS, Maven, Java, and others, as appropriate):

  • Affected version(s) of this project: 2.1.4
  • OS: Ubutnu 22.04

The Buggy Code

File: test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompactionProgressIT.java

Lines: 146-151

      // Wait until the compaction starts
      Wait.waitFor(() -> {
        Map<String,TExternalCompaction> compactions =
            getRunningCompactions(getCluster().getServerContext()).getCompactions();
        return compactions == null || compactions.isEmpty();  // <-- BUG: Inverted condition
      }, 30_000, 100, "Compaction did not start within the expected time");


      // start a timer after the compaction starts
      long compactionStartTime = System.nanoTime();

      // let the compaction advance a bit
      sleepUninterruptibly(6, TimeUnit.SECONDS);

The current test can still pass because there is a sleepUninterruptibly(), but the startTime actually is NOT really the start time when the compaction starts.

Expected behavior:

  • Wait should return when there ARE running compactions
  • Condition should be: compactions != null && !compactions.isEmpty()

Additional context
Happy to send a PR for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue has been verified to be a bug.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions