This is an automated email from the ASF dual-hosted git repository.
sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new aaabf5848f6 Fix discovery IT (#23909)
aaabf5848f6 is described below
commit aaabf5848f692bdcef636097faba676918240f52
Author: zhaojinchao <[email protected]>
AuthorDate: Wed Feb 1 22:25:49 2023 +0800
Fix discovery IT (#23909)
* Fix discovery IT
* Fix ut
---
.../dbdiscovery/algorithm/DatabaseDiscoveryEngine.java | 2 +-
...ransactionWeightReadQueryLoadBalanceAlgorithmTest.java | 15 ++-------------
2 files changed, 3 insertions(+), 14 deletions(-)
diff --git
a/features/db-discovery/core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
b/features/db-discovery/core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
index 6cbe6ef5010..7851a917511 100644
---
a/features/db-discovery/core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
+++
b/features/db-discovery/core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
@@ -107,7 +107,7 @@ public final class DatabaseDiscoveryEngine {
eventBusContext.post(new DataSourceDisabledEvent(databaseName,
groupName, entry.getKey(), replicaStorageNode));
continue;
}
- if
(!databaseDiscoveryProviderAlgorithm.getMinEnabledReplicas().isPresent()) {
+ if
(databaseDiscoveryProviderAlgorithm.getMinEnabledReplicas().isPresent() && 0 ==
databaseDiscoveryProviderAlgorithm.getMinEnabledReplicas().get()) {
eventBusContext.post(new DataSourceDisabledEvent(databaseName,
groupName, entry.getKey(), replicaStorageNode));
continue;
}
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithmTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithmTest.java
index ab8a9ea138a..3e4b4328bdf 100644
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithmTest.java
+++
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithmTest.java
@@ -23,15 +23,11 @@ import
org.apache.shardingsphere.infra.context.transaction.TransactionConnection
import
org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
-import org.mockito.internal.configuration.plugins.Plugins;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -40,16 +36,9 @@ import static org.junit.Assert.assertTrue;
public final class TransactionWeightReadQueryLoadBalanceAlgorithmTest {
- @Before
- @After
- public void reset() throws NoSuchFieldException, IllegalAccessException {
- ((Map<?, ?>) Plugins.getMemberAccessor()
-
.get(TransactionWeightReadQueryLoadBalanceAlgorithm.class.getDeclaredField("WEIGHT_MAP"),
TransactionWeightReadQueryLoadBalanceAlgorithm.class)).clear();
- }
-
@Test
public void assertGetSingleReadDataSource() {
- ReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
+ TransactionWeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
new AlgorithmConfiguration("TRANSACTION_WEIGHT",
PropertiesBuilder.build(new Property("test_read_ds_1", "5"))),
ReadQueryLoadBalanceAlgorithm.class);
TransactionConnectionContext context = new
TransactionConnectionContext();
context.setInTransaction(true);
@@ -58,7 +47,7 @@ public final class
TransactionWeightReadQueryLoadBalanceAlgorithmTest {
@Test
public void assertGetMultipleReadDataSources() {
- ReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(new AlgorithmConfiguration(
+ TransactionWeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(new AlgorithmConfiguration(
"TRANSACTION_WEIGHT", PropertiesBuilder.build(new
Property("test_read_ds_1", "5"), new Property("test_read_ds_2", "5"))),
ReadQueryLoadBalanceAlgorithm.class);
String writeDataSourceName = "test_write_ds";
String readDataSourceName1 = "test_read_ds_1";