Search in sources :

Example 61 with ExecutionInfo

use of com.datastax.oss.driver.api.core.cql.ExecutionInfo in project dsbulk by datastax.

the class ReadResultPublisherTest method mockPage.

private static CompletionStage<AsyncResultSet> mockPage(CompletionStage<AsyncResultSet> previous, int size) {
    CompletableFuture<AsyncResultSet> future = new CompletableFuture<>();
    ExecutionInfo executionInfo = mock(ExecutionInfo.class);
    when(executionInfo.getPagingState()).thenReturn(previous == null ? null : ByteBuffer.wrap(new byte[] { 1 }));
    future.complete(new MockAsyncResultSet(size, executionInfo, previous));
    previous = future;
    return previous;
}
Also used : MockAsyncResultSet(com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet) CompletableFuture(java.util.concurrent.CompletableFuture) MockAsyncResultSet(com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet) AsyncResultSet(com.datastax.oss.driver.api.core.cql.AsyncResultSet) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo)

Example 62 with ExecutionInfo

use of com.datastax.oss.driver.api.core.cql.ExecutionInfo in project dsbulk by datastax.

the class WriteResultPublisherTest method setUpSession.

private static CqlSession setUpSession() {
    CqlSession session = mock(CqlSession.class);
    CompletableFuture<AsyncResultSet> future = new CompletableFuture<>();
    ExecutionInfo executionInfo = mock(ExecutionInfo.class);
    future.complete(new MockAsyncResultSet(0, executionInfo, null));
    when(session.executeAsync(any(SimpleStatement.class))).thenReturn(future);
    return session;
}
Also used : MockAsyncResultSet(com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet) CompletableFuture(java.util.concurrent.CompletableFuture) MockAsyncResultSet(com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet) AsyncResultSet(com.datastax.oss.driver.api.core.cql.AsyncResultSet) SimpleStatement(com.datastax.oss.driver.api.core.cql.SimpleStatement) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo) CqlSession(com.datastax.oss.driver.api.core.CqlSession)

Example 63 with ExecutionInfo

use of com.datastax.oss.driver.api.core.cql.ExecutionInfo in project dsbulk by datastax.

the class LogManagerTest method should_log_query_warnings_when_reading.

@Test
void should_log_query_warnings_when_reading(@LogCapture(value = LogManager.class, level = WARN) LogInterceptor logs) throws Exception {
    Path outputDir = Files.createTempDirectory("test");
    LogManager logManager = new LogManager(session, outputDir, ErrorThreshold.forAbsoluteValue(100), ErrorThreshold.forAbsoluteValue(1), true, statementFormatter, EXTENDED, rowFormatter);
    logManager.init();
    ExecutionInfo info1 = mock(ExecutionInfo.class);
    when(info1.getWarnings()).thenReturn(ImmutableList.of("warning1", "warning2"));
    ExecutionInfo info2 = mock(ExecutionInfo.class);
    when(info2.getWarnings()).thenReturn(ImmutableList.of("warning3"));
    Flux.just(new DefaultReadResult(SimpleStatement.newInstance("SELECT 1"), info1, mockRow(1)), new DefaultReadResult(SimpleStatement.newInstance("SELECT 2"), info2, mockRow(2))).transform(logManager.newQueryWarningsHandler()).blockLast();
    logManager.close();
    assertThat(logs).hasMessageContaining("Query generated server-side warning: warning1").doesNotHaveMessageContaining("warning2").doesNotHaveMessageContaining("warning3").hasMessageContaining("The maximum number of logged query warnings has been exceeded (1); " + "subsequent warnings will not be logged.");
}
Also used : Path(java.nio.file.Path) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo) DefaultReadResult(com.datastax.oss.dsbulk.executor.api.result.DefaultReadResult) Test(org.junit.jupiter.api.Test)

Example 64 with ExecutionInfo

use of com.datastax.oss.driver.api.core.cql.ExecutionInfo in project dsbulk by datastax.

the class LogManagerTest method setUp.

@BeforeEach
void setUp() throws Exception {
    session = mockSession();
    resource1 = new URI("file:///file1.csv");
    resource2 = new URI("file:///file2.csv");
    resource3 = new URI("file:///file3.csv");
    csvRecord1 = new DefaultErrorRecord(source1, resource1, 1, new RuntimeException("error 1"));
    csvRecord2 = new DefaultErrorRecord(source2, resource2, 2, new RuntimeException("error 2"));
    csvRecord3 = new DefaultErrorRecord(source3, resource3, 3, new RuntimeException("error 3"));
    unmappableStmt1 = new UnmappableStatement(csvRecord1, new RuntimeException("error 1"));
    unmappableStmt2 = new UnmappableStatement(csvRecord2, new RuntimeException("error 2"));
    unmappableStmt3 = new UnmappableStatement(csvRecord3, new RuntimeException("error 3"));
    failedWriteResult1 = new DefaultWriteResult(new BulkExecutionException(new DriverTimeoutException("error 1"), new MappedBoundStatement(csvRecord1, mockBoundStatement("INSERT 1"))));
    failedWriteResult2 = new DefaultWriteResult(new BulkExecutionException(new DriverTimeoutException("error 2"), new MappedBoundStatement(csvRecord2, mockBoundStatement("INSERT 2"))));
    failedWriteResult3 = new DefaultWriteResult(new BulkExecutionException(new DriverTimeoutException("error 3"), new MappedBoundStatement(csvRecord3, mockBoundStatement("INSERT 3"))));
    failedReadResult1 = new DefaultReadResult(new BulkExecutionException(new DriverTimeoutException("error 1"), mockBoundStatement("SELECT 1")));
    failedReadResult2 = new DefaultReadResult(new BulkExecutionException(new DriverTimeoutException("error 2"), mockBoundStatement("SELECT 2")));
    failedReadResult3 = new DefaultReadResult(new BulkExecutionException(new DriverTimeoutException("error 3"), mockBoundStatement("SELECT 3")));
    BatchStatement batch = BatchStatement.newInstance(DefaultBatchType.UNLOGGED, new MappedBoundStatement(csvRecord1, mockBoundStatement("INSERT 1", "foo", 42)), new MappedBoundStatement(csvRecord2, mockBoundStatement("INSERT 2", "bar", 43)), new MappedBoundStatement(csvRecord3, mockBoundStatement("INSERT 3", "qix", 44)));
    batchWriteResult = new DefaultWriteResult(new BulkExecutionException(new DriverTimeoutException("error batch"), batch));
    ExecutionInfo info = mock(ExecutionInfo.class);
    row1 = mockRow(1);
    Row row2 = mockRow(2);
    Row row3 = mockRow(3);
    Statement<?> stmt1 = SimpleStatement.newInstance("SELECT 1");
    Statement<?> stmt2 = SimpleStatement.newInstance("SELECT 2");
    Statement<?> stmt3 = SimpleStatement.newInstance("SELECT 3");
    successfulReadResult1 = new DefaultReadResult(stmt1, info, row1);
    ReadResult successfulReadResult2 = new DefaultReadResult(stmt2, info, row2);
    ReadResult successfulReadResult3 = new DefaultReadResult(stmt3, info, row3);
    rowRecord1 = new DefaultErrorRecord(successfulReadResult1, tableResource, 1, new RuntimeException("error 1"));
    rowRecord2 = new DefaultErrorRecord(successfulReadResult2, tableResource, 2, new RuntimeException("error 2"));
    rowRecord3 = new DefaultErrorRecord(successfulReadResult3, tableResource, 3, new RuntimeException("error 3"));
}
Also used : BulkExecutionException(com.datastax.oss.dsbulk.executor.api.exception.BulkExecutionException) DefaultWriteResult(com.datastax.oss.dsbulk.executor.api.result.DefaultWriteResult) DriverTimeoutException(com.datastax.oss.driver.api.core.DriverTimeoutException) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo) ReadResult(com.datastax.oss.dsbulk.executor.api.result.ReadResult) DefaultReadResult(com.datastax.oss.dsbulk.executor.api.result.DefaultReadResult) MappedBoundStatement(com.datastax.oss.dsbulk.workflow.commons.statement.MappedBoundStatement) URI(java.net.URI) UnmappableStatement(com.datastax.oss.dsbulk.workflow.commons.statement.UnmappableStatement) DefaultErrorRecord(com.datastax.oss.dsbulk.connectors.api.DefaultErrorRecord) BatchStatement(com.datastax.oss.driver.api.core.cql.BatchStatement) DefaultReadResult(com.datastax.oss.dsbulk.executor.api.result.DefaultReadResult) Row(com.datastax.oss.driver.api.core.cql.Row) DriverUtils.mockRow(com.datastax.oss.dsbulk.tests.driver.DriverUtils.mockRow) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ExecutionInfo (com.datastax.oss.driver.api.core.cql.ExecutionInfo)64 Test (org.junit.Test)36 Row (com.datastax.oss.driver.api.core.cql.Row)23 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)19 AsyncResultSet (com.datastax.oss.driver.api.core.cql.AsyncResultSet)17 ColumnDefinitions (com.datastax.oss.driver.api.core.cql.ColumnDefinitions)13 ReactiveRow (com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow)12 RequestHandlerTestHarness (com.datastax.oss.driver.internal.core.cql.RequestHandlerTestHarness)12 ContinuousAsyncResultSet (com.datastax.dse.driver.api.core.cql.continuous.ContinuousAsyncResultSet)9 ResultSet (com.datastax.oss.driver.api.core.cql.ResultSet)9 CompletableFuture (java.util.concurrent.CompletableFuture)9 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)8 CqlSession (com.datastax.oss.driver.api.core.CqlSession)7 Test (org.junit.jupiter.api.Test)7 ReactiveResultSet (com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet)6 PoolBehavior (com.datastax.oss.driver.internal.core.cql.PoolBehavior)6 DefaultSession (com.datastax.oss.driver.internal.core.session.DefaultSession)6 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)5 ReactiveGraphNode (com.datastax.dse.driver.api.core.graph.reactive.ReactiveGraphNode)4 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)4