use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.
the class TestFlinkCDCMongoDBSourceFunction method testStart.
public void testStart() throws Exception {
FlinkCDCMongoDBSourceFactory mongoDBSourceFactory = this.mock("mongoDBSourceFactory", FlinkCDCMongoDBSourceFactory.class);
FlinkCDCMongoDBSourceFunction mongoDBSourceFunction = new FlinkCDCMongoDBSourceFunction(mongoDBSourceFactory);
DataXMongodbReader mongodbReader = new DataXMongodbReader();
List<ISelectedTab> tabs = Lists.newArrayList();
IDataxProcessor dataXProcessor = this.mock("dataxProcess", IDataxProcessor.class);
this.replay();
TargetResName dataXName = new TargetResName("test");
mongoDBSourceFunction.start(dataXName, mongodbReader, tabs, dataXProcessor);
this.verifyAll();
}
use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.
the class TestDefaultIncrK8sConfig method testlistPodsAndWatchLog.
// public void testDefaultIncrK8sConfig() throws Exception {
// DefaultIncrK8sConfig incrK8sCfg = new DefaultIncrK8sConfig();
// incrK8sCfg.namespace = "tis";
// incrK8sCfg.k8sName = "minikube";
// incrK8sCfg.imagePath = "registry.cn-hangzhou.aliyuncs.com/tis/tis-incr:latest";
//
// incrK8sCfg.getIncrSync().removeInstance("search4totalpay");
// }
public void testlistPodsAndWatchLog() throws Exception {
IRCController incrSync = getIncrSync();
String podName = "podname";
assertNotNull(incrSync);
final AtomicInteger msgReceiveCount = new AtomicInteger();
incrSync.listPodAndWatchLog(new TargetResName(totalpay), podName, new ILogListener() {
@Override
public void sendMsg2Client(Object biz) throws IOException {
System.out.println("flushCount:" + msgReceiveCount.incrementAndGet());
}
@Override
public void read(Object event) {
}
@Override
public boolean isClosed() {
return false;
}
});
Thread.sleep(5000);
assertTrue(msgReceiveCount.get() > 0);
}
use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.
the class TestK8sIncrSync method testLaunchIncrProcess.
public void testLaunchIncrProcess() throws Exception {
IRCController incrSync = TestDefaultIncrK8sConfig.getIncrSync();
incrSync.relaunch(new TargetResName(Config.S4TOTALPAY));
}
use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.
the class TestK8sIncrSync method testDeleteDeployment.
public void testDeleteDeployment() throws Exception {
IRCController incrSync = TestDefaultIncrK8sConfig.getIncrSync();
incrSync.removeInstance(new TargetResName(Config.S4TOTALPAY));
}
use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.
the class TestFlinkCDCMySQLSourceFactory method testBinlogConsumeWithDataStreamRegisterInstaneDetailTable.
/**
* 测试 instancedetail
*
* @throws Exception
*/
@Test
public void testBinlogConsumeWithDataStreamRegisterInstaneDetailTable() throws Exception {
FlinkCDCMySQLSourceFactory mysqlCDCFactory = new FlinkCDCMySQLSourceFactory();
mysqlCDCFactory.startupOptions = "latest";
final String tabName = "instancedetail";
CUDCDCTestSuit cdcTestSuit = new CUDCDCTestSuit() {
@Override
protected BasicDataSourceFactory createDataSourceFactory(TargetResName dataxName) {
return createMySqlDataSourceFactory(dataxName);
}
@Override
protected String getColEscape() {
return "`";
}
@Override
protected IResultRows createConsumerHandle(String tabName) {
return new TestTableRegisterFlinkSourceHandle(tabName, cols);
}
@Override
protected void verfiyTableCrudProcess(String tabName, BasicDataXRdbmsReader dataxReader, ISelectedTab tab, IResultRows consumerHandle, IMQListener<JobExecutionResult> imqListener) throws MQConsumeException, InterruptedException {
// super.verfiyTableCrudProcess(tabName, dataxReader, tab, consumerHandle, imqListener);
List<ISelectedTab> tabs = Collections.singletonList(tab);
List<TestRow> exampleRows = Lists.newArrayList();
exampleRows.add(this.parseTestRow(RowKind.INSERT, TestFlinkCDCMySQLSourceFactory.class, tabName + "/insert1.txt"));
Assert.assertEquals(1, exampleRows.size());
imqListener.start(dataxName, dataxReader, tabs, null);
Thread.sleep(1000);
CloseableIterator<Row> snapshot = consumerHandle.getRowSnapshot(tabName);
BasicDataSourceFactory dataSourceFactory = (BasicDataSourceFactory) dataxReader.getDataSourceFactory();
Assert.assertNotNull("dataSourceFactory can not be null", dataSourceFactory);
dataSourceFactory.visitFirstConnection((conn) -> {
startProcessConn(conn);
for (TestRow t : exampleRows) {
RowVals<Object> vals = t.vals;
final String insertBase = "insert into " + createTableName(tabName) + "(" + cols.stream().filter((c) -> vals.notNull(c.getName())).map((col) -> getColEscape() + col.getName() + getColEscape()).collect(Collectors.joining(" , ")) + ") " + "values(" + cols.stream().filter((c) -> vals.notNull(c.getName())).map((col) -> "?").collect(Collectors.joining(" , ")) + ")";
PreparedStatement statement = conn.prepareStatement(insertBase);
AtomicInteger ci = new AtomicInteger();
cols.stream().filter((c) -> vals.notNull(c.getName())).forEach((col) -> {
col.type.accept(new DataType.TypeVisitor<Void>() {
@Override
public Void longType(DataType type) {
try {
statement.setLong(ci.incrementAndGet(), Long.parseLong(vals.getString(col.getName())));
} catch (SQLException e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void doubleType(DataType type) {
try {
statement.setDouble(ci.incrementAndGet(), Double.parseDouble(vals.getString(col.getName())));
} catch (SQLException e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void dateType(DataType type) {
try {
statement.setDate(ci.incrementAndGet(), java.sql.Date.valueOf(vals.getString(col.getName())));
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void timestampType(DataType type) {
try {
statement.setTimestamp(ci.incrementAndGet(), java.sql.Timestamp.valueOf(vals.getString(col.getName())));
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void bitType(DataType type) {
try {
statement.setByte(ci.incrementAndGet(), Byte.parseByte(vals.getString(col.getName())));
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void blobType(DataType type) {
try {
try (InputStream input = new ByteArrayInputStream(vals.getString(col.getName()).getBytes(TisUTF8.get()))) {
statement.setBlob(ci.incrementAndGet(), input);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void varcharType(DataType type) {
try {
statement.setString(ci.incrementAndGet(), (vals.getString(col.getName())));
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void intType(DataType type) {
try {
statement.setInt(ci.incrementAndGet(), Integer.parseInt(vals.getString(col.getName())));
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void floatType(DataType type) {
try {
statement.setFloat(ci.incrementAndGet(), Float.parseFloat(vals.getString(col.getName())));
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void decimalType(DataType type) {
try {
statement.setBigDecimal(ci.incrementAndGet(), BigDecimal.valueOf(Double.parseDouble(vals.getString(col.getName()))));
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void timeType(DataType type) {
try {
statement.setTime(ci.incrementAndGet(), java.sql.Time.valueOf(vals.getString(col.getName())));
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void tinyIntType(DataType dataType) {
try {
statement.setShort(ci.incrementAndGet(), Short.parseShort(vals.getString(col.getName())));
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public Void smallIntType(DataType dataType) {
tinyIntType(dataType);
return null;
}
});
});
Assert.assertEquals(1, executePreparedStatement(conn, statement));
statement.close();
sleepForAWhile();
System.out.println("wait to show insert rows");
waitForSnapshotStarted(snapshot);
List<TestRow> rows = fetchRows(snapshot, 1, false);
for (TestRow rr : rows) {
System.out.println("------------" + rr.get("instance_id"));
assertTestRow(tabName, RowKind.INSERT, consumerHandle, t, rr);
}
}
});
}
};
cdcTestSuit.startTest(mysqlCDCFactory, tabName);
}
Aggregations