use of io.crate.action.sql.SQLOperations in project crate by crate.
the class QueryStatsTest method beforeClass.
@BeforeClass
public static void beforeClass() {
SQLOperations sqlOperations = mock(SQLOperations.class);
when(sqlOperations.createSession(anyString(), anyObject(), anyInt())).thenReturn(session);
doNothing().when(session).parse(anyString(), anyString(), anyListOf(DataType.class));
queryStats = spy(new QueryStats(sqlOperations, Settings.EMPTY));
}
use of io.crate.action.sql.SQLOperations in project crate by crate.
the class ConnectionContextTest method setUp.
@Before
public void setUp() throws Exception {
JobsLogs jobsLogs = new JobsLogs(() -> true);
sqlOperations = new SQLOperations(e.analyzer, e.planner, () -> mock(Executor.class), jobsLogs, Settings.EMPTY, clusterService) {
@Override
public Session createSession(@Nullable String defaultSchema, Set<Option> options, int defaultLimit) {
Session session = super.createSession(defaultSchema, options, defaultLimit);
sessions.add(session);
return session;
}
};
}
use of io.crate.action.sql.SQLOperations in project crate by crate.
the class DecommissioningServiceTest method setUp.
@Before
public void setUp() throws Exception {
NodeSettingsService settingsService = new NodeSettingsService(Settings.EMPTY);
threadPool = mock(ThreadPool.class, Answers.RETURNS_MOCKS.get());
jobsLogs = new JobsLogs(() -> true);
sqlOperations = mock(SQLOperations.class, Answers.RETURNS_MOCKS.get());
decommissioningService = new TestableDecommissioningService(Settings.EMPTY, new NoopClusterService(), jobsLogs, threadPool, settingsService, sqlOperations, mock(TransportClusterHealthAction.class), mock(TransportClusterUpdateSettingsAction.class));
}
use of io.crate.action.sql.SQLOperations in project crate by crate.
the class TableStatsServiceTest method testStatsQueriesCorrectly.
@Test
public void testStatsQueriesCorrectly() throws Throwable {
ClusterService clusterService = mock(ClusterService.class);
when(clusterService.localNode()).thenReturn(mock(DiscoveryNode.class));
final SQLOperations sqlOperations = mock(SQLOperations.class);
SQLOperations.SQLDirectExecutor sqlDirectExecutor = mock(SQLOperations.SQLDirectExecutor.class);
when(sqlOperations.createSQLDirectExecutor(eq("sys"), eq(TableStatsService.TABLE_STATS), eq(TableStatsService.STMT), eq(TableStatsService.DEFAULT_SOFT_LIMIT))).thenReturn(sqlDirectExecutor);
TableStatsService statsService = new TableStatsService(Settings.EMPTY, threadPool, clusterService, new TableStats(), new NodeSettingsService(Settings.EMPTY), sqlOperations);
statsService.run();
verify(sqlDirectExecutor, times(1)).execute(any(TableStatsService.TableStatsResultReceiver.class), eq(Collections.emptyList()));
}
use of io.crate.action.sql.SQLOperations in project crate by crate.
the class PreExecutionBenchmark method setup.
@Setup
public void setup() throws Exception {
Path tempDir = Files.createTempDirectory("");
Settings settings = Settings.builder().put("path.home", tempDir.toAbsolutePath().toString()).build();
Environment environment = new Environment(settings, tempDir);
node = new Node(environment, List.of(Netty4Plugin.class), true);
node.start();
Injector injector = node.injector();
sqlOperations = injector.getInstance(SQLOperations.class);
analyzer = injector.getInstance(Analyzer.class);
planner = injector.getInstance(Planner.class);
clusterService = injector.getInstance(ClusterService.class);
nodeCtx = injector.getInstance(NodeContext.class);
String statement = "create table users (id int primary key, name string, date timestamp, text string index using fulltext)";
var resultReceiver = new BaseResultReceiver();
sqlOperations.newSystemSession().quickExec(statement, resultReceiver, Row.EMPTY);
resultReceiver.completionFuture().get(5, TimeUnit.SECONDS);
}
Aggregations