elastic/elasticsearch · error · TestClustersException

Ran out of versions to go to for

Error message

Ran out of versions to go to for {}

What it means

Thrown by goToNextVersion() when currentDistro + 1 >= distributions.size(), i.e. a BWC/upgrade test asks the node to advance to the next registered distribution but none remains. The node carries an ordered list of distributions; this guard prevents an IndexOutOfBounds and signals the test wired too few versions for the number of upgrade steps it performs.

Solutions

  1. Register the missing older distribution(s) on the node: distribution 'integ-test-zip', '<old-version>' before the current version.
  2. If using the bwc plugin, ensure bwcVersionList / the bwc task graph actually adds the distributions; check the test's distributions block.
  3. Review the calling test: only call goToNextVersion() on nodes that have a next version; guard with a check or rely on the framework's rolling-upgrade helper.
  4. Inspect distributions.size() at config time (e.g. add an assertion) to fail fast with a clearer message than the runtime throw.

Example fix

// before: single distribution, upgrade step has nowhere to go
testClusters {
  myNode {
    distribution 'integ-test-zip', '8.15.0'
  }
}
// after: register old then new so goToNextVersion can advance
testClusters {
  myNode {
    distribution 'integ-test-zip', '7.17.0'
    distribution 'integ-test-zip', '8.15.0'
  }
}
Defensive patterns

Strategy: validation

Validate before calling

// At config freeze time, assert enough distributions are registered for upgrade steps
int needed = expectedUpgradeSteps + 1;
if (node.getDistributions().size() < needed) {
    throw new IllegalStateException("Node has " + node.getDistributions().size()
        + " distributions but upgrade plan needs " + needed
        + "; register older versions via distribution(...)");
}

Prevention

When it happens

Trigger: An upgrade task (e.g. RollingUpgradeTask / bwc test) calls node.goToNextVersion() more times than the number of distributions registered via distribution(...) minus one. Commonly hit when a BWC matrix is configured with only the current version but the test plan performs an old->new upgrade requiring at least two.

Common situations: BWC test misconfigured with a single distribution. Old version added via bwcVersion but not actually registered in the distributions list. Bug in an upgrade-task loop that calls goToNextVersion unconditionally on every node even when it is already on the final version.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/ea6fafa0a13effb7. Report an issue: GitHub.

Appendix: source

Thrown at build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java:601

                "[" + Instant.now().toString() + "] [BUILD] " + message + "\n",
                StandardOpenOption.CREATE,
                StandardOpenOption.APPEND
            );
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    @Override
    public void restart() {
        LOGGER.info("Restarting {}", this);
        stop(false);
        start();
    }

    void goToNextVersion() {
        if (currentDistro + 1 >= distributions.size()) {
            throw new TestClustersException("Ran out of versions to go to for " + this);
        }
        logToProcessStdout("Switch version from " + getVersion() + " to " + distributions.get(currentDistro + 1).getVersion());
        currentDistro += 1;
        setting("node.attr.upgraded", "true");
    }

    private boolean isSettingTrue(String name) {
        return Boolean.parseBoolean(settings.getOrDefault(name, "false").toString());
    }

    private void copyExtraConfigFiles() {
        if (extraConfigFiles.isEmpty() == false) {
            logToProcessStdout("Setting up " + extraConfigFiles.size() + " additional config files");
        }
        extraConfigFiles.forEach((destination, from) -> {
            if (Files.exists(from.toPath()) == false) {
                throw new TestClustersException("Can't create extra config file from " + from + " for " + this + " as it does not exist");
            }

View on GitHub (pinned to db6a809a66)