Search in sources :

Example 1 with JobConsoleLoggers

use of com.datastax.fallout.ops.JobConsoleLoggers in project fallout by datastax.

the class FalloutValidateCommand method run.

private void run(Validator validator, FC configuration, Path testYamlPath, Map<String, Object> templateParams, Path credsYamlPath) {
    final var testYaml = readString(testYamlPath);
    final var userCredentials = parseUserCredentials(validator, credsYamlPath);
    final var test = Test.createTest(userCredentials.owner.getEmail(), getNameWithoutExtension(testYamlPath), testYaml);
    final var testRun = test.createTestRun(templateParams);
    testRun.setCreatedAt(new Date());
    final var loggers = new JobConsoleLoggers();
    final var outputDir = Exceptions.getUncheckedIO(() -> Files.createTempDirectory("fallout-validation"));
    final var scratchSpace = new TestRunScratchSpaceFactory(outputDir).createGlobal();
    final var stateStorage = new InMemoryTestRunStateStorage(TestRun.State.PREPARING_RUN);
    final var testRunStatusUpdater = new TestRunAbortedStatusUpdater(stateStorage);
    try {
        ActiveTestRunBuilder.create().withFalloutConfiguration(configuration).withTestDefinitionFromYaml(testRun.getExpandedDefinition()).withUserCredentials(userCredentials).withTestRunArtifactPath(outputDir).withTestRunStatusUpdater(testRunStatusUpdater).withLoggers(loggers).withTestRunScratchSpace(scratchSpace).withTestRunIdentifier(testRun.getTestRunIdentifier()).withTestRun(testRun).build();
    } finally {
        ClojureShutdown.shutdown();
        Exceptions.runUncheckedIO(() -> MoreFiles.deleteRecursively(outputDir, RecursiveDeleteOption.ALLOW_INSECURE));
    }
}
Also used : TestRunAbortedStatusUpdater(com.datastax.fallout.harness.TestRunAbortedStatusUpdater) InMemoryTestRunStateStorage(com.datastax.fallout.harness.InMemoryTestRunStateStorage) JobConsoleLoggers(com.datastax.fallout.ops.JobConsoleLoggers) TestRunScratchSpaceFactory(com.datastax.fallout.ops.TestRunScratchSpaceFactory) Date(java.util.Date)

Aggregations

InMemoryTestRunStateStorage (com.datastax.fallout.harness.InMemoryTestRunStateStorage)1 TestRunAbortedStatusUpdater (com.datastax.fallout.harness.TestRunAbortedStatusUpdater)1 JobConsoleLoggers (com.datastax.fallout.ops.JobConsoleLoggers)1 TestRunScratchSpaceFactory (com.datastax.fallout.ops.TestRunScratchSpaceFactory)1 Date (java.util.Date)1