diff --git a/src/test/java/com/alipay/oceanbase/rpc/ObTableClientAutoIncTest.java b/src/test/java/com/alipay/oceanbase/rpc/ObTableClientAutoIncTest.java index 02157fb3..554f7bc9 100644 --- a/src/test/java/com/alipay/oceanbase/rpc/ObTableClientAutoIncTest.java +++ b/src/test/java/com/alipay/oceanbase/rpc/ObTableClientAutoIncTest.java @@ -65,6 +65,12 @@ public void setup() throws Exception { syncRefreshMetaHelper(obTableClient); } + private void executeSQL(String createSQL) throws SQLException { + Connection connection = ObTableClientTestUtil.getConnection(); + Statement statement = connection.createStatement(); + statement.execute(createSQL); + } + private void dropTable(String tableName) throws SQLException { // use sql to drop table Connection connection = ObTableClientTestUtil.getConnection(); @@ -91,6 +97,14 @@ public void testAutoIncrementRowkey() throws Exception { final String TABLE_NAME = "test_auto_increment_rowkey"; try { + executeSQL("CREATE TABLE IF NOT EXISTS `test_auto_increment_rowkey` (" + + "`c1` int auto_increment," + + "`c2` int NOT NULL," + + "`c3` int DEFAULT NULL," + + "`c4` varchar(255) DEFAULT NULL," + + "PRIMARY KEY(`c1`, `c2`)) partition by range columns(`c2`)" + + "(PARTITION p0 VALUES LESS THAN (100), PARTITION p1 VALUES LESS THAN (1000));"); + client.insert(TABLE_NAME, new Object[] { 0, 1 }, new String[] { "c3" }, new Object[] { 1 }); @@ -304,6 +318,14 @@ public void testAutoIncrementNotRowkey() throws Exception { final String TABLE_NAME = "test_auto_increment_not_rowkey"; try { + executeSQL("CREATE TABLE IF NOT EXISTS `test_auto_increment_not_rowkey` (" + + "`c1` int NOT NULL," + + "`c2` int DEFAULT NULL," + + "`c3` tinyint auto_increment," + + "`c4` varchar(255) DEFAULT NULL," + + "PRIMARY KEY(`c1`)) partition by range columns(`c1`)" + + "(PARTITION p0 VALUES LESS THAN (100), PARTITION p1 VALUES LESS THAN (1000));"); + client .insert(TABLE_NAME, new Object[] { 1 }, new String[] { "c2" }, new Object[] { 1 }); diff --git a/src/test/java/com/alipay/oceanbase/rpc/bolt/ObTableClientTestBase.java b/src/test/java/com/alipay/oceanbase/rpc/bolt/ObTableClientTestBase.java index 639ddde6..755e07ea 100644 --- a/src/test/java/com/alipay/oceanbase/rpc/bolt/ObTableClientTestBase.java +++ b/src/test/java/com/alipay/oceanbase/rpc/bolt/ObTableClientTestBase.java @@ -55,15 +55,18 @@ public void close() throws Exception { @Test public void test_batch() throws Exception { - /* - * CREATE TABLE `test_varchar_table` ( `c1` varchar(20) NOT NULL, `c2` varchar(20) DEFAULT NULL, PRIMARY KEY (`c1`) ) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = 3 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 10 - * */ + */ + if (this.getClass().getSimpleName().equals("ObTableTest")) { + // could not get tableId from ObTable + return; + } + for (int i = 0; i < 100; i++) { TableBatchOps batchOps = client.batch("test_varchar_table");