use of com.datastax.fallout.runner.CheckResourcesResult in project fallout by datastax.
the class ActiveTestRunTransitionTest method nodeGroupBuilder.
private NodeGroupBuilder nodeGroupBuilder(Optional<NodeGroup.State> launchState, CheckResourcesResult createResult) {
WritablePropertyGroup pg = new WritablePropertyGroup();
launchState.ifPresent(ls -> pg.put(FalloutPropertySpecs.launchRunLevelPropertySpec.name(), ls));
return NodeGroupBuilder.create().withProvisioner(new FakeProvisioner() {
@Override
protected CheckResourcesResult createImpl(NodeGroup nodeGroup) {
return createResult;
}
}).withConfigurationManager(new FakeConfigurationManager()).withPropertyGroup(pg).withNodeCount(1).withName(NODE_GROUP_NAME);
}
use of com.datastax.fallout.runner.CheckResourcesResult in project fallout by datastax.
the class ActiveTestRun method transitionEnsembleStateUpwards.
private CheckResourcesResult transitionEnsembleStateUpwards(Optional<NodeGroup.State> maximumState, TestRun.State testRunState, String stage) {
CheckResourcesResult transitionResult = CheckResourcesResult.FAILED;
setTestRunState(testRunState);
try {
transitionResult = transitionEnsembleStateUpwards(maximumState);
failTestIfCheckResourcesDidNotSucceed(transitionResult, stage);
} catch (Exception e) {
failTest("Error " + stage + " ensemble for test run", e);
}
return transitionResult;
}
use of com.datastax.fallout.runner.CheckResourcesResult in project fallout by datastax.
the class ActiveTestRun method transitionEnsembleStateUpwards.
private CheckResourcesResult transitionEnsembleStateUpwards(Optional<NodeGroup.State> maximumState) {
List<CompletableFuture<CheckResourcesResult>> futures = new ArrayList<>();
for (NodeGroup nodeGroup : ensemble.getUniqueNodeGroupInstances()) {
NodeGroup.State requiredState = FalloutPropertySpecs.launchRunLevelPropertySpec.value(nodeGroup);
requiredState = NodeGroup.State.values()[Math.min(maximumState.orElse(requiredState).ordinal(), requiredState.ordinal())];
futures.add(nodeGroup.transitionStateIfUpwards(requiredState));
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture[] {})).join();
return futures.stream().map(CompletableFuture::join).reduce(CheckResourcesResult.AVAILABLE, CheckResourcesResult::worstCase);
}
use of com.datastax.fallout.runner.CheckResourcesResult in project fallout by datastax.
the class ActiveTestRun method doSetup.
private CheckResourcesResult doSetup() {
try {
logger.info("Setting up ensemble before beginning jepsen test");
if (!ensemble.createAllLocalFiles()) {
return CheckResourcesResult.FAILED;
}
// Check states and kick off any post-check-state actions.
final List<CompletableFuture<Boolean>> postCheckStateActions = ensemble.getUniqueNodeGroupInstances().stream().map(NodeGroup::checkState).map(CompletableFuture::join).map(postCheckStateAction -> CompletableFuture.supplyAsync(postCheckStateAction::getAsBoolean)).toList();
return transitionEnsembleStateUpwards(Optional.of(NodeGroup.State.RESERVED), TestRun.State.RESERVING_RESOURCES, "reserving").ifSuccessful(() -> transitionEnsembleStateUpwards(Optional.of(NodeGroup.State.CREATED), TestRun.State.ACQUIRING_RESOURCES, "acquiring")).ifSuccessful(() -> transitionEnsembleStateUpwards(Optional.of(NodeGroup.State.STARTED_SERVICES_CONFIGURED), TestRun.State.SETTING_UP, "setting up")).ifSuccessful(() -> CheckResourcesResult.fromWasSuccessful(postSetupHook.apply(ensemble))).ifSuccessful(() -> CheckResourcesResult.fromWasSuccessful(Utils.waitForAll(postCheckStateActions, logger, "post check-state actions"))).ifSuccessful(() -> transitionEnsembleStateUpwards(Optional.empty(), TestRun.State.SETTING_UP, "setting up"));
} finally {
// Summarize ensemble info to aid post-hoc debugging
String downloadPath = testRunArtifactPath.toAbsolutePath().toString();
Path ensembleSummary = Paths.get(downloadPath, "ensemble-summary.json");
HashMap<String, Object> ensembleInfo = new HashMap<>();
DebugInfoProvidingComponent.InfoConsumer infoConsumer = ensembleInfo::put;
infoConsumer.accept("fallout_version", FalloutVersion.getVersion());
ensemble.summarizeInfo(infoConsumer);
try {
ObjectWriter writer = new ObjectMapper().writerWithDefaultPrettyPrinter();
writer.writeValue(ensembleSummary.toFile(), ensembleInfo);
} catch (IOException e) {
logger.warn("Error writing summaryInfo to file", e);
}
}
}
Aggregations