use of com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse in project kylo by Teradata.
the class BatchJobSupplierTest method testPending.
/**
* Verify handling <i>PENDING</i> responses.
*/
@Test
public void testPending() {
// Mock rest client
Mockito.when(restClient.createJob(process, request)).thenReturn(PENDING_RESPONSE);
Mockito.when(restClient.getJobResult(process, PENDING_RESPONSE.getId())).thenReturn(Optional.of(PENDING_RESPONSE)).thenReturn(Optional.of(SUCCESS_RESPONSE));
// Test success response
final MockBatchJob job = new MockBatchJob();
job.setPollInterval(200, TimeUnit.MILLISECONDS);
final SparkJobResponse response = job.get();
Assert.assertEquals(SUCCESS_RESPONSE, response);
Assert.assertEquals(400, sleepMillis.get());
}
use of com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse in project kylo by Teradata.
the class BatchJobSupplierTest method testSuccess.
/**
* Verify handling <i>SUCCESS</i> responses.
*/
@Test
public void testSuccess() {
// Mock rest client
Mockito.when(restClient.createJob(process, request)).thenReturn(SUCCESS_RESPONSE);
// Test success response
final SparkJobResponse response = new MockBatchJob().get();
Assert.assertEquals(SUCCESS_RESPONSE, response);
Assert.assertEquals(0, sleepMillis.get());
}
use of com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse in project kylo by Teradata.
the class BatchJobSupplierTest method testError.
/**
* Verify handling <i>ERROR</i> responses.
*/
@Test
public void testError() {
// Mock rest client
Mockito.when(restClient.createJob(process, request)).thenReturn(ERROR_RESPONSE);
// Test success response
final SparkJobResponse response = new MockBatchJob().get();
Assert.assertEquals(ERROR_RESPONSE, response);
Assert.assertEquals(0, sleepMillis.get());
}
use of com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse in project kylo by Teradata.
the class DefaultSparkJobContextTest method testSuccess.
/**
* Verify handling of a <i>SUCCESS</i> response.
*/
@Test
public void testSuccess() {
// Mock response
final SparkJobResponse response = new SparkJobResponse();
response.setId("mock-job");
response.setResult(new SparkJobResult());
response.setStatus(SparkJobResponse.Status.SUCCESS);
// Test first subscriber
final DefaultSparkJobContext context = DefaultSparkJobContext.create(() -> response, cache, executor);
Assert.assertNotNull(take(context));
// Test second subscriber
Assert.assertEquals(response.getResult(), take(context).getResult());
}
use of com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse in project kylo by Teradata.
the class TransformService method submitSparkJob.
/**
* Submits the specified job to be executed.
*/
@Nonnull
public SparkJobResponse submitSparkJob(@Nonnull final Supplier<SparkJobResult> task) {
log.entry(task);
// Execute script
final String id = newTableName();
final SparkJob job = new SparkJob(id, task, engine.getSparkContext());
tracker.submitJob(job);
// Build response
final SparkJobResponse response = new SparkJobResponse();
response.setId(id);
response.setStatus(SparkJobResponse.Status.PENDING);
return log.exit(response);
}
Aggregations