Skip to content

Commit

Permalink
Design a longer wait time before executing INSERT SQL in nativeTest o…
Browse files Browse the repository at this point in the history
…f Zookeeper and Etcd (#32782)
  • Loading branch information
linghengqian authored Sep 3, 2024
1 parent 4427d86 commit 3ac3b54
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
"condition":{"typeReachable":"org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepository"},
"name":"org.apache.shardingsphere.driver.ShardingSphereDriver"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement"},
"name":"org.apache.shardingsphere.driver.executor.engine.facade.standard.StandardDriverExecutorFacadeFactory"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
"name":"org.apache.shardingsphere.driver.yaml.YamlJDBCConfiguration",
Expand Down Expand Up @@ -329,6 +333,11 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
"name":"org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfigurationCustomizer"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.encrypt.algorithm.standard.AESEncryptAlgorithm"},
"name":"org.apache.shardingsphere.infra.algorithm.cryptographic.aes.AESCryptographicAlgorithm",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.sharding.checker.ShardingRuleConfigurationChecker"},
"name":"org.apache.shardingsphere.infra.algorithm.keygen.snowflake.SnowflakeKeyGenerateAlgorithm",
Expand Down Expand Up @@ -591,15 +600,6 @@
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.infra.util.eventbus.EventSubscriber"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.event.subsciber.DeliverEventSubscriberRegistry$$Lambda/0x00007fce7f479688"},
"name":"org.apache.shardingsphere.infra.util.eventbus.EventSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"name":"org.apache.shardingsphere.infra.util.eventbus.EventSubscriber",
"queryAllDeclaredMethods":true
},
Expand Down Expand Up @@ -913,80 +913,72 @@
"name":"org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfigurationCustomizer"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.event.subsciber.DeliverEventSubscriberRegistry$$Lambda/0x00007fce7f479688"},
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.deliver.DeliverQualifiedDataSourceSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.CacheEvictedSubscriber",
"queryAllDeclaredMethods":true,
"methods":[{"name":"cleanCache","parameterTypes":["org.apache.shardingsphere.mode.event.dispatch.DispatchEvent"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.CacheEvictedSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ComputeNodeOnlineSubscriber",
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ComputeNodeStateSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.DatabaseChangedSubscriber",
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.DatabaseDataChangedSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.GlobalRuleConfigurationEventSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ListenerAssistedSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ProcessListChangedSubscriber",
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.MetaDataChangedSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.PropertiesEventSubscriber",
"queryAllDeclaredMethods":true
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.listener.MetaDataChangedListener$$Lambda/0x00007f04a35d5a38"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.MetaDataChangedSubscriber"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.QualifiedDataSourceSubscriber",
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ProcessListChangedSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ResourceMetaDataChangedSubscriber"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ResourceMetaDataChangedSubscriber",
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.PropertiesEventSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.listener.MetaDataChangedListener$$Lambda/0x00007fce7f5d5000"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ResourceMetaDataChangedSubscriber"
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.QualifiedDataSourceSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.RuleItemChangedSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.StateChangedSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry.ClusterDispatchEventSubscriberRegistry$$Lambda/0x00007fce7f490a30"},
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.StorageUnitEventSubscriber",
"queryAllDeclaredMethods":true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.authority.rule.AuthorityRule"},
"pattern":"\\QMETA-INF/services/org.apache.shardingsphere.authority.spi.PrivilegeProvider\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement"},
"pattern":"\\QMETA-INF/services/org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader"},
"pattern":"\\QMETA-INF/services/org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationChecker\\E"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ResourceMetaDataChangedSubscriber",
"methods":[{"name":"renew","parameterTypes":["org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.CreateOrAlterTableEvent"] }, {"name":"renew","parameterTypes":["org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.DropTableEvent"] }]
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.MetaDataChangedSubscriber",
"allPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.StateChangedSubscriber",
"methods":[{"name":"renew","parameterTypes":["org.apache.shardingsphere.mode.event.dispatch.state.cluster.ClusterStateEvent"] }]
"allPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
import org.apache.shardingsphere.test.natived.jdbc.commons.repository.AddressRepository;
import org.apache.shardingsphere.test.natived.jdbc.commons.repository.OrderItemRepository;
import org.apache.shardingsphere.test.natived.jdbc.commons.repository.OrderRepository;
import org.awaitility.Awaitility;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -88,6 +90,8 @@ public void processSuccess() throws SQLException {

/**
* Process success in ClickHouse.
* TODO On low-performance devices like Github Actions, it takes longer to execute DELETE statements,
* which leads to the use of {@code org.awaitility.Awaitility.await()} here. Maybe there is room for improvement in Clickhouse JDBC Driver.
* ClickHouse has not fully supported transactions. Refer to <a href="https://github.com/ClickHouse/clickhouse-docs/issues/2300">ClickHouse/clickhouse-docs#2300</a>.
* So ShardingSphere should not use {@link OrderItemRepository#assertRollbackWithTransactions()} in the method here.
*
Expand All @@ -114,6 +118,7 @@ public void processSuccessInClickHouse() throws SQLException {
assertThat(addressRepository.selectAll(),
equalTo(LongStream.range(1L, 11L).mapToObj(each -> new Address(each, "address_test_" + each)).collect(Collectors.toList())));
deleteDataInClickHouse(orderIds);
Awaitility.await().pollDelay(Duration.ofSeconds(5L)).until(() -> true);
assertThat(orderRepository.selectAll(), equalTo(Collections.emptyList()));
assertThat(orderItemRepository.selectAll(), equalTo(Collections.emptyList()));
assertThat(addressRepository.selectAll(), equalTo(Collections.emptyList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ void assertShardingInLocalTransactions() throws SQLException {
DataSource dataSource = createDataSource(CLUSTER.clientEndpoints());
testShardingService = new TestShardingService(dataSource);
initEnvironment();
Awaitility.await().atMost(Duration.ofSeconds(30L)).ignoreExceptions().until(() -> {
dataSource.getConnection().close();
return true;
});
Awaitility.await().pollDelay(Duration.ofSeconds(5L)).until(() -> true);
testShardingService.processSuccess();
testShardingService.cleanEnvironment();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledInNativeImage;

import javax.sql.DataSource;
import java.sql.SQLException;
Expand All @@ -38,6 +39,7 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;

@EnabledInNativeImage
class ZookeeperTest {

private static final String SYSTEM_PROP_KEY_PREFIX = "fixture.test-native.yaml.mode.cluster.zookeeper.";
Expand Down Expand Up @@ -68,10 +70,7 @@ void assertShardingInLocalTransactions() throws Exception {
DataSource dataSource = createDataSource(connectString);
testShardingService = new TestShardingService(dataSource);
initEnvironment();
Awaitility.await().atMost(Duration.ofSeconds(30L)).ignoreExceptions().until(() -> {
dataSource.getConnection().close();
return true;
});
Awaitility.await().pollDelay(Duration.ofSeconds(5L)).until(() -> true);
testShardingService.processSuccess();
testShardingService.cleanEnvironment();
}
Expand Down

0 comments on commit 3ac3b54

Please sign in to comment.