Search in sources :

Example 1 with RunnableExecutorFactory

use of com.datastax.fallout.runner.RunnableExecutorFactory in project fallout by datastax.

the class FalloutServiceBase method createThreadedTestRunExecutorFactoryWithFinishedCallbacks.

/**
 * Create the {@link RunnableExecutorFactory} that will actually create the {@link ActiveTestRun}s via the specified
 * {@link ActiveTestRunFactory} and run them; used in {@link ServerMode#STANDALONE} and {@link ServerMode#RUNNER}.
 * Finished callbacks are processed by this executor, because if we try to process them in {@link ServerMode#QUEUE}
 * they could be lost due to missed updates while {@link ServerMode#QUEUE} is offline during a redeploy
 */
private RunnableExecutorFactory createThreadedTestRunExecutorFactoryWithFinishedCallbacks(FC conf, LifecycleManager m, UserMessenger mailer, TestDAO testDAO, TestRunDAO testRunDAO, ActiveTestRunFactory activeTestRunFactory) {
    JobLoggersFactory fileLoggersFactory = new JobLoggersFactory(Paths.get(conf.getArtifactPath()), conf.logTestRunsToConsole());
    final var threadedTestRunExecutorFactory = new ThreadedRunnableExecutorFactory(fileLoggersFactory, testRunDAO::update, activeTestRunFactory, conf);
    final var userNotifier = new FinishedTestRunUserNotifier(conf.getExternalUrl(), mailer, SlackUserMessenger.create(conf.getSlackToken(), m.manage(FalloutClientBuilder.forComponent(SlackUserMessenger.class).build(), Client::close)));
    return new RunnableExecutorFactory() {

        @Override
        public RunnableExecutor create(TestRun testRun, UserCredentials userCredentials) {
            final var executor = threadedTestRunExecutorFactory.create(testRun, userCredentials);
            executor.getTestRunStatus().addFinishedCallback(() -> {
                testDAO.increaseSizeOnDiskBytesByTestRunSize(testRun);
                userNotifier.notify(testRun);
            });
            return executor;
        }

        @Override
        public void close() {
            threadedTestRunExecutorFactory.close();
        }
    };
}
Also used : ReadOnlyTestRun(com.datastax.fallout.service.core.ReadOnlyTestRun) TestRun(com.datastax.fallout.service.core.TestRun) ActiveTestRun(com.datastax.fallout.harness.ActiveTestRun) FinishedTestRunUserNotifier(com.datastax.fallout.util.FinishedTestRunUserNotifier) UserCredentials(com.datastax.fallout.runner.UserCredentialsFactory.UserCredentials) ThreadedRunnableExecutorFactory(com.datastax.fallout.runner.ThreadedRunnableExecutorFactory) Client(javax.ws.rs.client.Client) AbortableRunnableExecutorFactory(com.datastax.fallout.runner.AbortableRunnableExecutorFactory) RunnableExecutorFactory(com.datastax.fallout.runner.RunnableExecutorFactory) ThreadedRunnableExecutorFactory(com.datastax.fallout.runner.ThreadedRunnableExecutorFactory) DelegatingRunnableExecutorFactory(com.datastax.fallout.runner.DelegatingRunnableExecutorFactory) JobLoggersFactory(com.datastax.fallout.runner.JobLoggersFactory)

Aggregations

ActiveTestRun (com.datastax.fallout.harness.ActiveTestRun)1 AbortableRunnableExecutorFactory (com.datastax.fallout.runner.AbortableRunnableExecutorFactory)1 DelegatingRunnableExecutorFactory (com.datastax.fallout.runner.DelegatingRunnableExecutorFactory)1 JobLoggersFactory (com.datastax.fallout.runner.JobLoggersFactory)1 RunnableExecutorFactory (com.datastax.fallout.runner.RunnableExecutorFactory)1 ThreadedRunnableExecutorFactory (com.datastax.fallout.runner.ThreadedRunnableExecutorFactory)1 UserCredentials (com.datastax.fallout.runner.UserCredentialsFactory.UserCredentials)1 ReadOnlyTestRun (com.datastax.fallout.service.core.ReadOnlyTestRun)1 TestRun (com.datastax.fallout.service.core.TestRun)1 FinishedTestRunUserNotifier (com.datastax.fallout.util.FinishedTestRunUserNotifier)1 Client (javax.ws.rs.client.Client)1