use of org.xbib.tools.JDBCImporter in project elasticsearch-jdbc by jprante.
the class JDBCImporterTest method testImporter.
public void testImporter() throws Exception {
final JDBCImporter importer = new JDBCImporter();
Settings settings = Settings.settingsBuilder().put("url", "jdbc:mysql://localhost:3306/test").put("sql", "select * from test").put("index", "jdbc").put("type", "jdbc").build();
importer.setSettings(settings);
importer.run();
Thread.sleep(12000L);
importer.shutdown();
}
use of org.xbib.tools.JDBCImporter in project elasticsearch-jdbc by jprante.
the class StandardScheduleTests method createImporter.
private JDBCImporter createImporter(final String resource) throws Exception {
final JDBCImporter importer = new JDBCImporter();
Context context = createContext(resource);
logger.info("createImporter: setting context {}", context);
importer.setContext(context);
logger.info("createImporter: settings = {}", context.getSettings());
// dispatch in a thread
new Thread() {
public void run() {
importer.run();
}
}.start();
return importer;
}
use of org.xbib.tools.JDBCImporter in project elasticsearch-jdbc by jprante.
the class StandardScheduleTests method testTimestamps.
/**
* Test read and write of timestamps in a table. We create 100 timestamps over hour interval,
* current timestamp $now is in the center.
* Selecting timestamps from $now, there should be at least 50 rows/hits per run, if $now works.
*
* @param resource the JSON resource
* @param sql the sql statement to select timestamps
* @throws Exception
*/
@Test
@Parameters({ "task7", "sql2" })
public void testTimestamps(String resource, String sql) throws Exception {
// TODO make timezone/locale configurable for better randomized testing
createTimestampedLogs(sql, 100, "iw_IL", "Asia/Jerusalem");
JDBCImporter importer = createImporter(resource);
// run more than twice
Thread.sleep(12500L);
importer.shutdown();
long hits = client("1").prepareSearch(index).execute().actionGet().getHits().getTotalHits();
// just an estimation, at least two runs should deliver 50 hits each.
logger.info("found {} hits", hits);
assertTrue(hits > 99L);
}
use of org.xbib.tools.JDBCImporter in project elasticsearch-jdbc by jprante.
the class StandardScheduleTests method testSimpleSchedule.
/**
* Product table star select, scheduled for more than two runs
*
* @param resource the resource
* @param sql the SQL statement
* @throws Exception if test fails
*/
@Test
@Parameters({ "task6", "sql1" })
public void testSimpleSchedule(String resource, String sql) throws Exception {
createRandomProducts(sql, 100);
JDBCImporter importer = createImporter(resource);
// run more than twice
Thread.sleep(12500L);
importer.shutdown();
long hits = client("1").prepareSearch(index).execute().actionGet().getHits().getTotalHits();
logger.info("found {} hits", hits);
assertTrue(hits > 104L);
}
Aggregations