diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json index 995222a3c6b519..410db67b1c2d9a 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json @@ -40,15 +40,25 @@ "fields":[{"name":"value"}] }, { - "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.NodeFactory"}, - "name":"com.github.benmanes.caffeine.cache.PDMS", + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.PDW"}, + "name":"com.github.benmanes.caffeine.cache.PDW", + "fields":[{"name":"writeTime"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SIMSW"}, + "name":"com.github.benmanes.caffeine.cache.PDWMS", "methods":[{"name":"","parameterTypes":[] }] }, { - "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.LocalCacheFactory"}, + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache"}, "name":"com.github.benmanes.caffeine.cache.SIMS", "methods":[{"name":"","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }] }, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache"}, + "name":"com.github.benmanes.caffeine.cache.SIMSW", + "methods":[{"name":"","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }] +}, { "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.StripedBuffer"}, "name":"com.github.benmanes.caffeine.cache.StripedBuffer", @@ -58,5 +68,10 @@ "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.StripedBuffer"}, "name":"java.lang.Thread", "fields":[{"name":"threadLocalRandomProbe"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.NodeFactory"}, + "name":"com.github.benmanes.caffeine.cache.PDMS", + "methods":[{"name":"","parameterTypes":[] }] } ] diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json index 02082e722764e1..2cdd46ae336dee 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json @@ -65,31 +65,6 @@ "condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"}, "name":"org.apache.shardingsphere.driver.api.yaml.YamlJDBCConfigurationCustomizer" }, -{ - "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereURLManager"}, - "name":"org.apache.shardingsphere.driver.jdbc.core.driver.spi.absolutepath.AbsolutePathURLProvider", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereURLManager"}, - "name":"org.apache.shardingsphere.driver.jdbc.core.driver.spi.absolutepath.AbsolutePathWithEnvironmentURLProvider", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereURLManager"}, - "name":"org.apache.shardingsphere.driver.jdbc.core.driver.spi.classpath.ClasspathURLProvider", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereURLManager"}, - "name":"org.apache.shardingsphere.driver.jdbc.core.driver.spi.classpath.ClasspathWithEnvironmentURLProvider", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereURLManager"}, - "name":"org.apache.shardingsphere.driver.jdbc.core.driver.spi.classpath.ClasspathWithSystemPropsURLProvider", - "methods":[{"name":"","parameterTypes":[] }] -}, { "condition":{"typeReachable":"org.apache.shardingsphere.encrypt.rule.EncryptRule"}, "name":"org.apache.shardingsphere.encrypt.algorithm.assisted.MD5AssistedEncryptAlgorithm", @@ -1191,6 +1166,16 @@ "condition":{"typeReachable":"org.apache.shardingsphere.infra.yaml.config.shortcut.YamlRuleConfigurationShortcuts"}, "name":"org.apache.shardingsphere.traffic.yaml.config.YamlTrafficRuleConfiguration" }, +{ + "condition":{"typeReachable":"org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine"}, + "name":"org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.shardingsphere.infra.executor.sql.hook.SPISQLExecutionHook"}, + "name":"org.apache.shardingsphere.transaction.base.seata.at.SeataTransactionalSQLExecutionHook", + "methods":[{"name":"","parameterTypes":[] }] +}, { "condition":{"typeReachable":"org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine"}, "name":"org.apache.shardingsphere.transaction.xa.XAShardingSphereTransactionManager", diff --git a/kernel/transaction/type/base/seata-at/src/test/resources/file.conf b/kernel/transaction/type/base/seata-at/src/test/resources/file.conf index 47f45ee06beccd..0a3731adf57055 100644 --- a/kernel/transaction/type/base/seata-at/src/test/resources/file.conf +++ b/kernel/transaction/type/base/seata-at/src/test/resources/file.conf @@ -39,11 +39,9 @@ transport { } service { #vgroup->rgroup - vgroupMapping.my_test_tx_group = "default" + vgroupMapping.default_tx_group = "default" #only support single node default.grouplist = "127.0.0.1:8891" - #degrade current not support - enableDegrade = false #disable disable = false } @@ -54,4 +52,7 @@ client { retry.internal = 10 retry.times = 30 } + tm { + degradeCheck = false + } } diff --git a/kernel/transaction/type/base/seata-at/src/test/resources/seata.conf b/kernel/transaction/type/base/seata-at/src/test/resources/seata.conf index 069a678a7e5df1..dd4a21605412d0 100644 --- a/kernel/transaction/type/base/seata-at/src/test/resources/seata.conf +++ b/kernel/transaction/type/base/seata-at/src/test/resources/seata.conf @@ -20,5 +20,5 @@ sharding.transaction.seata.tx.timeout = 30 client { application.id = jdbc-test - transaction.service.group = my_test_tx_group + transaction.service.group = default_tx_group } diff --git a/pom.xml b/pom.xml index 0efa42e3dc0358..ca0c5d7d67cac3 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ 5.12.4.Final 7.6.0.Final 3.2.1.Final - 1.6.1 + 1.7.1 4.1.106.Final 1.70 diff --git a/test/native/native-image-filter/extra-filter.json b/test/native/native-image-filter/extra-filter.json index facc03118b9fb3..197076d15ed76b 100644 --- a/test/native/native-image-filter/extra-filter.json +++ b/test/native/native-image-filter/extra-filter.json @@ -19,6 +19,7 @@ {"excludeClasses": "android.app.**"}, {"excludeClasses": "com.arjuna.**"}, {"excludeClasses": "com.atomikos.logging.**"}, + {"excludeClasses": "com.alibaba.druid.**"}, {"excludeClasses": "com.fasterxml.jackson.databind.**"}, {"excludeClasses": "com.github.benmanes.caffeine.cache.**"}, {"excludeClasses": "com.github.dockerjava.api.**"}, @@ -30,10 +31,13 @@ {"excludeClasses": "ch.qos.logback.classic.**"}, {"excludeClasses": "io.grpc.**"}, {"excludeClasses": "io.netty.**"}, + {"excludeClasses": "io.seata.**"}, {"excludeClasses": "io.vertx.core.**"}, {"excludeClasses": "groovy.**"}, {"excludeClasses": "libcore.io.**"}, + {"excludeClasses": "net.bytebuddy.**"}, {"excludeClasses": "org.apache.calcite.**"}, + {"excludeClasses": "org.apache.commons.logging.**"}, {"excludeClasses": "org.apache.logging.log4j.**"}, {"excludeClasses": "org.apache.log4j.**"}, {"excludeClasses": "org.apache.zookeeper.**"}, diff --git a/test/native/pom.xml b/test/native/pom.xml index 79fac3e641ec8c..33c641034cd2ae 100644 --- a/test/native/pom.xml +++ b/test/native/pom.xml @@ -26,6 +26,12 @@ shardingsphere-test-native ${project.artifactId} + + + 1.7.0-native-rc2 + + org.apache.shardingsphere @@ -61,31 +67,55 @@ org.apache.shardingsphere shardingsphere-transaction-xa-core ${project.version} + test org.apache.shardingsphere shardingsphere-transaction-xa-narayana ${project.version} + test org.jboss.narayana.jta jta ${narayana.version} + test org.jboss.narayana.jts narayana-jts-integration ${narayana.version} + test org.jboss jboss-transaction-spi ${jboss-transaction-spi.version} + test org.jboss.logging jboss-logging ${jboss-logging.version} + test + + + org.apache.shardingsphere + shardingsphere-transaction-base-seata-at + ${project.version} + test + + + io.seata + seata-all + ${seata.version} + test + + + org.antlr + antlr4-runtime + + diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java index 501c19efdcbbfb..8e734f8d956e6f 100644 --- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java +++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java @@ -81,6 +81,7 @@ public void processSuccess() throws SQLException { assertThat(orderRepository.selectAll(), equalTo(new ArrayList<>())); assertThat(orderItemRepository.selectAll(), equalTo(new ArrayList<>())); assertThat(addressRepository.selectAll(), equalTo(new ArrayList<>())); + addressRepository.assertRollbackWithTransactions(); } /** diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/AddressRepository.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/AddressRepository.java index 4dcf0c7e2aa88e..20dae55798024e 100644 --- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/AddressRepository.java +++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/AddressRepository.java @@ -28,6 +28,9 @@ import java.util.LinkedList; import java.util.List; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + @SuppressWarnings({"SqlDialectInspection", "SqlNoDataSourceInspection"}) public final class AddressRepository { @@ -39,6 +42,7 @@ public AddressRepository(final DataSource dataSource) { /** * create table t_address if not exists. + * * @throws SQLException SQL exception */ public void createTableIfNotExists() throws SQLException { @@ -53,6 +57,7 @@ public void createTableIfNotExists() throws SQLException { /** * create table t_address in MS SQL Server. * This also ignored the default schema of the `dbo`. + * * @throws SQLException SQL exception */ public void createTableInSQLServer() throws SQLException { @@ -70,6 +75,7 @@ public void createTableInSQLServer() throws SQLException { /** * drop table t_address. + * * @throws SQLException SQL exception */ public void dropTable() throws SQLException { @@ -83,6 +89,7 @@ public void dropTable() throws SQLException { /** * truncate table t_address. + * * @throws SQLException SQL exception */ public void truncateTable() throws SQLException { @@ -96,6 +103,7 @@ public void truncateTable() throws SQLException { /** * insert something to table t_address. + * * @param address address * @return addressId of the insert statement * @throws SQLException SQL exception @@ -114,6 +122,7 @@ public Long insert(final Address address) throws SQLException { /** * delete by id. + * * @param id id * @throws SQLException SQL exception */ @@ -129,6 +138,7 @@ public void delete(final Long id) throws SQLException { /** * select all. + * * @return list of address * @throws SQLException SQL exception */ @@ -148,4 +158,30 @@ public List
selectAll() throws SQLException { } return result; } + + /** + * Assert rollback with transactions. + * This is currently just a simple test against a non-existent table and does not involve the competition scenario of distributed transactions. + * + * @throws SQLException An exception that provides information on a database access error or other errors. + */ + public void assertRollbackWithTransactions() throws SQLException { + Connection connection = dataSource.getConnection(); + try { + connection.setAutoCommit(false); + connection.createStatement().executeUpdate("INSERT INTO t_address (address_id, address_name) VALUES (2024, 'address_test_2024')"); + connection.createStatement().executeUpdate("INSERT INTO t_table_does_not_exist (test_id_does_not_exist) VALUES (2024)"); + connection.commit(); + } catch (SQLException e) { + connection.rollback(); + } finally { + connection.setAutoCommit(true); + connection.close(); + } + try ( + Connection conn = dataSource.getConnection(); + ResultSet resultSet = conn.createStatement().executeQuery("SELECT * FROM t_address WHERE address_id = 2024")) { + assertThat(resultSet.next(), is(false)); + } + } } diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/transactions/base/SeataTest.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/transactions/base/SeataTest.java new file mode 100644 index 00000000000000..4f3dfd8277838b --- /dev/null +++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/transactions/base/SeataTest.java @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.test.natived.jdbc.transactions.base; + +import com.mysql.cj.jdbc.exceptions.CommunicationsException; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService; +import org.awaitility.Awaitility; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledInNativeImage; +import org.testcontainers.containers.FixedHostPortGenericContainer; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.utility.DockerImageName; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.time.Duration; +import java.util.Properties; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; + +class SeataTest { + + private static final String SYSTEM_PROP_KEY_PREFIX = "fixture.test-native.yaml.transactions.base."; + + private static final String USERNAME = "root"; + + private static final String PASSWORD = "123456"; + + private static final String DATABASE = "test"; + + private String jdbcUrlPrefix; + + private TestShardingService testShardingService; + + @SuppressWarnings({"resource", "deprecation"}) + @Test + @EnabledInNativeImage + void assertShardingInSeataTransactions() throws SQLException { + try ( + GenericContainer container = new FixedHostPortGenericContainer<>("seataio/seata-server:1.7.1") + .withFixedExposedPort(8091, 8091) + .withFixedExposedPort(7091, 7091); + GenericContainer mySqlContainer = new GenericContainer<>(DockerImageName.parse("mysql:8.3.0-oraclelinux8")) + .withEnv("MYSQL_DATABASE", DATABASE) + .withEnv("MYSQL_ROOT_PASSWORD", PASSWORD) + .withExposedPorts(3306)) { + container.start(); + mySqlContainer.start(); + jdbcUrlPrefix = "jdbc:mysql://localhost:" + mySqlContainer.getMappedPort(3306) + "/"; + DataSource dataSource = createDataSource(); + testShardingService = new TestShardingService(dataSource); + this.initEnvironment(); + testShardingService.processSuccess(); + testShardingService.cleanEnvironment(); + } + } + + private void initEnvironment() throws SQLException { + testShardingService.getOrderRepository().createTableIfNotExistsInMySQL(); + testShardingService.getOrderItemRepository().createTableIfNotExistsInMySQL(); + testShardingService.getAddressRepository().createTableIfNotExists(); + testShardingService.getOrderRepository().truncateTable(); + testShardingService.getOrderItemRepository().truncateTable(); + testShardingService.getAddressRepository().truncateTable(); + } + + private Connection openConnection(final String databaseName) throws SQLException { + Properties props = new Properties(); + props.setProperty("user", USERNAME); + props.setProperty("password", PASSWORD); + return DriverManager.getConnection(jdbcUrlPrefix + databaseName, props); + } + + @SuppressWarnings({"SqlNoDataSourceInspection", "SqlDialectInspection"}) + private DataSource createDataSource() { + Awaitility.await().atMost(Duration.ofMinutes(1)).ignoreExceptionsMatching(e -> e instanceof CommunicationsException) + .until(() -> { + openConnection(DATABASE).close(); + return true; + }); + try (Connection connection = openConnection(DATABASE)) { + connection.createStatement().executeUpdate("CREATE DATABASE demo_ds_0;"); + connection.createStatement().executeUpdate("CREATE DATABASE demo_ds_1;"); + connection.createStatement().executeUpdate("CREATE DATABASE demo_ds_2;"); + } catch (SQLException e) { + throw new RuntimeException(e); + } + String sql = "CREATE TABLE `undo_log` (\n" + + " `id` bigint(20) NOT NULL AUTO_INCREMENT,\n" + + " `branch_id` bigint(20) NOT NULL,\n" + + " `xid` varchar(100) NOT NULL,\n" + + " `context` varchar(128) NOT NULL,\n" + + " `rollback_info` longblob NOT NULL,\n" + + " `log_status` int(11) NOT NULL,\n" + + " `log_created` datetime NOT NULL,\n" + + " `log_modified` datetime NOT NULL,\n" + + " `ext` varchar(100) DEFAULT NULL,\n" + + " PRIMARY KEY (`id`),\n" + + " UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)\n" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; + try ( + Connection ds0Connection = openConnection("demo_ds_0"); + Connection ds1Connection = openConnection("demo_ds_1"); + Connection ds2Connection = openConnection("demo_ds_2")) { + ds0Connection.createStatement().executeUpdate(sql); + ds1Connection.createStatement().executeUpdate(sql); + ds2Connection.createStatement().executeUpdate(sql); + } catch (SQLException e) { + throw new RuntimeException(e); + } + HikariConfig config = new HikariConfig(); + config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver"); + config.setJdbcUrl("jdbc:shardingsphere:classpath:test-native/yaml/transactions/base/seata.yaml?placeholder-type=system_props"); + try { + assertThat(System.getProperty(SYSTEM_PROP_KEY_PREFIX + "ds0.jdbc-url"), is(nullValue())); + assertThat(System.getProperty(SYSTEM_PROP_KEY_PREFIX + "ds1.jdbc-url"), is(nullValue())); + assertThat(System.getProperty(SYSTEM_PROP_KEY_PREFIX + "ds2.jdbc-url"), is(nullValue())); + System.setProperty(SYSTEM_PROP_KEY_PREFIX + "ds0.jdbc-url", jdbcUrlPrefix + "demo_ds_0"); + System.setProperty(SYSTEM_PROP_KEY_PREFIX + "ds1.jdbc-url", jdbcUrlPrefix + "demo_ds_1"); + System.setProperty(SYSTEM_PROP_KEY_PREFIX + "ds2.jdbc-url", jdbcUrlPrefix + "demo_ds_2"); + return new HikariDataSource(config); + } finally { + System.clearProperty(SYSTEM_PROP_KEY_PREFIX + "ds0.jdbc-url"); + System.clearProperty(SYSTEM_PROP_KEY_PREFIX + "ds1.jdbc-url"); + System.clearProperty(SYSTEM_PROP_KEY_PREFIX + "ds2.jdbc-url"); + } + } +} diff --git a/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json b/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json index eb118f6ef69d3f..aaecde3e1a2d38 100644 --- a/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json +++ b/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json @@ -45,6 +45,18 @@ }, { "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.transactions.xa.NarayanaTest"}, "pattern":"\\Qtest-native/yaml/transactions/xa/narayana.yaml\\E" + }, { + "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest"}, + "pattern":"\\Qtest-native/yaml/transactions/base/seata.yaml\\E" + }, { + "condition":{"typeReachable":"org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager"}, + "pattern":"\\Qfile.conf\\E" + }, { + "condition":{"typeReachable":"org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager"}, + "pattern":"\\Qregistry.conf\\E" + },{ + "condition":{"typeReachable":"org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager"}, + "pattern":"\\Qseata.conf\\E" }]}, "bundles":[] } diff --git a/test/native/src/test/resources/file.conf b/test/native/src/test/resources/file.conf new file mode 100644 index 00000000000000..e418f61ba31574 --- /dev/null +++ b/test/native/src/test/resources/file.conf @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +service { + vgroupMapping.default_tx_group = "default" + default.grouplist = "127.0.0.1:8091" + enableDegrade = false + disable = false +} diff --git a/test/native/src/test/resources/registry.conf b/test/native/src/test/resources/registry.conf new file mode 100644 index 00000000000000..961283a7f82fa1 --- /dev/null +++ b/test/native/src/test/resources/registry.conf @@ -0,0 +1,30 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +registry { + type = "file" + file { + name = "file.conf" + } +} + +config { + type = "file" + file { + name = "file.conf" + } +} diff --git a/test/native/src/test/resources/seata.conf b/test/native/src/test/resources/seata.conf new file mode 100644 index 00000000000000..5026984ee401e7 --- /dev/null +++ b/test/native/src/test/resources/seata.conf @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +sharding.transaction.seata.at.enable = true +sharding.transaction.seata.tx.timeout = 60 + +client { + application.id = test-native + transaction.service.group = default_tx_group +} diff --git a/test/native/src/test/resources/test-native/yaml/transactions/base/seata.yaml b/test/native/src/test/resources/test-native/yaml/transactions/base/seata.yaml new file mode 100644 index 00000000000000..0c4e4d7a7d0fe0 --- /dev/null +++ b/test/native/src/test/resources/test-native/yaml/transactions/base/seata.yaml @@ -0,0 +1,82 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +mode: + type: Standalone + repository: + type: JDBC + +dataSources: + ds_0: + dataSourceClassName: com.zaxxer.hikari.HikariDataSource + driverClassName: com.mysql.cj.jdbc.Driver + jdbcUrl: $${fixture.test-native.yaml.transactions.base.ds0.jdbc-url::} + username: root + password: 123456 + ds_1: + dataSourceClassName: com.zaxxer.hikari.HikariDataSource + driverClassName: com.mysql.cj.jdbc.Driver + jdbcUrl: $${fixture.test-native.yaml.transactions.base.ds1.jdbc-url::} + username: root + password: 123456 + ds_2: + dataSourceClassName: com.zaxxer.hikari.HikariDataSource + driverClassName: com.mysql.cj.jdbc.Driver + jdbcUrl: $${fixture.test-native.yaml.transactions.base.ds2.jdbc-url::} + username: root + password: 123456 + +rules: +- !SHARDING + tables: + t_order: + actualDataNodes: + keyGenerateStrategy: + column: order_id + keyGeneratorName: snowflake + t_order_item: + actualDataNodes: + keyGenerateStrategy: + column: order_item_id + keyGeneratorName: snowflake + defaultDatabaseStrategy: + standard: + shardingColumn: user_id + shardingAlgorithmName: inline + shardingAlgorithms: + inline: + type: CLASS_BASED + props: + strategy: STANDARD + algorithmClassName: org.apache.shardingsphere.test.natived.jdbc.commons.algorithm.ClassBasedInlineShardingAlgorithmFixture + keyGenerators: + snowflake: + type: SNOWFLAKE + auditors: + sharding_key_required_auditor: + type: DML_SHARDING_CONDITIONS + +- !BROADCAST + tables: + - t_address + +transaction: + defaultType: BASE + providerType: Seata + +props: + sql-show: false