menghaoranss commented on a change in pull request #11638:
URL: https://github.com/apache/shardingsphere/pull/11638#discussion_r683106851



##########
File path: 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/ShardingSphereAdapterContainer.java
##########
@@ -72,6 +72,14 @@ private YamlUserConfiguration loadAuthentication(final 
ParameterizedArray parame
      */
     public abstract DataSource getDataSource();
 
+    /**
+     * Get Governance DataSource.

Review comment:
       Get governance data source

##########
File path: 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/impl/ShardingSphereJDBCContainer.java
##########
@@ -66,14 +72,35 @@ public void start() {
      */
     public DataSource getDataSource() {
         try {
-            if 
("sharding_governance".equals(getParameterizedArray().getScenario())) {
-                return 
YamlGovernanceShardingSphereDataSourceFactory.createDataSource(new 
File(EnvironmentPath.getRulesConfigurationFile(getParameterizedArray().getScenario())));
-            }
             return 
YamlShardingSphereDataSourceFactory.createDataSource(dataSourceMap, new 
File(EnvironmentPath.getRulesConfigurationFile(getParameterizedArray().getScenario())));
         } catch (SQLException | IOException ex) {

Review comment:
       final

##########
File path: 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/impl/ShardingSphereProxyContainer.java
##########
@@ -110,7 +110,17 @@ public DataSource getDataSource() {
         }
         return dataSourceProvider.get();
     }
-    
+
+    /**
+     * Get DataSource.

Review comment:
       Get governance data source

##########
File path: 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java
##########
@@ -22,10 +22,19 @@
 import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
 
 public class ZookeeperContainer extends ShardingSphereContainer {

Review comment:
       Need final ?

##########
File path: 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/ShardingSphereAdapterContainer.java
##########
@@ -72,6 +72,14 @@ private YamlUserConfiguration loadAuthentication(final 
ParameterizedArray parame
      */
     public abstract DataSource getDataSource();
 
+    /**
+     * Get Governance DataSource.
+     *
+     * @param serverLists server list
+     * @return DataSource

Review comment:
       return data source

##########
File path: 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/impl/ShardingSphereProxyContainer.java
##########
@@ -110,7 +110,17 @@ public DataSource getDataSource() {
         }
         return dataSourceProvider.get();
     }
-    
+
+    /**
+     * Get DataSource.
+     *
+     * @param serverLists server list
+     * @return DataSource

Review comment:
       return data source

##########
File path: 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java
##########
@@ -22,10 +22,19 @@
 import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
 
 public class ZookeeperContainer extends ShardingSphereContainer {
-    
+
     public ZookeeperContainer(final ParameterizedArray parameterizedArray) {
         super("zookeeper", "zookeeper:3.6.2", false, parameterizedArray);
         setWaitStrategy(new 
LogMessageWaitStrategy().withRegEx(".*PrepRequestProcessor \\(sid:[0-9]+\\) 
started.*"));
     }
-    
+
+    /**
+     * Get server list.
+     *
+     * @return serverLists

Review comment:
       return server list

##########
File path: 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/impl/ShardingSphereJDBCContainer.java
##########
@@ -66,14 +72,35 @@ public void start() {
      */
     public DataSource getDataSource() {
         try {
-            if 
("sharding_governance".equals(getParameterizedArray().getScenario())) {
-                return 
YamlGovernanceShardingSphereDataSourceFactory.createDataSource(new 
File(EnvironmentPath.getRulesConfigurationFile(getParameterizedArray().getScenario())));
-            }
             return 
YamlShardingSphereDataSourceFactory.createDataSource(dataSourceMap, new 
File(EnvironmentPath.getRulesConfigurationFile(getParameterizedArray().getScenario())));
         } catch (SQLException | IOException ex) {
             throw new RuntimeException(ex);
         }
     }
+
+    /**
+     * Get governance data source.
+     *
+     * @param serverLists server list
+     * @return data source
+     */
+    public DataSource getGovernanceDataSource(final String serverLists) {
+        try {
+            File yamlFile = new 
File(EnvironmentPath.getRulesConfigurationFile(getParameterizedArray().getScenario()));
+            YamlGovernanceRootRuleConfigurations configurations = 
YamlEngine.unmarshal(yamlFile, YamlGovernanceRootRuleConfigurations.class);
+            YamlGovernanceConfiguration governance = 
configurations.getGovernance();
+            governance.getRegistryCenter().setServerLists(serverLists);
+            Properties properties = configurations.getProps();
+            if (configurations.getRules().isEmpty() || 
dataSourceMap.isEmpty()) {
+                return new 
GovernanceShardingSphereDataSource(YamlGovernanceConfigurationSwapperUtil.marshal(governance));
+            } else {
+                return new GovernanceShardingSphereDataSource(dataSourceMap, 
new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(configurations.getRules()),
 properties,
+                        
YamlGovernanceConfigurationSwapperUtil.marshal(governance));
+            }
+        } catch (SQLException | IOException ex) {

Review comment:
       final




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to